software: some clean up and generate clk in dump

This commit is contained in:
Florent Kermarrec 2016-06-13 17:07:56 +02:00
parent b989ad6ce2
commit edbcf65f6f
2 changed files with 8 additions and 25 deletions

View File

@ -66,8 +66,11 @@ class Dump:
def add_from_layout(self, layout, variable):
i = 0
for s, n in layout:
self.add(DumpVariable(s, n, variable[i:i+n]))
values = variable[i:i+n]
values2x = [values[i//2] for i in range(len(values)*2)]
self.add(DumpVariable(s, n, values2x))
i += n
self.add(DumpVariable("clk", 1, [1, 0]*(len(self)//2)))
def __len__(self):
l = 0

View File

@ -41,30 +41,20 @@ class VCDDump(Dump):
def generate_version(self):
r = "$version\n"
r += "\tmiscope VCD dump\n"
r += "\tlitescope VCD dump\n"
r += "$end\n"
return r
def generate_comment(self):
r = "$comment\n"
r += self.comment
r += "\n$end\n"
return r
def generate_timescale(self):
r = "$timescale "
r += self.timescale
r += " $end\n"
return r
def generate_scope(self):
def generate_vars(self):
r = "$scope "
r += self.timescale
r += " $end\n"
return r
def generate_vars(self):
r = ""
for v in self.variables:
r += "$var wire "
r += str(v.width)
@ -73,15 +63,9 @@ class VCDDump(Dump):
r += " "
r += v.name
r += " $end\n"
return r
def generate_unscope(self):
r = "$unscope "
r += "$unscope "
r += " $end\n"
return r
def generate_enddefinitions(self):
r = "$enddefinitions "
r += "$enddefinitions "
r += " $end\n"
return r
@ -118,12 +102,8 @@ class VCDDump(Dump):
self.finalize()
f = open(filename, "w")
f.write(self.generate_date())
f.write(self.generate_comment())
f.write(self.generate_timescale())
f.write(self.generate_scope())
f.write(self.generate_vars())
f.write(self.generate_unscope())
f.write(self.generate_enddefinitions())
f.write(self.generate_dumpvars())
f.write(self.generate_valuechange())
f.close()