Skip to content

Commit 99e5da8

Browse files
Merge pull request #3670 from Apotell/select
Model class hierarchy change for select nodes
2 parents e11c334 + e63d876 commit 99e5da8

File tree

363 files changed

+19803
-27247
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

363 files changed

+19803
-27247
lines changed

include/Surelog/DesignCompile/CompileHelper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ class CompileHelper final {
154154
ValuedComponentI* instance);
155155

156156
UHDM::any* compileTfCall(DesignComponent* component, const FileContent* fC,
157-
NodeId Tf_call_stmt, CompileDesign* compileDesign);
157+
NodeId Tf_call_stmt, CompileDesign* compileDesign,
158+
UHDM::any* pexpr);
158159

159160
UHDM::VectorOfany* compileTfCallArguments(
160161
DesignComponent* component, const FileContent* fC, NodeId Arg_list_node,

src/DesignCompile/CompileExpression.cpp

Lines changed: 93 additions & 144 deletions
Large diffs are not rendered by default.

src/DesignCompile/CompileHelper.cpp

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,19 +2292,21 @@ n<> u<17> t<Continuous_assign> p<18> c<16> l<4>
22922292
compileDesign, Reduce::No, nullptr, instance);
22932293
NodeId Constant_select = fC->Sibling(Ps_or_hierarchical_identifier);
22942294
if ((fC->Type(Constant_select) == VObjectType::slConstant_select) &&
2295-
(Ps_or_hierarchical_identifier != Hierarchical_identifier)) {
2296-
UHDM::any* sel = compileSelectExpression(
2297-
component, fC, fC->Child(Constant_select), "", compileDesign,
2298-
Reduce::No, nullptr, instance, false);
2299-
if ((lhs_exp->UhdmType() == uhdmhier_path) && sel) {
2295+
(Ps_or_hierarchical_identifier != Hierarchical_identifier) &&
2296+
(lhs_exp->UhdmType() == uhdmhier_path)) {
2297+
if (UHDM::any* sel = compileSelectExpression(
2298+
component, fC, fC->Child(Constant_select), "", compileDesign,
2299+
Reduce::No, lhs_exp, instance, false)) {
23002300
hier_path* path = (hier_path*)lhs_exp;
23012301
any* last = path->Path_elems()->back();
23022302
if (last->UhdmType() == uhdmref_obj &&
23032303
sel->UhdmType() == uhdmbit_select) {
2304+
ref_obj* last_ro = (ref_obj*)last;
2305+
bit_select* sel_bs = (bit_select*)sel;
23042306
path->Path_elems()->pop_back();
2305-
((bit_select*)sel)->VpiName(last->VpiName());
2306-
((bit_select*)sel)->VpiFullName(last->VpiName());
2307-
sel->VpiParent(last);
2307+
sel_bs->VpiName(last->VpiName());
2308+
sel_bs->VpiFullName(
2309+
StrCat(last_ro->VpiFullName(), decompileHelper(sel)));
23082310
}
23092311
path->Path_elems()->push_back(sel);
23102312
std::string path_name(path->VpiName());
@@ -3758,7 +3760,8 @@ UHDM::constant* CompileHelper::adjustSize(const UHDM::typespec* ts,
37583760
UHDM::any* CompileHelper::compileTfCall(DesignComponent* component,
37593761
const FileContent* fC,
37603762
NodeId Tf_call_stmt,
3761-
CompileDesign* compileDesign) {
3763+
CompileDesign* compileDesign,
3764+
any* pexpr) {
37623765
UHDM::Serializer& s = compileDesign->getSerializer();
37633766

37643767
NodeId dollar_or_string = fC->Child(Tf_call_stmt);
@@ -3778,14 +3781,15 @@ UHDM::any* CompileHelper::compileTfCall(DesignComponent* component,
37783781
name.assign("$").append(fC->SymName(tfNameNode));
37793782
} else if (leaf_type == VObjectType::slImplicit_class_handle) {
37803783
return compileComplexFuncCall(component, fC, fC->Child(Tf_call_stmt),
3781-
compileDesign, Reduce::No, nullptr, nullptr,
3784+
compileDesign, Reduce::No, pexpr, nullptr,
37823785
false);
37833786
} else if (leaf_type == VObjectType::slDollar_root_keyword) {
37843787
NodeId Dollar_root_keyword = dollar_or_string;
37853788
NodeId nameId = fC->Sibling(Dollar_root_keyword);
37863789
name.assign("$root.").append(fC->SymName(nameId));
37873790
nameId = fC->Sibling(nameId);
37883791
tfNameNode = nameId;
3792+
func_call* fcall = s.MakeFunc_call();
37893793
while (nameId) {
37903794
if (fC->Type(nameId) == VObjectType::slStringConst) {
37913795
name.append(".").append(fC->SymName(nameId));
@@ -3794,8 +3798,9 @@ UHDM::any* CompileHelper::compileTfCall(DesignComponent* component,
37943798
NodeId Constant_expresion = fC->Child(nameId);
37953799
if (Constant_expresion) {
37963800
name += "[";
3797-
expr* select = (expr*)compileExpression(
3798-
component, fC, Constant_expresion, compileDesign, Reduce::No);
3801+
expr* select =
3802+
(expr*)compileExpression(component, fC, Constant_expresion,
3803+
compileDesign, Reduce::No, fcall);
37993804
name += select->VpiDecompile();
38003805
name += "]";
38013806
tfNameNode = nameId;
@@ -3805,8 +3810,8 @@ UHDM::any* CompileHelper::compileTfCall(DesignComponent* component,
38053810
}
38063811
nameId = fC->Sibling(nameId);
38073812
}
3808-
func_call* fcall = s.MakeFunc_call();
38093813
fcall->VpiName(name);
3814+
fcall->VpiParent(pexpr);
38103815
call = fcall;
38113816
} else if (leaf_type == VObjectType::slSystem_task_names) {
38123817
tfNameNode = dollar_or_string;
@@ -3819,7 +3824,7 @@ UHDM::any* CompileHelper::compileTfCall(DesignComponent* component,
38193824
fC->Type(handle) == VObjectType::slThis_dot_super) {
38203825
return (tf_call*)compileComplexFuncCall(
38213826
component, fC, fC->Child(Tf_call_stmt), compileDesign, Reduce::No,
3822-
nullptr, nullptr, false);
3827+
pexpr, nullptr, false);
38233828
} else if (fC->Type(handle) == VObjectType::slDollar_root_keyword) {
38243829
name = "$root.";
38253830
tfNameNode = fC->Sibling(dollar_or_string);
@@ -3829,7 +3834,7 @@ UHDM::any* CompileHelper::compileTfCall(DesignComponent* component,
38293834
} else if (leaf_type == VObjectType::slClass_scope) {
38303835
return (tf_call*)compileComplexFuncCall(
38313836
component, fC, fC->Child(Tf_call_stmt), compileDesign, Reduce::No,
3832-
nullptr, nullptr, false);
3837+
pexpr, nullptr, false);
38333838
} else {
38343839
// User call, AST is:
38353840
// n<> u<27> t<Subroutine_call> p<28> c<17> l<3>
@@ -3848,6 +3853,7 @@ UHDM::any* CompileHelper::compileTfCall(DesignComponent* component,
38483853
const std::string_view mname = fC->SymName(tfNameNode);
38493854
fC->populateCoreMembers(tfNameNode, tfNameNode, fcall);
38503855
fcall->VpiName(mname);
3856+
fcall->VpiParent(pexpr);
38513857
ref_obj* prefix = s.MakeRef_obj();
38523858
prefix->VpiName(name);
38533859
prefix->VpiParent(fcall);
@@ -3868,6 +3874,7 @@ UHDM::any* CompileHelper::compileTfCall(DesignComponent* component,
38683874
tcall->Task(any_cast<task*>(tf));
38693875
call = tcall;
38703876
}
3877+
call->VpiParent(pexpr);
38713878
}
38723879
if (call == nullptr) {
38733880
LetStmt* stmt = component->getLetStmt(name);
@@ -4078,6 +4085,7 @@ UHDM::assignment* CompileHelper::compileBlockingAssignment(
40784085
} else {
40794086
Variable_lvalue = fC->Child(Operator_assignment);
40804087
}
4088+
assignment* assign = s.MakeAssignment();
40814089
UHDM::expr* lhs_rf = nullptr;
40824090
UHDM::any* rhs_rf = nullptr;
40834091
NodeId Delay_or_event_control;
@@ -4088,8 +4096,8 @@ UHDM::assignment* CompileHelper::compileBlockingAssignment(
40884096
Delay_or_event_control = fC->Sibling(Variable_lvalue);
40894097
NodeId Expression = fC->Sibling(Delay_or_event_control);
40904098
lhs_rf = any_cast<expr*>(compileExpression(component, fC, Variable_lvalue,
4091-
compileDesign, Reduce::No, pstmt,
4092-
instance));
4099+
compileDesign, Reduce::No,
4100+
assign, instance));
40934101
AssignOp_Assign = InvalidNodeId;
40944102
if (fC->Type(Delay_or_event_control) == VObjectType::slDynamic_array_new) {
40954103
method_func_call* fcall = s.MakeMethod_func_call();
@@ -4107,7 +4115,7 @@ UHDM::assignment* CompileHelper::compileBlockingAssignment(
41074115
rhs_rf = fcall;
41084116
} else {
41094117
rhs_rf = compileExpression(component, fC, Expression, compileDesign,
4110-
Reduce::No, pstmt, instance);
4118+
Reduce::No, assign, instance);
41114119
}
41124120
} else if (fC->Type(Variable_lvalue) == VObjectType::slVariable_lvalue) {
41134121
AssignOp_Assign = fC->Sibling(Variable_lvalue);
@@ -4123,7 +4131,7 @@ UHDM::assignment* CompileHelper::compileBlockingAssignment(
41234131

41244132
lhs_rf = any_cast<expr*>(
41254133
compileExpression(component, fC, Hierarchical_identifier, compileDesign,
4126-
Reduce::No, pstmt, instance));
4134+
Reduce::No, assign, instance));
41274135
NodeId Expression;
41284136
if (fC->Type(AssignOp_Assign) == VObjectType::slExpression) {
41294137
Expression = AssignOp_Assign;
@@ -4137,7 +4145,7 @@ UHDM::assignment* CompileHelper::compileBlockingAssignment(
41374145
Expression = fC->Sibling(AssignOp_Assign);
41384146
}
41394147
rhs_rf = compileExpression(component, fC, Expression, compileDesign,
4140-
Reduce::No, pstmt, instance);
4148+
Reduce::No, assign, instance);
41414149
} else if (fC->Type(Operator_assignment) ==
41424150
VObjectType::slHierarchical_identifier) {
41434151
// = new ...
@@ -4147,9 +4155,10 @@ UHDM::assignment* CompileHelper::compileBlockingAssignment(
41474155
NodeId List_of_arguments = fC->Child(Class_new);
41484156
lhs_rf = any_cast<expr*>(
41494157
compileExpression(component, fC, Hierarchical_identifier, compileDesign,
4150-
Reduce::No, pstmt, instance));
4158+
Reduce::No, assign, instance));
41514159
method_func_call* fcall = s.MakeMethod_func_call();
41524160
fcall->VpiName("new");
4161+
fcall->VpiParent(assign);
41534162
fC->populateCoreMembers(Hierarchical_identifier, Hierarchical_identifier,
41544163
fcall);
41554164
if (List_of_arguments) {
@@ -4162,7 +4171,6 @@ UHDM::assignment* CompileHelper::compileBlockingAssignment(
41624171
rhs_rf = fcall;
41634172
}
41644173

4165-
assignment* assign = s.MakeAssignment();
41664174
UHDM::delay_control* delay_control = nullptr;
41674175
if (Delay_or_event_control &&
41684176
(fC->Type(Delay_or_event_control) != VObjectType::slSelect)) {
@@ -4183,8 +4191,6 @@ UHDM::assignment* CompileHelper::compileBlockingAssignment(
41834191
if (blocking) assign->VpiBlocking(true);
41844192
assign->Lhs(lhs_rf);
41854193
assign->Rhs(rhs_rf);
4186-
setParentNoOverride(lhs_rf, assign);
4187-
setParentNoOverride(rhs_rf, assign);
41884194
return assign;
41894195
}
41904196

src/DesignCompile/CompileStmt.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,12 @@ VectorOfany* CompileHelper::compileStmt(DesignComponent* component,
238238
}
239239
case VObjectType::slSubroutine_call_statement: {
240240
NodeId Subroutine_call = fC->Child(the_stmt);
241-
stmt = compileTfCall(component, fC, Subroutine_call, compileDesign);
241+
stmt =
242+
compileTfCall(component, fC, Subroutine_call, compileDesign, pstmt);
242243
break;
243244
}
244245
case VObjectType::slSystem_task: {
245-
stmt = compileTfCall(component, fC, the_stmt, compileDesign);
246+
stmt = compileTfCall(component, fC, the_stmt, compileDesign, pstmt);
246247
break;
247248
}
248249
case VObjectType::slConditional_statement: {

tests/AlwaysNoElab/AlwaysNoElab.log

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,23 +1063,20 @@ design: (work@dut)
10631063
|vpiBlocking:1
10641064
|vpiRhs:
10651065
\_operation: , line:9:22, endln:9:47
1066-
|vpiParent:
1067-
\_assignment: , line:9:5, endln:9:47
10681066
|vpiTypespec:
10691067
\_int_typespec: , line:5:14, endln:5:26
10701068
|vpiOpType:67
10711069
|vpiOperand:
1072-
\_ref_obj: (work@dut.device), line:9:40, endln:9:46
1070+
\_ref_obj: (device), line:9:40, endln:9:46
10731071
|vpiParent:
10741072
\_operation: , line:9:22, endln:9:47
10751073
|vpiName:device
1076-
|vpiFullName:[email protected]
10771074
|vpiActual:
10781075
\_int_var: ([email protected]), line:7:7, endln:7:17
10791076
|vpiLhs:
10801077
\_ref_obj: ([email protected]_sel_req), line:9:5, endln:9:19
10811078
|vpiParent:
1082-
\_begin: (work@dut), line:8:15, endln:10:6
1079+
\_assignment: , line:9:5, endln:9:47
10831080
|vpiName:device_sel_req
10841081
|vpiFullName:[email protected]_sel_req
10851082
|vpiActual:

0 commit comments

Comments
 (0)