mirror of https://github.com/YosysHQ/yosys.git
Merge pull request #5685 from chathhorn-galois/chathhorn/issue5684
Fix segfault from shift with 0-width signed arg.
This commit is contained in:
commit
74f7b0cf92
|
|
@ -291,7 +291,7 @@ static RTLIL::Const const_shift_worker(const RTLIL::Const &arg1, const RTLIL::Co
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
result.set(i, vacant_bits);
|
result.set(i, vacant_bits);
|
||||||
else if (pos >= BigInteger(GetSize(arg1)))
|
else if (pos >= BigInteger(GetSize(arg1)))
|
||||||
result.set(i, sign_ext ? arg1.back() : vacant_bits);
|
result.set(i, sign_ext && !arg1.empty() ? arg1.back() : vacant_bits);
|
||||||
else
|
else
|
||||||
result.set(i, arg1[pos.toInt()]);
|
result.set(i, arg1[pos.toInt()]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
# Regression test for #5684: const_shift_worker must not crash when arg1 is
|
||||||
|
# empty.
|
||||||
|
|
||||||
|
read_json << EOF
|
||||||
|
{
|
||||||
|
"modules": {
|
||||||
|
"sshl": {
|
||||||
|
"cells": {
|
||||||
|
"sshlCell": {
|
||||||
|
"connections": {
|
||||||
|
"A": [],
|
||||||
|
"B": [3],
|
||||||
|
"Y": [1]
|
||||||
|
},
|
||||||
|
"parameters": {
|
||||||
|
"A_SIGNED": "1",
|
||||||
|
"A_WIDTH": "0",
|
||||||
|
"B_SIGNED": "0",
|
||||||
|
"B_WIDTH": "1",
|
||||||
|
"Y_WIDTH": "1"
|
||||||
|
},
|
||||||
|
"port_directions": {
|
||||||
|
"A": "input",
|
||||||
|
"B": "input",
|
||||||
|
"Y": "output"
|
||||||
|
},
|
||||||
|
"type": "$sshl"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ports": {
|
||||||
|
"A": {
|
||||||
|
"bits": [],
|
||||||
|
"direction": "input"
|
||||||
|
},
|
||||||
|
"B": {
|
||||||
|
"bits": [3],
|
||||||
|
"direction": "input"
|
||||||
|
},
|
||||||
|
"Y": {
|
||||||
|
"bits": [1],
|
||||||
|
"direction": "output"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
eval -set B 0 -show Y sshl
|
||||||
Loading…
Reference in New Issue