From: Florent Kermarrec Date: Tue, 20 May 2014 09:36:10 +0000 (+0200) Subject: move some functions in drivers and export layout in csv X-Git-Tag: 24jan2021_ls180~2575^2~78 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ba0382ad923d5950f398decfbf526b3d6144246a;p=litex.git move some functions in drivers and export layout in csv --- diff --git a/miscope/host/drivers.py b/miscope/host/drivers.py index b3a19cea..efa2e0a0 100644 --- a/miscope/host/drivers.py +++ b/miscope/host/drivers.py @@ -1,3 +1,5 @@ +import csv +from miscope.host.vcd import * class MiIoDriver(): def __init__(self, regs, name): @@ -18,16 +20,27 @@ class MiIoDriver(): return self.miio_i.read() class MiLaDriver(): - def __init__(self, regs, name): + def __init__(self, width, regs, name, config_csv=None, use_rle=True): self.regs = regs self.name = name self.build_mila() + if csv: + self.build_layout(config_csv) + self.dat = VcdDat(width) + self.use_rle = use_rle def build_mila(self): for key, value in self.regs.d.items(): if self.name in key: key.replace(self.name, "mila") - setattr(self, key, value) + setattr(self, key, value) + + def build_layout(self, config_csv): + self.layout = [] + csv_reader = csv.reader(open(config_csv), delimiter=',', quotechar='#') + for item in csv_reader: + name, length = item + self.layout.append((name, int(length))) def prog_term(self, port, trigger, mask): t = getattr(self, "mila_trigger_port{d}_trig".format(d=int(port))) @@ -65,15 +78,24 @@ class MiLaDriver(): return self.mila_recorder_done.read() def trigger(self, offset, length): + print("T") + if self.use_rle: + self.enable_rle() self.mila_recorder_offset.write(offset) self.mila_recorder_length.write(length) self.mila_recorder_trigger.write(1) - def read(self): - r = [] + def read(self, vcd=None): + print("R") empty = self.mila_recorder_read_empty.read() while(not empty): - r.append(self.mila_recorder_read_dat.read()) + self.dat.append(self.mila_recorder_read_dat.read()) empty = self.mila_recorder_read_empty.read() self.mila_recorder_read_en.write(1) - return r \ No newline at end of file + if self.use_rle: + self.dat = self.dat.decode_rle() + if vcd: + print("V") + _vcd = Vcd() + _vcd.add_from_layout(self.layout, self.dat) + _vcd.write(vcd) diff --git a/miscope/mila.py b/miscope/mila.py index e9bb875b..805ee10a 100644 --- a/miscope/mila.py +++ b/miscope/mila.py @@ -29,3 +29,9 @@ class MiLa(Module, AutoCSR): self.comb += self.sink.connect(self.rle.sink) recorder_dat_source = self.rle.source self.comb += recorder_dat_source.connect(recorder.dat_sink) + + def get_csv(self, dat): + r = "" + for e in dat: + r += e.backtrace[-1][0] + "," + str(flen(e)) + "\n" + return r