def makeBlock(x):
if(type(x) == Assignment):
return [x]
+ elif(type(x) == CondStatement):
+ return [x]
else:
return x.statements
self.ports = []
self.wires = []
self.comb = []
+ self.sync = []
def open(self):
if(self.outputfile is None):
def do_assign(self, a, stmts, indent):
stmts.children.append(self.indent(indent))
- stmts.children.append(Leaf(token.STRING, "m.d.comb += "))
+ stmts.children.append(Leaf(token.STRING, "m.d."))
+ stmts.children.append(Leaf(token.STRING, self.blocktype))
+ stmts.children.append(Leaf(token.STRING, " += "))
if(self.isPort(a.left)):
stmts.children.append(Leaf(token.STRING, "self."))
stmts.children.append(Leaf(token.STRING, a.left))
stmts.children.append(Leaf(token.STRING, ")"))
stmts.children.append(self.nl())
- # refactor: assignments non cond
+ self.blocktype = "comb"
for a in self.assign:
- self.do_assign(a, stmts)
+ self.do_assign(a, stmts, 2)
for c in self.comb:
- print("comb", c)
+ if(type(c) == Assignment):
+ self.do_assign(c, stmts, 2)
+ else:
+ self.do_ifblock(c, stmts, 2)
+
+ self.blocktype = "sync"
+ for c in self.sync:
if(type(c) == Assignment):
self.do_assign(c, stmts, 2)
else:
# cond assigmments and other nested blocks
def always_comb(self, p3, p1):
- print("always_comb")
slist = p3[6]
self.comb += slist.statements
+
+ def always_ff(self, p3, p1):
+ slist = p3[1]
+ self.sync += slist.statements