nexus: Be robust to parameters shorter than expected

Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
gatecat 2023-08-23 10:46:46 +02:00 committed by myrtle
parent 053dfc98f0
commit a01e2c9068

View File

@ -82,19 +82,22 @@ Property Arch::parse_lattice_param(const Property &val, IdString prop, int width
} }
temp = Property(ival); temp = Property(ival);
} }
if (int(temp.size()) > width) {
for (auto b : temp.str.substr(width)) { for (auto b : temp.str.substr(width)) {
if (b == Property::S1) if (b == Property::S1)
log_error("Found value for property %s.%s with width greater than %d\n", ci, nameOf(prop), width); log_error("Found value for property %s.%s with width greater than %d\n", ci, nameOf(prop), width);
}
} }
temp.update_intval(); temp.update_intval();
return temp.extract(0, width); return temp.extract(0, width);
} else { } else {
for (auto b : val.str.substr(width)) { if (int(val.str.size()) > width) {
if (b == Property::S1) for (auto b : val.str.substr(width)) {
log_error("Found bitvector value for property %s.%s with width greater than %d - perhaps a string was " if (b == Property::S1)
"converted to bits?\n", log_error("Found bitvector value for property %s.%s with width greater than %d - perhaps a string was "
ci, nameOf(prop), width); "converted to bits?\n",
ci, nameOf(prop), width);
}
} }
return val.extract(0, width); return val.extract(0, width);
} }