From 8ba7793b245c0d2c3cf1c475521443716575fc1f Mon Sep 17 00:00:00 2001 From: morgan Date: Fri, 28 Jun 2024 12:46:35 +0800 Subject: [PATCH] cxp upconn: fix word count issue --- src/gateware/cxp_upconn.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/gateware/cxp_upconn.py b/src/gateware/cxp_upconn.py index ae8f9ba..3aa09b5 100644 --- a/src/gateware/cxp_upconn.py +++ b/src/gateware/cxp_upconn.py @@ -10,12 +10,9 @@ from misoc.interconnect.csr import * IDLE_CHARS = [ #[data, k] [0b10111100, 1], #K28.5 - [0b10111100, 1], #K28.5 - [0b10111100, 1], #K28.5 - [0b10111100, 1], #K28.5 - # [0b00111100, 1], #K28.1 - # [0b00111100, 1], #K28.1 - # [0b10111100, 0], #D28.5 + [0b00111100, 1], #K28.1 + [0b00111100, 1], #K28.1 + [0b10111100, 0], #D28.5 ] @@ -82,7 +79,7 @@ class CXP_UpConn(Module, AutoCSR): NextValue(self.encoder.d, IDLE_CHARS[0][0]), NextValue(self.encoder.k, IDLE_CHARS[0][1]), NextValue(self.encoder.disp_in, 0), - NextValue(tx_wordcount, 0), + NextValue(tx_wordcount, 1), NextValue(tx_bitcount, 0), NextState("LOAD_CHAR") ) @@ -103,6 +100,9 @@ class CXP_UpConn(Module, AutoCSR): ) # CXP 2.1 section 9.2.4 + # Higher priority packet can be inserted into a lower priority packet during transmission + # Priority lv 0 can be inserted in char boundary of the packet + # Priority lv 1-2 need to be inserted in word boundary of the packet self.sync.cxp_upconn += [ self.tx_fifos.disp_in.eq(disp), self.encoder.disp_in.eq(disp), @@ -122,10 +122,15 @@ class CXP_UpConn(Module, AutoCSR): self.tx_fifos.source_ack[0].eq(1), disp.eq(self.tx_fifos.disp_out[0]), ).Else( - # at word boundary - If(tx_wordcount == 3, + # priority zero doesn't contribute to word count + If(tx_wordcount != 3, + tx_wordcount.eq(tx_wordcount + 1), + ).Else( tx_wordcount.eq(0), - # at word boundary + ), + + # word boundary + If(tx_wordcount == 0, If(~self.tx_fifos.pe.n, idling.eq(0), priority.eq(self.tx_fifos.pe.o), @@ -138,8 +143,6 @@ class CXP_UpConn(Module, AutoCSR): disp.eq(self.encoder.disp_out), ) ).Else( - # priority zero doesn't contribute to word count - tx_wordcount.eq(tx_wordcount + 1), If(~idling, self.tx_fifos.source_ack[priority].eq(1), tx_reg.eq(self.tx_fifos.source_data[priority]), @@ -171,7 +174,7 @@ class CXP_UpConn(Module, AutoCSR): p2 = Signal() self.comb += [ ninth_bit.eq(tx_bitcount == 9), - word_bound.eq(tx_wordcount == 3), + word_bound.eq(tx_wordcount == 0), p1.eq(priority == 1), p2.eq(priority == 2), ]