Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions test/err_nonconst_select/dut.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// A select whose index or width is not constant where the LRM requires one.
// The legal forms below must stay silent; each ILLEGAL line is one error.
module err_nonconst_select #(parameter int W = 8) (
input logic clk,
input logic [2:0] n,
input logic [7:0] d,
output logic [7:0] q,
output logic [7:0] r
);
logic [7:0] arr [8];
logic [7:0] row;
logic [15:0] acc;

// Legal: genvar-indexed targets, parameter bounds, constant-width slides.
for (genvar g = 0; g < 8; g++) begin : g_arr
assign arr[g] = d ^ 8'(g);
end
assign row[W-1:4] = d[3:0];
assign row[3:0] = d[7:4];

always_ff @(posedge clk)
for (int i = 0; i < 8; i++) acc[i+1 -: 2] <= {d[i], row[i]};

// Illegal: a variable index in a continuous-assignment target
// (LRM 10.3.1) and a part-select whose WIDTH varies (LRM 11.5.1).
logic [7:0] tgt [8];
assign tgt[n] = d; // ILLEGAL: variable element index
assign q = arr[n];
always_comb begin
r = '0;
r[n:0] = d[n:0]; // ILLEGAL x2: variable width
end
endmodule
7 changes: 7 additions & 0 deletions test/err_nonconst_select/test_structural.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The read must FAIL: Surelog reports UH0734 on the three ILLEGAL selects in
# dut.sv -- a variable index in a continuous-assignment target, and the two
# bounds `n` of part-selects whose other bound is the constant 0 (the width
# varies with n). The exact count pins it to those lines: the genvar-indexed
# targets, the parameter-bounded slice and `acc[i+1 -: 2]` must stay silent.
logger -expect error "Surelog reported 0 fatal, 0 syntax and 3 other error" 1
read_sv -nonote -noinfo -nowarning dut.sv
33 changes: 33 additions & 0 deletions test/err_xz_size_argcount/dut.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// A size or bound with unknown (x/z) bits, and calls with the wrong number
// of arguments. The legal forms must stay silent; each ILLEGAL line is one
// error.
module err_xz_size_argcount (
input logic [7:0] a,
output logic [7:0] y,
output logic [7:0] z,
output logic [31:0] w
);
localparam int N = 4;
localparam logic [3:0] PX = 4'bx; // x as DATA: legal
localparam integer LPX = 32'b01x;

function automatic logic [7:0] add(logic [7:0] p, logic [7:0] q = 8'd1);
return p + q;
endfunction
function automatic logic [7:0] ones();
return '1;
endfunction

// Legal: a defaulted formal left out, a zero-argument call, x data.
assign y = add(a) ^ add(a, 8'd2) ^ ones();
assign w = {N{a}};
logic [3:0] data_x;
assign data_x = PX;

// Illegal.
logic [LPX:0] bad_range; // ILLEGAL: x range bound
assign bad_range = '0;
assign z = add(a, a, a); // ILLEGAL: 3 arguments for 2
logic [7:0] z2;
assign z2 = add(); // ILLEGAL: `p` has no default
endmodule
8 changes: 8 additions & 0 deletions test/err_xz_size_argcount/test_structural.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# The read must FAIL: Surelog reports the three ILLEGAL lines in dut.sv --
# a range bound whose value has x bits (UH0740) and two calls with the wrong
# number of arguments (UH0741: one argument too many, one required formal
# left out). The exact count pins it to those lines: the defaulted formal
# left out, the zero-argument call and the x-valued DATA parameter must
# stay silent.
logger -expect error "Surelog reported 0 fatal, 0 syntax and 3 other error" 1
read_sv -nonote -noinfo -nowarning dut.sv
Loading