Add more robust check
Signed-off-by: Pawel Kojma <pkojma@internships.antmicro.com>
This commit is contained in:
parent
3dd2b762e7
commit
ae135d8fdd
|
|
@ -33,13 +33,12 @@
|
||||||
|
|
||||||
#include "verilatedos.h"
|
#include "verilatedos.h"
|
||||||
|
|
||||||
#include "V3Randomize.h"
|
|
||||||
|
|
||||||
#include "V3Ast.h"
|
#include "V3Ast.h"
|
||||||
#include "V3Error.h"
|
#include "V3Error.h"
|
||||||
#include "V3FileLine.h"
|
#include "V3FileLine.h"
|
||||||
#include "V3Global.h"
|
#include "V3Global.h"
|
||||||
#include "V3MemberMap.h"
|
#include "V3MemberMap.h"
|
||||||
|
#include "V3Randomize.h"
|
||||||
#include "V3UniqueNames.h"
|
#include "V3UniqueNames.h"
|
||||||
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
@ -278,7 +277,8 @@ class RandomizeMarkVisitor final : public VNVisitor {
|
||||||
|
|
||||||
// Process a single constraint during nested constraint cloning
|
// Process a single constraint during nested constraint cloning
|
||||||
void processNestedConstraint(AstConstraint* const constrp, AstVarRef* rootVarRefp,
|
void processNestedConstraint(AstConstraint* const constrp, AstVarRef* rootVarRefp,
|
||||||
const std::vector<AstVar*>& newPath, AstClass* targetClassp) {
|
const std::vector<AstVar*>& newPath, AstClass* targetClassp,
|
||||||
|
AstClass* const memberClassp) {
|
||||||
std::string pathPrefix = rootVarRefp->name();
|
std::string pathPrefix = rootVarRefp->name();
|
||||||
for (AstVar* pathMemberVarp : newPath) {
|
for (AstVar* pathMemberVarp : newPath) {
|
||||||
pathPrefix += GLOBAL_CONSTRAINT_SEPARATOR + pathMemberVarp->name();
|
pathPrefix += GLOBAL_CONSTRAINT_SEPARATOR + pathMemberVarp->name();
|
||||||
|
|
@ -295,7 +295,6 @@ class RandomizeMarkVisitor final : public VNVisitor {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (isDuplicate) return;
|
if (isDuplicate) return;
|
||||||
|
|
||||||
AstConstraint* const cloneConstrp = constrp->cloneTree(false);
|
AstConstraint* const cloneConstrp = constrp->cloneTree(false);
|
||||||
cloneConstrp->name(newName);
|
cloneConstrp->name(newName);
|
||||||
cloneConstrp->foreach([&](AstVarRef* varRefp) {
|
cloneConstrp->foreach([&](AstVarRef* varRefp) {
|
||||||
|
|
@ -336,7 +335,8 @@ class RandomizeMarkVisitor final : public VNVisitor {
|
||||||
// member selections
|
// member selections
|
||||||
nestedClassp->foreachMember(
|
nestedClassp->foreachMember(
|
||||||
[&](AstClass* const containingClassp, AstConstraint* const constrp) {
|
[&](AstClass* const containingClassp, AstConstraint* const constrp) {
|
||||||
processNestedConstraint(constrp, rootVarRefp, newPath, targetClassp);
|
processNestedConstraint(constrp, rootVarRefp, newPath, targetClassp,
|
||||||
|
containingClassp);
|
||||||
});
|
});
|
||||||
cloneNestedConstraintsRecurse(rootVarRefp, nestedClassp, newPath, targetClassp);
|
cloneNestedConstraintsRecurse(rootVarRefp, nestedClassp, newPath, targetClassp);
|
||||||
}
|
}
|
||||||
|
|
@ -571,9 +571,11 @@ class RandomizeMarkVisitor final : public VNVisitor {
|
||||||
AstVarRef* rootVarRefp
|
AstVarRef* rootVarRefp
|
||||||
= new AstVarRef{nodep->fileline(), classp, memberVarp, VAccess::READ};
|
= new AstVarRef{nodep->fileline(), classp, memberVarp, VAccess::READ};
|
||||||
std::vector<AstVar*> emptyPath;
|
std::vector<AstVar*> emptyPath;
|
||||||
memberClassp->foreachMember([&](AstClass* const, AstConstraint* const constrp) {
|
memberClassp->foreachMember(
|
||||||
processNestedConstraint(constrp, rootVarRefp, emptyPath, classp);
|
[&](AstClass* const containingClassp, AstConstraint* const constrp) {
|
||||||
});
|
processNestedConstraint(constrp, rootVarRefp, emptyPath, classp,
|
||||||
|
containingClassp);
|
||||||
|
});
|
||||||
cloneNestedConstraintsRecurse(rootVarRefp, memberClassp, emptyPath, classp);
|
cloneNestedConstraintsRecurse(rootVarRefp, memberClassp, emptyPath, classp);
|
||||||
// Delete the temporary VarRef created for constraint cloning
|
// Delete the temporary VarRef created for constraint cloning
|
||||||
VL_DO_DANGLING(rootVarRefp->deleteTree(), rootVarRefp);
|
VL_DO_DANGLING(rootVarRefp->deleteTree(), rootVarRefp);
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,11 @@ parameter int LEN = 32;
|
||||||
|
|
||||||
class A;
|
class A;
|
||||||
rand int x;
|
rand int x;
|
||||||
|
rand int array[5];
|
||||||
constraint a_c {
|
constraint a_c {
|
||||||
x <= LEN;
|
x <= LEN;
|
||||||
x >= LEN;
|
x >= LEN;
|
||||||
|
foreach (array[i]) {array[i] == array[i-1];}
|
||||||
}
|
}
|
||||||
endclass
|
endclass
|
||||||
|
|
||||||
|
|
@ -25,6 +27,9 @@ module t;
|
||||||
b.a = new;
|
b.a = new;
|
||||||
if (b.randomize() == 0) $stop;
|
if (b.randomize() == 0) $stop;
|
||||||
if (b.a.x != LEN) $stop;
|
if (b.a.x != LEN) $stop;
|
||||||
|
for (int i = 0; i < 4; i++) begin
|
||||||
|
if (b.a.array[i] != b.a.array[i+1]) $stop;
|
||||||
|
end
|
||||||
$write("*-* All finished *-*\n");
|
$write("*-* All finished *-*\n");
|
||||||
$finish;
|
$finish;
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue