core/bandwidth: avoid missing a command
This commit is contained in:
parent
c03bed8ef6
commit
f0496b20ec
|
@ -14,8 +14,8 @@ from litex.soc.interconnect.csr import *
|
||||||
class Bandwidth(Module, AutoCSR):
|
class Bandwidth(Module, AutoCSR):
|
||||||
def __init__(self, cmd, data_width, period_bits=24):
|
def __init__(self, cmd, data_width, period_bits=24):
|
||||||
self.update = CSR()
|
self.update = CSR()
|
||||||
self.nreads = CSRStatus(period_bits)
|
self.nreads = CSRStatus(period_bits + 1)
|
||||||
self.nwrites = CSRStatus(period_bits)
|
self.nwrites = CSRStatus(period_bits + 1)
|
||||||
self.data_width = CSRStatus(bits_for(data_width), reset=data_width)
|
self.data_width = CSRStatus(bits_for(data_width), reset=data_width)
|
||||||
|
|
||||||
# # #
|
# # #
|
||||||
|
@ -33,17 +33,22 @@ class Bandwidth(Module, AutoCSR):
|
||||||
|
|
||||||
counter = Signal(period_bits)
|
counter = Signal(period_bits)
|
||||||
period = Signal()
|
period = Signal()
|
||||||
nreads = Signal(period_bits)
|
nreads = Signal(period_bits + 1)
|
||||||
nwrites = Signal(period_bits)
|
nwrites = Signal(period_bits + 1)
|
||||||
nreads_r = Signal(period_bits)
|
nreads_r = Signal(period_bits + 1)
|
||||||
nwrites_r = Signal(period_bits)
|
nwrites_r = Signal(period_bits + 1)
|
||||||
self.sync += [
|
self.sync += [
|
||||||
Cat(counter, period).eq(counter + 1),
|
Cat(counter, period).eq(counter + 1),
|
||||||
If(period,
|
If(period,
|
||||||
nreads_r.eq(nreads),
|
nreads_r.eq(nreads),
|
||||||
nwrites_r.eq(nwrites),
|
nwrites_r.eq(nwrites),
|
||||||
nreads.eq(0),
|
nreads.eq(0),
|
||||||
nwrites.eq(0)
|
nwrites.eq(0),
|
||||||
|
# don't miss command if there is one on period boundary
|
||||||
|
If(cmd_valid & cmd_ready,
|
||||||
|
If(cmd_is_read, nreads.eq(1)),
|
||||||
|
If(cmd_is_write, nwrites.eq(1)),
|
||||||
|
)
|
||||||
).Elif(cmd_valid & cmd_ready,
|
).Elif(cmd_valid & cmd_ready,
|
||||||
If(cmd_is_read, nreads.eq(nreads + 1)),
|
If(cmd_is_read, nreads.eq(nreads + 1)),
|
||||||
If(cmd_is_write, nwrites.eq(nwrites + 1)),
|
If(cmd_is_write, nwrites.eq(nwrites + 1)),
|
||||||
|
|
Loading…
Reference in New Issue