mirror of
https://github.com/YosysHQ/yosys.git
synced 2026-08-22 14:17:27 +02:00
Added constant size expression support of sized constants
This commit is contained in:
@@ -258,6 +258,7 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
|
||||
}
|
||||
break;
|
||||
|
||||
case AST_TO_BITS:
|
||||
case AST_TO_SIGNED:
|
||||
case AST_TO_UNSIGNED:
|
||||
case AST_CONCAT:
|
||||
@@ -442,6 +443,17 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
|
||||
goto apply_newNode;
|
||||
}
|
||||
|
||||
// evaluate TO_BITS nodes
|
||||
if (type == AST_TO_BITS) {
|
||||
if (children[0]->type != AST_CONSTANT)
|
||||
log_error("Left operand of to_bits expression is not constant at %s:%d!\n", filename.c_str(), linenum);
|
||||
if (children[1]->type != AST_CONSTANT)
|
||||
log_error("Right operand of to_bits expression is not constant at %s:%d!\n", filename.c_str(), linenum);
|
||||
RTLIL::Const new_value = children[1]->bitsAsConst(children[0]->bitsAsConst().as_int(), children[1]->is_signed);
|
||||
newNode = mkconst_bits(new_value.bits, children[1]->is_signed);
|
||||
goto apply_newNode;
|
||||
}
|
||||
|
||||
// annotate constant ranges
|
||||
if (type == AST_RANGE) {
|
||||
bool old_range_valid = range_valid;
|
||||
|
||||
Reference in New Issue
Block a user