当前位置:   article > 正文

FPGA学习-基于FPGA的高速串行通信GTX知识梳理

fpga gtx

e80e781dcaf3d22904392b0da23d3821.png

对于XILINX,7系列FPGA,关于GTX核对配置见PG168,了解GTX内部结构及更多的知识见ug476。

        以7系列XC7k325t-ffg900为例,见各ug476,351页。可看到该芯片共有4个高速bank,分别为115 116 117 118;每个bank又有4组收发模块和两组时钟模块。

1,GTX时钟和复位

      (1)时钟源:

477eefc9ffcd2dd7b0345c067752cc06.png

     GTX输入参考时钟通过2组时钟模块的任意一组输入.后通过 IBUFDS_GTE2源于得到参考时钟输入给GT模块.。此处有两种PLL由Xilinx提供给用户使用。一种为CPLL,一种为QPLL,其中主要区别为CPLL一个bank中共有4个,一个收发模块一个;而QPLL只有两个,一个时钟模块对应一个。从GTX速率而言,CPLL主要用低于6.25G速率的收发设计;而QPLL主要支持高于6.25G低于10.3025G速率的收发器设计。

    (2)发送端初始化复位:

     在时钟CPLL或QPLL时钟locked拉高(表示时钟稳定,可以正常工作)。通过GTTXRESET复位GT发送器,发送器收到复位信号从底层PMA到PCS依次复位。在PMA层,待TXPMAREAET从高变成低通过PMA层,待TXUSERRDY为高,到达PCS层;在PCS层,待TXPCSREAET从高变成低通过PCS层,则TXREAETDONE拉高,发送器复位完成。之后发送复位状态机完成复位,输出发送状态机复位完成信号。复位关系和时序如图所示:

ee6a34cf755189295a58490fe9d4c05a.png

ba3636c6e0102f73cd3a218d722d7e89.png

       (3)接收端初始化复位:

   在时钟CPLL或QPLL时钟locked拉高(表示时钟稳定,可以正常工作)。通过GTRXRESET复位GT接收器,接收器收到复位信号从底层PMA到到DFE,LPM到EYESCAN到PCS到BUF依次复位。在PMA层,待RXPMAREAET从高变成低通过PMA层,RXPMARESETDONE拉高;到达DFELPM层,待RXDFELPMRESET从高变成低通过DFE LPM层,RXDFE LPMRESETDONE拉高;到达EYECAN层,待RXEYECANRESET从高变成低通过EYECAN层,RXEYECANRESETDONE拉高;待RXUSERRDY为高;到达PCS层;在PCS层,待RXPCSREAET从高变成低通过PCS层,则RXPCSREAETDONE拉高;到达BUF层,待RXBUFRESET从高变成低通过BUF层,RXBUFRESETDONE拉高;最后RXRESETDONE拉高;接收器复位完成。之后接收复位状态机完成复位,输出接收状态机复位完成信号。复位关系和时序如图所示:

3cb31ceba18c8146fa16145344a082d7.png

fa5d77c6228fa7188320e54789a9c868.png

 2,GTX发送器

      FPGA内部每一个收发器都有一个独立的发送端,发送端由PMA,PCS组成;由图可以看出PMA层包括并串转换,预加重,均衡,时钟发生器等;PCS层包括 8B/10B编码,数据缓冲区等。具体如图所示:

d4f1c68a1b0767b33e63e169138e240e.png

       interface用户接口:使能8B/10B,数据位宽可以为:16,32,64;不使能8B/10B,数据位宽可以为:16,20,32,40,64,80;时钟=线速率/(8B/10B编码后的数据位宽);

       8B/10B编码:保证时钟恢复,提供数据对齐,保持良好的直流平衡;

       tx buffer :主要用户消除两个时钟直接的相位差;也可以不用; 

       tx pattern generator :通过伪随机数来扩频;

       tx polarity control :如果P N接反,则通过配置该为矫正;

 3,GTX接收器

         接收器和发送器的数据流相反,接收器需要恢复时钟,补偿数据,恢复数据,串并转换,再8B/10B解码;最后输出数据给用户接口;如图:

9348e0fe8f5abd52cb63260fd7fe92e2.png

     DFE和LPM :数据到达接收器后,先经过RX均衡器,均衡器主要用于补偿信号在信道传输过程中的高频损失;DFE和LPM是接收器中的两种均衡器,LPM功耗较低,DFE能提供更精准的滤波参数。

     RX,CDR :时钟恢复电路, 接收端需要恢复时钟和数据,主要通过这个模块实现时钟,数据恢复。

     其余模块都与发送端类似。

