mirror of
https://github.com/verilator/verilator.git
synced 2024-12-29 10:47:34 +00:00
Fix empty foreach
in if
in constraints (#5408)
Signed-off-by: Krzysztof Bieganski <kbieganski@antmicro.com>
This commit is contained in:
parent
e927536099
commit
155dcc5658
@ -695,11 +695,13 @@ class ConstraintExprVisitor final : public VNVisitor {
|
||||
AstNode* const cstmtp = new AstText{fl, "ret += \" \" + "};
|
||||
cstmtp->addNext(itemp);
|
||||
cstmtp->addNext(new AstText{fl, ";"});
|
||||
AstNode* const exprsp = new AstText{fl, "([&]{ std::string ret = \"(bvand\";"};
|
||||
AstNode* const exprsp = new AstText{fl, "([&]{ std::string ret;"};
|
||||
exprsp->addNext(new AstBegin{
|
||||
fl, "",
|
||||
new AstForeach{fl, nodep->arrayp()->unlinkFrBack(), new AstCStmt{fl, cstmtp}},
|
||||
false, true});
|
||||
exprsp->addNext(
|
||||
new AstText{fl, "return ret.empty() ? \"#b1\" : \"(bvand \" + ret + \")\";"});
|
||||
exprsp->addNext(new AstText{fl, "return ret + \")\"; })()"});
|
||||
AstNodeExpr* const newp = new AstCExpr{fl, exprsp};
|
||||
newp->dtypeSetString();
|
||||
|
@ -32,8 +32,16 @@ endclass
|
||||
class D;
|
||||
rand bit posit;
|
||||
rand int x;
|
||||
int o[$]; // empty
|
||||
int p[$] = {1};
|
||||
int q[$] = {0, 0, 0, 0, 0};
|
||||
constraint fore {
|
||||
if (posit == 1) {
|
||||
foreach(o[i]) o[i] > 0;
|
||||
}
|
||||
if (posit == 1) {
|
||||
foreach(p[i]) p[i] > 0;
|
||||
}
|
||||
if (posit == 1) {
|
||||
x < 7;
|
||||
foreach(q[i])
|
||||
|
Loading…
Reference in New Issue
Block a user