mirror of
https://github.com/steveicarus/iverilog.git
synced 2026-08-28 16:53:45 +02:00
By adding ivtest to the iverilog source tree, it is easier to keep the regression test synchronized with the source that is being tested. This should be especially helpful for PRs that add a new feature, and have a matching ivtest PR with the regression test for that feature.
91 lines
2.3 KiB
Verilog
91 lines
2.3 KiB
Verilog
module top;
|
|
reg pass = 1'b1;
|
|
reg signed [7:0] arr [0:7];
|
|
integer idx;
|
|
reg signed [1:0] idx2;
|
|
reg [7:0] res;
|
|
|
|
real rarr [0:7];
|
|
real rres;
|
|
|
|
reg signed [2:0] a [0:3];
|
|
wire signed [2:0] n [0:3];
|
|
assign n[3] = 0;
|
|
assign n[0] = -1;
|
|
|
|
initial for (idx = 0; idx < 8 ; idx = idx + 1) rarr[idx] = idx+1.0;
|
|
initial for (idx = 0; idx < 8 ; idx = idx + 1) arr[idx] = idx+1;
|
|
initial begin
|
|
#1;
|
|
idx = 'bx;
|
|
|
|
// Test %load/ar
|
|
rres = rarr[idx];
|
|
if (rres != 0.0) begin
|
|
$display("Failed simple real array test, got %f.", rres);
|
|
pass = 1'b0;
|
|
end
|
|
|
|
// Test %load/av
|
|
res = arr[idx];
|
|
if (res !== 8'bx) begin
|
|
$display("Failed simple array vector test, got %b.", res);
|
|
pass = 1'b0;
|
|
end
|
|
|
|
// Test %load/avp0
|
|
res = arr[idx]+8'b1;
|
|
if (res !== 8'bx) begin
|
|
$display("Failed array vector plus constant test, got %b.", res);
|
|
pass = 1'b0;
|
|
end
|
|
|
|
// Test %load/avp0/s
|
|
res = arr[idx]+8'sb1;
|
|
if (res !== 8'bx) begin
|
|
$display("Failed array vector plus signed constant test, got %b.", res);
|
|
pass = 1'b0;
|
|
end
|
|
|
|
// Test %load/avx.p with a 'bx array select.
|
|
res = arr[idx][0];
|
|
if (res !== 8'b0x) begin
|
|
$display("Failed array vector bit select test 1, got %b.", res);
|
|
pass = 1'b0;
|
|
end
|
|
// Test %load/avx.p with a 'bx bit select.
|
|
res = arr[0][idx];
|
|
if (res !== 8'b0x) begin
|
|
$display("Failed array vector bit select test 2, got %b.", res);
|
|
pass = 1'b0;
|
|
end
|
|
// Test %load/avx.p with a negative bit select.
|
|
idx2 = -1;
|
|
res = arr[0][idx2];
|
|
if (res !== 8'b0x) begin
|
|
$display("Failed array vector bit select test 3, got %b.", res);
|
|
pass = 1'b0;
|
|
end
|
|
|
|
// This should be out of bounds and should be 'bx, but if this
|
|
// is being loaded as an unsigned value it will return 1.
|
|
idx2 = -1;
|
|
a[3] = 0;
|
|
a[0] = -1;
|
|
res = arr[a[idx2]];
|
|
if (res !== 8'bx) begin
|
|
$display("Failed: reg array select driving array select, got %b", res);
|
|
pass = 1'b0;
|
|
end
|
|
|
|
// The same here, but check a net array.
|
|
res = arr[n[idx2]];
|
|
if (res !== 8'bx) begin
|
|
$display("Failed: wire array select driving array select, got %b", res);
|
|
pass = 1'b0;
|
|
end
|
|
|
|
if (pass) $display("PASSED");
|
|
end
|
|
endmodule
|