return x
class Signal(Value):
+ _counter = 0
def __init__(self, bv=BV(), name=None, variable=False, reset=0, name_override=None):
assert(isinstance(bv, BV))
self.bv = bv
self.reset = Constant(reset, bv)
self.name_override = name_override
self.backtrace = tracer.trace_back(name)
-
+ self.order = Signal._counter
+ Signal._counter += 1
+
def __len__(self):
return self.bv.width
def insert_reset(rst, sl):
targets = list_targets(sl)
- resetcode = [t.eq(t.reset) for t in targets]
+ resetcode = [t.eq(t.reset) for t in sorted(targets, key=lambda x: x.order)]
return If(rst, *resetcode).Else(*sl)
def value_bv(v):
wires = _list_comb_wires(f) | inst_mem_outs
r = "module " + name + "(\n"
firstp = True
- for sig in ios:
+ for sig in sorted(ios, key=lambda x: x.order):
if not firstp:
r += ",\n"
firstp = False
else:
r += "\tinput " + _printsig(ns, sig)
r += "\n);\n\n"
- for sig in sigs - ios:
+ for sig in sorted(sigs - ios, key=lambda x: x.order):
if sig in wires:
r += "wire " + _printsig(ns, sig) + ";\n"
else:
- list_mem_ios(f, False, True)
if signals:
r += "initial begin\n"
- for s in signals:
+ for s in sorted(signals, key=lambda x: x.order):
r += "\t" + ns.get_name(s) + " <= " + _printexpr(ns, s.reset) + ";\n"
r += "end\n\n"
return r