frontend/etherbone: timing optimizations

This commit is contained in:
Florent Kermarrec 2017-07-19 12:20:17 +02:00
parent 042d3aee3e
commit c43fb269a7
1 changed files with 33 additions and 23 deletions

View File

@ -283,41 +283,49 @@ class LiteEthEtherboneRecordSender(Module):
# # # # # #
# TODO: optimize ressources (no need to store parameters as datas) # TODO: optimize ressources (no need to store parameters as datas)
pbuffer = stream.SyncFIFO(eth_etherbone_mmap_description(32), buffer_depth) fifo = stream.SyncFIFO(eth_etherbone_mmap_description(32), buffer_depth,
self.submodules += pbuffer buffered=True)
self.comb += sink.connect(pbuffer.sink) self.submodules += fifo
self.comb += sink.connect(fifo.sink)
data_sel = Signal()
self.submodules.fsm = fsm = FSM(reset_state="IDLE") self.submodules.fsm = fsm = FSM(reset_state="IDLE")
fsm.act("IDLE", fsm.act("IDLE",
pbuffer.source.ready.eq(1), fifo.source.ready.eq(1),
If(pbuffer.source.valid, If(fifo.source.valid,
pbuffer.source.ready.eq(0), fifo.source.ready.eq(0),
NextState("SEND_BASE_ADDRESS") NextState("SEND_BASE_ADDRESS")
) )
) )
self.comb += [ self.sync += [
source.byte_enable.eq(pbuffer.source.be), source.byte_enable.eq(fifo.source.be),
If(pbuffer.source.we, If(fifo.source.we,
source.wcount.eq(pbuffer.source.count) source.wcount.eq(fifo.source.count)
).Else( ).Else(
source.rcount.eq(pbuffer.source.count) source.rcount.eq(fifo.source.count)
),
If(data_sel,
source.data.eq(fifo.source.data)
).Else(
source.data.eq(fifo.source.base_addr)
) )
] ]
fsm.act("SEND_BASE_ADDRESS", fsm.act("SEND_BASE_ADDRESS",
source.valid.eq(pbuffer.source.valid), source.valid.eq(1),
source.last.eq(0), source.last.eq(0),
source.data.eq(pbuffer.source.base_addr),
If(source.ready, If(source.ready,
data_sel.eq(1),
NextState("SEND_DATA") NextState("SEND_DATA")
) )
) )
fsm.act("SEND_DATA", fsm.act("SEND_DATA",
source.valid.eq(pbuffer.source.valid), source.valid.eq(1),
source.last.eq(pbuffer.source.last), source.last.eq(fifo.source.last),
source.data.eq(pbuffer.source.data), data_sel.eq(1),
If(source.valid & source.ready, If(source.valid & source.ready,
pbuffer.source.ready.eq(1), fifo.source.ready.eq(1),
If(source.last, If(source.last,
NextState("IDLE") NextState("IDLE")
) )
@ -380,9 +388,7 @@ class LiteEthEtherboneWishboneMaster(Module):
# # # # # #
data = Signal(32, reset_less=True)
data_update = Signal() data_update = Signal()
self.sync += If(data_update, data.eq(bus.dat_r))
self.submodules.fsm = fsm = FSM(reset_state="IDLE") self.submodules.fsm = fsm = FSM(reset_state="IDLE")
fsm.act("IDLE", fsm.act("IDLE",
@ -420,15 +426,19 @@ class LiteEthEtherboneWishboneMaster(Module):
NextState("SEND_DATA") NextState("SEND_DATA")
) )
) )
fsm.act("SEND_DATA", self.sync += [
source.valid.eq(sink.valid),
source.last.eq(sink.last),
source.base_addr.eq(sink.base_addr), source.base_addr.eq(sink.base_addr),
source.addr.eq(sink.addr), source.addr.eq(sink.addr),
source.count.eq(sink.count), source.count.eq(sink.count),
source.be.eq(sink.be), source.be.eq(sink.be),
source.we.eq(1), source.we.eq(1),
source.data.eq(data), If(data_update,
source.data.eq(bus.dat_r)
)
]
fsm.act("SEND_DATA",
source.valid.eq(sink.valid),
source.last.eq(sink.last),
If(source.valid & source.ready, If(source.valid & source.ready,
sink.ready.eq(1), sink.ready.eq(1),
If(source.last, If(source.last,