1
0
Fork 0

pipeline GW: cleanup

This commit is contained in:
morgan 2024-10-09 12:45:37 +08:00
parent cc066933fb
commit 59e3b2f1c4
1 changed files with 14 additions and 36 deletions

View File

@ -330,8 +330,6 @@ class CXP_Data_Packet_Decode(Module):
self.buffer_err = Signal()
# # #
# DEBUG: remove debug
# TODO: decode all packet type here
# TODO: heartbeat
type = {
"data_stream": 0x01,
@ -340,29 +338,14 @@ class CXP_Data_Packet_Decode(Module):
"control_ack_with_tag": 0x06,
"event": 0x07,
"heartbeat": 0x09,
"debug" : 0x02,
}
self.sink = stream.Endpoint(word_layout)
self.source = stream.Endpoint(word_layout)
self.submodules.fsm = fsm = FSM(reset_state="IDLE")
self.submodules.voter = voter = Duplicate_Majority_Voter(self.sink.data, self.sink.k)
# # Section 9.2.2.1 (CXP-001-2021)
# # decoder should immune to single bit errors when handling duplicated characters
# char_majority = Signal(char_width)
# k_majority = Signal()
# a, b, c, d = self.sink.data[:8], self.sink.data[8:16], self.sink.data[16:24], self.sink.data[24:]
# a_k, b_k, c_k, d_k = self.sink.k[0], self.sink.k[1], self.sink.k[2], self.sink.k[3]
# self.comb += [
# char_majority.eq(a&b&c | a&b&d | a&c&d | b&c&d),
# k_majority.eq(a_k&b_k&c_k | a_k&b_k&d_k | a_k&c_k&d_k | b_k&c_k&d_k),
# ]
fsm.act("IDLE",
self.sink.ack.eq(1),
If((self.sink.stb & (voter.char == KCode["pak_start"]) & (voter.k == 1)),
@ -380,14 +363,14 @@ class CXP_Data_Packet_Decode(Module):
Case(voter.char, {
type["data_stream"]: NextState("STREAMING"),
type["control_ack_no_tag"]:[
NextValue(addr, addr.reset),
NextState("LOAD_BUFFER"),
],
type["test_packet"]: [
NextValue(cnt, cnt.reset),
NextState("VERIFY_TEST_PATTERN"),
],
type["control_ack_no_tag"]:[
NextValue(addr, addr.reset),
NextState("LOAD_BUFFER"),
],
type["control_ack_with_tag"]:[
NextValue(addr, addr.reset),
NextState("LOAD_BUFFER"),
@ -396,10 +379,6 @@ class CXP_Data_Packet_Decode(Module):
NextValue(addr, addr.reset),
NextState("LOAD_BUFFER"),
],
type["debug"]: [
NextValue(addr, addr.reset),
NextState("LOAD_BUFFER"),
],
"default": [
self.decode_err.eq(1),
# wait till next valid packet
@ -408,6 +387,16 @@ class CXP_Data_Packet_Decode(Module):
}),
)
)
# For stream data packet
fsm.act("STREAMING",
If((self.sink.stb & (voter.char == KCode["pak_end"]) & (voter.k == 1)),
# discard K29,7
self.sink.ack.eq(1),
NextState("IDLE")
).Else(
self.sink.connect(self.source),
)
)
# Section 9.9.1 (CXP-001-2021)
# the received test data packet (0x00, 0x01 ... 0xFF)
@ -431,17 +420,6 @@ class CXP_Data_Packet_Decode(Module):
)
# For stream data packet
fsm.act("STREAMING",
If((self.sink.stb & (voter.char == KCode["pak_end"]) & (voter.k == 1)),
# discard K29,7
self.sink.ack.eq(1),
NextState("IDLE")
).Else(
self.sink.connect(self.source),
)
)
# A circular buffer for firmware to read packet from
self.specials.mem = mem = Memory(word_dw, buffer_count*buffer_depth)
self.specials.mem_port = mem_port = mem.get_port(write_capable=True)