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.cores.liteeth_mini.mac.crc import LiteEthMACCRCEngine, LiteEthMACCRCChecker
import struct
upconn_dw = 8
upconn_layout = [("data", upconn_dw), ("k", upconn_dw//8)]
@ -22,12 +25,11 @@ KCode = {
}
def _bytes2word(arr):
assert len(arr) == 4
sum = 0
for i, val in enumerate(arr):
sum += (val & 0xFF) << i*8
return sum
def _bytes2word(bytes, big_endian=True):
if big_endian:
return struct.unpack(">I", struct.pack(">4B", *bytes))[0]
else:
return struct.unpack("<I", struct.pack(">4B", *bytes))[0]
class Code_Source(Module):
def __init__(self, layout, counts=4):
@ -390,6 +392,8 @@ class Receiver_Path(Module, AutoCSR):
# TODO:
self.packet_type = Signal(8)
self.decoder_err = Signal()
self.decoder_err_clr = Signal()
# # #
@ -401,7 +405,16 @@ class Receiver_Path(Module, AutoCSR):
self.trig_ack.eq(1),
).Elif(self.trig_clr,
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"],
self.sink.connect(self.source),
).Else(
# discard K29,7
self.sink.ack.eq(1),
NextValue(self.decode_err, 1),
self.decode_err.eq(1),
)
)
class CXP_Trig_Ack_Checker(Module, AutoCSR):
def __init__(self):
self.sink = stream.Endpoint(downconn_layout)