Skip to content
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

Fix #3258 of internal error with inout port #3268

Merged
merged 3 commits into from Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -36,6 +36,7 @@ Verilator 4.217 devel
* Fix $random not updating seed (#3238). [Julie Schwartz]
* Fix spurious UNUSED by ignoring inout pin connections (#3242). [Julie Schwartz]
* Fix splitting of _eval and other top level functions. [Geza Lore, Shunyao CAD]
* Fix internal error by inout port (#3258). [Yutetsu TAKATSUKASA]


Verilator 4.216 2021-12-05
Expand Down
9 changes: 6 additions & 3 deletions src/V3Tristate.cpp
Expand Up @@ -546,8 +546,7 @@ class TristateVisitor final : public TristateBaseVisitor {
UINFO(9, " TRISTATE propagates up with " << lhsp << endl);
// Create an output enable port (__en)
// May already be created if have foo === 1'bz somewhere
envarp = getCreateEnVarp(invarp);
envarp->varType2Out();
envarp = getCreateEnVarp(invarp); // direction will be sen in visit(AstPin*)
//
outvarp->user1p(envarp);
outvarp->user3p(invarp->user3p()); // AstPull* propagation
Expand Down Expand Up @@ -1162,7 +1161,11 @@ class TristateVisitor final : public TristateBaseVisitor {
AstVar* const enVarp = new AstVar(nodep->fileline(), VVarType::MODULETEMP,
nodep->name() + "__en" + cvtToStr(m_unique++),
VFlagBitPacked(), enModVarp->width());
enModVarp->direction(VDirection::INPUT);
if (inDeclProcessing) { // __en(from-resolver-const) or __en(from-resolver-wire)
enModVarp->varType2In();
} else {
enModVarp->varType2Out();
}
UINFO(9, " newenv " << enVarp << endl);
AstPin* const enpinp
= new AstPin(nodep->fileline(), nodep->pinNum(),
Expand Down
9 changes: 8 additions & 1 deletion test_regress/t/t_tri_inout.v
Expand Up @@ -11,7 +11,7 @@ module top (input A, input B, input SEL, output Y1, output Y2, output Z);
endmodule

module pass (input A, input OE, inout Z, output Y);
io io(.A(A), .OE(OE), .Z(Z), .Y(Y));
io_noinline io(.A(A), .OE(OE), .Z(Z), .Y(Y));
assign Z = 1'bz;
endmodule

Expand All @@ -20,3 +20,10 @@ module io (input A, input OE, inout Z, output Y);
assign Y = Z;
assign Z = 1'bz;
endmodule

module io_noinline (input A, input OE, inout Z, output Y);
/*verilator no_inline_module*/
assign Z = (OE) ? A : 1'bz;
assign Y = Z;
assign Z = 1'bz;
endmodule