From: Kazuki Sakamoto Date: Sat, 20 Jun 2020 02:09:43 +0000 (-0700) Subject: static cast: simplify X-Git-Tag: working-ls180~432^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=429d37ff41b5a058fdd0b70f23a55170a973c369;p=yosys.git static cast: simplify --- diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 1d5dd91a7..e2da17c09 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -3484,6 +3484,13 @@ replace_fcall_later:; } } break; + case AST_CAST_SIZE: + if (children.at(0)->type == AST_CONSTANT && children.at(1)->type == AST_CONSTANT) { + int width = children[0]->bitsAsConst().as_int(); + RTLIL::Const val = children[1]->bitsAsConst(width); + newNode = mkconst_bits(val.bits, children[1]->is_signed); + } + break; case AST_CONCAT: string_op = !children.empty(); for (auto it = children.begin(); it != children.end(); it++) {