cri: add buffer space request protocol

This commit is contained in:
Sebastien Bourdeauducq 2018-08-29 15:16:43 +08:00
parent ba6094c3e5
commit aa64e6c1c6
3 changed files with 23 additions and 9 deletions

View File

@ -113,7 +113,7 @@ class RTPacketSatellite(Module):
rx_plm.types["echo_request"]: echo_req.eq(1), rx_plm.types["echo_request"]: echo_req.eq(1),
rx_plm.types["set_time"]: NextState("SET_TIME"), rx_plm.types["set_time"]: NextState("SET_TIME"),
rx_plm.types["write"]: NextState("WRITE"), rx_plm.types["write"]: NextState("WRITE"),
rx_plm.types["buffer_space_request"]: NextState("BUFFER_SPACE"), rx_plm.types["buffer_space_request"]: NextState("BUFFER_SPACE_REQUEST"),
rx_plm.types["read_request"]: NextState("READ_REQUEST"), rx_plm.types["read_request"]: NextState("READ_REQUEST"),
"default": self.unknown_packet_type.eq(1) "default": self.unknown_packet_type.eq(1)
}) })
@ -142,10 +142,16 @@ class RTPacketSatellite(Module):
) )
) )
) )
rx_fsm.act("BUFFER_SPACE_REQUEST",
self.cri.cmd.eq(cri.commands["get_buffer_space"]),
NextState("BUFFER_SPACE")
)
rx_fsm.act("BUFFER_SPACE", rx_fsm.act("BUFFER_SPACE",
buffer_space_set.eq(1), If(self.cri.o_buffer_space_valid,
buffer_space_update.eq(1), buffer_space_set.eq(1),
NextState("INPUT") buffer_space_update.eq(1),
NextState("INPUT")
)
) )
rx_fsm.act("READ_REQUEST", rx_fsm.act("READ_REQUEST",

View File

@ -13,11 +13,13 @@ from misoc.interconnect.csr import *
commands = { commands = {
"nop": 0, "nop": 0,
"write": 1, "write": 1,
# i_status should have the "wait for status" bit set until # i_status should have the "wait for status" bit set until
# an event is available, or timestamp is reached. # an event is available, or timestamp is reached.
"read": 2 "read": 2,
# targets must assert o_buffer_space_valid in response
# to this command
"get_buffer_space": 3
} }
@ -32,8 +34,11 @@ layout = [
# o_status bits: # o_status bits:
# <0:wait> <1:underflow> <2:link error> # <0:wait> <1:underflow> <2:link error>
("o_status", 3, DIR_S_TO_M), ("o_status", 3, DIR_S_TO_M),
# targets may optionally report a pessimistic estimate of the number
# of outputs events that can be written without waiting. # pessimistic estimate of the number of outputs events that can be
# written without waiting.
# this feature may be omitted on systems without DRTIO.
("o_buffer_space_valid", 1, DIR_S_TO_M),
("o_buffer_space", 16, DIR_S_TO_M), ("o_buffer_space", 16, DIR_S_TO_M),
("i_data", 32, DIR_S_TO_M), ("i_data", 32, DIR_S_TO_M),

View File

@ -55,7 +55,10 @@ class SED(Module):
self.comb += i.eq(o) self.comb += i.eq(o)
if report_buffer_space: if report_buffer_space:
self.comb += self.cri.o_buffer_space.eq(self.fifos.buffer_space) self.comb += [
self.cri.o_buffer_space_valid.eq(1),
self.cri.o_buffer_space.eq(self.fifos.buffer_space)
]
@property @property
def cri(self): def cri(self):