projects
/
sv2nmigen.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
convert numbers to python format
[sv2nmigen.git]
/
absyn.py
diff --git
a/absyn.py
b/absyn.py
index 2931be810ea3533f828bcd85c9c4e576bf00000b..386e5d3f23bfe1ddd981d38cc1d7079a865e2fd2 100644
(file)
--- a/
absyn.py
+++ b/
absyn.py
@@
-57,6
+57,8
@@
class CondStatement:
def makeBlock(x):
if(type(x) == Assignment):
return [x]
def makeBlock(x):
if(type(x) == Assignment):
return [x]
+ elif(type(x) == CondStatement):
+ return [x]
else:
return x.statements
else:
return x.statements
@@
-69,6
+71,7
@@
class Absyn:
self.ports = []
self.wires = []
self.comb = []
self.ports = []
self.wires = []
self.comb = []
+ self.sync = []
def open(self):
if(self.outputfile is None):
def open(self):
if(self.outputfile is None):
@@
-133,7
+136,9
@@
class Absyn:
def do_assign(self, a, stmts, indent):
stmts.children.append(self.indent(indent))
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))
if(self.isPort(a.left)):
stmts.children.append(Leaf(token.STRING, "self."))
stmts.children.append(Leaf(token.STRING, a.left))
@@
-196,12
+201,18
@@
class Absyn:
stmts.children.append(Leaf(token.STRING, ")"))
stmts.children.append(self.nl())
stmts.children.append(Leaf(token.STRING, ")"))
stmts.children.append(self.nl())
- # refactor: assignments non cond
+ self.blocktype = "comb"
for a in self.assign:
for a in self.assign:
- self.do_assign(a, stmts)
+ self.do_assign(a, stmts
, 2
)
for c in self.comb:
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:
if(type(c) == Assignment):
self.do_assign(c, stmts, 2)
else:
@@
-258,6
+269,9
@@
class Absyn:
# cond assigmments and other nested blocks
def always_comb(self, p3, p1):
# cond assigmments and other nested blocks
def always_comb(self, p3, p1):
- print("always_comb")
slist = p3[6]
self.comb += slist.statements
slist = p3[6]
self.comb += slist.statements
+
+ def always_ff(self, p3, p1):
+ slist = p3[1]
+ self.sync += slist.statements