diff --git a/src/V3SplitVar.cpp b/src/V3SplitVar.cpp index 4b0539dae..403bbb6d5 100644 --- a/src/V3SplitVar.cpp +++ b/src/V3SplitVar.cpp @@ -1098,15 +1098,11 @@ static const char* cannotSplitPackedVarReason(const AstVar* varp) { //###################################################################### // Split class functions -void V3SplitVar::splitUnpackedVariable(AstNetlist* nodep) { +void V3SplitVar::splitVariable(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { SplitUnpackedVarVisitor visitor(nodep); } V3Global::dumpCheckGlobalTree("split_var", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 9); -} - -void V3SplitVar::splitPackedVariable(AstNetlist* nodep) { - UINFO(2, __FUNCTION__ << ": " << endl); - { SplitPackedVarVisitor visitor(nodep); } // Destruct before checking + { SplitPackedVarVisitor visitor(nodep); } V3Global::dumpCheckGlobalTree("split_var", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 9); } diff --git a/src/V3SplitVar.h b/src/V3SplitVar.h index 0c5922f1a..61a9e8db2 100644 --- a/src/V3SplitVar.h +++ b/src/V3SplitVar.h @@ -28,11 +28,8 @@ class AstVar; class V3SplitVar { public: - // Split variables marked with split_var pragma. - static void splitUnpackedVariable(AstNetlist* nodep); - - // Split variables marked with split_var pragma. - static void splitPackedVariable(AstNetlist* nodep); + // Split variables marked with split_var metacomment. + static void splitVariable(AstNetlist* nodep); // Return true if the variable can be split. // This check is not perfect. diff --git a/src/Verilator.cpp b/src/Verilator.cpp index 63c47519b..8a072c266 100644 --- a/src/Verilator.cpp +++ b/src/Verilator.cpp @@ -155,11 +155,6 @@ static void process() { // so V3Undriven sees variables to be eliminated, ie "if (0 && foo) ..." V3Const::constifyAllLive(v3Global.rootp()); - // Split variables into multiple pieces to resolve UNOPTFLAT. - // This should come before undrivenAll() to eliminate ALWCOMBORDER warning - // which can be resolved by splitUnpackedVariable(). - V3SplitVar::splitUnpackedVariable(v3Global.rootp()); - // Signal based lint checks, no change to structures // Must be before first constification pass drops dead code V3Undriven::undrivenAll(v3Global.rootp()); @@ -182,7 +177,7 @@ static void process() { // Split packed variables into multiple pieces to resolve UNOPTFLAT. // should be after constifyAllLint() which flattens to 1D bit vector - V3SplitVar::splitPackedVariable(v3Global.rootp()); + V3SplitVar::splitVariable(v3Global.rootp()); if (!v3Global.opt.xmlOnly()) { // Remove cell arrays (must be between V3Width and scoping) diff --git a/test_regress/t/t_split_var_0.v b/test_regress/t/t_split_var_0.v index ccabb1511..e3e0d5363 100644 --- a/test_regress/t/t_split_var_0.v +++ b/test_regress/t/t_split_var_0.v @@ -14,7 +14,9 @@ module barshift_1d_unpacked #(parameter DEPTH = 2, localparam WIDTH = 2**DEPTH) for(genvar i = 0; i < DEPTH; ++i) begin always_comb if (shift[i]) begin + /*verilator lint_off ALWCOMBORDER*/ tmp[i+1+OFFSET] = {tmp[i+OFFSET][(1 << i)-1:0], tmp[i+OFFSET][WIDTH-1:(2**i)]}; + /*verilator lint_on ALWCOMBORDER*/ end else begin tmp[i+1+OFFSET] = tmp[i+OFFSET]; @@ -37,7 +39,9 @@ module barshift_1d_unpacked_le #(parameter DEPTH = 2, localparam WIDTH = 2**DEPT for(genvar i = 0; i < DEPTH; ++i) begin always_comb if (shift[i]) begin + /*verilator lint_off ALWCOMBORDER*/ tmp[i+1+OFFSET] = {tmp[i+OFFSET][(1 << i)-1:0], tmp[i+OFFSET][WIDTH-1:(2**i)]}; + /*verilator lint_on ALWCOMBORDER*/ end else begin tmp[i+1+OFFSET] = tmp[i+OFFSET]; @@ -59,7 +63,9 @@ module barshift_1d_unpacked_struct0 #(parameter DEPTH = 2, localparam WIDTH = 2* for(genvar i = 0; i < DEPTH; ++i) begin always_comb if (shift[i]) begin + /*verilator lint_off ALWCOMBORDER*/ tmp[i+1+OFFSET] = {tmp[i+OFFSET][(1 << i)-1:0], tmp[i+OFFSET][WIDTH-1:(2**i)]}; + /*verilator lint_on ALWCOMBORDER*/ end else begin tmp[i+1+OFFSET] = tmp[i+OFFSET]; @@ -101,7 +107,9 @@ module barshift_2d_unpacked #(parameter DEPTH = 2, localparam WIDTH = 2**DEPTH) for(genvar j = OFFSET; j < N + OFFSET; ++j) begin always_comb if (shift[i]) begin + /*verilator lint_off ALWCOMBORDER*/ tmp0[i+1+OFFSET][j] = {tmp0[i+OFFSET][j][(1 << i)-1:0], tmp0[i+OFFSET][j][WIDTH-1:(2**i)]}; + /*verilator lint_on ALWCOMBORDER*/ end else begin tmp0[i+1+OFFSET][j] = tmp0[i+OFFSET][j]; @@ -143,7 +151,9 @@ module barshift_1d_unpacked_struct1 #(parameter DEPTH = 2, localparam WIDTH = 2* for(genvar i = 0; i < DEPTH; ++i) begin always_comb if (shift[i]) begin + /*verilator lint_off ALWCOMBORDER*/ tmp[i+1+OFFSET] = {pad, tmp[i+OFFSET][(1 << i)-1:0], tmp[i+OFFSET][WIDTH-1:(2**i)]}; + /*verilator lint_on ALWCOMBORDER*/ end else begin tmp[i+1+OFFSET] = tmp[i+OFFSET]; diff --git a/test_regress/t/t_split_var_1_bad.out b/test_regress/t/t_split_var_1_bad.out index a93e26b6f..27cedceca 100644 --- a/test_regress/t/t_split_var_1_bad.out +++ b/test_regress/t/t_split_var_1_bad.out @@ -22,6 +22,10 @@ logic [7:0] should_show_warning_global1 [1:0] /*verilator split_var*/ ; : ... In instance t i_sub0.cannot_split1[1] = bad_func(addr, rd_data0); ^ +%Error: t/t_split_var_1_bad.v:71: Illegal assignment of constant to unpacked array + : ... In instance t.i_sub2 + assign b = a[0]; + ^ %Warning-SPLITVAR: t/t_split_var_1_bad.v:50: 'cannot_split0' has split_var metacomment but will not be split because index cannot be determined statically. : ... In instance t.i_sub0 rd_data = cannot_split0[addr]; @@ -58,7 +62,4 @@ logic [7:0] should_show_warning_global1 [1:0] /*verilator split_var*/ ; : ... In instance t.i_sub1 rd_data = cannot_split[addr]; ^ -%Error: t/t_split_var_1_bad.v:70: Illegal assignment of constant to unpacked array - assign a = 1'b0; - ^ %Error: Exiting due to