forked from M-Labs/artiq-zynq
cxp downconn: refactor to allow gtx extensions
This commit is contained in:
parent
2dade34119
commit
f34f500ed8
|
@ -26,6 +26,7 @@ class CXP_DownConn(Module, AutoCSR):
|
||||||
self.qpll_reset = CSR()
|
self.qpll_reset = CSR()
|
||||||
self.qpll_locked = CSRStatus()
|
self.qpll_locked = CSRStatus()
|
||||||
|
|
||||||
|
self.gtxs = []
|
||||||
# # #
|
# # #
|
||||||
|
|
||||||
self.submodules.qpll = qpll = QPLL(refclk, sys_clk_freq)
|
self.submodules.qpll = qpll = QPLL(refclk, sys_clk_freq)
|
||||||
|
@ -34,31 +35,25 @@ class CXP_DownConn(Module, AutoCSR):
|
||||||
self.qpll_locked.status.eq(qpll.lock),
|
self.qpll_locked.status.eq(qpll.lock),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
nconn = len(pads)
|
||||||
|
|
||||||
|
for i in range(nconn):
|
||||||
|
if i != 0:
|
||||||
|
break
|
||||||
|
gtx = GTX(self.qpll, pads[i], sys_clk_freq, tx_mode="single", rx_mode="single")
|
||||||
|
self.gtxs.append(gtx)
|
||||||
|
setattr(self.submodules, "gtx"+str(i), gtx)
|
||||||
|
|
||||||
# TODO: add extension gtx connections
|
# TODO: add extension gtx connections
|
||||||
|
# TODO: add connection interface
|
||||||
|
|
||||||
# single & master tx_mode can lock with rx in loopback
|
|
||||||
self.submodules.gtx = gtx = GTX(self.qpll, pads[0], sys_clk_freq, tx_mode="single", rx_mode="single")
|
|
||||||
|
|
||||||
# NOTE: No need to connect cxp_gtx_tx, we don't use tx anyway (just for loopback)
|
|
||||||
|
|
||||||
# TODO: Connect slave cxp_gtx_rx clock tgt
|
# TODO: Connect slave cxp_gtx_rx clock tgt
|
||||||
# checkout channel interfaces & drtio_gtx
|
# checkout channel interfaces & drtio_gtx
|
||||||
# checkout GTPTXPhaseAlignement for inspiration
|
# GTPTXPhaseAlignement for inspiration
|
||||||
|
|
||||||
self.sync += [
|
# Connect all GTX connections' DRP
|
||||||
# GTX
|
|
||||||
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),
|
|
||||||
|
|
||||||
gtx.txenable.eq(self.txenable.storage[0]),
|
|
||||||
gtx.tx_restart.eq(self.tx_restart.re),
|
|
||||||
gtx.rx_restart.eq(self.rx_restart.re),
|
|
||||||
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 Channels DRP
|
|
||||||
self.tx_div = CSRStorage(3)
|
self.tx_div = CSRStorage(3)
|
||||||
self.rx_div = CSRStorage(3)
|
self.rx_div = CSRStorage(3)
|
||||||
|
|
||||||
|
@ -70,6 +65,19 @@ class CXP_DownConn(Module, AutoCSR):
|
||||||
self.gtx_dout = CSRStatus(16)
|
self.gtx_dout = CSRStatus(16)
|
||||||
self.gtx_dready = CSR()
|
self.gtx_dready = CSR()
|
||||||
|
|
||||||
|
for gtx in self.gtxs:
|
||||||
|
self.sync += [
|
||||||
|
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),
|
||||||
|
|
||||||
|
gtx.txenable.eq(self.txenable.storage[0]),
|
||||||
|
gtx.tx_restart.eq(self.tx_restart.re),
|
||||||
|
gtx.rx_restart.eq(self.rx_restart.re),
|
||||||
|
gtx.tx_init.clk_path_ready.eq(self.tx_start_init.storage),
|
||||||
|
gtx.rx_init.clk_path_ready.eq(self.rx_start_init.storage),
|
||||||
|
]
|
||||||
|
|
||||||
self.comb += gtx.dclk.eq(ClockSignal("sys"))
|
self.comb += gtx.dclk.eq(ClockSignal("sys"))
|
||||||
self.sync += [
|
self.sync += [
|
||||||
gtx.tx_rate.eq(self.tx_div.storage),
|
gtx.tx_rate.eq(self.tx_div.storage),
|
||||||
|
@ -95,6 +103,9 @@ class CXP_DownConn(Module, AutoCSR):
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# DEBUG: txusrclk PLL DRG
|
# DEBUG: txusrclk PLL DRG
|
||||||
|
|
||||||
self.txpll_reset = CSRStorage()
|
self.txpll_reset = CSRStorage()
|
||||||
|
@ -108,6 +119,7 @@ class CXP_DownConn(Module, AutoCSR):
|
||||||
self.pll_dout = CSRStatus(16)
|
self.pll_dout = CSRStatus(16)
|
||||||
self.pll_dready = CSRStatus()
|
self.pll_dready = CSRStatus()
|
||||||
|
|
||||||
|
for n, gtx in enumerate(self.gtxs):
|
||||||
self.comb += [
|
self.comb += [
|
||||||
gtx.txpll_reset.eq(self.txpll_reset.storage),
|
gtx.txpll_reset.eq(self.txpll_reset.storage),
|
||||||
gtx.pll_daddr.eq(self.pll_daddr.storage),
|
gtx.pll_daddr.eq(self.pll_daddr.storage),
|
||||||
|
@ -126,6 +138,7 @@ class CXP_DownConn(Module, AutoCSR):
|
||||||
self.comb += gtx.loopback_mode.eq(self.loopback_mode.storage)
|
self.comb += gtx.loopback_mode.eq(self.loopback_mode.storage)
|
||||||
|
|
||||||
# DEBUG: IO SMA & PMOD
|
# DEBUG: IO SMA & PMOD
|
||||||
|
if n == 0:
|
||||||
self.specials += [
|
self.specials += [
|
||||||
Instance("OBUF", i_I=gtx.cd_cxp_gtx_rx.clk, o_O=debug_sma.p_tx),
|
Instance("OBUF", i_I=gtx.cd_cxp_gtx_rx.clk, o_O=debug_sma.p_tx),
|
||||||
Instance("OBUF", i_I=gtx.cd_cxp_gtx_tx.clk, o_O=debug_sma.n_rx),
|
Instance("OBUF", i_I=gtx.cd_cxp_gtx_tx.clk, o_O=debug_sma.n_rx),
|
||||||
|
@ -150,14 +163,14 @@ class CXP_DownConn(Module, AutoCSR):
|
||||||
|
|
||||||
|
|
||||||
self.sync.cxp_gtx_tx += [
|
self.sync.cxp_gtx_tx += [
|
||||||
self.gtx.encoder.d[0].eq(0xBC),
|
gtx.encoder.d[0].eq(0xBC),
|
||||||
self.gtx.encoder.k[0].eq(1),
|
gtx.encoder.k[0].eq(1),
|
||||||
self.gtx.encoder.d[1].eq(0x3C),
|
gtx.encoder.d[1].eq(0x3C),
|
||||||
self.gtx.encoder.k[1].eq(1),
|
gtx.encoder.k[1].eq(1),
|
||||||
self.gtx.encoder.d[2].eq(0x3C),
|
gtx.encoder.d[2].eq(0x3C),
|
||||||
self.gtx.encoder.k[2].eq(1),
|
gtx.encoder.k[2].eq(1),
|
||||||
self.gtx.encoder.d[3].eq(0xB5),
|
gtx.encoder.d[3].eq(0xB5),
|
||||||
self.gtx.encoder.k[3].eq(0),
|
gtx.encoder.k[3].eq(0),
|
||||||
]
|
]
|
||||||
|
|
||||||
self.rxdata_0 = CSRStatus(10)
|
self.rxdata_0 = CSRStatus(10)
|
||||||
|
@ -174,21 +187,21 @@ class CXP_DownConn(Module, AutoCSR):
|
||||||
self.decoded_k_3 = CSRStatus()
|
self.decoded_k_3 = CSRStatus()
|
||||||
|
|
||||||
self.sync.cxp_gtx_rx += [
|
self.sync.cxp_gtx_rx += [
|
||||||
self.rxdata_0.status.eq(self.gtx.decoders[0].input),
|
self.rxdata_0.status.eq(gtx.decoders[0].input),
|
||||||
self.decoded_data_0.status.eq(self.gtx.decoders[0].d),
|
self.decoded_data_0.status.eq(gtx.decoders[0].d),
|
||||||
self.decoded_k_0.status.eq(self.gtx.decoders[0].k),
|
self.decoded_k_0.status.eq(gtx.decoders[0].k),
|
||||||
|
|
||||||
self.rxdata_1.status.eq(self.gtx.decoders[1].input),
|
self.rxdata_1.status.eq(gtx.decoders[1].input),
|
||||||
self.decoded_data_1.status.eq(self.gtx.decoders[1].d),
|
self.decoded_data_1.status.eq(gtx.decoders[1].d),
|
||||||
self.decoded_k_1.status.eq(self.gtx.decoders[1].k),
|
self.decoded_k_1.status.eq(gtx.decoders[1].k),
|
||||||
|
|
||||||
self.rxdata_2.status.eq(self.gtx.decoders[2].input),
|
self.rxdata_2.status.eq(gtx.decoders[2].input),
|
||||||
self.decoded_data_2.status.eq(self.gtx.decoders[2].d),
|
self.decoded_data_2.status.eq(gtx.decoders[2].d),
|
||||||
self.decoded_k_2.status.eq(self.gtx.decoders[2].k),
|
self.decoded_k_2.status.eq(gtx.decoders[2].k),
|
||||||
|
|
||||||
self.rxdata_3.status.eq(self.gtx.decoders[3].input),
|
self.rxdata_3.status.eq(gtx.decoders[3].input),
|
||||||
self.decoded_data_3.status.eq(self.gtx.decoders[3].d),
|
self.decoded_data_3.status.eq(gtx.decoders[3].d),
|
||||||
self.decoded_k_3.status.eq(self.gtx.decoders[3].k),
|
self.decoded_k_3.status.eq(gtx.decoders[3].k),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue