mirror of https://github.com/zachjs/sv2v.git
drop tf block edge case
- The deleted chunk in TFBlock has been unreachable since 57ef23ef. The
RemoveComments change would make it reachable by dropping the leading
Null in a task or function body.
- The optimization in TFBlock was unsound because the nested block could
shadow identifiers used (but not defined) in the tail of the outer
block.
- The optimization is not clearly necessary, so I'm dropping it for now.
- Expand tf_block test coverage.
This commit is contained in:
parent
0fb3a41ed3
commit
2aff725ea2
|
|
@ -61,4 +61,6 @@ convertDecls = filter (not . isCommentDecl)
|
||||||
isCommentDecl _ = False
|
isCommentDecl _ = False
|
||||||
|
|
||||||
convertStmts :: [Stmt] -> [Stmt]
|
convertStmts :: [Stmt] -> [Stmt]
|
||||||
convertStmts = map $ traverseNestedStmts convertStmt
|
convertStmts =
|
||||||
|
filter (/= Null) .
|
||||||
|
map (traverseNestedStmts convertStmt)
|
||||||
|
|
|
||||||
|
|
@ -47,11 +47,6 @@ flattenOuterBlocks (Block Seq "" declsA [stmt]) =
|
||||||
then (declsA ++ declsB, stmtsB)
|
then (declsA ++ declsB, stmtsB)
|
||||||
else (declsA, [stmt])
|
else (declsA, [stmt])
|
||||||
where (declsB, stmtsB) = flattenOuterBlocks stmt
|
where (declsB, stmtsB) = flattenOuterBlocks stmt
|
||||||
flattenOuterBlocks (Block Seq "" declsA (Block Seq name declsB stmtsA : stmtsB)) =
|
|
||||||
if canCombine declsA declsB
|
|
||||||
then flattenOuterBlocks $
|
|
||||||
Block Seq name (declsA ++ declsB) (stmtsA ++ stmtsB)
|
|
||||||
else (declsA, Block Seq name declsB stmtsA : stmtsB)
|
|
||||||
flattenOuterBlocks (Block Seq name decls stmts)
|
flattenOuterBlocks (Block Seq name decls stmts)
|
||||||
| null name = (decls, stmts)
|
| null name = (decls, stmts)
|
||||||
| otherwise = ([], [Block Seq name decls stmts])
|
| otherwise = ([], [Block Seq name decls stmts])
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,66 @@ module top;
|
||||||
initial t();
|
initial t();
|
||||||
initial $display("f(0) = ", f(0));
|
initial $display("f(0) = ", f(0));
|
||||||
initial $display("f(1) = ", f(1));
|
initial $display("f(1) = ", f(1));
|
||||||
|
|
||||||
|
task t1;
|
||||||
|
localparam X = 1;
|
||||||
|
begin
|
||||||
|
localparam X = 2;
|
||||||
|
$display("t1", X);
|
||||||
|
end
|
||||||
|
endtask
|
||||||
|
task t2;
|
||||||
|
localparam X = 10;
|
||||||
|
begin
|
||||||
|
localparam X = 20;
|
||||||
|
$display("t2", X);
|
||||||
|
end
|
||||||
|
$display("t2", X);
|
||||||
|
endtask
|
||||||
|
task t3;
|
||||||
|
localparam X = 100;
|
||||||
|
begin
|
||||||
|
localparam Y = 200;
|
||||||
|
$display("t3", Y);
|
||||||
|
end
|
||||||
|
$display("t3", X);
|
||||||
|
endtask
|
||||||
|
task t4;
|
||||||
|
begin
|
||||||
|
begin
|
||||||
|
localparam Y = 99;
|
||||||
|
$display("t4", Y);
|
||||||
|
end
|
||||||
|
$display("t4", 123);
|
||||||
|
end
|
||||||
|
endtask
|
||||||
|
initial begin
|
||||||
|
t1;
|
||||||
|
t2;
|
||||||
|
t3;
|
||||||
|
t4;
|
||||||
|
end
|
||||||
|
|
||||||
|
localparam X = 1;
|
||||||
|
task a;
|
||||||
|
localparam X = 2;
|
||||||
|
begin
|
||||||
|
begin : blk
|
||||||
|
localparam X = 3;
|
||||||
|
$display("a", X);
|
||||||
|
end
|
||||||
|
$display("a", X);
|
||||||
|
end
|
||||||
|
endtask
|
||||||
|
task b;
|
||||||
|
begin : blk
|
||||||
|
localparam X = 5;
|
||||||
|
$display("b", X);
|
||||||
|
end
|
||||||
|
$display("b", X);
|
||||||
|
endtask
|
||||||
|
initial begin
|
||||||
|
a;
|
||||||
|
b;
|
||||||
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,59 @@ module top;
|
||||||
initial t();
|
initial t();
|
||||||
initial $display("f(0) = ", f(0));
|
initial $display("f(0) = ", f(0));
|
||||||
initial $display("f(1) = ", f(1));
|
initial $display("f(1) = ", f(1));
|
||||||
|
|
||||||
|
task t1;
|
||||||
|
localparam X = 2;
|
||||||
|
$display("t1", X);
|
||||||
|
endtask
|
||||||
|
task t2;
|
||||||
|
localparam X = 10;
|
||||||
|
localparam Y = 20;
|
||||||
|
begin
|
||||||
|
$display("t2", Y);
|
||||||
|
$display("t2", X);
|
||||||
|
end
|
||||||
|
endtask
|
||||||
|
task t3;
|
||||||
|
localparam X = 100;
|
||||||
|
localparam Y = 200;
|
||||||
|
begin
|
||||||
|
$display("t3", Y);
|
||||||
|
$display("t3", X);
|
||||||
|
end
|
||||||
|
endtask
|
||||||
|
task t4;
|
||||||
|
localparam Y = 99;
|
||||||
|
begin
|
||||||
|
$display("t4", Y);
|
||||||
|
$display("t4", 123);
|
||||||
|
end
|
||||||
|
endtask
|
||||||
|
initial begin
|
||||||
|
t1;
|
||||||
|
t2;
|
||||||
|
t3;
|
||||||
|
t4;
|
||||||
|
end
|
||||||
|
|
||||||
|
localparam X = 1;
|
||||||
|
task a;
|
||||||
|
localparam X = 2;
|
||||||
|
localparam Y = 3;
|
||||||
|
begin
|
||||||
|
$display("a", Y);
|
||||||
|
$display("a", X);
|
||||||
|
end
|
||||||
|
endtask
|
||||||
|
task b;
|
||||||
|
localparam Y = 5;
|
||||||
|
begin
|
||||||
|
$display("b", Y);
|
||||||
|
$display("b", X);
|
||||||
|
end
|
||||||
|
endtask
|
||||||
|
initial begin
|
||||||
|
a;
|
||||||
|
b;
|
||||||
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue