Commit 7f2fe54b by Zachary Snow

fix jump statement conversion

parent fb5fd393
...@@ -31,9 +31,15 @@ module top; ...@@ -31,9 +31,15 @@ module top;
$display("test1: %b %b", 3'b0z1, test1(3'b0z1)); $display("test1: %b %b", 3'b0z1, test1(3'b0z1));
end end
integer arr [] = { 32'd60, 32'd61, 32'd63 };
function test2; function test2;
input integer inp; input integer inp;
return inp inside { [16:23], [32:47] }; // TODO: Add support for array value ranges.
test2 = 0;
for (integer i = 0; i < 3; ++i)
if (inp == arr[i])
return 1'b1;
return test2 || inp inside { [16:23], [32:47] };
endfunction endfunction
initial begin initial begin
for (integer i = 0; i < 64; ++i) for (integer i = 0; i < 64; ++i)
......
...@@ -33,9 +33,17 @@ module top; ...@@ -33,9 +33,17 @@ module top;
$display("test1: %b %b", 3'b0z1, test1(3'b0z1)); $display("test1: %b %b", 3'b0z1, test1(3'b0z1));
end end
wire [0:2][31:0] arr;
assign arr = { 32'd60, 32'd61, 32'd63 };
function test2; function test2;
input integer inp; input integer inp;
test2 = (16 <= inp && inp <= 23) || (32 <= inp && inp <= 47); integer i;
begin
test2 = 0;
for (i = 0; i < 3; ++i)
test2 = test2 || (inp == arr[i]);
test2 = test2 || (16 <= inp && inp <= 23) || (32 <= inp && inp <= 47);
end
endfunction endfunction
initial begin : foobar initial begin : foobar
integer i; integer i;
......
...@@ -3,25 +3,25 @@ module top; ...@@ -3,25 +3,25 @@ module top;
task skip1; task skip1;
$display("HELLO skip1"); $display("HELLO skip1");
return; return;
$display("UNREACHABLE"); $display("UNREACHABLE ", `__LINE__);
endtask endtask
function void skip2; function void skip2;
$display("HELLO skip2"); $display("HELLO skip2");
return; return;
$display("UNREACHABLE"); $display("UNREACHABLE ", `__LINE__);
endfunction endfunction
function int skip3; function int skip3;
$display("HELLO skip3"); $display("HELLO skip3");
return 1; return 1;
$display("UNREACHABLE"); $display("UNREACHABLE ", `__LINE__);
endfunction endfunction
task skip4; task skip4;
for (int i = 0; i < 10; ++i) begin for (int i = 0; i < 10; ++i) begin
$display("HELLO skip4"); $display("HELLO skip4");
return; return;
$display("UNREACHABLE"); $display("UNREACHABLE ", `__LINE__);
end end
$display("UNREACHABLE"); $display("UNREACHABLE ", `__LINE__);
endtask endtask
task skip5; task skip5;
for (int i = 0; i < 10; ++i) begin for (int i = 0; i < 10; ++i) begin
...@@ -29,11 +29,36 @@ module top; ...@@ -29,11 +29,36 @@ module top;
for (int j = 0; j < 10; ++j) begin for (int j = 0; j < 10; ++j) begin
$display("HELLO skip5-2"); $display("HELLO skip5-2");
return; return;
$display("UNREACHABLE"); $display("UNREACHABLE ", `__LINE__);
end end
$display("UNREACHABLE"); $display("UNREACHABLE ", `__LINE__);
end end
$display("UNREACHABLE"); $display("UNREACHABLE ", `__LINE__);
endtask
task skip6;
for (int i = 0; i < 0; ++i) begin
$display("UNREACHABLE ", `__LINE__);
return;
end
$display("HELLO skip6");
endtask
task skip7;
begin
parameter x = 1;
$display("HELLO skip7");
if (x == 1) return;
$display("UNREACHABLE ", `__LINE__);
end
$display("UNREACHABLE ", `__LINE__);
endtask
task skip8;
begin
parameter x = 1;
$display("HELLO skip8-1");
if (x == 2) return;
$display("HELLO skip8-2");
end
$display("HELLO skip8-3");
endtask endtask
initial begin initial begin
skip1; skip1;
...@@ -41,20 +66,23 @@ module top; ...@@ -41,20 +66,23 @@ module top;
$display(skip3()); $display(skip3());
skip4; skip4;
skip5; skip5;
skip6;
skip7;
skip8;
end end
initial initial
for (int i = 0; i < 10; ++i) begin for (int i = 0; i < 10; ++i) begin
$display("Loop Y:", i); $display("Loop Y:", i);
continue; continue;
$display("UNREACHABLE"); $display("UNREACHABLE ", `__LINE__);
end end
initial initial
for (int i = 0; i < 10; ++i) begin for (int i = 0; i < 10; ++i) begin
$display("Loop Z:", i); $display("Loop Z:", i);
break; break;
$display("UNREACHABLE"); $display("UNREACHABLE ", `__LINE__);
end end
initial initial
...@@ -73,7 +101,7 @@ module top; ...@@ -73,7 +101,7 @@ module top;
else begin else begin
$display("Loop B-3:", i); $display("Loop B-3:", i);
continue; continue;
$display("UNREACHABLE"); $display("UNREACHABLE ", `__LINE__);
end end
$display("Loop B:", i); $display("Loop B:", i);
end end
......
...@@ -22,12 +22,28 @@ module top; ...@@ -22,12 +22,28 @@ module top;
$display("HELLO skip5-2"); $display("HELLO skip5-2");
end end
endtask endtask
task skip6;
$display("HELLO skip6");
endtask
task skip7;
$display("HELLO skip7");
endtask
task skip8;
begin
$display("HELLO skip8-1");
$display("HELLO skip8-2");
$display("HELLO skip8-3");
end
endtask
initial begin initial begin
skip1; skip1;
skip2; skip2;
$display(skip3(0)); $display(skip3(0));
skip4; skip4;
skip5; skip5;
skip6;
skip7;
skip8;
end end
initial begin : loop_y initial begin : loop_y
......
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