Fix public function arguments that are arrayed (#3316).

This commit is contained in:
Wilson Snyder 2022-03-05 16:19:53 -05:00
parent 321880f5a6
commit c3dd6f5344
3 changed files with 33 additions and 17 deletions

View File

@ -19,6 +19,7 @@ Verilator 4.219 devel
* Add trace dumpvars() call for selective runtime tracing (#3322). [Shunyao CAD]
* Fix skipping public enum values with four-state values (#3303).
* Fix $readmem file not found to be warning not error (#3310). [Alexander Grobman]
* Fix public function arguments that are arrayed (#3316). [pawel256]
* Fix compile error with --trace-fst --sc (#3332). [leavinel]
* Fix crash in recursive module inlining (#3324). [Larry Doolittle]

View File

@ -454,25 +454,33 @@ string AstVar::cPubArgType(bool named, bool forReturn) const {
if (forReturn) named = false;
string arg;
if (isWide() && isReadOnly()) arg += "const ";
if (widthMin() == 1) {
arg += "bool";
} else if (widthMin() <= VL_IDATASIZE) {
arg += "uint32_t";
} else if (widthMin() <= VL_QUADSIZE) {
arg += "vluint64_t";
} else {
arg += "uint32_t"; // []'s added later
}
if (isWide()) {
if (forReturn) {
v3warn(E_UNSUPPORTED, "Unsupported: Public functions with >64 bit outputs; "
"make an output of a public task instead");
const bool isRef = !forReturn && (isWritable() || direction().isRefOrConstRef());
if (VN_IS(dtypeSkipRefp(), BasicDType) && !dtypeSkipRefp()->isDouble()
&& !dtypeSkipRefp()->isString()) {
// Backward compatible type declaration
if (widthMin() == 1) {
arg += "bool";
} else if (widthMin() <= VL_IDATASIZE) {
arg += "uint32_t";
} else if (widthMin() <= VL_QUADSIZE) {
arg += "vluint64_t";
} else {
arg += "uint32_t"; // []'s added later
}
if (isWide()) {
if (forReturn) {
v3warn(E_UNSUPPORTED, "Unsupported: Public functions with >64 bit outputs; "
"make an output of a public task instead");
}
arg += " (& " + name();
arg += ")[" + cvtToStr(widthWords()) + "]";
} else {
if (isRef) arg += "&";
if (named) arg += " " + name();
}
arg += " (& " + name();
arg += ")[" + cvtToStr(widthWords()) + "]";
} else {
if (!forReturn && (isWritable() || direction().isRefOrConstRef())) arg += "&";
if (named) arg += " " + name();
// Newer internal-compatible types
arg += dtypep()->cType((named ? name() : string{}), true, isRef);
}
return arg;
}

View File

@ -32,6 +32,13 @@ module t (clk);
$write("Hello in publicTop\n");
endtask
task test_task(input [19:0] in [2], output [19:0] out [2]);
// Issue 3316
// verilator public
out[0] = in[1];
out[1] = in[0];
endtask
endmodule
module tpub (