4,IP配置(以XC7K325T-FFG900为例)

     (1) IP配置有两种方式选择。有两种方式:一种完成集成与IP核,只需要列化一个模块就能可以,但是这种种方式不太灵活,如果多通道并用,可能不好处理,还有一种核心模块为IP,其余使用例程,参考例程设计。具体选择可根据具体需求来实现:(我的设计中采用了只使用核心IP,其余参考例程设计)

0d78db859617f1045eed65f116d04cef.png

   (2)主要配置页

381fba51f4d8f7c68e011a9320fbcf27.png

           protocol :协议选择,GTX是高速串行收发器,在他的基础上可以很多的协议如SDI ,10Gbase,aurora,hdmi,sata等;

           line rate  :线速率配置,当前芯片最大支持10.3125G;

           reference clock :参考时钟,由外部输入,根据线速率选择合适的参考时钟输入;

           pll selection :PLL选择;

           transceiver selection:收发器选择,一个bank有4个收发器,根据项目需求,原理设计选择。

    (3)8B/10B使能,BUF配置,por选择

a712a0155eabc8fd3bb1029c9bf6d1c3.png

         8B/10B :根据设计选择8B/10B是否使能,配置数据位宽为16,32,64;

         drpclk/sysclk :系统时钟输入,复位信号等由该时钟产生;可输入0-175m时钟;

         synchronization and clocking :配置接收时钟,配置时钟源,是否使用buf;

         optional port :可以根据需求引出相关端口,以帮助IP核配置,控制使用。

   (4)K码,均衡配置

