mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-26 03:38:25 +08:00
rtio: use Record
This commit is contained in:
parent
901073acf3
commit
9aafe89518
@ -2,6 +2,7 @@ from fractions import Fraction
|
|||||||
|
|
||||||
from migen.fhdl.std import *
|
from migen.fhdl.std import *
|
||||||
from migen.bank.description import *
|
from migen.bank.description import *
|
||||||
|
from migen.genlib.record import Record
|
||||||
from migen.genlib.cdc import *
|
from migen.genlib.cdc import *
|
||||||
from migen.genlib.fifo import AsyncFIFO
|
from migen.genlib.fifo import AsyncFIFO
|
||||||
from migen.genlib.resetsync import AsyncResetSynchronizer
|
from migen.genlib.resetsync import AsyncResetSynchronizer
|
||||||
@ -98,29 +99,25 @@ class _RTIOBankO(Module):
|
|||||||
|
|
||||||
signal_underflow = Signal()
|
signal_underflow = Signal()
|
||||||
fifos = []
|
fifos = []
|
||||||
fifo_layout = [("timestamp", counter.width + fine_ts_width),
|
ev_layout = [("timestamp", counter.width + fine_ts_width),
|
||||||
("value", 2)]
|
("value", 2)]
|
||||||
for n, chif in enumerate(rbus):
|
for n, chif in enumerate(rbus):
|
||||||
# FIFO
|
# FIFO
|
||||||
fifo = RenameClockDomains(AsyncFIFO(fifo_layout, fifo_depth),
|
fifo = RenameClockDomains(AsyncFIFO(ev_layout, fifo_depth),
|
||||||
{"write": "rsys", "read": "rio"})
|
{"write": "rsys", "read": "rio"})
|
||||||
self.submodules += fifo
|
self.submodules += fifo
|
||||||
fifos.append(fifo)
|
fifos.append(fifo)
|
||||||
|
|
||||||
# Buffer
|
# Buffer
|
||||||
buf_valid = Signal()
|
buf_valid = Signal()
|
||||||
buf_timestamp = Signal(counter.width + fine_ts_width)
|
buf = Record(ev_layout)
|
||||||
buf_value = Signal(2)
|
|
||||||
buf_just_written = Signal()
|
buf_just_written = Signal()
|
||||||
|
|
||||||
# Buffer read and FIFO write
|
# Buffer read and FIFO write
|
||||||
self.comb += [
|
self.comb += fifo.din.eq(buf)
|
||||||
fifo.din.timestamp.eq(buf_timestamp),
|
|
||||||
fifo.din.value.eq(buf_value)
|
|
||||||
]
|
|
||||||
in_guard_time = Signal()
|
in_guard_time = Signal()
|
||||||
self.comb += in_guard_time.eq(
|
self.comb += in_guard_time.eq(
|
||||||
buf_timestamp[fine_ts_width:] < counter.o_value_sys + guard_io_cycles)
|
buf.timestamp[fine_ts_width:] < counter.o_value_sys + guard_io_cycles)
|
||||||
self.sync.rsys += If(in_guard_time, buf_valid.eq(0))
|
self.sync.rsys += If(in_guard_time, buf_valid.eq(0))
|
||||||
self.comb += \
|
self.comb += \
|
||||||
If(buf_valid,
|
If(buf_valid,
|
||||||
@ -143,8 +140,8 @@ class _RTIOBankO(Module):
|
|||||||
# on underflows, which will be correctly reported.
|
# on underflows, which will be correctly reported.
|
||||||
buf_just_written.eq(1),
|
buf_just_written.eq(1),
|
||||||
buf_valid.eq(1),
|
buf_valid.eq(1),
|
||||||
buf_timestamp.eq(self.timestamp),
|
buf.timestamp.eq(self.timestamp),
|
||||||
buf_value.eq(self.value)
|
buf.value.eq(self.value)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -186,7 +183,7 @@ class _RTIOBankI(Module):
|
|||||||
readables = []
|
readables = []
|
||||||
overflows = []
|
overflows = []
|
||||||
pileup_counts = []
|
pileup_counts = []
|
||||||
fifo_layout = [("timestamp", counter.width+fine_ts_width),
|
ev_layout = [("timestamp", counter.width+fine_ts_width),
|
||||||
("value", 1)]
|
("value", 1)]
|
||||||
for n, chif in enumerate(rbus):
|
for n, chif in enumerate(rbus):
|
||||||
if hasattr(chif, "oe"):
|
if hasattr(chif, "oe"):
|
||||||
@ -194,7 +191,7 @@ class _RTIOBankI(Module):
|
|||||||
self.sync.rio += If(~chif.oe & chif.o_stb,
|
self.sync.rio += If(~chif.oe & chif.o_stb,
|
||||||
sensitivity.eq(chif.o_value))
|
sensitivity.eq(chif.o_value))
|
||||||
|
|
||||||
fifo = RenameClockDomains(AsyncFIFO(fifo_layout, fifo_depth),
|
fifo = RenameClockDomains(AsyncFIFO(ev_layout, fifo_depth),
|
||||||
{"read": "rsys", "write": "rio"})
|
{"read": "rsys", "write": "rio"})
|
||||||
self.submodules += fifo
|
self.submodules += fifo
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user