Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alaindargelas committed Dec 18, 2023
1 parent 6f7dacc commit dc0697f
Showing 1 changed file with 14 additions and 51 deletions.
65 changes: 14 additions & 51 deletions frontends/systemverilog/uhdm_ast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2318,44 +2318,29 @@ void UhdmAst::process_module()
current_node->children.erase(process_it, current_node->children.end());
auto old_top = shared.current_top_node;
shared.current_top_node = current_node;
visit_one_to_many(
{vpiModule, vpiInterface, vpiParameter, vpiParamAssign, vpiPort, vpiNet, vpiArrayNet, vpiTaskFunc, vpiGenScopeArray, vpiContAssign},
obj_h, [&](AST::AstNode *node) {
if (node) {
if (get_attribute(node, attr_id::is_type_parameter)) {
// Don't process type parameters.
delete node;
return;
}
add_or_replace_child(current_node, node);
}
});
visit_one_to_many({vpiModule, vpiInterface, vpiParameter, vpiParamAssign, vpiPort, vpiNet, vpiArrayNet, vpiTaskFunc, vpiGenScopeArray,
vpiContAssign, vpiVariables},
obj_h, [&](AST::AstNode *node) {
if (node) {
if (get_attribute(node, attr_id::is_type_parameter)) {
// Don't process type parameters.
delete node;
return;
}
add_or_replace_child(current_node, node);
}
});

visit_one_to_many({vpiProcess}, obj_h, [&](AST::AstNode *node) {
if (node) {
if (node->type == AST::AST_ALWAYS) {
if (get_attribute(node, attr_id::is_type_parameter)) {
// Don't process type parameters.
delete node;
return;
}
add_or_replace_child(current_node, node);
} else {
delete node;
}
}
});

visit_one_to_many({vpiVariables}, obj_h, [&](AST::AstNode *node) {
if (node) {
if (get_attribute(node, attr_id::is_type_parameter)) {
// Don't process type parameters.
delete node;
return;
}
add_or_replace_child(current_node, node);
}
});
// Primitives will have the same names (like "and"), so we need to make sure we don't replace them
visit_one_to_many({vpiPrimitive}, obj_h, [&](AST::AstNode *node) {
if (node) {
Expand Down Expand Up @@ -2385,7 +2370,7 @@ void UhdmAst::process_module()
move_type_to_new_typedef(current_node, node);
}
});
visit_one_to_many({vpiModule, vpiParameter, vpiParamAssign, vpiNet, vpiArrayNet}, obj_h, [&](AST::AstNode *node) {
visit_one_to_many({vpiModule, vpiParameter, vpiParamAssign, vpiNet, vpiArrayNet, vpiProcess}, obj_h, [&](AST::AstNode *node) {
if (node) {
if (get_attribute(node, attr_id::is_type_parameter)) {
// Don't process type parameters.
Expand All @@ -2399,23 +2384,6 @@ void UhdmAst::process_module()
add_or_replace_child(current_node, node);
}
});

visit_one_to_many({vpiProcess}, obj_h, [&](AST::AstNode *node) {
// if (node && (node->type == AST::AST_INITIAL)) {
if (get_attribute(node, attr_id::is_type_parameter)) {
// Don't process type parameters.
delete node;
return;
}
if ((node->type == AST::AST_ASSIGN && node->children.size() < 2)) {
delete node;
return;
}
add_or_replace_child(current_node, node);
// } else {
// delete node;
// }
});
}
} else {
// A module instance inside another uhdmTopModules' module.
Expand Down Expand Up @@ -2547,7 +2515,7 @@ void UhdmAst::process_module()
current_node->children.insert(current_node->children.begin(), typeNode);
auto old_top = shared.current_top_node;
shared.current_top_node = module_node;
visit_one_to_many({vpiVariables, vpiNet, vpiArrayNet, vpiInterface, vpiModule, vpiPort, vpiGenScopeArray, vpiContAssign}, obj_h,
visit_one_to_many({vpiVariables, vpiNet, vpiArrayNet, vpiInterface, vpiModule, vpiPort, vpiGenScopeArray, vpiContAssign, vpiTaskFunc}, obj_h,
[&](AST::AstNode *node) {
if (node) {
add_or_replace_child(module_node, node);
Expand All @@ -2562,11 +2530,6 @@ void UhdmAst::process_module()
}
});

visit_one_to_many({vpiTaskFunc}, obj_h, [&](AST::AstNode *node) {
if (node) {
add_or_replace_child(module_node, node);
}
});
make_cell(obj_h, current_node, module_node);
shared.current_top_node = old_top;
set_attribute(module_node, attr_id::is_elaborated_module, AST::AstNode::mkconst_int(1, true));
Expand Down

0 comments on commit dc0697f

Please sign in to comment.