core/mac: simplify/improve performance of LiteEthMACSRAMReader
now read data from sram on every clock cycle, allow lower system clock frequency (tested with 50MHz system clock / 125MHz ethernet clock)
This commit is contained in:
parent
c6875b7bff
commit
f55ce1aac6
|
@ -167,22 +167,14 @@ class LiteEthMACSRAMReader(Module, AutoCSR):
|
||||||
|
|
||||||
# fsm
|
# fsm
|
||||||
last = Signal()
|
last = Signal()
|
||||||
last_d = Signal()
|
|
||||||
|
|
||||||
fsm = FSM(reset_state="IDLE")
|
fsm = FSM(reset_state="IDLE")
|
||||||
self.submodules += fsm
|
self.submodules += fsm
|
||||||
|
|
||||||
fsm.act("IDLE",
|
fsm.act("IDLE",
|
||||||
counter_reset.eq(1),
|
|
||||||
If(fifo.source.valid,
|
If(fifo.source.valid,
|
||||||
NextState("CHECK")
|
counter_ce.eq(1),
|
||||||
)
|
NextState("SEND")
|
||||||
)
|
|
||||||
fsm.act("CHECK",
|
|
||||||
If(~last_d,
|
|
||||||
NextState("SEND"),
|
|
||||||
).Else(
|
|
||||||
NextState("END"),
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
length_lsb = fifo.source.length[0:2]
|
length_lsb = fifo.source.length[0:2]
|
||||||
|
@ -203,19 +195,21 @@ class LiteEthMACSRAMReader(Module, AutoCSR):
|
||||||
source.valid.eq(1),
|
source.valid.eq(1),
|
||||||
source.last.eq(last),
|
source.last.eq(last),
|
||||||
If(source.ready,
|
If(source.ready,
|
||||||
counter_ce.eq(~last),
|
counter_ce.eq(1),
|
||||||
NextState("CHECK")
|
If(last,
|
||||||
|
NextState("TERMINATE")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
fsm.act("END",
|
)
|
||||||
|
fsm.act("TERMINATE",
|
||||||
fifo.source.ready.eq(1),
|
fifo.source.ready.eq(1),
|
||||||
self.ev.done.trigger.eq(1),
|
self.ev.done.trigger.eq(1),
|
||||||
|
counter_reset.eq(1),
|
||||||
NextState("IDLE")
|
NextState("IDLE")
|
||||||
)
|
)
|
||||||
|
|
||||||
# last computation
|
# last computation
|
||||||
self.comb += last.eq((counter + 4) >= fifo.source.length)
|
self.comb += last.eq(counter >= fifo.source.length)
|
||||||
self.sync += last_d.eq(last)
|
|
||||||
|
|
||||||
# memory
|
# memory
|
||||||
rd_slot = fifo.source.slot
|
rd_slot = fifo.source.slot
|
||||||
|
|
|
@ -142,7 +142,7 @@ if __name__ == "__main__":
|
||||||
tb.phy_model.generator()],
|
tb.phy_model.generator()],
|
||||||
"eth_rx": tb.phy_model.phy_source.generator()
|
"eth_rx": tb.phy_model.phy_source.generator()
|
||||||
}
|
}
|
||||||
clocks = {"sys": 10,
|
clocks = {"sys": 20,
|
||||||
"eth_rx": 10,
|
"eth_rx": 8,
|
||||||
"eth_tx": 10}
|
"eth_tx": 8}
|
||||||
run_simulation(tb, generators, clocks, vcd_name="sim.vcd")
|
run_simulation(tb, generators, clocks, vcd_name="sim.vcd")
|
||||||
|
|
Loading…
Reference in New Issue