Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion include/Surelog/DesignCompile/CompileHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ class CompileHelper final {
ValuedComponentI* instance);

UHDM::any* compileTfCall(DesignComponent* component, const FileContent* fC,
NodeId Tf_call_stmt, CompileDesign* compileDesign);
NodeId Tf_call_stmt, CompileDesign* compileDesign,
UHDM::any* pexpr);

UHDM::VectorOfany* compileTfCallArguments(
DesignComponent* component, const FileContent* fC, NodeId Arg_list_node,
Expand Down
237 changes: 93 additions & 144 deletions src/DesignCompile/CompileExpression.cpp

Large diffs are not rendered by default.

54 changes: 30 additions & 24 deletions src/DesignCompile/CompileHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2292,19 +2292,21 @@ n<> u<17> t<Continuous_assign> p<18> c<16> l<4>
compileDesign, Reduce::No, nullptr, instance);
NodeId Constant_select = fC->Sibling(Ps_or_hierarchical_identifier);
if ((fC->Type(Constant_select) == VObjectType::slConstant_select) &&
(Ps_or_hierarchical_identifier != Hierarchical_identifier)) {
UHDM::any* sel = compileSelectExpression(
component, fC, fC->Child(Constant_select), "", compileDesign,
Reduce::No, nullptr, instance, false);
if ((lhs_exp->UhdmType() == uhdmhier_path) && sel) {
(Ps_or_hierarchical_identifier != Hierarchical_identifier) &&
(lhs_exp->UhdmType() == uhdmhier_path)) {
if (UHDM::any* sel = compileSelectExpression(
component, fC, fC->Child(Constant_select), "", compileDesign,
Reduce::No, lhs_exp, instance, false)) {
hier_path* path = (hier_path*)lhs_exp;
any* last = path->Path_elems()->back();
if (last->UhdmType() == uhdmref_obj &&
sel->UhdmType() == uhdmbit_select) {
ref_obj* last_ro = (ref_obj*)last;
bit_select* sel_bs = (bit_select*)sel;
path->Path_elems()->pop_back();
((bit_select*)sel)->VpiName(last->VpiName());
((bit_select*)sel)->VpiFullName(last->VpiName());
sel->VpiParent(last);
sel_bs->VpiName(last->VpiName());
sel_bs->VpiFullName(
StrCat(last_ro->VpiFullName(), decompileHelper(sel)));
}
path->Path_elems()->push_back(sel);
std::string path_name(path->VpiName());
Expand Down Expand Up @@ -3758,7 +3760,8 @@ UHDM::constant* CompileHelper::adjustSize(const UHDM::typespec* ts,
UHDM::any* CompileHelper::compileTfCall(DesignComponent* component,
const FileContent* fC,
NodeId Tf_call_stmt,
CompileDesign* compileDesign) {
CompileDesign* compileDesign,
any* pexpr) {
UHDM::Serializer& s = compileDesign->getSerializer();

NodeId dollar_or_string = fC->Child(Tf_call_stmt);
Expand All @@ -3778,14 +3781,15 @@ UHDM::any* CompileHelper::compileTfCall(DesignComponent* component,
name.assign("$").append(fC->SymName(tfNameNode));
} else if (leaf_type == VObjectType::slImplicit_class_handle) {
return compileComplexFuncCall(component, fC, fC->Child(Tf_call_stmt),
compileDesign, Reduce::No, nullptr, nullptr,
compileDesign, Reduce::No, pexpr, nullptr,
false);
} else if (leaf_type == VObjectType::slDollar_root_keyword) {
NodeId Dollar_root_keyword = dollar_or_string;
NodeId nameId = fC->Sibling(Dollar_root_keyword);
name.assign("$root.").append(fC->SymName(nameId));
nameId = fC->Sibling(nameId);
tfNameNode = nameId;
func_call* fcall = s.MakeFunc_call();
while (nameId) {
if (fC->Type(nameId) == VObjectType::slStringConst) {
name.append(".").append(fC->SymName(nameId));
Expand All @@ -3794,8 +3798,9 @@ UHDM::any* CompileHelper::compileTfCall(DesignComponent* component,
NodeId Constant_expresion = fC->Child(nameId);
if (Constant_expresion) {
name += "[";
expr* select = (expr*)compileExpression(
component, fC, Constant_expresion, compileDesign, Reduce::No);
expr* select =
(expr*)compileExpression(component, fC, Constant_expresion,
compileDesign, Reduce::No, fcall);
name += select->VpiDecompile();
name += "]";
tfNameNode = nameId;
Expand All @@ -3805,8 +3810,8 @@ UHDM::any* CompileHelper::compileTfCall(DesignComponent* component,
}
nameId = fC->Sibling(nameId);
}
func_call* fcall = s.MakeFunc_call();
fcall->VpiName(name);
fcall->VpiParent(pexpr);
call = fcall;
} else if (leaf_type == VObjectType::slSystem_task_names) {
tfNameNode = dollar_or_string;
Expand All @@ -3819,7 +3824,7 @@ UHDM::any* CompileHelper::compileTfCall(DesignComponent* component,
fC->Type(handle) == VObjectType::slThis_dot_super) {
return (tf_call*)compileComplexFuncCall(
component, fC, fC->Child(Tf_call_stmt), compileDesign, Reduce::No,
nullptr, nullptr, false);
pexpr, nullptr, false);
} else if (fC->Type(handle) == VObjectType::slDollar_root_keyword) {
name = "$root.";
tfNameNode = fC->Sibling(dollar_or_string);
Expand All @@ -3829,7 +3834,7 @@ UHDM::any* CompileHelper::compileTfCall(DesignComponent* component,
} else if (leaf_type == VObjectType::slClass_scope) {
return (tf_call*)compileComplexFuncCall(
component, fC, fC->Child(Tf_call_stmt), compileDesign, Reduce::No,
nullptr, nullptr, false);
pexpr, nullptr, false);
} else {
// User call, AST is:
// n<> u<27> t<Subroutine_call> p<28> c<17> l<3>
Expand All @@ -3848,6 +3853,7 @@ UHDM::any* CompileHelper::compileTfCall(DesignComponent* component,
const std::string_view mname = fC->SymName(tfNameNode);
fC->populateCoreMembers(tfNameNode, tfNameNode, fcall);
fcall->VpiName(mname);
fcall->VpiParent(pexpr);
ref_obj* prefix = s.MakeRef_obj();
prefix->VpiName(name);
prefix->VpiParent(fcall);
Expand All @@ -3868,6 +3874,7 @@ UHDM::any* CompileHelper::compileTfCall(DesignComponent* component,
tcall->Task(any_cast<task*>(tf));
call = tcall;
}
call->VpiParent(pexpr);
}
if (call == nullptr) {
LetStmt* stmt = component->getLetStmt(name);
Expand Down Expand Up @@ -4078,6 +4085,7 @@ UHDM::assignment* CompileHelper::compileBlockingAssignment(
} else {
Variable_lvalue = fC->Child(Operator_assignment);
}
assignment* assign = s.MakeAssignment();
UHDM::expr* lhs_rf = nullptr;
UHDM::any* rhs_rf = nullptr;
NodeId Delay_or_event_control;
Expand All @@ -4088,8 +4096,8 @@ UHDM::assignment* CompileHelper::compileBlockingAssignment(
Delay_or_event_control = fC->Sibling(Variable_lvalue);
NodeId Expression = fC->Sibling(Delay_or_event_control);
lhs_rf = any_cast<expr*>(compileExpression(component, fC, Variable_lvalue,
compileDesign, Reduce::No, pstmt,
instance));
compileDesign, Reduce::No,
assign, instance));
AssignOp_Assign = InvalidNodeId;
if (fC->Type(Delay_or_event_control) == VObjectType::slDynamic_array_new) {
method_func_call* fcall = s.MakeMethod_func_call();
Expand All @@ -4107,7 +4115,7 @@ UHDM::assignment* CompileHelper::compileBlockingAssignment(
rhs_rf = fcall;
} else {
rhs_rf = compileExpression(component, fC, Expression, compileDesign,
Reduce::No, pstmt, instance);
Reduce::No, assign, instance);
}
} else if (fC->Type(Variable_lvalue) == VObjectType::slVariable_lvalue) {
AssignOp_Assign = fC->Sibling(Variable_lvalue);
Expand All @@ -4123,7 +4131,7 @@ UHDM::assignment* CompileHelper::compileBlockingAssignment(

lhs_rf = any_cast<expr*>(
compileExpression(component, fC, Hierarchical_identifier, compileDesign,
Reduce::No, pstmt, instance));
Reduce::No, assign, instance));
NodeId Expression;
if (fC->Type(AssignOp_Assign) == VObjectType::slExpression) {
Expression = AssignOp_Assign;
Expand All @@ -4137,7 +4145,7 @@ UHDM::assignment* CompileHelper::compileBlockingAssignment(
Expression = fC->Sibling(AssignOp_Assign);
}
rhs_rf = compileExpression(component, fC, Expression, compileDesign,
Reduce::No, pstmt, instance);
Reduce::No, assign, instance);
} else if (fC->Type(Operator_assignment) ==
VObjectType::slHierarchical_identifier) {
// = new ...
Expand All @@ -4147,9 +4155,10 @@ UHDM::assignment* CompileHelper::compileBlockingAssignment(
NodeId List_of_arguments = fC->Child(Class_new);
lhs_rf = any_cast<expr*>(
compileExpression(component, fC, Hierarchical_identifier, compileDesign,
Reduce::No, pstmt, instance));
Reduce::No, assign, instance));
method_func_call* fcall = s.MakeMethod_func_call();
fcall->VpiName("new");
fcall->VpiParent(assign);
fC->populateCoreMembers(Hierarchical_identifier, Hierarchical_identifier,
fcall);
if (List_of_arguments) {
Expand All @@ -4162,7 +4171,6 @@ UHDM::assignment* CompileHelper::compileBlockingAssignment(
rhs_rf = fcall;
}

assignment* assign = s.MakeAssignment();
UHDM::delay_control* delay_control = nullptr;
if (Delay_or_event_control &&
(fC->Type(Delay_or_event_control) != VObjectType::slSelect)) {
Expand All @@ -4183,8 +4191,6 @@ UHDM::assignment* CompileHelper::compileBlockingAssignment(
if (blocking) assign->VpiBlocking(true);
assign->Lhs(lhs_rf);
assign->Rhs(rhs_rf);
setParentNoOverride(lhs_rf, assign);
setParentNoOverride(rhs_rf, assign);
return assign;
}

Expand Down
5 changes: 3 additions & 2 deletions src/DesignCompile/CompileStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,12 @@ VectorOfany* CompileHelper::compileStmt(DesignComponent* component,
}
case VObjectType::slSubroutine_call_statement: {
NodeId Subroutine_call = fC->Child(the_stmt);
stmt = compileTfCall(component, fC, Subroutine_call, compileDesign);
stmt =
compileTfCall(component, fC, Subroutine_call, compileDesign, pstmt);
break;
}
case VObjectType::slSystem_task: {
stmt = compileTfCall(component, fC, the_stmt, compileDesign);
stmt = compileTfCall(component, fC, the_stmt, compileDesign, pstmt);
break;
}
case VObjectType::slConditional_statement: {
Expand Down
7 changes: 2 additions & 5 deletions tests/AlwaysNoElab/AlwaysNoElab.log
Original file line number Diff line number Diff line change
Expand Up @@ -1063,23 +1063,20 @@ design: (work@dut)
|vpiBlocking:1
|vpiRhs:
\_operation: , line:9:22, endln:9:47
|vpiParent:
\_assignment: , line:9:5, endln:9:47
|vpiTypespec:
\_int_typespec: , line:5:14, endln:5:26
|vpiOpType:67
|vpiOperand:
\_ref_obj: (work@dut.device), line:9:40, endln:9:46
\_ref_obj: (device), line:9:40, endln:9:46
|vpiParent:
\_operation: , line:9:22, endln:9:47
|vpiName:device
|vpiFullName:[email protected]
|vpiActual:
\_int_var: ([email protected]), line:7:7, endln:7:17
|vpiLhs:
\_ref_obj: ([email protected]_sel_req), line:9:5, endln:9:19
|vpiParent:
\_begin: (work@dut), line:8:15, endln:10:6
\_assignment: , line:9:5, endln:9:47
|vpiName:device_sel_req
|vpiFullName:[email protected]_sel_req
|vpiActual:
Expand Down
Loading