mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-07 01:54:10 +00:00
Add "noblackbox" attribute
Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
parent
fb7f02be55
commit
5b7fea5245
|
@ -310,7 +310,12 @@ Verilog Attributes and non-standard features
|
||||||
that have the same ports as the real thing but do not contain information
|
that have the same ports as the real thing but do not contain information
|
||||||
on the internal configuration. This modules are only used by the synthesis
|
on the internal configuration. This modules are only used by the synthesis
|
||||||
passes to identify input and output ports of cells. The Verilog backend
|
passes to identify input and output ports of cells. The Verilog backend
|
||||||
also does not output blackbox modules on default.
|
also does not output blackbox modules on default. ``read_verilog``, unless
|
||||||
|
called with ``-noblackbox`` will automatically set the blackbox attribute
|
||||||
|
on any empty module it reads.
|
||||||
|
|
||||||
|
- The ``noblackbox`` attribute set on an empty module prevents ``read_verilog``
|
||||||
|
from automatically setting the blackbox attribute on the module.
|
||||||
|
|
||||||
- The ``whitebox`` attribute on modules triggers the same behavior as
|
- The ``whitebox`` attribute on modules triggers the same behavior as
|
||||||
``blackbox``, but is for whitebox modules, i.e. library modules that
|
``blackbox``, but is for whitebox modules, i.e. library modules that
|
||||||
|
|
|
@ -942,6 +942,20 @@ static AstModule* process_module(AstNode *ast, bool defer, AstNode *original_ast
|
||||||
|
|
||||||
if (!defer)
|
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)) { }
|
while (ast->simplify(!flag_noopt, false, false, 0, -1, false, false)) { }
|
||||||
|
|
||||||
if (flag_dump_ast2) {
|
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")) {
|
if (!blackbox_module && ast->attributes.count("\\blackbox")) {
|
||||||
AstNode *n = ast->attributes.at("\\blackbox");
|
AstNode *n = ast->attributes.at("\\blackbox");
|
||||||
if (n->type != AST_CONSTANT)
|
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();
|
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")) {
|
if (blackbox_module && ast->attributes.count("\\whitebox")) {
|
||||||
AstNode *n = ast->attributes.at("\\whitebox");
|
AstNode *n = ast->attributes.at("\\whitebox");
|
||||||
if (n->type != AST_CONSTANT)
|
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();
|
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 (blackbox_module)
|
||||||
{
|
{
|
||||||
if (ast->attributes.count("\\whitebox")) {
|
if (ast->attributes.count("\\whitebox")) {
|
||||||
|
|
Loading…
Reference in a new issue