aboutsummaryrefslogtreecommitdiffstats
path: root/frontends
diff options
context:
space:
mode:
authorclairexen <claire@symbioticeda.com>2020-09-17 18:27:05 +0200
committerGitHub <noreply@github.com>2020-09-17 18:27:05 +0200
commitf176bd7778bff924b1d74b3ea8208ff019a9cb95 (patch)
treee7363dfa1937d602993999f3bef1c2d453fc69d9 /frontends
parent9e937961dc026751f8961dfff12aa50411750070 (diff)
parent6e78f3a197509a12bdd5dc09244f31f13b8321fc (diff)
downloadyosys-f176bd7778bff924b1d74b3ea8208ff019a9cb95.tar.gz
yosys-f176bd7778bff924b1d74b3ea8208ff019a9cb95.tar.bz2
yosys-f176bd7778bff924b1d74b3ea8208ff019a9cb95.zip
Merge pull request #2329 from antmicro/arrays-fix-multirange-size
Rewrite multirange arrays sizes [n] as [n-1:0]
Diffstat (limited to 'frontends')
-rw-r--r--frontends/verilog/verilog_parser.y13
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);
}