fix premature typename cast conversion (resolves #88)

This commit is contained in:
Zachary Snow 2020-06-01 18:17:51 -04:00
parent 9042145695
commit 478f0d19d2
3 changed files with 17 additions and 0 deletions

View File

@ -70,6 +70,12 @@ traverseExprM =
_ -> convertCastM (Number s) (Number n)
convertExprM (orig @ (Cast (Right DimsFn{}) _)) =
return orig
convertExprM (Cast (Right (Ident x)) e) = do
typeMap <- get
-- can't convert this cast yet because x could be a typename
if Map.notMember x typeMap
then return $ Cast (Right $ Ident x) e
else convertCastM (Ident x) e
convertExprM (Cast (Right s) e) =
convertCastM s e
convertExprM (Cast (Left (IntegerVector _ Signed rs)) e) =

View File

@ -0,0 +1,6 @@
module Example;
parameter type T = logic [3:0];
T v = T'('1);
initial #1 $display("%b", v);
endmodule
module top; Example example(); endmodule

View File

@ -0,0 +1,5 @@
module Example;
wire [3:0] v = 4'b1111;
initial #1 $display("%b", v);
endmodule
module top; Example example(); endmodule