aboutsummaryrefslogtreecommitdiffstats
path: root/frontends/ast
diff options
context:
space:
mode:
authorwhitequark <whitequark@whitequark.org>2020-04-14 12:40:00 +0000
committerGitHub <noreply@github.com>2020-04-14 12:40:00 +0000
commitf41c7ccfff4bf104c646ca4b85e079a0f91c9151 (patch)
treeeb15a12b1d4cbb0656740f86f7da824777ed0678 /frontends/ast
parent0e1beb6f308da18b952e562b85504258d20ffcc7 (diff)
parent249876b61405a83ed19a9cc20fcffbf9313f2619 (diff)
downloadyosys-f41c7ccfff4bf104c646ca4b85e079a0f91c9151.tar.gz
yosys-f41c7ccfff4bf104c646ca4b85e079a0f91c9151.tar.bz2
yosys-f41c7ccfff4bf104c646ca4b85e079a0f91c9151.zip
Merge pull request #1879 from jjj11x/jjj11x/package_decl
support using previously declared types/localparams/parameters in package
Diffstat (limited to 'frontends/ast')
-rw-r--r--frontends/ast/simplify.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc
index 3fde26fab..ced5e5cf9 100644
--- a/frontends/ast/simplify.cc
+++ b/frontends/ast/simplify.cc
@@ -442,6 +442,29 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
}
}
+ // create name resolution entries for all objects with names
+ if (type == AST_PACKAGE) {
+ //add names to package scope
+ for (size_t i = 0; i < children.size(); i++) {
+ AstNode *node = children[i];
+ // these nodes appear at the top level in a package and can define names
+ if (node->type == AST_PARAMETER || node->type == AST_LOCALPARAM || node->type == AST_TYPEDEF) {
+ current_scope[node->str] = node;
+ }
+ if (node->type == AST_ENUM) {
+ current_scope[node->str] = node;
+ for (auto enode : node->children) {
+ log_assert(enode->type==AST_ENUM_ITEM);
+ if (current_scope.count(enode->str) == 0)
+ current_scope[enode->str] = enode;
+ else
+ log_file_error(filename, location.first_line, "enum item %s already exists in package\n", enode->str.c_str());
+ }
+ }
+ }
+ }
+
+
auto backup_current_block = current_block;
auto backup_current_block_child = current_block_child;
auto backup_current_top_block = current_top_block;