aboutsummaryrefslogtreecommitdiffstats
path: root/frontends/ast
diff options
context:
space:
mode:
authorJeff Wang <jjj11x@gmail.com>2020-04-07 00:37:44 -0400
committerJeff Wang <jeffrey.wang@ll.mit.edu>2020-04-07 00:38:15 -0400
commit249876b61405a83ed19a9cc20fcffbf9313f2619 (patch)
tree58327f14d6d09c271218a08837533cbb10c54991 /frontends/ast
parentebf23cd62e7617ef2510a5bdc7e66ac5f82b7991 (diff)
downloadyosys-249876b61405a83ed19a9cc20fcffbf9313f2619.tar.gz
yosys-249876b61405a83ed19a9cc20fcffbf9313f2619.tar.bz2
yosys-249876b61405a83ed19a9cc20fcffbf9313f2619.zip
support using previously declared types/localparams/params in package
(parameters in systemverilog packages can't actually be overridden, so allowing parameters in addition to localparams doesn't actually add any new functionality, but it's useful to be able to use the parameter keyword also)
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 b87af0f8c..bdb48e82f 100644
--- a/frontends/ast/simplify.cc
+++ b/frontends/ast/simplify.cc
@@ -441,6 +441,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;