From 2d497e249092727ceb28e5c525ad4e0e9efec91c Mon Sep 17 00:00:00 2001 From: mszelwiga Date: Fri, 22 Nov 2024 11:47:51 +0100 Subject: [PATCH] Fix setting up scope for parameter simplification --- src/frontends/systemverilog/uhdm_ast.cc | 13 +++++++++++++ .../opentitan_parsing_test/ot_cores_passlist.txt | 1 + 2 files changed, 14 insertions(+) diff --git a/src/frontends/systemverilog/uhdm_ast.cc b/src/frontends/systemverilog/uhdm_ast.cc index 667b93d49..762c5b757 100644 --- a/src/frontends/systemverilog/uhdm_ast.cc +++ b/src/frontends/systemverilog/uhdm_ast.cc @@ -2379,6 +2379,19 @@ void UhdmAst::simplify_parameter(AST::AstNode *parameter, const std::vector<::Yo } }); } + auto ancestor_node = this; + while (ancestor_node) { + if (ancestor_node->current_node) { + visitEachDescendant(ancestor_node->current_node, [&](AST::AstNode *current_scope_node) { + if (current_scope_node->type == AST::AST_TYPEDEF || current_scope_node->type == AST::AST_PARAMETER || + current_scope_node->type == AST::AST_LOCALPARAM || current_scope_node->type == AST::AST_FUNCTION) { + AST_INTERNAL::current_scope[current_scope_node->str] = current_scope_node; + } + }); + } + ancestor_node = ancestor_node->parent; + } + // first apply custom simplification step if needed simplify_sv(parameter, nullptr); // workaround for yosys sometimes not simplifying parameters children diff --git a/tests/opentitan/opentitan_parsing_test/ot_cores_passlist.txt b/tests/opentitan/opentitan_parsing_test/ot_cores_passlist.txt index f91516f45..0b715e12b 100644 --- a/tests/opentitan/opentitan_parsing_test/ot_cores_passlist.txt +++ b/tests/opentitan/opentitan_parsing_test/ot_cores_passlist.txt @@ -46,6 +46,7 @@ lowrisc:ip:rom_ctrl:0.1 lowrisc:ip:rom_ctrl_pkg:0.1 lowrisc:ip:rstmgr_cnsty_chk:0 lowrisc:ip:rstmgr_reg:0.1 +lowrisc:ip:rv_core_ibex:0.1 lowrisc:ip:rv_core_ibex_pkg:0.1 lowrisc:ip:rv_dm:0.1 lowrisc:ip:rv_plic_component:0.1