mirror of https://github.com/m-labs/artiq.git
rtio: ignore series of writes with the same value and add pileup detection
This commit is contained in:
parent
5144da3f9a
commit
a580d44007
|
@ -14,18 +14,32 @@ class _RTIOBankO(Module):
|
||||||
self.writable = Signal()
|
self.writable = Signal()
|
||||||
self.we = Signal()
|
self.we = Signal()
|
||||||
self.underflow = Signal()
|
self.underflow = Signal()
|
||||||
|
self.pileup = Signal()
|
||||||
self.level = Signal(bits_for(fifo_depth))
|
self.level = Signal(bits_for(fifo_depth))
|
||||||
|
|
||||||
# # #
|
# # #
|
||||||
|
|
||||||
|
# counter
|
||||||
counter = Signal(counter_width, reset=counter_init)
|
counter = Signal(counter_width, reset=counter_init)
|
||||||
self.sync += [
|
self.sync += counter.eq(counter + 1)
|
||||||
counter.eq(counter + 1),
|
|
||||||
If(self.we & self.writable,
|
# ignore series of writes with the same value
|
||||||
If(self.timestamp[fine_ts_width:] < counter + 2,
|
we_filtered = Signal()
|
||||||
self.underflow.eq(1))
|
prev_value = Signal(2)
|
||||||
|
self.comb += we_filtered.eq(self.we & (self.value != prev_value))
|
||||||
|
self.sync += If(self.we & self.writable, prev_value.eq(self.value))
|
||||||
|
|
||||||
|
# detect underflows and pileups
|
||||||
|
prev_ts_coarse = Signal(counter_width)
|
||||||
|
ts_coarse = self.timestamp[fine_ts_width:]
|
||||||
|
self.sync += \
|
||||||
|
If(we_filtered & self.writable,
|
||||||
|
If(ts_coarse < counter + 2,
|
||||||
|
self.underflow.eq(1)),
|
||||||
|
If(ts_coarse == prev_ts_coarse,
|
||||||
|
self.pileup.eq(1)),
|
||||||
|
prev_ts_coarse.eq(ts_coarse)
|
||||||
)
|
)
|
||||||
]
|
|
||||||
|
|
||||||
fifos = []
|
fifos = []
|
||||||
for n, chif in enumerate(rbus):
|
for n, chif in enumerate(rbus):
|
||||||
|
@ -39,7 +53,7 @@ class _RTIOBankO(Module):
|
||||||
self.comb += [
|
self.comb += [
|
||||||
fifo.din.timestamp.eq(self.timestamp),
|
fifo.din.timestamp.eq(self.timestamp),
|
||||||
fifo.din.value.eq(self.value),
|
fifo.din.value.eq(self.value),
|
||||||
fifo.we.eq(self.we & (self.sel == n))
|
fifo.we.eq(we_filtered & (self.sel == n))
|
||||||
]
|
]
|
||||||
|
|
||||||
# FIFO read
|
# FIFO read
|
||||||
|
@ -68,6 +82,7 @@ class _RTIOBankI(Module):
|
||||||
self.readable = Signal()
|
self.readable = Signal()
|
||||||
self.re = Signal()
|
self.re = Signal()
|
||||||
self.overflow = Signal()
|
self.overflow = Signal()
|
||||||
|
self.pileup = Signal()
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
|
@ -78,6 +93,7 @@ class _RTIOBankI(Module):
|
||||||
values = []
|
values = []
|
||||||
readables = []
|
readables = []
|
||||||
overflows = []
|
overflows = []
|
||||||
|
pileups = []
|
||||||
for n, chif in enumerate(rbus):
|
for n, chif in enumerate(rbus):
|
||||||
if hasattr(chif, "oe"):
|
if hasattr(chif, "oe"):
|
||||||
sensitivity = Signal(2)
|
sensitivity = Signal(2)
|
||||||
|
@ -112,17 +128,23 @@ class _RTIOBankI(Module):
|
||||||
overflow = Signal()
|
overflow = Signal()
|
||||||
self.sync += If(fifo.we & ~fifo.writable, overflow.eq(1))
|
self.sync += If(fifo.we & ~fifo.writable, overflow.eq(1))
|
||||||
overflows.append(overflow)
|
overflows.append(overflow)
|
||||||
|
|
||||||
|
pileup = Signal()
|
||||||
|
self.sync += If(chif.i_pileup, pileup.eq(1))
|
||||||
|
pileups.append(pileup)
|
||||||
else:
|
else:
|
||||||
timestamps.append(0)
|
timestamps.append(0)
|
||||||
values.append(0)
|
values.append(0)
|
||||||
readables.append(0)
|
readables.append(0)
|
||||||
overflows.append(0)
|
overflows.append(0)
|
||||||
|
pileups.append(0)
|
||||||
|
|
||||||
self.comb += [
|
self.comb += [
|
||||||
self.timestamp.eq(Array(timestamps)[self.sel]),
|
self.timestamp.eq(Array(timestamps)[self.sel]),
|
||||||
self.value.eq(Array(values)[self.sel]),
|
self.value.eq(Array(values)[self.sel]),
|
||||||
self.readable.eq(Array(readables)[self.sel]),
|
self.readable.eq(Array(readables)[self.sel]),
|
||||||
self.overflow.eq(Array(overflows)[self.sel])
|
self.overflow.eq(Array(overflows)[self.sel]),
|
||||||
|
self.pileup.eq(Array(pileups)[self.sel])
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,14 +171,14 @@ class RTIO(Module, AutoCSR):
|
||||||
self._r_o_value = CSRStorage(2)
|
self._r_o_value = CSRStorage(2)
|
||||||
self._r_o_writable = CSRStatus()
|
self._r_o_writable = CSRStatus()
|
||||||
self._r_o_we = CSR()
|
self._r_o_we = CSR()
|
||||||
self._r_o_underflow = CSRStatus()
|
self._r_o_error = CSRStatus(2)
|
||||||
self._r_o_level = CSRStatus(bits_for(ofifo_depth))
|
self._r_o_level = CSRStatus(bits_for(ofifo_depth))
|
||||||
|
|
||||||
self._r_i_timestamp = CSRStatus(counter_width+fine_ts_width)
|
self._r_i_timestamp = CSRStatus(counter_width+fine_ts_width)
|
||||||
self._r_i_value = CSRStatus()
|
self._r_i_value = CSRStatus()
|
||||||
self._r_i_readable = CSRStatus()
|
self._r_i_readable = CSRStatus()
|
||||||
self._r_i_re = CSR()
|
self._r_i_re = CSR()
|
||||||
self._r_i_overflow = CSRStatus()
|
self._r_i_error = CSRStatus(2)
|
||||||
|
|
||||||
# OE
|
# OE
|
||||||
oes = []
|
oes = []
|
||||||
|
@ -179,7 +201,8 @@ class RTIO(Module, AutoCSR):
|
||||||
self.bank_o.value.eq(self._r_o_value.storage),
|
self.bank_o.value.eq(self._r_o_value.storage),
|
||||||
self._r_o_writable.status.eq(self.bank_o.writable),
|
self._r_o_writable.status.eq(self.bank_o.writable),
|
||||||
self.bank_o.we.eq(self._r_o_we.re),
|
self.bank_o.we.eq(self._r_o_we.re),
|
||||||
self._r_o_underflow.status.eq(self.bank_o.underflow),
|
self._r_o_error.status.eq(
|
||||||
|
Cat(self.bank_o.underflow, self.bank_o.pileup)),
|
||||||
self._r_o_level.status.eq(self.bank_o.level)
|
self._r_o_level.status.eq(self.bank_o.level)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -191,5 +214,6 @@ class RTIO(Module, AutoCSR):
|
||||||
self._r_i_value.status.eq(self.bank_i.value),
|
self._r_i_value.status.eq(self.bank_i.value),
|
||||||
self._r_i_readable.status.eq(self.bank_i.readable),
|
self._r_i_readable.status.eq(self.bank_i.readable),
|
||||||
self.bank_i.re.eq(self._r_i_re.re),
|
self.bank_i.re.eq(self._r_i_re.re),
|
||||||
self._r_i_overflow.status.eq(self.bank_i.overflow)
|
self._r_i_error.status.eq(
|
||||||
|
Cat(self.bank_i.overflow, self.bank_i.pileup))
|
||||||
]
|
]
|
||||||
|
|
|
@ -15,7 +15,8 @@ def create_rbus(fine_ts_bits, pads, output_only_pads):
|
||||||
layout += [
|
layout += [
|
||||||
("oe", 1),
|
("oe", 1),
|
||||||
("i_stb", 1),
|
("i_stb", 1),
|
||||||
("i_value", 1)
|
("i_value", 1),
|
||||||
|
("i_pileup", 1)
|
||||||
]
|
]
|
||||||
if fine_ts_bits:
|
if fine_ts_bits:
|
||||||
layout.append(("i_fine_ts", fine_ts_bits))
|
layout.append(("i_fine_ts", fine_ts_bits))
|
||||||
|
|
Loading…
Reference in New Issue