mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-01 17:03:19 +00:00
Merge pull request #2317 from zachjs/expand-genblock
Fix generate scoping issues
This commit is contained in:
commit
a9681f4e06
3 changed files with 168 additions and 42 deletions
|
@ -159,3 +159,88 @@ generate
|
|||
end
|
||||
endgenerate
|
||||
endmodule
|
||||
|
||||
// ------------------------------------------
|
||||
|
||||
module gen_test7;
|
||||
reg [2:0] out1;
|
||||
reg [2:0] out2;
|
||||
wire [2:0] out3;
|
||||
generate
|
||||
begin : cond
|
||||
reg [2:0] sub_out1;
|
||||
reg [2:0] sub_out2;
|
||||
wire [2:0] sub_out3;
|
||||
initial begin : init
|
||||
reg signed [31:0] x;
|
||||
x = 2 ** 2;
|
||||
out1 = x;
|
||||
sub_out1 = x;
|
||||
end
|
||||
always @* begin : proc
|
||||
reg signed [31:0] x;
|
||||
x = 2 ** 1;
|
||||
out2 = x;
|
||||
sub_out2 = x;
|
||||
end
|
||||
genvar x;
|
||||
for (x = 0; x < 3; x = x + 1) begin
|
||||
assign out3[x] = 1;
|
||||
assign sub_out3[x] = 1;
|
||||
end
|
||||
end
|
||||
endgenerate
|
||||
|
||||
// `define VERIFY
|
||||
`ifdef VERIFY
|
||||
assert property (out1 == 4);
|
||||
assert property (out2 == 2);
|
||||
assert property (out3 == 7);
|
||||
assert property (cond.sub_out1 == 4);
|
||||
assert property (cond.sub_out2 == 2);
|
||||
assert property (cond.sub_out3 == 7);
|
||||
`endif
|
||||
endmodule
|
||||
|
||||
// ------------------------------------------
|
||||
|
||||
module gen_test8;
|
||||
|
||||
// `define VERIFY
|
||||
`ifdef VERIFY
|
||||
`define ASSERT(expr) assert property (expr);
|
||||
`else
|
||||
`define ASSERT(expr)
|
||||
`endif
|
||||
|
||||
wire [1:0] x = 2'b11;
|
||||
generate
|
||||
begin : A
|
||||
wire [1:0] x;
|
||||
begin : B
|
||||
wire [1:0] x = 2'b00;
|
||||
`ASSERT(x == 0)
|
||||
`ASSERT(A.x == 2)
|
||||
`ASSERT(A.C.x == 1)
|
||||
`ASSERT(A.B.x == 0)
|
||||
end
|
||||
begin : C
|
||||
wire [1:0] x = 2'b01;
|
||||
`ASSERT(x == 1)
|
||||
`ASSERT(A.x == 2)
|
||||
`ASSERT(A.C.x == 1)
|
||||
`ASSERT(A.B.x == 0)
|
||||
end
|
||||
assign x = B.x ^ 2'b11 ^ C.x;
|
||||
`ASSERT(x == 2)
|
||||
`ASSERT(A.x == 2)
|
||||
`ASSERT(A.C.x == 1)
|
||||
`ASSERT(A.B.x == 0)
|
||||
end
|
||||
endgenerate
|
||||
|
||||
`ASSERT(x == 3)
|
||||
`ASSERT(A.x == 2)
|
||||
`ASSERT(A.C.x == 1)
|
||||
`ASSERT(A.B.x == 0)
|
||||
endmodule
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue