Commit 623f0a2d by Zachary Snow

fix missing top reference renames in param type instantiation

- renaming applies to nodes within generate blocks
- renaming applies to LHSs
parent 4ddbff9b
...@@ -149,8 +149,10 @@ convert files = ...@@ -149,8 +149,10 @@ convert files =
where where
Part attrs extern kw ml m p items = part Part attrs extern kw ml m p items = part
m' = moduleInstanceName m typeMap m' = moduleInstanceName m typeMap
items' = map (traverseExprs rewriteExpr) $ items' = map rewriteModuleItem items
map (traverseDecls rewriteDecl) items rewriteModuleItem = traverseDecls rewriteDecl .
traverseNestedModuleItems
(traverseExprs rewriteExpr . traverseLHSs rewriteLHS)
rewriteDecl :: Decl -> Decl rewriteDecl :: Decl -> Decl
rewriteDecl (ParamType Parameter x _) = rewriteDecl (ParamType Parameter x _) =
ParamType Localparam x (fst $ typeMap Map.! x) ParamType Localparam x (fst $ typeMap Map.! x)
...@@ -165,6 +167,14 @@ convert files = ...@@ -165,6 +167,14 @@ convert files =
rewriteExpr other = rewriteExpr other =
traverseExprTypes rewriteType $ traverseExprTypes rewriteType $
traverseSinglyNestedExprs rewriteExpr other traverseSinglyNestedExprs rewriteExpr other
rewriteLHS :: LHS -> LHS
rewriteLHS (orig @ (LHSDot (LHSIdent x) y)) =
if x == m
then LHSDot (LHSIdent m') y
else orig
rewriteLHS other =
traverseLHSExprs rewriteExpr $
traverseSinglyNestedLHSs rewriteLHS other
rewriteType :: Type -> Type rewriteType :: Type -> Type
rewriteType = rewriteType =
traverseNestedTypes $ traverseTypeExprs rewriteExpr traverseNestedTypes $ traverseTypeExprs rewriteExpr
......
module Module; module Module #(
parameter int S; parameter int S,
parameter type T; parameter type T
T x = '1; );
initial $display("Module %0d: %b, %0d", S, Module.x, $bits(T)); T x;
if (S) begin : a
if (S) begin : b
assign Module.x = '1;
logic [$bits(Module.x):0] y = 'z;
end
end
initial $display("Module %0d: %b %0d %b %0d", S, Module.x, $bits(T), Module.a.b.y, $bits(Module.a.b.y));
endmodule endmodule
module top; module top;
......
module Module; module Module;
parameter S = 0; parameter S = 0;
parameter T = 0; parameter T = 0;
wire [T-1:0] x = 1'sb1; wire [T-1:0] x;
initial $display("Module %0d: %b, %0d", S, Module.x, T); generate
if (S) begin : a
if (S) begin : b
assign Module.x = 1'sb1;
wire [T:0] y = 1'sbz;
end
end
endgenerate
initial $display("Module %0d: %b %0d %b %0d", S, Module.x, T, Module.a.b.y, T + 1);
endmodule endmodule
module top; module top;
......
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