Internals: Remove unneeded return, cleanup param test. No functional change

This commit is contained in:
Wilson Snyder 2025-08-30 07:42:41 -04:00
parent fbfd1f12dd
commit 712ff95a48
6 changed files with 111 additions and 109 deletions

View File

@ -4047,8 +4047,7 @@ void V3Const::constifyParamsNoWarnEdit(AstNode* nodep) {
//! generated. Since such occurrences, must be constant, in order to be //! generated. Since such occurrences, must be constant, in order to be
//! something a generate block can depend on, we can wait until later to do the //! something a generate block can depend on, we can wait until later to do the
//! width check. //! width check.
//! @return Pointer to the edited node. void V3Const::constifyGenerateParamsEdit(AstNode* nodep) {
AstNode* V3Const::constifyGenerateParamsEdit(AstNode* nodep) {
// UINFOTREE(1, nodep, "", "forceConPRE:"); // UINFOTREE(1, nodep, "", "forceConPRE:");
// Resize even if the node already has a width, because buried in the tree // Resize even if the node already has a width, because buried in the tree
// we may have a node we just created with signing, etc, that isn't sized // we may have a node we just created with signing, etc, that isn't sized
@ -4064,11 +4063,10 @@ AstNode* V3Const::constifyGenerateParamsEdit(AstNode* nodep) {
// init value because we need widthing above to handle the var's type. // init value because we need widthing above to handle the var's type.
if (varp->valuep()) visitor.mainAcceptEdit(varp->valuep()); if (varp->valuep()) visitor.mainAcceptEdit(varp->valuep());
} else { } else {
nodep = visitor.mainAcceptEdit(nodep); VL_DO_DANGLING(visitor.mainAcceptEdit(nodep), nodep);
} }
// Because we do edits, nodep links may get trashed and core dump this. // Because we do edits, nodep links may get trashed and core dump this.
// UINFOTREE(1, nodep, "", "forceConDONE"); // UINFOTREE(1, nodep, "", "forceConDONE");
return nodep;
} }
void V3Const::constifyAllLint(AstNetlist* nodep) { void V3Const::constifyAllLint(AstNetlist* nodep) {

View File

@ -28,7 +28,7 @@ class V3Const final {
public: public:
static void constifyParamsEdit(AstNode* nodep) VL_MT_DISABLED; static void constifyParamsEdit(AstNode* nodep) VL_MT_DISABLED;
static void constifyParamsNoWarnEdit(AstNode* nodep) VL_MT_DISABLED; static void constifyParamsNoWarnEdit(AstNode* nodep) VL_MT_DISABLED;
static AstNode* constifyGenerateParamsEdit(AstNode* nodep) VL_MT_DISABLED; static void constifyGenerateParamsEdit(AstNode* nodep) VL_MT_DISABLED;
// Only do constant pushing, without removing dead logic // Only do constant pushing, without removing dead logic
static void constifyAllLive(AstNetlist* nodep) VL_MT_DISABLED; static void constifyAllLive(AstNetlist* nodep) VL_MT_DISABLED;
// Everything that's possible // Everything that's possible

View File

@ -4,7 +4,7 @@
// any use, without warranty, 2021 by Michael Lefebvre. // any use, without warranty, 2021 by Michael Lefebvre.
// SPDX-License-Identifier: CC0-1.0 // SPDX-License-Identifier: CC0-1.0
module t(/*AUTOARG*/); module t;
localparam int unsigned A3[2:0] = '{4, 5, 6}; localparam int unsigned A3[2:0] = '{4, 5, 6};

View File

@ -14,9 +14,9 @@ package config_pkg;
int USE_QUAD0; int USE_QUAD0;
int USE_QUAD1; int USE_QUAD1;
int USE_QUAD2; int USE_QUAD2;
} config_struct; } config_struct_t;
endpackage : config_pkg endpackage
module t; module t;
import config_pkg::*; import config_pkg::*;
@ -28,11 +28,11 @@ module t;
USE_QUAD1: 5, USE_QUAD1: 5,
USE_QUAD2: 6 USE_QUAD2: 6
})) a_submodule_I (); })) a_submodule_I ();
endmodule : t endmodule
module struct_submodule module struct_submodule
import config_pkg::*; import config_pkg::*;
#(parameter config_struct MY_CONFIG = '0); #(parameter config_struct_t MY_CONFIG = '0);
initial begin initial begin
`checkd(MY_CONFIG.UPPER0, 10); `checkd(MY_CONFIG.UPPER0, 10);
@ -43,4 +43,4 @@ module struct_submodule
$write("*-* All Finished *-*\n"); $write("*-* All Finished *-*\n");
$finish; $finish;
end end
endmodule : struct_submodule endmodule

