pcie_app_7x.v 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. //-----------------------------------------------------------------------------
  2. //
  3. // (c) Copyright 2020-2024 Advanced Micro Devices, Inc. All rights reserved.
  4. //
  5. // This file contains confidential and proprietary information
  6. // of AMD and is protected under U.S. and
  7. // international copyright and other intellectual property
  8. // laws.
  9. //
  10. // DISCLAIMER
  11. // This disclaimer is not a license and does not grant any
  12. // rights to the materials distributed herewith. Except as
  13. // otherwise provided in a valid license issued to you by
  14. // AMD, and to the maximum extent permitted by applicable
  15. // law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
  16. // WITH ALL FAULTS, AND AMD HEREBY DISCLAIMS ALL WARRANTIES
  17. // AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
  18. // BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
  19. // INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
  20. // (2) AMD shall not be liable (whether in contract or tort,
  21. // including negligence, or under any other theory of
  22. // liability) for any loss or damage of any kind or nature
  23. // related to, arising under or in connection with these
  24. // materials, including for any direct, or any indirect,
  25. // special, incidental, or consequential loss or damage
  26. // (including loss of data, profits, goodwill, or any type of
  27. // loss or damage suffered as a result of any action brought
  28. // by a third party) even if such damage or loss was
  29. // reasonably foreseeable or AMD had been advised of the
  30. // possibility of the same.
  31. //
  32. // CRITICAL APPLICATIONS
  33. // AMD products are not designed or intended to be fail-
  34. // safe, or for use in any application requiring fail-safe
  35. // performance, such as life-support or safety devices or
  36. // systems, Class III medical devices, nuclear facilities,
  37. // applications related to the deployment of airbags, or any
  38. // other applications that could lead to death, personal
  39. // injury, or severe property or environmental damage
  40. // (individually and collectively, "Critical
  41. // Applications"). Customer assumes the sole risk and
  42. // liability of any use of AMD products in Critical
  43. // Applications, subject only to applicable laws and
  44. // regulations governing limitations on product liability.
  45. //
  46. // THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
  47. // PART OF THIS FILE AT ALL TIMES.
  48. //
  49. //-----------------------------------------------------------------------------
  50. // Project : Series-7 Integrated Block for PCI Express
  51. // File : pcie_app_7x.v
  52. // Version : 3.3
  53. //--
  54. //-- Description: PCI Express Endpoint sample application
  55. //-- design.
  56. //--
  57. //------------------------------------------------------------------------------
  58. `timescale 1ps / 1ps
  59. `define PCI_EXP_EP_OUI 24'h000A35
  60. `define PCI_EXP_EP_DSN_1 {{8'h1},`PCI_EXP_EP_OUI}
  61. `define PCI_EXP_EP_DSN_2 32'h00000001
  62. module pcie_app_7x#(
  63. parameter C_DATA_WIDTH = 64, // RX/TX interface data width
  64. // Do not override parameters below this line
  65. parameter KEEP_WIDTH = C_DATA_WIDTH / 8, // TSTRB width
  66. parameter TCQ = 1
  67. )(
  68. input user_clk,
  69. input clk_50,
  70. input user_reset,
  71. input user_lnk_up,
  72. // Tx
  73. input s_axis_tx_tready,
  74. output [C_DATA_WIDTH-1:0] s_axis_tx_tdata,
  75. output [KEEP_WIDTH-1:0] s_axis_tx_tkeep,
  76. output [3:0] s_axis_tx_tuser,
  77. output s_axis_tx_tlast,
  78. output s_axis_tx_tvalid,
  79. // Rx
  80. input [C_DATA_WIDTH-1:0] m_axis_rx_tdata,
  81. input [KEEP_WIDTH-1:0] m_axis_rx_tkeep,
  82. input m_axis_rx_tlast,
  83. input m_axis_rx_tvalid,
  84. output m_axis_rx_tready,
  85. input [21:0] m_axis_rx_tuser,
  86. input cfg_to_turnoff,
  87. input [7:0] cfg_bus_number,
  88. input [4:0] cfg_device_number,
  89. input [2:0] cfg_function_number,
  90. output tx_cfg_gnt,
  91. output cfg_pm_halt_aspm_l0s,
  92. output cfg_pm_halt_aspm_l1,
  93. output cfg_pm_force_state_en,
  94. output [1:0] cfg_pm_force_state,
  95. output rx_np_ok,
  96. output rx_np_req,
  97. output cfg_turnoff_ok,
  98. output cfg_trn_pending,
  99. output cfg_pm_wake,
  100. output [63:0] cfg_dsn,
  101. // Flow Control
  102. output [2:0] fc_sel,
  103. // CFG
  104. output cfg_err_cor,
  105. output cfg_err_ur,
  106. output cfg_err_ecrc,
  107. output cfg_err_cpl_timeout,
  108. output cfg_err_cpl_unexpect,
  109. output cfg_err_cpl_abort,
  110. output cfg_err_atomic_egress_blocked,
  111. output cfg_err_internal_cor,
  112. output cfg_err_malformed,
  113. output cfg_err_mc_blocked,
  114. output cfg_err_poisoned,
  115. output cfg_err_norecovery,
  116. output cfg_err_acs,
  117. output cfg_err_internal_uncor,
  118. output cfg_err_posted,
  119. output cfg_err_locked,
  120. output [47:0] cfg_err_tlp_cpl_header,
  121. output [127:0] cfg_err_aer_headerlog,
  122. output [4:0] cfg_aer_interrupt_msgnum,
  123. output [1:0] pl_directed_link_change,
  124. output [1:0] pl_directed_link_width,
  125. output pl_directed_link_speed,
  126. output pl_directed_link_auton,
  127. output pl_upstream_prefer_deemph,
  128. output [31:0] cfg_mgmt_di,
  129. output [3:0] cfg_mgmt_byte_en,
  130. output [9:0] cfg_mgmt_dwaddr,
  131. output cfg_mgmt_wr_en,
  132. output cfg_mgmt_rd_en,
  133. output cfg_mgmt_wr_readonly,
  134. output cfg_interrupt,
  135. output cfg_interrupt_assert,
  136. output [7:0] cfg_interrupt_di,
  137. output cfg_interrupt_stat,
  138. output [4:0] cfg_pciecap_interrupt_msgnum,
  139. input [31:0] Data_i,
  140. output [31:0] Cmd_o,
  141. output [7:0] Addr_o,
  142. output ReadReq_o,
  143. output WrReq_o
  144. );
  145. //----------------------------------------------------------------------------------------------------------------//
  146. // PCIe Block EP Tieoffs - Example PIO doesn't support the following inputs //
  147. //----------------------------------------------------------------------------------------------------------------//
  148. assign fc_sel = 3'b0;
  149. assign tx_cfg_gnt = 1'b1; // Always allow transmission of Config traffic within block
  150. assign rx_np_ok = 1'b1; // Allow Reception of Non-posted Traffic
  151. assign rx_np_req = 1'b1; // Always request Non-posted Traffic if available
  152. assign cfg_pm_wake = 1'b0; // Never direct the core to send a PM_PME Message
  153. assign cfg_trn_pending = 1'b0; // Never set the transaction pending bit in the Device Status Register
  154. assign cfg_pm_halt_aspm_l0s = 1'b0; // Allow entry into L0s
  155. assign cfg_pm_halt_aspm_l1 = 1'b0; // Allow entry into L1
  156. assign cfg_pm_force_state_en = 1'b0; // Do not qualify cfg_pm_force_state
  157. assign cfg_pm_force_state = 2'b00; // Do not move force core into specific PM state
  158. assign cfg_dsn = {`PCI_EXP_EP_DSN_2, `PCI_EXP_EP_DSN_1}; // Assign the input DSN
  159. assign s_axis_tx_tuser[0] = 1'b0; // Unused for V6
  160. assign s_axis_tx_tuser[1] = 1'b0; // Error forward packet
  161. assign s_axis_tx_tuser[2] = 1'b0; // Stream packet
  162. assign cfg_err_cor = 1'b0; // Never report Correctable Error
  163. assign cfg_err_ur = 1'b0; // Never report UR
  164. assign cfg_err_ecrc = 1'b0; // Never report ECRC Error
  165. assign cfg_err_cpl_timeout = 1'b0; // Never report Completion Timeout
  166. assign cfg_err_cpl_abort = 1'b0; // Never report Completion Abort
  167. assign cfg_err_cpl_unexpect = 1'b0; // Never report unexpected completion
  168. assign cfg_err_posted = 1'b0; // Never qualify cfg_err_* inputs
  169. assign cfg_err_locked = 1'b0; // Never qualify cfg_err_ur or cfg_err_cpl_abort
  170. assign cfg_err_atomic_egress_blocked = 1'b0; // Never report Atomic TLP blocked
  171. assign cfg_err_internal_cor = 1'b0; // Never report internal error occurred
  172. assign cfg_err_malformed = 1'b0; // Never report malformed error
  173. assign cfg_err_mc_blocked = 1'b0; // Never report multi-cast TLP blocked
  174. assign cfg_err_poisoned = 1'b0; // Never report poisoned TLP received
  175. assign cfg_err_norecovery = 1'b0; // Never qualify cfg_err_poisoned or cfg_err_cpl_timeout
  176. assign cfg_err_acs = 1'b0; // Never report an ACS violation
  177. assign cfg_err_internal_uncor = 1'b0; // Never report internal uncorrectable error
  178. assign cfg_err_aer_headerlog = 128'h0; // Zero out the AER Header Log
  179. assign cfg_aer_interrupt_msgnum = 5'b00000; // Zero out the AER Root Error Status Register
  180. assign cfg_err_tlp_cpl_header = 48'h0; // Zero out the header information
  181. assign cfg_interrupt_stat = 1'b0; // Never set the Interrupt Status bit
  182. assign cfg_pciecap_interrupt_msgnum = 5'b00000; // Zero out Interrupt Message Number
  183. assign cfg_interrupt_assert = 1'b0; // Always drive interrupt de-assert
  184. assign cfg_interrupt = 1'b0; // Never drive interrupt by qualifying cfg_interrupt_assert
  185. assign cfg_interrupt_di = 8'b0; // Do not set interrupt fields
  186. assign pl_directed_link_change = 2'b00; // Never initiate link change
  187. assign pl_directed_link_width = 2'b00; // Zero out directed link width
  188. assign pl_directed_link_speed = 1'b0; // Zero out directed link speed
  189. assign pl_directed_link_auton = 1'b0; // Zero out link autonomous input
  190. assign pl_upstream_prefer_deemph = 1'b1; // Zero out preferred de-emphasis of upstream port
  191. assign cfg_mgmt_di = 32'h0; // Zero out CFG MGMT input data bus
  192. assign cfg_mgmt_byte_en = 4'h0; // Zero out CFG MGMT byte enables
  193. assign cfg_mgmt_dwaddr = 10'h0; // Zero out CFG MGMT 10-bit address port
  194. assign cfg_mgmt_wr_en = 1'b0; // Do not write CFG space
  195. assign cfg_mgmt_rd_en = 1'b0; // Do not read CFG space
  196. assign cfg_mgmt_wr_readonly = 1'b0; // Never treat RO bit as RW
  197. //----------------------------------------------------------------------------------------------------------------//
  198. // Programmable I/O Module //
  199. //----------------------------------------------------------------------------------------------------------------//
  200. wire [15:0] cfg_completer_id = { cfg_bus_number, cfg_device_number, cfg_function_number };
  201. // reg s_axis_tx_tready_i ;
  202. // always @(posedge user_clk)
  203. // begin
  204. // if (user_reset)
  205. // s_axis_tx_tready_i <= #TCQ 1'b0;
  206. // else
  207. // s_axis_tx_tready_i <= #TCQ s_axis_tx_tready;
  208. // end
  209. wire s_axis_tx_tready_i ;
  210. assign s_axis_tx_tready_i = s_axis_tx_tready;
  211. //----------------------------------------------------------------------------------------------------------------//
  212. PIO #(
  213. .C_DATA_WIDTH( C_DATA_WIDTH ),
  214. .KEEP_WIDTH( KEEP_WIDTH ),
  215. .TCQ( TCQ )
  216. ) PIO (
  217. .user_clk ( user_clk ), // I
  218. .clk_50 ( clk_50 ), // I
  219. .user_reset ( user_reset ), // I
  220. .user_lnk_up ( user_lnk_up ), // I
  221. .cfg_to_turnoff ( cfg_to_turnoff ), // I
  222. .cfg_completer_id ( cfg_completer_id ), // I [15:0]
  223. .cfg_turnoff_ok ( cfg_turnoff_ok ), // O
  224. .s_axis_tx_tready ( s_axis_tx_tready_i ), // I
  225. .s_axis_tx_tdata ( s_axis_tx_tdata ), // O
  226. .s_axis_tx_tkeep ( s_axis_tx_tkeep ), // O
  227. .s_axis_tx_tlast ( s_axis_tx_tlast ), // O
  228. .s_axis_tx_tvalid ( s_axis_tx_tvalid ), // O
  229. .tx_src_dsc ( s_axis_tx_tuser[3] ), // O
  230. .m_axis_rx_tdata ( m_axis_rx_tdata ), // I
  231. .m_axis_rx_tkeep ( m_axis_rx_tkeep ), // I
  232. .m_axis_rx_tlast ( m_axis_rx_tlast ), // I
  233. .m_axis_rx_tvalid( m_axis_rx_tvalid ), // I
  234. .m_axis_rx_tready( m_axis_rx_tready ), // O
  235. .m_axis_rx_tuser ( m_axis_rx_tuser ), // I
  236. .Data_i(Data_i),
  237. .Cmd_o(Cmd_o),
  238. .Addr_o(Addr_o),
  239. .ReadReq_o(ReadReq_o),
  240. .WrReq_o(WrReq_o)
  241. );
  242. endmodule // pcie_app