From 305e2fa177e23ecf398374be36bcb8ed968dc5de Mon Sep 17 00:00:00 2001 From: morgan Date: Mon, 2 Sep 2024 13:06:43 +0800 Subject: [PATCH] cxp upconn: add IDLE word to debug fifo --- src/gateware/cxp_upconn.py | 65 +++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/src/gateware/cxp_upconn.py b/src/gateware/cxp_upconn.py index 8c81c18..2ef391e 100644 --- a/src/gateware/cxp_upconn.py +++ b/src/gateware/cxp_upconn.py @@ -95,7 +95,7 @@ class SERDES_10bits(Module): @ResetInserter() @CEInserter() class Packets_Scheduler(Module): - def __init__(self, tx_fifos, buf_out): + def __init__(self, tx_fifos, debug_buf): self.tx_enable = Signal() self.oe = Signal() @@ -126,6 +126,13 @@ class Packets_Scheduler(Module): NextValue(encoder.d, IDLE_CHARS[0][0]), NextValue(encoder.k, IDLE_CHARS[0][1]), NextState("START_TX"), + + # DEBUG: + If(debug_buf.sink_ack, + NextValue(debug_buf.sink_stb, 1), + NextValue(debug_buf.sink_data, IDLE_CHARS[0][0]), + NextValue(debug_buf.sink_k, IDLE_CHARS[0][1]), + ) ) ) @@ -146,10 +153,10 @@ class Packets_Scheduler(Module): encoder.k.eq(tx_fifos.source_k[0]), # DEBUG: - If(buf_out.sink_ack, - buf_out.sink_stb.eq(1), - buf_out.sink_data.eq(tx_fifos.source_data[0]), - buf_out.sink_k.eq(tx_fifos.source_k[0]), + If(debug_buf.sink_ack, + debug_buf.sink_stb.eq(1), + debug_buf.sink_data.eq(tx_fifos.source_data[0]), + debug_buf.sink_k.eq(tx_fifos.source_k[0]), ) ).Else( If(tx_charcount == 3, @@ -167,10 +174,10 @@ class Packets_Scheduler(Module): encoder.k.eq(tx_fifos.source_k[tx_fifos.pe.o]), # DEBUG: - If(buf_out.sink_ack, - buf_out.sink_stb.eq(1), - buf_out.sink_data.eq(tx_fifos.source_data[tx_fifos.pe.o]), - buf_out.sink_k.eq(tx_fifos.source_k[tx_fifos.pe.o]), + If(debug_buf.sink_ack, + debug_buf.sink_stb.eq(1), + debug_buf.sink_data.eq(tx_fifos.source_data[tx_fifos.pe.o]), + debug_buf.sink_k.eq(tx_fifos.source_k[tx_fifos.pe.o]), ) ).Else( # Section 9.2.5.1 (CXP-001-2021) @@ -182,11 +189,11 @@ class Packets_Scheduler(Module): encoder.k.eq(IDLE_CHARS[0][1]), # DEBUG: - # If(buf_out.sink.ack, - # buf_out.sink.stb.eq(1), - # buf_out.sink.data.eq(IDLE_CHARS[0][0]), - # buf_out.sink.k.eq(IDLE_CHARS[0][1]), - # ) + If(debug_buf.sink_ack, + debug_buf.sink_stb.eq(1), + debug_buf.sink_data.eq(IDLE_CHARS[0][0]), + debug_buf.sink_k.eq(IDLE_CHARS[0][1]), + ) ) ).Else( tx_charcount.eq(tx_charcount + 1), @@ -196,21 +203,21 @@ class Packets_Scheduler(Module): encoder.k.eq(tx_fifos.source_k[priorities]), # DEBUG: - If(buf_out.sink_ack, - buf_out.sink_stb.eq(1), - buf_out.sink_data.eq(tx_fifos.source_data[priorities]), - buf_out.sink_k.eq(tx_fifos.source_k[priorities]), + If(debug_buf.sink_ack, + debug_buf.sink_stb.eq(1), + debug_buf.sink_data.eq(tx_fifos.source_data[priorities]), + debug_buf.sink_k.eq(tx_fifos.source_k[priorities]), ) ).Else( encoder.d.eq(IDLE_CHARS[tx_charcount + 1][0]), encoder.k.eq(IDLE_CHARS[tx_charcount + 1][1]), # DEBUG: - # If(buf_out.sink.ack, - # buf_out.sink.stb.eq(1), - # buf_out.sink.data.eq(IDLE_CHARS[tx_charcount + 1][0]), - # buf_out.sink.k.eq(IDLE_CHARS[tx_charcount + 1][1]), - # ) + If(debug_buf.sink_ack, + debug_buf.sink_stb.eq(1), + debug_buf.sink_data.eq(IDLE_CHARS[tx_charcount + 1][0]), + debug_buf.sink_k.eq(IDLE_CHARS[tx_charcount + 1][1]), + ) ) ), ), @@ -269,7 +276,7 @@ class Debug_buffer(Module,AutoCSR): self.sync += [ If(self.sink_stb, # reset ack after asserted - # since upconn clk run much slower, the ack will be high for longer than expected which will result in data loss + # since upconn clk run much slower, the stb will be high for longer than expected which will result in multiple data entry self.sink_stb.eq(0), buf_out.sink.stb.eq(1), ).Else( @@ -353,11 +360,6 @@ class CXP_UpConn_PHY(Module, AutoCSR): # Instance("OBUF", i_I=cg.clk_10x, o_O=debug_sma.n_rx), - # pmod 0-7 pin - Instance("OBUF", i_I=debug_buf.buf_out.sink.stb, o_O=pmod_pads[4]), - Instance("OBUF", i_I=debug_buf.buf_out.sink.ack, o_O=pmod_pads[5]), - Instance("OBUF", i_I=debug_buf.buf_out.source.stb, o_O=pmod_pads[6]), - Instance("OBUF", i_I=debug_buf.buf_out.source.ack, o_O=pmod_pads[7]), # # pmod 0-7 pin # Instance("OBUF", i_I=serdes.o, o_O=pmod_pads[0]), @@ -365,6 +367,11 @@ class CXP_UpConn_PHY(Module, AutoCSR): # Instance("OBUF", i_I=~tx_fifos.pe.n, o_O=pmod_pads[2]), # Instance("OBUF", i_I=prioity_0, o_O=pmod_pads[3]), # Instance("OBUF", i_I=word_bound, o_O=pmod_pads[4]), + # Instance("OBUF", i_I=debug_buf.buf_out.sink.stb, o_O=pmod_pads[4]), + # Instance("OBUF", i_I=debug_buf.buf_out.sink.ack, o_O=pmod_pads[5]), + # Instance("OBUF", i_I=debug_buf.buf_out.source.stb, o_O=pmod_pads[6]), + # Instance("OBUF", i_I=debug_buf.buf_out.source.ack, o_O=pmod_pads[7]), + # Instance("OBUF", i_I=scheduler.idling, o_O=pmod_pads[5]), # # Instance("OBUF", i_I=tx_fifos.source_ack[0], o_O=pmod[6]), # # Instance("OBUF", i_I=tx_fifos.source_ack[2], o_O=pmod[6]),