View File

@ -4,8 +4,10 @@
// without warranty, 2017 by Matt Myers. // without warranty, 2017 by Matt Myers.
// SPDX-License-Identifier: CC0-1.0 // SPDX-License-Identifier: CC0-1.0
// verilog_format: off
`define stop $stop `define stop $stop
`define checkd(gotv, expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0); `define checkd(gotv, expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0);
// verilog_format: on
package config_pkg; package config_pkg;
typedef struct packed { typedef struct packed {
@ -16,10 +18,10 @@ package config_pkg;
int USE_QUAD2; int USE_QUAD2;
} mac; } mac;
int UPPER2; int UPPER2;
} config_struct; } config_struct_t;
function automatic config_struct static_config(int selector); function automatic config_struct_t static_config(int selector);
config_struct return_config; config_struct_t return_config;
return_config = '0; return_config = '0;
return_config.UPPER0 = 10; return_config.UPPER0 = 10;
return_config.UPPER2 = 20; return_config.UPPER2 = 20;
@ -30,19 +32,21 @@ package config_pkg;
endcase endcase
return return_config; return return_config;
endfunction endfunction
endpackage : config_pkg endpackage
module t; module t;
import config_pkg::*; import config_pkg::*;
localparam config_struct MY_CONFIG = static_config(1); localparam config_struct_t MY_CONFIG = static_config(1);
struct_submodule #(.MY_CONFIG(MY_CONFIG)) a_submodule_I (); struct_submodule #(.MY_CONFIG(MY_CONFIG)) a_submodule_I ();
endmodule : t endmodule
module struct_submodule module struct_submodule
import config_pkg::*; import config_pkg::*;
#(parameter config_struct MY_CONFIG = '0); #(
parameter config_struct_t MY_CONFIG = '0
);
initial begin initial begin
`checkd(MY_CONFIG.UPPER0, 10); `checkd(MY_CONFIG.UPPER0, 10);
@ -53,4 +57,4 @@ module struct_submodule
$write("*-* All Finished *-*\n"); $write("*-* All Finished *-*\n");
$finish; $finish;
end end
endmodule : struct_submodule endmodule

View File

@ -13,13 +13,13 @@ package config_pkg;
logic [N-1:0][31:0] hi; logic [N-1:0][31:0] hi;
logic [100-1:0][31:0] x; logic [100-1:0][31:0] x;
int unsigned n; int unsigned n;
} config_struct; } config_struct_t;
function automatic logic subcheck(logic [31:0] lo, logic [31:0] hi, logic [31:0] val); function automatic logic subcheck(logic [31:0] lo, logic [31:0] hi, logic [31:0] val);
return lo <= val && val < hi; return lo <= val && val < hi;
endfunction endfunction
function automatic logic check(config_struct cfg, logic[31:0] val); function automatic logic check(config_struct_t cfg, logic [31:0] val);
logic [N-1:0] good = '0; logic [N-1:0] good = '0;
logic [N-1:0] bad = '0; logic [N-1:0] bad = '0;
for (int i = 0; i < cfg.n; i++) begin for (int i = 0; i < cfg.n; i++) begin
@ -41,7 +41,7 @@ module t(/*AUTOARG*/
input clk; input clk;
import config_pkg::*; import config_pkg::*;
parameter config_struct MY_CONFIG = '{ parameter config_struct_t MY_CONFIG = '{
lo: {((N - 3) * 32)'('0), 32'h00, 32'h10, 32'h20}, lo: {((N - 3) * 32)'('0), 32'h00, 32'h10, 32'h20},
hi: {((N - 3) * 32)'('0), 32'h10, 32'h20, 32'h30}, hi: {((N - 3) * 32)'('0), 32'h10, 32'h20, 32'h30},
x : 3200'h0deadbeef, x : 3200'h0deadbeef,
@ -49,12 +49,12 @@ module t(/*AUTOARG*/
}; };
struct_submodule #(.MY_CONFIG(MY_CONFIG)) a_submodule_I (.clk); struct_submodule #(.MY_CONFIG(MY_CONFIG)) a_submodule_I (.clk);
endmodule : t endmodule
module struct_submodule module struct_submodule
import config_pkg::*; import config_pkg::*;
#( #(
parameter config_struct MY_CONFIG = '0 parameter config_struct_t MY_CONFIG = '0
) ( ) (
input clk input clk
); );
@ -78,4 +78,4 @@ module struct_submodule
end end
end end
endmodule : struct_submodule endmodule