Add a test for unpacked_array[small:big] case.

This commit is contained in:
Yutetsu TAKATSUKASA 2020-01-17 06:30:06 +09:00
parent e73f00ed9a
commit a31a942586
4 changed files with 965 additions and 888 deletions

View File

@ -9,15 +9,18 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(simulator => 1);
# Travis environment offers 2 VCPUs, 2 thread setting causes the following warning.
# %Warning-UNOPTTHREADS: Thread scheduler is unable to provide requested parallelism; consider asking for fewer threads.
# So use 3 threads here though it's not optimal in performace wise, but ok.
compile(
verilator_flags2 => ['--stats '],
verilator_flags2 => ['--stats ' . ($Self->{vltmt} ? '--threads 3' : '')],
);
execute(
check_finished => 1,
);
file_grep($Self->{stats}, qr/SplitVar,\s+Split packed variables\s+(\d+)/i, 80);
file_grep($Self->{stats}, qr/SplitVar,\s+Split unpacked arrays\s+(\d+)/i, 12);
file_grep($Self->{stats}, qr/SplitVar,\s+Split packed variables\s+(\d+)/i, 84);
file_grep($Self->{stats}, qr/SplitVar,\s+Split unpacked arrays\s+(\d+)/i, 13);
ok(1);
1;

View File

@ -25,6 +25,28 @@ module barshift_1d_unpacked #(parameter depth = 2, localparam width = 2**depth)
endmodule
module barshift_1d_unpacked_le #(parameter depth = 2, localparam width = 2**depth) (
input [width-1:0] in, input [depth-1:0] shift, output [width-1:0]out);
localparam offset = -3;
// almost same as above module, but tmp[smaller:bigger] here.
logic [width-1:0] tmp[offset:depth+offset]; /*verilator split_var*/
generate
for(genvar i = 0; i < depth; ++i) begin
always_comb
if (shift[i]) begin
tmp[i+1+offset] = {tmp[i+offset][(1 << i)-1:0], tmp[i+offset][width-1:(2**i)]};
end else begin
tmp[i+1+offset] = tmp[i+offset];
end
end
endgenerate
assign tmp[0+offset] = in;
assign out = tmp[depth+offset];
endmodule
module barshift_1d_unpacked_struct0 #(parameter depth = 2, localparam width = 2**depth) (
input [width-1:0] in, input [depth-1:0] shift, output [width-1:0]out);
@ -229,24 +251,26 @@ end
endmodule
module t(/*AUTOARG*/ clk);
input clk;
localparam depth = 3;
localparam width = 2**depth;
localparam numsub = 8;
localparam numsub = 9;
logic [width-1:0] in;
logic [width-1:0] out[0:numsub-1];
logic [depth-1:0] shift = 0;
// barrel shifter
barshift_1d_unpacked #(.depth(depth)) shifter0(.in(in), .out(out[0]), .shift(shift));
barshift_1d_unpacked_struct0 #(.depth(depth)) shifter1(.in(in), .out(out[1]), .shift(shift));
barshift_2d_unpacked #(.depth(depth)) shifter2(.in(in), .out(out[2]), .shift(shift));
barshift_1d_unpacked_struct1 #(.depth(depth)) shifter3(.in(in), .out(out[3]), .shift(shift));
barshift_2d_packed_array #(.depth(depth)) shifter4(.in(in), .out(out[4]), .shift(shift));
barshift_2d_packed_array_le #(.depth(depth)) shifter5(.in(in), .out(out[5]), .shift(shift));
barshift_1d_packed_struct shifter6(.in(in), .out(out[6]), .shift(shift));
barshift_bitslice #(.depth(depth)) shifter7(.in(in), .out(out[7]), .shift(shift));
barshift_1d_unpacked_le #(.depth(depth)) shifter1(.in(in), .out(out[1]), .shift(shift));
barshift_1d_unpacked_struct0 #(.depth(depth)) shifter2(.in(in), .out(out[2]), .shift(shift));
barshift_2d_unpacked #(.depth(depth)) shifter3(.in(in), .out(out[3]), .shift(shift));
barshift_1d_unpacked_struct1 #(.depth(depth)) shifter4(.in(in), .out(out[4]), .shift(shift));
barshift_2d_packed_array #(.depth(depth)) shifter5(.in(in), .out(out[5]), .shift(shift));
barshift_2d_packed_array_le #(.depth(depth)) shifter6(.in(in), .out(out[6]), .shift(shift));
barshift_1d_packed_struct shifter7(.in(in), .out(out[7]), .shift(shift));
barshift_bitslice #(.depth(depth)) shifter8(.in(in), .out(out[8]), .shift(shift));
var_decl_with_init i_var_decl_with_init();
assign in = 8'b10001110;

File diff suppressed because it is too large Load Diff

View File

@ -12,9 +12,9 @@ top_filename("t/t_split_var_0.v");
# Travis environment offers 2 VCPUs, 2 thread setting causes the following warning.
# %Warning-UNOPTTHREADS: Thread scheduler is unable to provide requested parallelism; consider asking for fewer threads.
# So use 4 threads here though it's not optimal in performace wise, but ok.
# So use 3 threads here though it's not optimal in performace wise, but ok.
compile(
verilator_flags2 => ['--cc --trace --stats ' . ($Self->{vltmt} ? '--threads 4' : '')],
verilator_flags2 => ['--cc --trace --stats ' . ($Self->{vltmt} ? '--threads 3' : '')],
);
execute(
@ -22,8 +22,8 @@ execute(
);
vcd_identical("$Self->{obj_dir}/simx.vcd", $Self->{golden_filename});
file_grep($Self->{stats}, qr/SplitVar,\s+Split packed variables\s+(\d+)/i, 92);
file_grep($Self->{stats}, qr/SplitVar,\s+Split unpacked arrays\s+(\d+)/i, 12);
file_grep($Self->{stats}, qr/SplitVar,\s+Split packed variables\s+(\d+)/i, 96);
file_grep($Self->{stats}, qr/SplitVar,\s+Split unpacked arrays\s+(\d+)/i, 13);
ok(1);
1;