aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUdi Finkelstein <github@udifink.com>2017-09-26 08:36:45 +0300
committerUdi Finkelstein <github@udifink.com>2017-09-26 08:36:45 +0300
commit17f8b4160574d34c446782952f09f940cd66c290 (patch)
treec00b20ab8efa70dfd290660a59d8ff8bf39c552b
parent64eb8f29adcc3e6ee92e083ae0fee3aaf85dbbc4 (diff)
downloadyosys-17f8b4160574d34c446782952f09f940cd66c290.tar.gz
yosys-17f8b4160574d34c446782952f09f940cd66c290.tar.bz2
yosys-17f8b4160574d34c446782952f09f940cd66c290.zip
$size() now works with memories as well!
-rw-r--r--frontends/ast/simplify.cc4
-rw-r--r--tests/simple/functions01.sv6
2 files changed, 7 insertions, 3 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc
index 541fe1b18..608df0cb9 100644
--- a/frontends/ast/simplify.cc
+++ b/frontends/ast/simplify.cc
@@ -387,7 +387,7 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
}
for (size_t i = 0; i < children.size(); i++) {
AstNode *node = children[i];
- if (node->type == AST_PARAMETER || node->type == AST_LOCALPARAM || node->type == AST_WIRE || node->type == AST_AUTOWIRE)
+ if (node->type == AST_PARAMETER || node->type == AST_LOCALPARAM || node->type == AST_WIRE || node->type == AST_AUTOWIRE || node->type == AST_MEMORY)
while (node->simplify(true, false, false, 1, -1, false, node->type == AST_PARAMETER || node->type == AST_LOCALPARAM))
did_something = true;
}
@@ -1877,6 +1877,8 @@ skip_dynamic_range_lvalue_expansion:;
RTLIL::unescape_id(str).c_str(), int(children.size()), filename.c_str(), linenum);
AstNode *buf = children[0]->clone();
+ // Is this needed?
+ //while (buf->simplify(true, false, false, stage, width_hint, sign_hint, false)) { }
buf->detectSignWidth(width_hint, sign_hint);
delete buf;
diff --git a/tests/simple/functions01.sv b/tests/simple/functions01.sv
index 0fa1da6bd..cd87a49b7 100644
--- a/tests/simple/functions01.sv
+++ b/tests/simple/functions01.sv
@@ -2,13 +2,15 @@ module functions01;
wire [3:0]x;
wire [$size(x)-1:0]x_size;
wire [$size({x, x})-1:0]xx_size;
-wire [3:0]w[0:5];
+wire [3:0]y[0:5];
+wire [$size(y)-1:0]y_size;
+wire [3:0]z[0:5][0:7];
+wire [$size(z)-1:0]z_size;
//
// The following are not supported yet:
//
-//wire [$size(w)-1:0]w_s;
//wire [$bits(x)-1:0]x_bits;
//wire [$bits({x, x})-1:0]xx_bits;