1
0
Fork 0

pipeline GW: refactor byte2word & cleanup

This commit is contained in:
morgan 2024-09-20 15:11:12 +08:00
parent 04e8a7d59f
commit 89be86be88
1 changed files with 23 additions and 10 deletions

View File

@ -3,6 +3,9 @@ from misoc.interconnect.csr import *
from misoc.interconnect import stream from misoc.interconnect import stream
from misoc.cores.liteeth_mini.mac.crc import LiteEthMACCRCEngine, LiteEthMACCRCChecker from misoc.cores.liteeth_mini.mac.crc import LiteEthMACCRCEngine, LiteEthMACCRCChecker
import struct
upconn_dw = 8 upconn_dw = 8
upconn_layout = [("data", upconn_dw), ("k", upconn_dw//8)] upconn_layout = [("data", upconn_dw), ("k", upconn_dw//8)]
@ -22,12 +25,11 @@ KCode = {
} }
def _bytes2word(arr): def _bytes2word(bytes, big_endian=True):
assert len(arr) == 4 if big_endian:
sum = 0 return struct.unpack(">I", struct.pack(">4B", *bytes))[0]
for i, val in enumerate(arr): else:
sum += (val & 0xFF) << i*8 return struct.unpack("<I", struct.pack(">4B", *bytes))[0]
return sum
class Code_Source(Module): class Code_Source(Module):
def __init__(self, layout, counts=4): def __init__(self, layout, counts=4):
@ -390,6 +392,8 @@ class Receiver_Path(Module, AutoCSR):
# TODO: # TODO:
self.packet_type = Signal(8) self.packet_type = Signal(8)
self.decoder_err = Signal()
self.decoder_err_clr = Signal()
# # # # # #
@ -398,10 +402,19 @@ class Receiver_Path(Module, AutoCSR):
self.submodules.packet_decoder = packet_decoder = CXP_Data_Packet_Decode() self.submodules.packet_decoder = packet_decoder = CXP_Data_Packet_Decode()
self.sync += [ self.sync += [
If(trig_ack_checker.ack, If(trig_ack_checker.ack,
self.trig_ack.eq(1), self.trig_ack.eq(1),
).Elif(self.trig_clr, ).Elif(self.trig_clr,
self.trig_ack.eq(0), self.trig_ack.eq(0),
),
If(packet_decoder.decode_err,
self.decoder_err.eq(1),
).Elif(self.decoder_err_clr,
self.decoder_err.eq(0),
) )
]
self.comb += [
self.packet_type.eq(packet_decoder.packet_type),
] ]
@ -465,11 +478,11 @@ class CXP_Data_Packet_Decode(Module):
).Elif(self.packet_type == type["debug"], ).Elif(self.packet_type == type["debug"],
self.sink.connect(self.source), self.sink.connect(self.source),
).Else( ).Else(
# discard K29,7
self.sink.ack.eq(1), self.sink.ack.eq(1),
NextValue(self.decode_err, 1), self.decode_err.eq(1),
) )
) )
class CXP_Trig_Ack_Checker(Module, AutoCSR): class CXP_Trig_Ack_Checker(Module, AutoCSR):
def __init__(self): def __init__(self):
self.sink = stream.Endpoint(downconn_layout) self.sink = stream.Endpoint(downconn_layout)