mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-25 10:05:33 +00:00
verilog: Fix const eval of unbased unsized constants
When the verilog frontend perfomed constant evaluation of unbased unsized constants in a context-determined expression it did not properly extend them by repeating the bit value. This only affected constant evaluation and not constants that made it through unchanged to RTLIL. The latter case was already covered by tests and working before. This fixes the const-eval issue by checking the `is_unsized` flag in bitsAsConst and extending the value accordingly. The newly added test also tests the already working non-const-eval case to highlight that both cases should behave the same.
This commit is contained in:
parent
7efc50367e
commit
985f4926b7
3 changed files with 36 additions and 1 deletions
|
@ -847,7 +847,7 @@ RTLIL::Const AstNode::bitsAsConst(int width, bool is_signed)
|
|||
bits.resize(width);
|
||||
if (width >= 0 && width > int(bits.size())) {
|
||||
RTLIL::State extbit = RTLIL::State::S0;
|
||||
if (is_signed && !bits.empty())
|
||||
if ((is_signed || is_unsized) && !bits.empty())
|
||||
extbit = bits.back();
|
||||
while (width > int(bits.size()))
|
||||
bits.push_back(extbit);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue