aboutsummaryrefslogtreecommitdiffstats
path: root/frontends/ast/simplify.cc
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2020-04-16 13:48:20 +0100
committerGitHub <noreply@github.com>2020-04-16 13:48:20 +0100
commit2b57c06360fd453840aa1e3b76a410ad300ae197 (patch)
tree3f6432e5c18281c405d3ead0b12d0ff054634389 /frontends/ast/simplify.cc
parent2f8541a92eb6a733c90170709c4c597452036ab6 (diff)
parent4d025058208f3b3096192b09371c9320610a44b8 (diff)
downloadyosys-2b57c06360fd453840aa1e3b76a410ad300ae197.tar.gz
yosys-2b57c06360fd453840aa1e3b76a410ad300ae197.tar.bz2
yosys-2b57c06360fd453840aa1e3b76a410ad300ae197.zip
Merge pull request #1943 from YosysHQ/dave/fix-1919
ast: Fix handling of identifiers in the global scope
Diffstat (limited to 'frontends/ast/simplify.cc')
-rw-r--r--frontends/ast/simplify.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc
index cb89f58ba..372dcf95c 100644
--- a/frontends/ast/simplify.cc
+++ b/frontends/ast/simplify.cc
@@ -1169,7 +1169,8 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
// annotate identifiers using scope resolution and create auto-wires as needed
if (type == AST_IDENTIFIER) {
if (current_scope.count(str) == 0) {
- for (auto node : current_ast_mod->children) {
+ AstNode *current_scope_ast = (current_ast_mod == nullptr) ? current_ast : current_ast_mod;
+ for (auto node : current_scope_ast->children) {
//log("looking at mod scope child %s\n", type2str(node->type).c_str());
switch (node->type) {
case AST_PARAMETER:
@@ -1203,7 +1204,9 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
}
}
if (current_scope.count(str) == 0) {
- if (flag_autowire || str == "\\$global_clock") {
+ if (current_ast_mod == nullptr) {
+ log_file_error(filename, location.first_line, "Identifier `%s' is implicitly declared outside of a module.\n", str.c_str());
+ } else if (flag_autowire || str == "\\$global_clock") {
AstNode *auto_wire = new AstNode(AST_AUTOWIRE);
auto_wire->str = str;
current_ast_mod->children.push_back(auto_wire);