fix early conversion cast struct types

This commit is contained in:
Zachary Snow 2024-12-14 11:08:11 -05:00
parent 12618d541e
commit 30677b3dcb
4 changed files with 15 additions and 5 deletions

View File

@ -15,6 +15,7 @@
* Fixed `--write path/to/dir/` with directives like `` `default_nettype ``
* Fixed `logic` incorrectly converted to `wire` even when provided to a task or
function output port
* Fixed conversion of fields accessed from explicitly-cast structs
* Fixed conversion of enum item names and typenames nested deeply within the
left-hand side of an assignment
* Fixed `input signed` ports of interface-using modules producing invalid

View File

@ -298,10 +298,6 @@ convertExpr scopes struct@(Struct _ fields []) (Pattern itemsOrig) =
Just value = numberToInteger n
Right (Number n) = item
convertExpr scopes _ (Cast (Left t) expr) =
Cast (Left t') $ convertExpr scopes t expr
where t' = convertType t
convertExpr scopes (Implicit _ []) expr =
traverseSinglyNestedExprs (convertExpr scopes UnknownType) expr
convertExpr scopes (Implicit sg rs) expr =
@ -495,7 +491,7 @@ convertSubExpr scopes (Call e args) =
(retType, _) = fallbackType scopes e
args' = convertCall scopes e args
convertSubExpr scopes (Cast (Left t) e) =
(t', Cast (Left t') e')
(t, Cast (Left t') e')
where
e' = convertExpr scopes t $ snd $ convertSubExpr scopes e
t' = convertType t

View File

@ -0,0 +1,8 @@
module top;
localparam type U = struct packed { integer s; };
localparam type T = struct packed { U x, y, z; };
localparam T L = '{x: '{s: 1}, y: '{s: 2}, z: '{s: 3}};
logic [L.x.s-1:0] a;
logic [T'(L).y.s-1:0] b;
logic [U'(T'(L).z).s-1:0] c;
endmodule

View File

@ -0,0 +1,5 @@
module top;
wire a;
wire [1:0] b;
wire [2:0] c;
endmodule