aboutsummaryrefslogtreecommitdiffstats
path: root/frontends/ast
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-08-21 12:42:28 +0200
committerClifford Wolf <clifford@clifford.at>2014-08-21 12:42:28 +0200
commit38addd4c67905e3d1514ba839f07d94058e42560 (patch)
tree2c4a13cdfe523a6b460df75fbd0f863d97817087 /frontends/ast
parenta92a68ce521c1e86c0666b9add0c88d59154325e (diff)
downloadyosys-38addd4c67905e3d1514ba839f07d94058e42560.tar.gz
yosys-38addd4c67905e3d1514ba839f07d94058e42560.tar.bz2
yosys-38addd4c67905e3d1514ba839f07d94058e42560.zip
Added support for global tasks and functions
Diffstat (limited to 'frontends/ast')
-rw-r--r--frontends/ast/ast.cc38
1 files changed, 26 insertions, 12 deletions
diff --git a/frontends/ast/ast.cc b/frontends/ast/ast.cc
index 0ea38b506..d59ff1bb6 100644
--- a/frontends/ast/ast.cc
+++ b/frontends/ast/ast.cc
@@ -945,21 +945,35 @@ void AST::process(RTLIL::Design *design, AstNode *ast, bool dump_ast1, bool dump
flag_icells = icells;
flag_autowire = autowire;
+ std::vector<AstNode*> global_decls;
+
log_assert(current_ast->type == AST_DESIGN);
- for (auto it = current_ast->children.begin(); it != current_ast->children.end(); it++) {
- if (flag_icells && (*it)->str.substr(0, 2) == "\\$")
- (*it)->str = (*it)->str.substr(1);
- if (defer)
- (*it)->str = "$abstract" + (*it)->str;
- if (design->has((*it)->str)) {
- if (!ignore_redef)
- log_error("Re-definition of module `%s' at %s:%d!\n",
+ for (auto it = current_ast->children.begin(); it != current_ast->children.end(); it++)
+ {
+ if ((*it)->type == AST_MODULE)
+ {
+ for (auto n : global_decls)
+ (*it)->children.push_back(n->clone());
+
+ if (flag_icells && (*it)->str.substr(0, 2) == "\\$")
+ (*it)->str = (*it)->str.substr(1);
+
+ if (defer)
+ (*it)->str = "$abstract" + (*it)->str;
+
+ if (design->has((*it)->str)) {
+ if (!ignore_redef)
+ log_error("Re-definition of module `%s' at %s:%d!\n",
+ (*it)->str.c_str(), (*it)->filename.c_str(), (*it)->linenum);
+ log("Ignoring re-definition of module `%s' at %s:%d!\n",
(*it)->str.c_str(), (*it)->filename.c_str(), (*it)->linenum);
- log("Ignoring re-definition of module `%s' at %s:%d!\n",
- (*it)->str.c_str(), (*it)->filename.c_str(), (*it)->linenum);
- continue;
+ continue;
+ }
+
+ design->add(process_module(*it, defer));
}
- design->add(process_module(*it, defer));
+ else
+ global_decls.push_back(*it);
}
}