fix premature conversion of casts containing dimension queries

This commit is contained in:
Zachary Snow
2020-07-12 16:23:08 -06:00
parent d46e1f24b4
commit db21869e69
3 changed files with 52 additions and 3 deletions
+20
View File
@@ -0,0 +1,20 @@
package P;
function automatic logic [7:0] f(input logic [2:0] p);
logic [7:0] r;
r = '0;
r[p+:2] = '1;
return r;
endfunction
endpackage
module top;
logic [2:0] p;
logic [7:0] q;
assign q = P::f(p);
initial begin
$monitor("%0d, p=%b q=%b", $time, p, q);
#1 p = 0;
while (p != 7)
#1 p = p + 1;
end
endmodule
+18
View File
@@ -0,0 +1,18 @@
module top;
function automatic [7:0] f;
input [2:0] p;
begin
f = 7'b0;
f[p+:2] = 2'b11;
end
endfunction
reg [2:0] p;
wire [7:0] q;
assign q = f(p);
initial begin
$monitor("%0d, p=%b q=%b", $time, p, q);
#1 p = 0;
while (p != 7)
#1 p = p + 1;
end
endmodule