mirror of
https://github.com/verilator/verilator.git
synced 2025-01-08 15:47:36 +00:00
Internals: Refactor param array handling to use subroutine. No functional change intended.
This commit is contained in:
parent
47f040a5fd
commit
3963a50aef
@ -176,6 +176,13 @@ private:
|
||||
}
|
||||
return string("z") + cvtToStr(num);
|
||||
}
|
||||
AstNodeDType* arraySubDTypep(AstNodeDType* nodep) {
|
||||
// If an unpacked array, return the subDTypep under it
|
||||
if (AstUnpackArrayDType* adtypep = VN_CAST(nodep, UnpackArrayDType)) {
|
||||
return adtypep->subDTypep();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
void collectPins(CloneMap* clonemapp, AstNodeModule* modp) {
|
||||
// Grab all I/O so we can remap our pins later
|
||||
for (AstNode* stmtp = modp->stmtsp(); stmtp; stmtp = stmtp->nextp()) {
|
||||
@ -585,7 +592,7 @@ void ParamVisitor::visitCell(AstCell* nodep, const string& hierName) {
|
||||
pinp->v3error("Attempted parameter setting of non-parameter: Param "
|
||||
<< pinp->prettyNameQ() << " of " << nodep->prettyNameQ());
|
||||
} else if (VN_IS(pinp->exprp(), InitArray)
|
||||
&& VN_IS(modvarp->subDTypep(), UnpackArrayDType)) {
|
||||
&& arraySubDTypep(modvarp->subDTypep())) {
|
||||
// Array assigned to array
|
||||
AstNode* exprp = pinp->exprp();
|
||||
longname += "_" + paramSmallName(srcModp, modvarp) + paramValueNumber(exprp);
|
||||
@ -647,10 +654,8 @@ void ParamVisitor::visitCell(AstCell* nodep, const string& hierName) {
|
||||
AstVar* modvarp = pinp->modVarp();
|
||||
if (modvarp->isIfaceRef()) {
|
||||
AstIfaceRefDType* portIrefp = VN_CAST(modvarp->subDTypep(), IfaceRefDType);
|
||||
if (!portIrefp && VN_IS(modvarp->subDTypep(), UnpackArrayDType)) {
|
||||
portIrefp
|
||||
= VN_CAST(VN_CAST(modvarp->subDTypep(), UnpackArrayDType)->subDTypep(),
|
||||
IfaceRefDType);
|
||||
if (!portIrefp && arraySubDTypep(modvarp->subDTypep())) {
|
||||
portIrefp = VN_CAST(arraySubDTypep(modvarp->subDTypep()), IfaceRefDType);
|
||||
}
|
||||
|
||||
AstIfaceRefDType* pinIrefp = NULL;
|
||||
@ -662,34 +667,20 @@ void ParamVisitor::visitCell(AstCell* nodep, const string& hierName) {
|
||||
} else if (exprp && exprp->op1p() && VN_IS(exprp->op1p(), VarRef)
|
||||
&& VN_CAST(exprp->op1p(), VarRef)->varp()
|
||||
&& VN_CAST(exprp->op1p(), VarRef)->varp()->subDTypep()
|
||||
&& VN_CAST(VN_CAST(exprp->op1p(), VarRef)->varp()->subDTypep(),
|
||||
UnpackArrayDType)
|
||||
&& VN_CAST(VN_CAST(exprp->op1p(), VarRef)->varp()->subDTypep(),
|
||||
UnpackArrayDType)
|
||||
->subDTypep()
|
||||
&& VN_CAST(VN_CAST(VN_CAST(exprp->op1p(), VarRef)->varp()->subDTypep(),
|
||||
UnpackArrayDType)
|
||||
->subDTypep(),
|
||||
IfaceRefDType)) {
|
||||
pinIrefp = VN_CAST(VN_CAST(VN_CAST(exprp->op1p(), VarRef)->varp()->subDTypep(),
|
||||
UnpackArrayDType)
|
||||
->subDTypep(),
|
||||
IfaceRefDType);
|
||||
&& arraySubDTypep(VN_CAST(exprp->op1p(), VarRef)->varp()->subDTypep())
|
||||
&& VN_CAST(
|
||||
arraySubDTypep(VN_CAST(exprp->op1p(), VarRef)->varp()->subDTypep()),
|
||||
IfaceRefDType)) {
|
||||
pinIrefp = VN_CAST(
|
||||
arraySubDTypep(VN_CAST(exprp->op1p(), VarRef)->varp()->subDTypep()),
|
||||
IfaceRefDType);
|
||||
} else if (exprp && VN_IS(exprp, VarRef) && VN_CAST(exprp, VarRef)->varp()
|
||||
&& VN_CAST(exprp, VarRef)->varp()->subDTypep()
|
||||
&& VN_CAST(VN_CAST(exprp, VarRef)->varp()->subDTypep(),
|
||||
UnpackArrayDType)
|
||||
&& VN_CAST(VN_CAST(exprp, VarRef)->varp()->subDTypep(),
|
||||
UnpackArrayDType)
|
||||
->subDTypep()
|
||||
&& VN_CAST(VN_CAST(VN_CAST(exprp, VarRef)->varp()->subDTypep(),
|
||||
UnpackArrayDType)
|
||||
->subDTypep(),
|
||||
&& arraySubDTypep(VN_CAST(exprp, VarRef)->varp()->subDTypep())
|
||||
&& VN_CAST(arraySubDTypep(VN_CAST(exprp, VarRef)->varp()->subDTypep()),
|
||||
IfaceRefDType)) {
|
||||
pinIrefp = VN_CAST(
|
||||
VN_CAST(VN_CAST(exprp, VarRef)->varp()->subDTypep(), UnpackArrayDType)
|
||||
->subDTypep(),
|
||||
IfaceRefDType);
|
||||
pinIrefp = VN_CAST(arraySubDTypep(VN_CAST(exprp, VarRef)->varp()->subDTypep()),
|
||||
IfaceRefDType);
|
||||
}
|
||||
|
||||
UINFO(9, " portIfaceRef " << portIrefp << endl);
|
||||
|
Loading…
Reference in New Issue
Block a user