diff options
author | clairexen <claire@symbioticeda.com> | 2020-08-18 17:22:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-18 17:22:20 +0200 |
commit | 5ee9349647cd2a77befb47c8c338a2afe9c2d0a8 (patch) | |
tree | 07640f7494e45823fd1200d8d96c6bac69fe36b7 /frontends | |
parent | 3cb3978ff4f8c917908d03eca6f07c57da52c0dc (diff) | |
parent | f285f7b76916420b5d55a83d53a371ebe257cfb2 (diff) | |
download | yosys-5ee9349647cd2a77befb47c8c338a2afe9c2d0a8.tar.gz yosys-5ee9349647cd2a77befb47c8c338a2afe9c2d0a8.tar.bz2 yosys-5ee9349647cd2a77befb47c8c338a2afe9c2d0a8.zip |
Merge pull request #2281 from zachjs/const-real
Allow reals as constant function parameters
Diffstat (limited to 'frontends')
-rw-r--r-- | frontends/ast/simplify.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 66f22e113..5a9707976 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -3052,7 +3052,7 @@ skip_dynamic_range_lvalue_expansion:; bool all_args_const = true; for (auto child : children) { while (child->simplify(true, false, false, 1, -1, false, true)) { } - if (child->type != AST_CONSTANT) + if (child->type != AST_CONSTANT && child->type != AST_REALVALUE) all_args_const = false; } @@ -4379,8 +4379,16 @@ AstNode *AstNode::eval_const_function(AstNode *fcall) variables[child->str].val = RTLIL::Const(RTLIL::State::Sx, abs(child->range_left - child->range_right)+1); variables[child->str].offset = min(child->range_left, child->range_right); variables[child->str].is_signed = child->is_signed; - if (child->is_input && argidx < fcall->children.size()) - variables[child->str].val = fcall->children.at(argidx++)->bitsAsConst(variables[child->str].val.bits.size()); + if (child->is_input && argidx < fcall->children.size()) { + int width = variables[child->str].val.bits.size(); + auto* arg_node = fcall->children.at(argidx++); + if (arg_node->type == AST_CONSTANT) { + variables[child->str].val = arg_node->bitsAsConst(width); + } else { + log_assert(arg_node->type == AST_REALVALUE); + variables[child->str].val = arg_node->realAsConst(width); + } + } backup_scope[child->str] = current_scope[child->str]; current_scope[child->str] = child; continue; |