aboutsummaryrefslogtreecommitdiffstats
path: root/frontends/ast
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2019-04-21 11:40:09 +0200
committerClifford Wolf <clifford@clifford.at>2019-04-21 11:40:09 +0200
commit5b7fea5245671882dabe2ec319353fa4f2fb8f91 (patch)
tree27dd90e47a235b8e6f54d1b0e536899bb5dab37d /frontends/ast
parentfb7f02be5561ccfd5bee5f3235fbbae5ef618f36 (diff)
downloadyosys-5b7fea5245671882dabe2ec319353fa4f2fb8f91.tar.gz
yosys-5b7fea5245671882dabe2ec319353fa4f2fb8f91.tar.bz2
yosys-5b7fea5245671882dabe2ec319353fa4f2fb8f91.zip
Add "noblackbox" attribute
Signed-off-by: Clifford Wolf <clifford@clifford.at>
Diffstat (limited to 'frontends/ast')
-rw-r--r--frontends/ast/ast.cc44
1 files changed, 27 insertions, 17 deletions
diff --git a/frontends/ast/ast.cc b/frontends/ast/ast.cc
index e4f18a2ac..9f88b08c1 100644
--- a/frontends/ast/ast.cc
+++ b/frontends/ast/ast.cc
@@ -942,6 +942,20 @@ static AstModule* process_module(AstNode *ast, bool defer, AstNode *original_ast
if (!defer)
{
+ bool blackbox_module = flag_lib;
+
+ if (!blackbox_module && !flag_noblackbox) {
+ blackbox_module = true;
+ for (auto child : ast->children) {
+ if (child->type == AST_WIRE && (child->is_input || child->is_output))
+ continue;
+ if (child->type == AST_PARAMETER || child->type == AST_LOCALPARAM)
+ continue;
+ blackbox_module = false;
+ break;
+ }
+ }
+
while (ast->simplify(!flag_noopt, false, false, 0, -1, false, false)) { }
if (flag_dump_ast2) {
@@ -976,35 +990,31 @@ static AstModule* process_module(AstNode *ast, bool defer, AstNode *original_ast
}
}
- bool blackbox_module = flag_lib;
-
if (!blackbox_module && ast->attributes.count("\\blackbox")) {
AstNode *n = ast->attributes.at("\\blackbox");
if (n->type != AST_CONSTANT)
- log_file_error(ast->filename, ast->linenum, "Blackbox attribute with non-constant value!\n");
+ log_file_error(ast->filename, ast->linenum, "Got blackbox attribute with non-constant value!\n");
blackbox_module = n->asBool();
}
- if (!blackbox_module && !flag_noblackbox)
- {
- for (auto child : ast->children) {
- if (child->type == AST_WIRE && (child->is_input || child->is_output))
- continue;
- if (child->type == AST_PARAMETER || child->type == AST_LOCALPARAM)
- continue;
- goto noblackbox;
- }
- blackbox_module = 1;
- }
-
- noblackbox:
if (blackbox_module && ast->attributes.count("\\whitebox")) {
AstNode *n = ast->attributes.at("\\whitebox");
if (n->type != AST_CONSTANT)
- log_file_error(ast->filename, ast->linenum, "Whitebox attribute with non-constant value!\n");
+ log_file_error(ast->filename, ast->linenum, "Got whitebox attribute with non-constant value!\n");
blackbox_module = !n->asBool();
}
+ if (ast->attributes.count("\\noblackbox")) {
+ if (blackbox_module) {
+ AstNode *n = ast->attributes.at("\\noblackbox");
+ if (n->type != AST_CONSTANT)
+ log_file_error(ast->filename, ast->linenum, "Got noblackbox attribute with non-constant value!\n");
+ blackbox_module = !n->asBool();
+ }
+ delete ast->attributes.at("\\noblackbox");
+ ast->attributes.erase("\\noblackbox");
+ }
+
if (blackbox_module)
{
if (ast->attributes.count("\\whitebox")) {