Skip to content

simplify: Skip AST_PRIMITIVE in AST_CELLARRAY #4959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontends/ast/simplify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1758,7 +1758,7 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin
break;
if (type == AST_GENBLOCK)
break;
if (type == AST_CELLARRAY && children[i]->type == AST_CELL)
if (type == AST_CELLARRAY && (children[i]->type == AST_CELL || children[i]->type == AST_PRIMITIVE))
continue;
if (type == AST_BLOCK && !str.empty())
break;
Expand Down Expand Up @@ -2741,6 +2741,7 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin
if (new_cell->type == AST_PRIMITIVE) {
input_error("Cell arrays of primitives are currently not supported.\n");
} else {
this->dumpAst(NULL, " ");
log_assert(new_cell->children.at(0)->type == AST_CELLTYPE);
new_cell->children.at(0)->str = stringf("$array:%d:%d:%s", i, num, new_cell->children.at(0)->str.c_str());
}
Expand Down
9 changes: 9 additions & 0 deletions tests/verilog/bug4785.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
logger -expect error "Cell arrays of primitives are currently not supported" 1
read_verilog <<EOT
module test(in1, in2, out1);
input in1, in2;
output out1;

nand #2 t_nand[0:7](out1, in1, in2);
endmodule
EOT
Loading