Internals: Remove unneeded return, cleanup param test. No functional change
This commit is contained in:
parent
fbfd1f12dd
commit
712ff95a48
|
|
@ -4047,8 +4047,7 @@ void V3Const::constifyParamsNoWarnEdit(AstNode* nodep) {
|
|||
//! 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
|
||||
//! width check.
|
||||
//! @return Pointer to the edited node.
|
||||
AstNode* V3Const::constifyGenerateParamsEdit(AstNode* nodep) {
|
||||
void V3Const::constifyGenerateParamsEdit(AstNode* nodep) {
|
||||
// UINFOTREE(1, nodep, "", "forceConPRE:");
|
||||
// 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
|
||||
|
|
@ -4064,11 +4063,10 @@ AstNode* V3Const::constifyGenerateParamsEdit(AstNode* nodep) {
|
|||
// init value because we need widthing above to handle the var's type.
|
||||
if (varp->valuep()) visitor.mainAcceptEdit(varp->valuep());
|
||||
} 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.
|
||||
// UINFOTREE(1, nodep, "", "forceConDONE");
|
||||
return nodep;
|
||||
}
|
||||
|
||||
void V3Const::constifyAllLint(AstNetlist* nodep) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class V3Const final {
|
|||
public:
|
||||
static void constifyParamsEdit(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
|
||||
static void constifyAllLive(AstNetlist* nodep) VL_MT_DISABLED;
|
||||
// Everything that's possible
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@
|
|||
// any use, without warranty, 2021 by Michael Lefebvre.
|
||||
// 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};
|
||||
|
||||
// slicesel out of range should fail
|
||||
localparam int unsigned B32_T [1:0] = A3[3:1];
|
||||
// slicesel out of range should fail
|
||||
localparam int unsigned B32_T[1:0] = A3[3:1];
|
||||
|
||||
endmodule
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ package config_pkg;
|
|||
int USE_QUAD0;
|
||||
int USE_QUAD1;
|
||||
int USE_QUAD2;
|
||||
} config_struct;
|
||||
} config_struct_t;
|
||||
|
||||
endpackage : config_pkg
|
||||
endpackage
|
||||
|
||||
module t;
|
||||
import config_pkg::*;
|
||||
|
|
@ -28,11 +28,11 @@ module t;
|
|||
USE_QUAD1: 5,
|
||||
USE_QUAD2: 6
|
||||
})) a_submodule_I ();
|
||||
endmodule : t
|
||||
endmodule
|
||||
|
||||
module struct_submodule
|
||||
import config_pkg::*;
|
||||
#(parameter config_struct MY_CONFIG = '0);
|
||||
#(parameter config_struct_t MY_CONFIG = '0);
|
||||
|
||||
initial begin
|
||||
`checkd(MY_CONFIG.UPPER0, 10);
|
||||
|
|
@ -43,4 +43,4 @@ module struct_submodule
|
|||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
endmodule : struct_submodule
|
||||
endmodule
|
||||
|
|
|
|||
|
|
@ -4,53 +4,57 @@
|
|||
// without warranty, 2017 by Matt Myers.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
// verilog_format: off
|
||||
`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;
|
||||
typedef struct packed {
|
||||
int UPPER0;
|
||||
struct packed {
|
||||
int USE_QUAD0;
|
||||
int USE_QUAD1;
|
||||
int USE_QUAD2;
|
||||
} mac;
|
||||
int UPPER2;
|
||||
} config_struct;
|
||||
typedef struct packed {
|
||||
int UPPER0;
|
||||
struct packed {
|
||||
int USE_QUAD0;
|
||||
int USE_QUAD1;
|
||||
int USE_QUAD2;
|
||||
} mac;
|
||||
int UPPER2;
|
||||
} config_struct_t;
|
||||
|
||||
function automatic config_struct static_config(int selector);
|
||||
config_struct return_config;
|
||||
return_config = '0;
|
||||
return_config.UPPER0 = 10;
|
||||
return_config.UPPER2 = 20;
|
||||
return_config.mac.USE_QUAD0 = 4;
|
||||
return_config.mac.USE_QUAD2 = 6;
|
||||
case (selector)
|
||||
1: return_config.mac.USE_QUAD1 = 5;
|
||||
endcase
|
||||
return return_config;
|
||||
endfunction
|
||||
endpackage : config_pkg
|
||||
function automatic config_struct_t static_config(int selector);
|
||||
config_struct_t return_config;
|
||||
return_config = '0;
|
||||
return_config.UPPER0 = 10;
|
||||
return_config.UPPER2 = 20;
|
||||
return_config.mac.USE_QUAD0 = 4;
|
||||
return_config.mac.USE_QUAD2 = 6;
|
||||
case (selector)
|
||||
1: return_config.mac.USE_QUAD1 = 5;
|
||||
endcase
|
||||
return return_config;
|
||||
endfunction
|
||||
endpackage
|
||||
|
||||
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 ();
|
||||
endmodule : t
|
||||
struct_submodule #(.MY_CONFIG(MY_CONFIG)) a_submodule_I ();
|
||||
endmodule
|
||||
|
||||
module struct_submodule
|
||||
import config_pkg::*;
|
||||
#(parameter config_struct MY_CONFIG = '0);
|
||||
#(
|
||||
parameter config_struct_t MY_CONFIG = '0
|
||||
);
|
||||
|
||||
initial begin
|
||||
`checkd(MY_CONFIG.UPPER0, 10);
|
||||
`checkd(MY_CONFIG.mac.USE_QUAD0, 4);
|
||||
`checkd(MY_CONFIG.mac.USE_QUAD1, 5);
|
||||
`checkd(MY_CONFIG.mac.USE_QUAD2, 6);
|
||||
`checkd(MY_CONFIG.UPPER2, 20);
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
endmodule : struct_submodule
|
||||
initial begin
|
||||
`checkd(MY_CONFIG.UPPER0, 10);
|
||||
`checkd(MY_CONFIG.mac.USE_QUAD0, 4);
|
||||
`checkd(MY_CONFIG.mac.USE_QUAD1, 5);
|
||||
`checkd(MY_CONFIG.mac.USE_QUAD2, 6);
|
||||
`checkd(MY_CONFIG.UPPER2, 20);
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
endmodule
|
||||
|
|
|
|||
|
|
@ -6,76 +6,76 @@
|
|||
|
||||
package config_pkg;
|
||||
|
||||
localparam int unsigned N = 10;
|
||||
localparam int unsigned N = 10;
|
||||
|
||||
typedef struct packed {
|
||||
logic [N-1:0][31:0] lo;
|
||||
logic [N-1:0][31:0] hi;
|
||||
logic [100-1:0][31:0] x;
|
||||
int unsigned n;
|
||||
} config_struct;
|
||||
typedef struct packed {
|
||||
logic [N-1:0][31:0] lo;
|
||||
logic [N-1:0][31:0] hi;
|
||||
logic [100-1:0][31:0] x;
|
||||
int unsigned n;
|
||||
} config_struct_t;
|
||||
|
||||
function automatic logic subcheck(logic[31:0] lo, logic[31:0] hi, logic[31:0] val);
|
||||
return lo <= val && val < hi;
|
||||
endfunction
|
||||
function automatic logic subcheck(logic [31:0] lo, logic [31:0] hi, logic [31:0] val);
|
||||
return lo <= val && val < hi;
|
||||
endfunction
|
||||
|
||||
function automatic logic check(config_struct cfg, logic[31:0] val);
|
||||
logic[N-1:0] good = '0;
|
||||
logic[N-1:0] bad = '0;
|
||||
for (int i = 0; i < cfg.n; i++) begin
|
||||
good[i] = subcheck(cfg.lo[i], cfg.hi[i], val);
|
||||
end
|
||||
for (int i = cfg.n; i < N; i++) begin
|
||||
bad[i] = !(cfg.lo[i] == '0 && cfg.hi[i] == '0);
|
||||
end
|
||||
return good != '0 && bad == '0;
|
||||
endfunction
|
||||
function automatic logic check(config_struct_t cfg, logic [31:0] val);
|
||||
logic [N-1:0] good = '0;
|
||||
logic [N-1:0] bad = '0;
|
||||
for (int i = 0; i < cfg.n; i++) begin
|
||||
good[i] = subcheck(cfg.lo[i], cfg.hi[i], val);
|
||||
end
|
||||
for (int i = cfg.n; i < N; i++) begin
|
||||
bad[i] = !(cfg.lo[i] == '0 && cfg.hi[i] == '0);
|
||||
end
|
||||
return good != '0 && bad == '0;
|
||||
endfunction
|
||||
|
||||
endpackage : config_pkg
|
||||
|
||||
module t(/*AUTOARG*/
|
||||
// Inputs
|
||||
clk
|
||||
);
|
||||
module t ( /*AUTOARG*/
|
||||
// Inputs
|
||||
clk
|
||||
);
|
||||
|
||||
input clk;
|
||||
import config_pkg::*;
|
||||
input clk;
|
||||
import config_pkg::*;
|
||||
|
||||
parameter config_struct MY_CONFIG = '{
|
||||
lo: {((N-3)*32)'('0), 32'h00, 32'h10, 32'h20},
|
||||
hi: {((N-3)*32)'('0), 32'h10, 32'h20, 32'h30},
|
||||
x : 3200'h0deadbeef,
|
||||
n : 3
|
||||
};
|
||||
parameter config_struct_t MY_CONFIG = '{
|
||||
lo: {((N - 3) * 32)'('0), 32'h00, 32'h10, 32'h20},
|
||||
hi: {((N - 3) * 32)'('0), 32'h10, 32'h20, 32'h30},
|
||||
x : 3200'h0deadbeef,
|
||||
n : 3
|
||||
};
|
||||
|
||||
struct_submodule #(.MY_CONFIG(MY_CONFIG)) a_submodule_I (.clk);
|
||||
endmodule : t
|
||||
struct_submodule #(.MY_CONFIG(MY_CONFIG)) a_submodule_I (.clk);
|
||||
endmodule
|
||||
|
||||
module struct_submodule
|
||||
import config_pkg::*;
|
||||
#(
|
||||
parameter config_struct MY_CONFIG = '0
|
||||
) (
|
||||
input clk
|
||||
);
|
||||
import config_pkg::*;
|
||||
#(
|
||||
parameter config_struct_t MY_CONFIG = '0
|
||||
) (
|
||||
input clk
|
||||
);
|
||||
|
||||
logic [31:0] val;
|
||||
logic c;
|
||||
int count = 0;
|
||||
logic [31:0] val;
|
||||
logic c;
|
||||
int count = 0;
|
||||
|
||||
assign val = 3;
|
||||
assign c = check(MY_CONFIG, count);
|
||||
assign val = 3;
|
||||
assign c = check(MY_CONFIG, count);
|
||||
|
||||
always @(posedge clk) begin
|
||||
count <= count + 1;
|
||||
if (c != '1) begin
|
||||
$error("c not 1");
|
||||
$stop;
|
||||
end
|
||||
if (count >= 10) begin
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
always @(posedge clk) begin
|
||||
count <= count + 1;
|
||||
if (c != '1) begin
|
||||
$error("c not 1");
|
||||
$stop;
|
||||
end
|
||||
if (count >= 10) begin
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
end
|
||||
|
||||
endmodule : struct_submodule
|
||||
endmodule
|
||||
|
|
|
|||
Loading…
Reference in New Issue