1
0
Fork 0

cxp downconn: fix tx reset & cleanup

This commit is contained in:
morgan 2024-08-01 11:21:36 +08:00
parent e0369d2eb2
commit 5a40422f1d
1 changed files with 37 additions and 36 deletions

View File

@ -32,10 +32,10 @@ class CXP_DownConn(Module, AutoCSR):
# # #
self.submodules.qpll = QPLL(refclk, sys_clk_freq)
self.submodules.qpll = qpll = QPLL(refclk, sys_clk_freq)
# single & master tx_mode can lock with rx in loopback
self.submodules.gtx = GTX(self.qpll, pads, sys_clk_freq, tx_mode="single", rx_mode="single")
self.submodules.gtx = gtx = GTX(self.qpll, pads, sys_clk_freq, tx_mode="single", rx_mode="single")
# TEST: txusrclk alignment
# 1) use GTREFCLK with TXSYSCLKSEL = 0b10 -> still inconsistant
@ -44,26 +44,28 @@ class CXP_DownConn(Module, AutoCSR):
self.sync += [
# PLL
self.qpll.reset.eq(self.qpll_reset.re),
self.qpll_locked.status.eq(self.qpll.lock),
qpll.reset.eq(self.qpll_reset.re),
self.qpll_locked.status.eq(qpll.lock),
# GTX
self.txinit_phaligndone.status.eq(self.gtx.tx_init.Xxphaligndone),
self.rxinit_phaligndone.status.eq(self.gtx.rx_init.Xxphaligndone),
self.rx_ready.status.eq(self.gtx.rx_ready),
self.txinit_phaligndone.status.eq(gtx.tx_init.Xxphaligndone),
self.rxinit_phaligndone.status.eq(gtx.rx_init.Xxphaligndone),
self.rx_ready.status.eq(gtx.rx_ready),
self.gtx.txenable.eq(self.txenable.storage[0]),
self.gtx.tx_restart.eq(self.tx_restart.re),
self.gtx.rx_restart.eq(self.rx_restart.storage),
self.gtx.tx_init.clk_path_ready.eq(self.tx_start_init.storage),
self.gtx.rx_init.clk_path_ready.eq(self.rx_start_init.storage),
# self.gtx.rx_alignment_en.eq(self.rx_data_alignment.storage),
gtx.txenable.eq(self.txenable.storage[0]),
gtx.tx_restart.eq(self.tx_restart.re),
gtx.rx_restart.eq(self.rx_restart.storage),
gtx.tx_init.clk_path_ready.eq(self.tx_start_init.storage),
gtx.rx_init.clk_path_ready.eq(self.rx_start_init.storage),
# gtx.rx_alignment_en.eq(self.rx_data_alignment.storage),
# GTX DRP
self.gtx.tx_rate.eq(self.tx_div.storage),
self.gtx.rx_rate.eq(self.rx_div.storage),
gtx.tx_rate.eq(self.tx_div.storage),
gtx.rx_rate.eq(self.rx_div.storage),
]
# DEBUG: txusrclk PLL DRG
self.txpll_reset = CSRStorage()
self.pll_daddr = CSRStorage(7)
self.pll_dclk = CSRStorage()
@ -76,32 +78,32 @@ class CXP_DownConn(Module, AutoCSR):
self.pll_dready = CSRStatus()
self.comb += [
self.gtx.txpll_reset.eq(self.txpll_reset.storage),
self.gtx.pll_daddr.eq(self.pll_daddr.storage),
self.gtx.pll_dclk.eq(self.pll_dclk.storage),
self.gtx.pll_den.eq(self.pll_den.storage),
self.gtx.pll_din.eq(self.pll_din.storage),
self.gtx.pll_dwen.eq(self.pll_dwen.storage),
gtx.txpll_reset.eq(self.txpll_reset.storage),
gtx.pll_daddr.eq(self.pll_daddr.storage),
gtx.pll_dclk.eq(self.pll_dclk.storage),
gtx.pll_den.eq(self.pll_den.storage),
gtx.pll_din.eq(self.pll_din.storage),
gtx.pll_dwen.eq(self.pll_dwen.storage),
self.txpll_locked.status.eq(self.gtx.txpll_locked),
self.pll_dout.status.eq(self.gtx.pll_dout),
self.pll_dready.status.eq(self.gtx.pll_dready),
self.txpll_locked.status.eq(gtx.txpll_locked),
self.pll_dout.status.eq(gtx.pll_dout),
self.pll_dready.status.eq(gtx.pll_dready),
]
# DEBUG:loopback
self.loopback_mode = CSRStorage(3)
self.comb += self.gtx.loopback_mode.eq(self.loopback_mode.storage)
self.comb += gtx.loopback_mode.eq(self.loopback_mode.storage)
# DEBUG:SMA
# DEBUG: IO SMA & PMOD
self.specials += [
Instance("OBUF", i_I=self.gtx.rxoutclk, o_O=debug_sma.p_tx),
Instance("OBUF", i_I=self.gtx.cd_cxp_gtx_tx.clk, o_O=debug_sma.n_rx),
Instance("OBUF", i_I=gtx.rxoutclk, o_O=debug_sma.p_tx),
Instance("OBUF", i_I=gtx.cd_cxp_gtx_tx.clk, o_O=debug_sma.n_rx),
# pmod 0-7 pin
Instance("OBUF", i_I=self.qpll.lock, o_O=pmod_pads[0]),
Instance("OBUF", i_I=self.qpll.reset, o_O=pmod_pads[1]),
Instance("OBUF", i_I=self.gtx.tx_init.gtXxreset, o_O=pmod_pads[2]),
# Instance("OBUF", i_I=, o_O=pmod_pads[3]),
Instance("OBUF", i_I=gtx.tx_init.gtXxreset, o_O=pmod_pads[0]),
Instance("OBUF", i_I=gtx.tx_init.Xxdlysreset, o_O=pmod_pads[1]),
Instance("OBUF", i_I=gtx.tx_init.Xxdlysresetdone , o_O=pmod_pads[2]),
Instance("OBUF", i_I=gtx.tx_init.Xxphaligndone , o_O=pmod_pads[3]),
# Instance("OBUF", i_I=, o_O=pmod_pads[4]),
# Instance("OBUF", i_I=, o_O=pmod_pads[5]),
# Instance("OBUF", i_I=, o_O=pmod_pads[6]),
@ -397,11 +399,10 @@ class GTX(Module):
# # #
# TX generates cxp_tx clock, init must be in system domain
self.submodules.tx_init = tx_init = GTXInit(sys_clk_freq, False, mode=tx_mode)
# RX receives restart commands from RTIO domain
# DEBUG: 500e6 is used to fix tx reset by holding gtxtxreset for a couple cycle more
self.submodules.tx_init = tx_init = GTXInit(500e6, False, mode=tx_mode)
# RX receives restart commands from txusrclk domain
self.submodules.rx_init = rx_init = ClockDomainsRenamer("cxp_gtx_tx")(GTXInit(qpll.tx_usrclk_freq, True, mode=rx_mode))
# DEBUG: change back to cxp_gtx_tx once QPLL works
# self.submodules.rx_init = rx_init = GTXInit(sys_clk_freq, True, mode=rx_mode)
self.comb += [
tx_init.cplllock.eq(qpll.lock),