Use VAR_BASE as attr type if a select's base is a ref (#3943)
Signed-off-by: Ryszard Rozak <rrozak@antmicro.com>
This commit is contained in:
parent
3436d1780f
commit
072d76fe8e
|
|
@ -371,7 +371,6 @@ public:
|
||||||
//
|
//
|
||||||
DT_PUBLIC, // V3LinkParse moves to AstTypedef::attrPublic
|
DT_PUBLIC, // V3LinkParse moves to AstTypedef::attrPublic
|
||||||
//
|
//
|
||||||
ENUM_BASE, // V3LinkResolve creates for AstPreSel, V3LinkParam removes
|
|
||||||
ENUM_FIRST, // V3Width processes
|
ENUM_FIRST, // V3Width processes
|
||||||
ENUM_LAST, // V3Width processes
|
ENUM_LAST, // V3Width processes
|
||||||
ENUM_NUM, // V3Width processes
|
ENUM_NUM, // V3Width processes
|
||||||
|
|
@ -380,8 +379,6 @@ public:
|
||||||
ENUM_NAME, // V3Width processes
|
ENUM_NAME, // V3Width processes
|
||||||
ENUM_VALID, // V3Width processes
|
ENUM_VALID, // V3Width processes
|
||||||
//
|
//
|
||||||
MEMBER_BASE, // V3LinkResolve creates for AstPreSel, V3LinkParam removes
|
|
||||||
//
|
|
||||||
TYPENAME, // V3Width processes
|
TYPENAME, // V3Width processes
|
||||||
//
|
//
|
||||||
VAR_BASE, // V3LinkResolve creates for AstPreSel, V3LinkParam removes
|
VAR_BASE, // V3LinkResolve creates for AstPreSel, V3LinkParam removes
|
||||||
|
|
@ -407,9 +404,8 @@ public:
|
||||||
"DIM_BITS", "DIM_DIMENSIONS", "DIM_HIGH", "DIM_INCREMENT", "DIM_LEFT",
|
"DIM_BITS", "DIM_DIMENSIONS", "DIM_HIGH", "DIM_INCREMENT", "DIM_LEFT",
|
||||||
"DIM_LOW", "DIM_RIGHT", "DIM_SIZE", "DIM_UNPK_DIMENSIONS",
|
"DIM_LOW", "DIM_RIGHT", "DIM_SIZE", "DIM_UNPK_DIMENSIONS",
|
||||||
"DT_PUBLIC",
|
"DT_PUBLIC",
|
||||||
"ENUM_BASE", "ENUM_FIRST", "ENUM_LAST", "ENUM_NUM",
|
"ENUM_FIRST", "ENUM_LAST", "ENUM_NUM",
|
||||||
"ENUM_NEXT", "ENUM_PREV", "ENUM_NAME", "ENUM_VALID",
|
"ENUM_NEXT", "ENUM_PREV", "ENUM_NAME", "ENUM_VALID",
|
||||||
"MEMBER_BASE",
|
|
||||||
"TYPENAME",
|
"TYPENAME",
|
||||||
"VAR_BASE", "VAR_CLOCK_ENABLE", "VAR_FORCEABLE", "VAR_PUBLIC",
|
"VAR_BASE", "VAR_CLOCK_ENABLE", "VAR_FORCEABLE", "VAR_PUBLIC",
|
||||||
"VAR_PUBLIC_FLAT", "VAR_PUBLIC_FLAT_RD", "VAR_PUBLIC_FLAT_RW",
|
"VAR_PUBLIC_FLAT", "VAR_PUBLIC_FLAT_RD", "VAR_PUBLIC_FLAT_RW",
|
||||||
|
|
|
||||||
|
|
@ -869,7 +869,7 @@ AstNode* AstArraySel::baseFromp(AstNode* nodep, bool overMembers) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// AstNodeSelPre stashes the associated variable under an ATTROF
|
// AstNodeSelPre stashes the associated variable under an ATTROF
|
||||||
// of VAttrType::VAR_BASE/MEMBER_BASE so it isn't constified
|
// of VAttrType::VAR_BASE so it isn't constified
|
||||||
else if (VN_IS(nodep, AttrOf)) {
|
else if (VN_IS(nodep, AttrOf)) {
|
||||||
nodep = VN_AS(nodep, AttrOf)->fromp();
|
nodep = VN_AS(nodep, AttrOf)->fromp();
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -145,34 +145,13 @@ private:
|
||||||
void visit(AstNodePreSel* nodep) override {
|
void visit(AstNodePreSel* nodep) override {
|
||||||
if (!nodep->attrp()) {
|
if (!nodep->attrp()) {
|
||||||
iterateChildren(nodep);
|
iterateChildren(nodep);
|
||||||
// Constification may change the fromp() to a constant, which will lose the
|
|
||||||
// variable we're extracting from (to determine MSB/LSB/endianness/etc.)
|
|
||||||
// So we replicate it in another node
|
|
||||||
// Note that V3Param knows not to replace AstVarRef's under AstAttrOf's
|
|
||||||
AstNode* const basefromp = AstArraySel::baseFromp(nodep, false);
|
AstNode* const basefromp = AstArraySel::baseFromp(nodep, false);
|
||||||
if (AstNodeVarRef* const varrefp
|
if (VN_IS(basefromp, Replicate)) {
|
||||||
= VN_CAST(basefromp, NodeVarRef)) { // Maybe varxref - so need to clone
|
|
||||||
nodep->attrp(new AstAttrOf{nodep->fileline(), VAttrType::VAR_BASE,
|
|
||||||
varrefp->cloneTree(false)});
|
|
||||||
} else if (AstUnlinkedRef* const uvxrp
|
|
||||||
= VN_CAST(basefromp, UnlinkedRef)) { // Maybe unlinked - so need to clone
|
|
||||||
nodep->attrp(new AstAttrOf{nodep->fileline(), VAttrType::VAR_BASE,
|
|
||||||
uvxrp->cloneTree(false)});
|
|
||||||
} else if (auto* const fromp = VN_CAST(basefromp, LambdaArgRef)) {
|
|
||||||
nodep->attrp(new AstAttrOf{nodep->fileline(), VAttrType::VAR_BASE,
|
|
||||||
fromp->cloneTree(false)});
|
|
||||||
} else if (AstMemberSel* const fromp = VN_CAST(basefromp, MemberSel)) {
|
|
||||||
nodep->attrp(new AstAttrOf{nodep->fileline(), VAttrType::MEMBER_BASE,
|
|
||||||
fromp->cloneTree(false)});
|
|
||||||
} else if (AstEnumItemRef* const fromp = VN_CAST(basefromp, EnumItemRef)) {
|
|
||||||
nodep->attrp(new AstAttrOf{nodep->fileline(), VAttrType::ENUM_BASE,
|
|
||||||
fromp->cloneTree(false)});
|
|
||||||
} else if (VN_IS(basefromp, Replicate)) {
|
|
||||||
// From {...}[...] syntax in IEEE 2017
|
// From {...}[...] syntax in IEEE 2017
|
||||||
if (basefromp) UINFO(1, " Related node: " << basefromp << endl);
|
if (basefromp) UINFO(1, " Related node: " << basefromp << endl);
|
||||||
} else {
|
} else {
|
||||||
if (basefromp) UINFO(1, " Related node: " << basefromp << endl);
|
nodep->attrp(new AstAttrOf{nodep->fileline(), VAttrType::VAR_BASE,
|
||||||
nodep->v3fatalSrc("Illegal bit select; no signal/member being extracted from");
|
basefromp->cloneTree(false)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1452,8 +1452,6 @@ private:
|
||||||
// Don't iterate children, don't want to lose VarRef.
|
// Don't iterate children, don't want to lose VarRef.
|
||||||
switch (nodep->attrType()) {
|
switch (nodep->attrType()) {
|
||||||
case VAttrType::VAR_BASE:
|
case VAttrType::VAR_BASE:
|
||||||
case VAttrType::MEMBER_BASE:
|
|
||||||
case VAttrType::ENUM_BASE:
|
|
||||||
// Soon to be handled in V3LinkWidth SEL generation, under attrp() and newSubLsbOf
|
// Soon to be handled in V3LinkWidth SEL generation, under attrp() and newSubLsbOf
|
||||||
break;
|
break;
|
||||||
case VAttrType::DIM_DIMENSIONS:
|
case VAttrType::DIM_DIMENSIONS:
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,20 @@ class ClsWithParamField;
|
||||||
endfunction
|
endfunction
|
||||||
endclass
|
endclass
|
||||||
|
|
||||||
|
class DictWrapper;
|
||||||
|
int m_dict[string];
|
||||||
|
endclass
|
||||||
|
|
||||||
|
class DictOperator #(type T) extends T;
|
||||||
|
function void set(string s, int x);
|
||||||
|
m_dict[s] = x;
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function int get(string s);
|
||||||
|
return m_dict[s];
|
||||||
|
endfunction
|
||||||
|
endclass
|
||||||
|
|
||||||
module t (/*AUTOARG*/);
|
module t (/*AUTOARG*/);
|
||||||
|
|
||||||
Cls c12;
|
Cls c12;
|
||||||
|
|
@ -103,6 +117,7 @@ module t (/*AUTOARG*/);
|
||||||
SelfRefClassIntParam::self_int_t src10;
|
SelfRefClassIntParam::self_int_t src10;
|
||||||
IntQueue qi;
|
IntQueue qi;
|
||||||
ClsWithParamField cls_param_field;
|
ClsWithParamField cls_param_field;
|
||||||
|
DictOperator #(DictWrapper) dict_op;
|
||||||
int arr [1:0] = '{1, 2};
|
int arr [1:0] = '{1, 2};
|
||||||
initial begin
|
initial begin
|
||||||
c12 = new;
|
c12 = new;
|
||||||
|
|
@ -116,6 +131,7 @@ module t (/*AUTOARG*/);
|
||||||
src10 = new;
|
src10 = new;
|
||||||
qi = new;
|
qi = new;
|
||||||
cls_param_field = new;
|
cls_param_field = new;
|
||||||
|
dict_op = new;
|
||||||
if (Cls#()::PBASE != 12) $stop;
|
if (Cls#()::PBASE != 12) $stop;
|
||||||
if (Cls#(4)::PBASE != 4) $stop;
|
if (Cls#(4)::PBASE != 4) $stop;
|
||||||
if (Cls8_t::PBASE != 8) $stop;
|
if (Cls8_t::PBASE != 8) $stop;
|
||||||
|
|
@ -167,6 +183,9 @@ module t (/*AUTOARG*/);
|
||||||
cls_param_field.m_queue = '{1, 5, 7};
|
cls_param_field.m_queue = '{1, 5, 7};
|
||||||
if (cls_param_field.get(2) != 7) $stop;
|
if (cls_param_field.get(2) != 7) $stop;
|
||||||
|
|
||||||
|
dict_op.set("abcd", 1);
|
||||||
|
if(dict_op.get("abcd") != 1) $stop;
|
||||||
|
|
||||||
$write("*-* All Finished *-*\n");
|
$write("*-* All Finished *-*\n");
|
||||||
$finish;
|
$finish;
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue