diff options
author | Udi Finkelstein <github@udifink.com> | 2017-09-26 06:25:42 +0300 |
---|---|---|
committer | Udi Finkelstein <github@udifink.com> | 2017-09-26 06:25:42 +0300 |
commit | 64eb8f29adcc3e6ee92e083ae0fee3aaf85dbbc4 (patch) | |
tree | 845429786f8f0b8e39aece33fa4c2932ed81217e /frontends/ast | |
parent | 29f8acf09586c34222923139511ef64c00eccc8b (diff) | |
download | yosys-64eb8f29adcc3e6ee92e083ae0fee3aaf85dbbc4.tar.gz yosys-64eb8f29adcc3e6ee92e083ae0fee3aaf85dbbc4.tar.bz2 yosys-64eb8f29adcc3e6ee92e083ae0fee3aaf85dbbc4.zip |
Add $size() function. At the moment it works only on expressions, not on memories.
Diffstat (limited to 'frontends/ast')
-rw-r--r-- | frontends/ast/simplify.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 28c9945ab..541fe1b18 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -1870,6 +1870,20 @@ skip_dynamic_range_lvalue_expansion:; goto apply_newNode; } + if (str == "\\$size") + { + if (children.size() != 1) + log_error("System function %s got %d arguments, expected 1 at %s:%d.\n", + RTLIL::unescape_id(str).c_str(), int(children.size()), filename.c_str(), linenum); + + AstNode *buf = children[0]->clone(); + buf->detectSignWidth(width_hint, sign_hint); + delete buf; + + newNode = mkconst_int(width_hint, false); + goto apply_newNode; + } + if (str == "\\$ln" || str == "\\$log10" || str == "\\$exp" || str == "\\$sqrt" || str == "\\$pow" || str == "\\$floor" || str == "\\$ceil" || str == "\\$sin" || str == "\\$cos" || str == "\\$tan" || str == "\\$asin" || str == "\\$acos" || str == "\\$atan" || str == "\\$atan2" || str == "\\$hypot" || |