Skip to content

Commit

Permalink
pyverilog: fix bug and add serialization support for indexed partselect
Browse files Browse the repository at this point in the history
  • Loading branch information
ekiwi committed Jan 3, 2024
1 parent c1ea811 commit 132fe77
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions pyverilog/ast_code_generator/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,18 @@ def visit_Partselect(self, node):
rslt = template.render(template_dict)
return rslt

def visit_IndexedPartselect(self, node):
filename = getfilename(node)
template = self.get_template(filename)
template_dict = {
'var': self.visit(node.var),
'base': del_space(del_paren(self.visit(node.base))),
'stride': del_space(del_paren(self.visit(node.stride))),
'sign': '+' if node.is_plus else '-',
}
rslt = template.render(template_dict)
return rslt

def visit_Pointer(self, node):
filename = getfilename(node)
template = self.get_template(filename)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ var }}[{{ base }} {{ sign }}: {{ stride }}]
2 changes: 1 addition & 1 deletion pyverilog/vparser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2631,7 +2631,7 @@ def _raise_error(self, p):
raise ParseError("%s: %s" % (coord, msg))

def _coord(self, lineno, column=None):
ret = [self.lexer.lexer.filename, 'line:%s' % lineno]
ret = [self.lexer.filename, 'line:%s' % lineno]
if column is not None:
ret.append('column:%s' % column)
return ' '.join(ret)
Expand Down

0 comments on commit 132fe77

Please sign in to comment.