2013-02-22 08:28:05 -05:00
|
|
|
from migen.fhdl.structure import *
|
|
|
|
from migen.bank.description import *
|
2014-08-03 02:38:37 -04:00
|
|
|
from migen.genlib.record import *
|
2013-02-22 08:28:05 -05:00
|
|
|
|
2013-09-22 12:41:44 -04:00
|
|
|
from miscope.std import *
|
2013-09-22 07:28:12 -04:00
|
|
|
from miscope.trigger import Trigger
|
2014-04-18 04:33:05 -04:00
|
|
|
from miscope.storage import Recorder, RunLengthEncoder
|
2013-09-22 07:28:12 -04:00
|
|
|
|
2013-09-21 07:04:07 -04:00
|
|
|
class MiLa(Module, AutoCSR):
|
2014-05-20 03:02:35 -04:00
|
|
|
def __init__(self, width, depth, ports, with_rle=False):
|
2013-09-22 07:28:12 -04:00
|
|
|
self.width = width
|
2014-05-20 07:16:24 -04:00
|
|
|
self.depth = depth
|
|
|
|
self.with_rle = with_rle
|
|
|
|
self.ports = ports
|
2013-09-22 07:28:12 -04:00
|
|
|
|
2014-08-03 02:38:37 -04:00
|
|
|
self.sink = Record(dat_layout(width))
|
2013-09-22 12:41:44 -04:00
|
|
|
|
2013-09-22 07:28:12 -04:00
|
|
|
trigger = Trigger(width, ports)
|
|
|
|
recorder = Recorder(width, depth)
|
|
|
|
|
|
|
|
self.submodules.trigger = trigger
|
|
|
|
self.submodules.recorder = recorder
|
2013-03-21 07:23:44 -04:00
|
|
|
|
2014-08-03 02:38:37 -04:00
|
|
|
sink_d = Record(dat_layout(width))
|
2014-05-24 03:23:16 -04:00
|
|
|
self.sync += sink_d.eq(self.sink)
|
2013-03-21 07:23:44 -04:00
|
|
|
|
2013-09-22 12:41:44 -04:00
|
|
|
self.comb += [
|
2014-05-24 03:23:16 -04:00
|
|
|
sink_d.connect(trigger.sink),
|
2014-05-20 03:02:35 -04:00
|
|
|
trigger.source.connect(recorder.trig_sink)
|
2013-02-22 08:28:05 -05:00
|
|
|
]
|
2013-09-21 07:04:07 -04:00
|
|
|
|
2014-05-20 03:02:35 -04:00
|
|
|
recorder_dat_source = self.sink
|
|
|
|
if with_rle:
|
|
|
|
self.submodules.rle = RunLengthEncoder(width)
|
2014-05-24 03:23:16 -04:00
|
|
|
self.comb += sink_d.connect(self.rle.sink)
|
2014-05-20 03:02:35 -04:00
|
|
|
recorder_dat_source = self.rle.source
|
|
|
|
self.comb += recorder_dat_source.connect(recorder.dat_sink)
|
2014-05-20 05:36:10 -04:00
|
|
|
|
2014-05-20 07:16:24 -04:00
|
|
|
def get_csv(self, layout):
|
2014-05-20 05:36:10 -04:00
|
|
|
r = ""
|
2014-05-20 07:16:24 -04:00
|
|
|
def format_line(*args):
|
|
|
|
return ",".join(args) + "\n"
|
|
|
|
|
|
|
|
r += format_line("config", "width", str(self.width))
|
|
|
|
r += format_line("config", "depth", str(self.depth))
|
|
|
|
r += format_line("config", "with_rle", str(int(self.with_rle)))
|
|
|
|
|
|
|
|
for e in layout:
|
|
|
|
r += format_line("layout", e.backtrace[-1][0], str(flen(e)))
|
2014-05-20 05:36:10 -04:00
|
|
|
return r
|