Skip to content

Commit

Permalink
fix early conversion cast struct types
Browse files Browse the repository at this point in the history
  • Loading branch information
zachjs committed Dec 14, 2024
1 parent 12618d5 commit 30677b3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions src/Convert/Struct.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions test/core/struct_cast_dot.sv
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions test/core/struct_cast_dot.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module top;
wire a;
wire [1:0] b;
wire [2:0] c;
endmodule

0 comments on commit 30677b3

Please sign in to comment.