Commit aa294eaa by Zachary Snow

genvars declared in for loops retain scoping (resolves #46)

parent 142df3b5
...@@ -24,10 +24,10 @@ convert = ...@@ -24,10 +24,10 @@ convert =
) )
convertGenItem :: GenItem -> GenItem convertGenItem :: GenItem -> GenItem
convertGenItem (GenFor (True, x, e) a b c d) = convertGenItem (GenFor (True, x, e) a b mx c) =
GenBlock Nothing GenBlock (fmap (++ "_for_decl") mx)
[ GenModuleItem $ Genvar x [ GenModuleItem $ Genvar x
, GenFor (False, x, e) a b c d , GenFor (False, x, e) a b mx c
] ]
convertGenItem other = other convertGenItem other = other
......
...@@ -5,6 +5,11 @@ module top; ...@@ -5,6 +5,11 @@ module top;
assign a[n] = n & 1; assign a[n] = n & 1;
end end
wire [0:31] b;
for (genvar n = 0; n < 32; n++) begin : gen_filter_other
assign b[n] = ~a[n];
end
initial initial
for (integer i = 0; i < 32; i++) for (integer i = 0; i < 32; i++)
$display("1: ", a[i]); $display("1: ", a[i]);
...@@ -49,4 +54,8 @@ module top; ...@@ -49,4 +54,8 @@ module top;
end end
end end
initial
for (integer i = 0; i < 32; i++)
$display("8: ", a[i], b[i]);
endmodule endmodule
...@@ -8,6 +8,14 @@ module top; ...@@ -8,6 +8,14 @@ module top;
end end
endgenerate endgenerate
wire [0:31] b;
generate
genvar other_n;
for (other_n = 0; other_n < 32; other_n = other_n + 1) begin : gen_filter_other
assign b[other_n] = ~a[other_n];
end
endgenerate
integer i; integer i;
initial begin : foo_1 initial begin : foo_1
for (i = 0; i < 32; i = i + 1) for (i = 0; i < 32; i = i + 1)
...@@ -55,4 +63,10 @@ module top; ...@@ -55,4 +63,10 @@ module top;
$display("7: ", ~a[j * 8 + k] + 11); $display("7: ", ~a[j * 8 + k] + 11);
end end
initial begin : foo_8
integer i;
for (i = 0; i < 32; i = i + 1)
$display("8: ", a[i], b[i]);
end
endmodule endmodule
...@@ -20,6 +20,7 @@ simulate() { ...@@ -20,6 +20,7 @@ simulate() {
iv_output=`iverilog \ iv_output=`iverilog \
-Wall \ -Wall \
-Wno-select-range \ -Wno-select-range \
-Wno-anachronisms \
-o "$sim_prog" \ -o "$sim_prog" \
-g2005 \ -g2005 \
-DTEST_VCD="\"$sim_vcd\"" \ -DTEST_VCD="\"$sim_vcd\"" \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment