aboutsummaryrefslogtreecommitdiffstats
path: root/frontends
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-09-06 19:31:04 +0200
committerClifford Wolf <clifford@clifford.at>2014-09-06 19:31:04 +0200
commit680eaaac41bc64000faa483955279155b0fc0a6b (patch)
treee584e5acd3fe7edb8cd1abeaf1ee87cd9a8ab6f6 /frontends
parentbff4706b62ca73ba0a627eda2ad903b487634cae (diff)
downloadyosys-680eaaac41bc64000faa483955279155b0fc0a6b.tar.gz
yosys-680eaaac41bc64000faa483955279155b0fc0a6b.tar.bz2
yosys-680eaaac41bc64000faa483955279155b0fc0a6b.zip
Fixed $clog2 (off by one error)
Diffstat (limited to 'frontends')
-rw-r--r--frontends/ast/simplify.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc
index 1998c12e4..9e797573c 100644
--- a/frontends/ast/simplify.cc
+++ b/frontends/ast/simplify.cc
@@ -1123,7 +1123,7 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
if (left_at_zero_ast->type != AST_CONSTANT || right_at_zero_ast->type != AST_CONSTANT)
log_error("Unsupported expression on dynamic range select on signal `%s' at %s:%d!\n",
str.c_str(), filename.c_str(), linenum);
- result_width = left_at_zero_ast->integer - right_at_zero_ast->integer + 1;
+ result_width = abs(left_at_zero_ast->integer - right_at_zero_ast->integer) + 1;
}
did_something = true;
newNode = new AstNode(AST_CASE, shift_expr);
@@ -1370,7 +1370,7 @@ skip_dynamic_range_lvalue_expansion:;
uint32_t result = 0;
for (size_t i = 0; i < arg_value.bits.size(); i++)
if (arg_value.bits.at(i) == RTLIL::State::S1)
- result = i;
+ result = i + 1;
newNode = mkconst_int(result, false);
goto apply_newNode;