+ def do_assign(self, a, stmts, indent):
+ stmts.children.append(self.indent(indent))
+ stmts.children.append(Leaf(token.STRING, "m.d.comb += "))
+ 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, ".eq("))
+ if(self.isPort(a.right)):
+ stmts.children.append(Leaf(token.STRING, "self."))
+ stmts.children.append(Leaf(token.STRING, a.right))
+ stmts.children.append(Leaf(token.STRING, ")"))
+ stmts.children.append(self.nl())
+
+ def do_ifblock(self, c, stmts, indent):
+ stmts.children.append(self.indent(indent))
+ stmts.children.append(Leaf(token.STRING, "with m.If("))
+ if(self.isPort(c.cond)):
+ stmts.children.append(Leaf(token.STRING, "self."))
+ stmts.children.append(Leaf(token.STRING, c.cond))
+ stmts.children.append(Leaf(token.STRING, "):"))
+ stmts.children.append(self.nl())
+
+ for c1 in c.ifpart.statements:
+ if(type(c1) == Assignment):
+ self.do_assign(c1, stmts, indent+1)
+ else:
+ self.do_ifblock(c1, stmts, indent+1)
+
+ if(c.elsepart):
+ stmts.children.append(self.indent(indent))
+ stmts.children.append(Leaf(token.STRING, "with m.Else():"))
+ stmts.children.append(self.nl())
+
+ for c1 in c.elsepart.statements:
+ if(type(c1) == Assignment):
+ self.do_assign(c1, stmts, indent+1)
+ else:
+ self.do_ifblock(c1, stmts, indent+1)
+