diff options
author | Lukasz Dalek <ldalek@antmicro.com> | 2020-07-17 13:41:09 +0200 |
---|---|---|
committer | Lukasz Dalek <ldalek@antmicro.com> | 2020-08-03 14:48:27 +0200 |
commit | 83ddc62034dc5c7046a1ba7c5666e868b8346538 (patch) | |
tree | 5cf8088cf9770e665b934dc245b274ff85e7d365 /frontends/verilog/verilog_parser.y | |
parent | c39ebe6ae0e41cf9a84da852fa3cf9f71937a9b2 (diff) | |
download | yosys-83ddc62034dc5c7046a1ba7c5666e868b8346538.tar.gz yosys-83ddc62034dc5c7046a1ba7c5666e868b8346538.tar.bz2 yosys-83ddc62034dc5c7046a1ba7c5666e868b8346538.zip |
Rewrite multirange arrays sizes [n] as [n-1:0]
Signed-off-by: Lukasz Dalek <ldalek@antmicro.com>
Diffstat (limited to 'frontends/verilog/verilog_parser.y')
-rw-r--r-- | frontends/verilog/verilog_parser.y | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/frontends/verilog/verilog_parser.y b/frontends/verilog/verilog_parser.y index 63f0341d9..8e5236639 100644 --- a/frontends/verilog/verilog_parser.y +++ b/frontends/verilog/verilog_parser.y @@ -210,14 +210,23 @@ static AstNode *checkRange(AstNode *type_node, AstNode *range_node) return range_node; } -static void rewriteAsMemoryNode(AstNode *node, AstNode *rangeNode) +static void rewriteRange(AstNode *rangeNode) { - node->type = AST_MEMORY; if (rangeNode->type == AST_RANGE && rangeNode->children.size() == 1) { // SV array size [n], rewrite as [n-1:0] rangeNode->children[0] = new AstNode(AST_SUB, rangeNode->children[0], AstNode::mkconst_int(1, true)); rangeNode->children.push_back(AstNode::mkconst_int(0, false)); } +} + +static void rewriteAsMemoryNode(AstNode *node, AstNode *rangeNode) +{ + node->type = AST_MEMORY; + if (rangeNode->type == AST_MULTIRANGE) { + for (auto *itr : rangeNode->children) + rewriteRange(itr); + } else + rewriteRange(rangeNode); node->children.push_back(rangeNode); } |