7a56a83b02b2a89007001874ebdc710b.png

           rx comma detection : 接收端对齐数据选择,可配置为2byte, 4byte 等。具体根据数据位宽决定;

          termination and equalization :均衡器配置,可配合ibert核使用,得到最合理的参数然后配置给IP核。

      (5) 后面暂时不用管,直接下一步到最后完成配置。

  5, 附上一个简单GT口配置逻辑,以便今后回顾。

  1. // ____ ____
  2. // / /\/ /
  3. // /___/ \ / Vendor: Xilinx
  4. // \ \ \/ Version : 3.6
  5. // \ \ Application : 7 Series FPGAs Transceivers Wizard
  6. // / / Filename : gtwizard_0_support.v
  7. // /___/ /\
  8. // \ \ / \
  9. // \___\/\___\
  10. //
  11. //
  12. // Module gtwizard_0_support
  13. // Generated by Xilinx 7 Series FPGAs Transceivers Wizard
  14. //
  15. //
  16. // (c) Copyright 2010-2012 Xilinx, Inc. All rights reserved.
  17. //
  18. // This file contains confidential and proprietary information
  19. // of Xilinx, Inc. and is protected under U.S. and
  20. // international copyright and other intellectual property
  21. // laws.
  22. //
  23. // DISCLAIMER
  24. // This disclaimer is not a license and does not grant any
  25. // rights to the materials distributed herewith. Except as
  26. // otherwise provided in a valid license issued to you by
  27. // Xilinx, and to the maximum extent permitted by applicable
  28. // law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
  29. // WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
  30. // AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
  31. // BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
  32. // INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
  33. // (2) Xilinx shall not be liable (whether in contract or tort,
  34. // including negligence, or under any other theory of
  35. // liability) for any loss or damage of any kind or nature
  36. // related to, arising under or in connection with these
  37. // materials, including for any direct, or any indirect,
  38. // special, incidental, or consequential loss or damage
  39. // (including loss of data, profits, goodwill, or any type of
  40. // loss or damage suffered as a result of any action brought
  41. // by a third party) even if such damage or loss was
  42. // reasonably foreseeable or Xilinx had been advised of the
  43. // possibility of the same.
  44. //
  45. // CRITICAL APPLICATIONS
  46. // Xilinx products are not designed or intended to be fail-
  47. // safe, or for use in any application requiring fail-safe
  48. // performance, such as life-support or safety devices or
  49. // systems, Class III medical devices, nuclear facilities,
  50. // applications related to the deployment of airbags, or any
  51. // other applications that could lead to death, personal
  52. // injury, or severe property or environmental damage
  53. // (individually and collectively, "Critical
  54. // Applications"). Customer assumes the sole risk and
  55. // liability of any use of Xilinx products in Critical
  56. // Applications, subject only to applicable laws and
  57. // regulations governing limitations on product liability.
  58. //
  59. // THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
  60. // PART OF THIS FILE AT ALL TIMES.
  61. `timescale 1ns / 1ps
  62. module gt_wrap (
  63. input sysclk_in,
  64. input sysreset_in,
  65. input clk1_gtrefclk_n,
  66. input clk1_gtrefclk_p,
  67. input [1:0] gtxrxp_in,
  68. input [1:0] gtxrxn_in,
  69. output [1:0] gtxtxn_out,
  70. output [1:0] gtxtxp_out,
  71. output qpll_locked,
  72. output [1:0] rx_resetdone,
  73. output [1:0] tx_resetdone,
  74. output [1:0] tx_fsm_reset_done,
  75. output [1:0] rx_fsm_reset_done,
  76. output tx_clk,
  77. output rx_clk,
  78. output [7:0] rx_charisk,
  79. output [63:0] rx_data,
  80. input [7:0] tx_charisk,
  81. input [63:0] tx_data,
  82. input ctrl_loppback,
  83. output [7:0] rx_disperr,
  84. output [7:0] rx_notintable,
  85. output [5:0] rx_bufstatus
  86. );
  87. genvar i ;
  88. //qpll
  89. wire commonreset_i;
  90. wire gt0_qplllock_i;
  91. wire gt0_qpllrefclklost_i ;
  92. wire [1:0] gt0_qpllreset_i ;
  93. wire gt0_qpllreset_t ;
  94. wire gt0_qplloutclk_i ;
  95. wire gt0_qplloutrefclk_i ;
  96. //Reference Clocks
  97. wire q0_clk1_refclk_i;
  98. //User Clocks
  99. wire [1:0] gt0_rxoutclk_i;
  100. wire [1:0] gt0_txoutclk_i;
  101. wire gt0_txusrclk_i;
  102. wire gt0_rxusrclk_i;
  103. wire gt0_txusrclk2_i;
  104. wire gt0_rxusrclk2_i;
  105. //**************************** Main Body of Code *******************************
  106. assign qpll_locked = gt0_qplllock_i;
  107. assign tx_clk = gt0_txusrclk2_i;
  108. assign rx_clk = gt0_rxusrclk2_i;
  109. gtwizard_0_GT_USRCLK_SOURCE gtwizard_0_GT_USRCLK_SOURCE (
  110. .GT0_TXUSRCLK_OUT (gt0_txusrclk_i),
  111. .GT0_TXUSRCLK2_OUT (gt0_txusrclk2_i ),
  112. .GT0_TXOUTCLK_IN (gt0_txoutclk_i[0]),
  113. .GT0_RXUSRCLK_OUT (gt0_rxusrclk_i),
  114. .GT0_RXUSRCLK2_OUT (gt0_rxusrclk2_i ),
  115. .GT0_RXOUTCLK_IN (gt0_rxoutclk_i[0]),
  116. .Q0_CLK1_GTREFCLK_PAD_N_IN (clk1_gtrefclk_n),
  117. .Q0_CLK1_GTREFCLK_PAD_P_IN (clk1_gtrefclk_p),
  118. .Q0_CLK1_GTREFCLK_OUT (q0_clk1_refclk_i)
  119. );
  120. gtwizard_0_common #(
  121. .WRAPPER_SIM_GTRESET_SPEEDUP("TRUE"),
  122. .SIM_QPLLREFCLK_SEL(3'b010)
  123. )
  124. gtwizard_0_common (
  125. .QPLLREFCLKSEL_IN(3'b010),
  126. .GTREFCLK0_IN(1'b0),
  127. .GTREFCLK1_IN(q0_clk1_refclk_i),
  128. .QPLLLOCK_OUT(gt0_qplllock_i),
  129. .QPLLLOCKDETCLK_IN(sysclk_in),
  130. .QPLLOUTCLK_OUT(gt0_qplloutclk_i),
  131. .QPLLOUTREFCLK_OUT(gt0_qplloutrefclk_i),
  132. .QPLLREFCLKLOST_OUT(gt0_qpllrefclklost_i),
  133. .QPLLRESET_IN(gt0_qpllreset_t)
  134. );
  135. assign gt0_qpllreset_t = commonreset_i | &gt0_qpllreset_i;
  136. gtwizard_0_common_reset #(
  137. .STABLE_CLOCK_PERIOD (8) // Period of the stable clock driving this state-machine, unit is [ns]
  138. )
  139. gtwizard_0_common_reset (
  140. .STABLE_CLOCK(sysclk_in), //Stable Clock, either a stable clock from the PCB
  141. .SOFT_RESET(sysreset_in), //User Reset, can be pulled any time
  142. .COMMON_RESET(commonreset_i) //Reset QPLL
  143. );
  144. generate
  145. for (i=0;i<2;i=i+1)
  146. begin : gt_gen
  147. gtwizard_0 gtwizard_0_init_i (
  148. .sysclk_in (sysclk_in),
  149. .soft_reset_tx_in (sysreset_in),
  150. .soft_reset_rx_in (sysreset_in),
  151. .dont_reset_on_data_error_in (1'b0),
  152. .gt0_tx_fsm_reset_done_out (tx_fsm_reset_done[i]),
  153. .gt0_rx_fsm_reset_done_out (rx_fsm_reset_done[i]),
  154. .gt0_data_valid_in (1'b1),
  155. //_____________________________________________________________________
  156. //_____________________________________________________________________
  157. //GT0 (X1Y0)
  158. //-------------------------- Channel - DRP Ports --------------------------
  159. .gt0_drpaddr_in (9'd0), // input wire [8:0] gt0_drpaddr_in
  160. .gt0_drpclk_in (sysclk_in), // input wire sysclk_in_i
  161. .gt0_drpdi_in (16'd0), // input wire [15:0] gt0_drpdi_in
  162. .gt0_drpdo_out ( ), // output wire [15:0] gt0_drpdo_out
  163. .gt0_drpen_in (1'b0), // input wire gt0_drpen_in
  164. .gt0_drprdy_out ( ), // output wire gt0_drprdy_out
  165. .gt0_drpwe_in (1'b0), // input wire gt0_drpwe_in
  166. //------------------------- Digital Monitor Ports --------------------------
  167. .gt0_dmonitorout_out ( ), // output wire [7:0] gt0_dmonitorout_out
  168. //----------------------------- Loopback Ports -----------------------------
  169. .gt0_loopback_in ({2'd0,ctrl_loppback }), // input wire [2:0] gt0_loopback_in
  170. //------------------- RX Initialization and Reset Ports --------------------
  171. .gt0_eyescanreset_in (1'b0), // input wire gt0_eyescanreset_in
  172. .gt0_rxuserrdy_in (1'b0), // input wire gt0_rxuserrdy_in
  173. //------------------------ RX Margin Analysis Ports ------------------------
  174. .gt0_eyescandataerror_out ( ), // output wire gt0_eyescandataerror_out
  175. .gt0_eyescantrigger_in (1'b0), // input wire gt0_eyescantrigger_in
  176. //---------------- Receive Ports - FPGA RX Interface Ports -----------------
  177. .gt0_rxusrclk_in (gt0_rxusrclk_i), // input wire gt0_rxusrclk_i
  178. .gt0_rxusrclk2_in (gt0_rxusrclk_i), // input wire gt0_rxusrclk2_i
  179. //---------------- Receive Ports - FPGA RX interface Ports -----------------
  180. .gt0_rxdata_out (rx_data[32*i+:32]), // output wire [31:0] gt0_rxdata_out
  181. //---------------- Receive Ports - RX 8B/10B Decoder Ports -----------------
  182. .gt0_rxdisperr_out (rx_disperr[4*i+:4]), // output wire [3:0] gt0_rxdisperr_out
  183. .gt0_rxnotintable_out (rx_notintable[4*i+:4]), // output wire [3:0] gt0_rxnotintable_out
  184. //------------------------- Receive Ports - RX AFE -------------------------
  185. .gt0_gtxrxp_in (gtxrxp_in[i]), // input wire gt0_gtxrxp_in
  186. //---------------------- Receive Ports - RX AFE Ports ----------------------
  187. .gt0_gtxrxn_in (gtxrxn_in[i]), // input wire gt0_gtxrxn_in
  188. //----------------- Receive Ports - RX Buffer Bypass Ports -----------------
  189. .gt0_rxbufstatus_out (rx_bufstatus[3*i+:3]), // output wire [2:0] gt0_rxbufstatus_out
  190. //------------------- Receive Ports - RX Equalizer Ports -------------------
  191. .gt0_rxdfelpmreset_in (1'b0), // input wire gt0_rxdfelpmreset_in
  192. .gt0_rxmonitorout_out ( ), // output wire [6:0] gt0_rxmonitorout_out
  193. .gt0_rxmonitorsel_in (1'b0), // input wire [1:0] gt0_rxmonitorsel_in
  194. //------------- Receive Ports - RX Fabric Output Control Ports -------------
  195. .gt0_rxoutclk_out (gt0_rxoutclk_i[i]), // output wire gt0_rxoutclk_i
  196. .gt0_rxoutclkfabric_out ( ), // output wire gt0_rxoutclkfabric_out
  197. //----------- Receive Ports - RX Initialization and Reset Ports ------------
  198. .gt0_gtrxreset_in (1'b0), // input wire gt0_gtrxreset_in
  199. .gt0_rxpmareset_in (1'b0), // input wire gt0_rxpmareset_in
  200. //----------------- Receive Ports - RX8B/10B Decoder Ports -----------------
  201. .gt0_rxcharisk_out (rx_charisk[4*i+:4]), // output wire [3:0] gt0_rxcharisk_out
  202. //------------ Receive Ports -RX Initialization and Reset Ports ------------
  203. .gt0_rxresetdone_out (rx_resetdone[i]), // output wire gt0_rxresetdone_out
  204. //------------------- TX Initialization and Reset Ports --------------------
  205. .gt0_gttxreset_in (1'b0), // input wire gt0_gttxreset_in
  206. .gt0_txuserrdy_in (1'b0), // input wire gt0_txuserrdy_in
  207. //---------------- Transmit Ports - FPGA TX Interface Ports ----------------
  208. .gt0_txusrclk_in (gt0_txusrclk_i), // input wire gt0_txusrclk_i
  209. .gt0_txusrclk2_in (gt0_txusrclk_i), // input wire gt0_txusrclk2_i
  210. //---------------- Transmit Ports - TX Data Path interface -----------------
  211. .gt0_txdata_in (tx_data[32*i+:32]), // input wire [31:0] gt0_txdata_in
  212. //-------------- Transmit Ports - TX Driver and OOB signaling --------------
  213. .gt0_gtxtxn_out (gtxtxn_out[i]), // output wire gt0_gtxtxn_out
  214. .gt0_gtxtxp_out (gtxtxp_out[i]), // output wire gt0_gtxtxp_out
  215. //--------- Transmit Ports - TX Fabric Clock Output Control Ports ----------
  216. .gt0_txoutclk_out (gt0_txoutclk_i[i]), // output wire gt0_txoutclk_i
  217. .gt0_txoutclkfabric_out ( ), // output wire gt0_txoutclkfabric_out
  218. .gt0_txoutclkpcs_out ( ), // output wire gt0_txoutclkpcs_out
  219. //------------------- Transmit Ports - TX Gearbox Ports --------------------
  220. .gt0_txcharisk_in (tx_charisk[4*i+:4]), // input wire [3:0] gt0_txcharisk_in
  221. //----------- Transmit Ports - TX Initialization and Reset Ports -----------
  222. .gt0_txresetdone_out (tx_resetdone[i]), // output wire gt0_txresetdone_out
  223. .gt0_qplllock_in(gt0_qplllock_i),
  224. .gt0_qpllrefclklost_in(gt0_qpllrefclklost_i),
  225. .gt0_qpllreset_out(gt0_qpllreset_i[i]),
  226. .gt0_qplloutclk_in(gt0_qplloutclk_i),
  227. .gt0_qplloutrefclk_in(gt0_qplloutrefclk_i)
  228. );
  229. end
  230. endgenerate
  231. endmodule

相关问题记录:

1,GTX时钟专用buf原语   :

  1. IBUFDS_GTE2 IBUFDS_GTE2_inst (
  2. .O(gtx_clk_out),
  3. .ODIV2(),
  4. .I(gtx_clk_in_p),
  5. .CEB(1'b0),
  6. .IB(gtx_clk_in_n)
  7. );

2 ,光口接收时钟源配置一般有两种,使用RXOUTCLK,也可用RXOUTCLK;如果速率较高建议选择RXOUTCLK,保证数据和时钟同步,能更有效的保证数据采集。

3,data_valid_in端口外部配置1,改信号主要影响接收复位状态机。

e88da65f4cb7eca571e9014eeeaa05e8.png

4, gtx数据接口为isk和dat;isk和dat按字节对应。

2889d12edca1a9d2d0e51b26e99844c9.gif
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/807794
推荐阅读
相关标签
  

闽ICP备14008679号