From 12d977f070a7b1ac86015e781d9cc46a08ab8036 Mon Sep 17 00:00:00 2001 From: Zachary Snow Date: Sun, 1 Sep 2024 20:39:58 -0400 Subject: [PATCH] visit nested LHSs in enum, typedef, and typeof conversions --- CHANGELOG.md | 2 ++ src/Convert/Enum.hs | 2 +- src/Convert/TypeOf.hs | 2 +- src/Convert/Typedef.hs | 2 +- test/core/typename_lhs_nest.sv | 12 ++++++++++++ test/core/typename_lhs_nest.v | 5 +++++ 6 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 test/core/typename_lhs_nest.sv create mode 100644 test/core/typename_lhs_nest.v diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d8e13d5..2bc88496 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ * 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 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 declarations after inlining * Fixed `` `resetall `` not resetting the `` `default_nettype `` diff --git a/src/Convert/Enum.hs b/src/Convert/Enum.hs index ba8081d2..e189ae26 100644 --- a/src/Convert/Enum.hs +++ b/src/Convert/Enum.hs @@ -47,7 +47,7 @@ traverseModuleItemM (Genvar x) = insertElem x Nil >> return (Genvar x) traverseModuleItemM item = traverseNodesM traverseExprM return traverseTypeM traverseLHSM return item - where traverseLHSM = traverseLHSExprsM traverseExprM + where traverseLHSM = traverseNestedLHSsM $ traverseLHSExprsM traverseExprM traverseGenItemM :: GenItem -> SC GenItem traverseGenItemM = traverseGenItemExprsM traverseExprM diff --git a/src/Convert/TypeOf.hs b/src/Convert/TypeOf.hs index 3d871fd3..deaa497b 100644 --- a/src/Convert/TypeOf.hs +++ b/src/Convert/TypeOf.hs @@ -79,7 +79,7 @@ insertType ident typ = do traverseModuleItemM :: ModuleItem -> ST ModuleItem traverseModuleItemM = traverseNodesM traverseExprM return traverseTypeM traverseLHSM return - where traverseLHSM = traverseLHSExprsM traverseExprM + where traverseLHSM = traverseNestedLHSsM $ traverseLHSExprsM traverseExprM -- convert TypeOf in a GenItem traverseGenItemM :: GenItem -> ST GenItem diff --git a/src/Convert/Typedef.hs b/src/Convert/Typedef.hs index 6cc04274..7dea3d02 100644 --- a/src/Convert/Typedef.hs +++ b/src/Convert/Typedef.hs @@ -88,7 +88,7 @@ traverseModuleItemM item = traverseModuleItemM' item traverseModuleItemM' :: ModuleItem -> SC ModuleItem traverseModuleItemM' = traverseNodesM traverseExprM return traverseTypeM traverseLHSM return - where traverseLHSM = traverseLHSExprsM traverseExprM + where traverseLHSM = traverseNestedLHSsM $ traverseLHSExprsM traverseExprM traverseGenItemM :: GenItem -> SC GenItem traverseGenItemM = traverseGenItemExprsM traverseExprM diff --git a/test/core/typename_lhs_nest.sv b/test/core/typename_lhs_nest.sv new file mode 100644 index 00000000..6bfb8c09 --- /dev/null +++ b/test/core/typename_lhs_nest.sv @@ -0,0 +1,12 @@ +module top; + logic x; + logic [2:0] y; + for (genvar i = 0; i < 3; i++) begin : blk + wire w; + assign y[i] = w; + end + localparam type T = enum int { K = 0 }; + assign blk[K].w = 1; + assign blk[$bits(x)].w = 1; + assign blk[$bits(T) - 30].w = 1; +endmodule diff --git a/test/core/typename_lhs_nest.v b/test/core/typename_lhs_nest.v new file mode 100644 index 00000000..9b8ea764 --- /dev/null +++ b/test/core/typename_lhs_nest.v @@ -0,0 +1,5 @@ +module top; + wire x; + wire [2:0] y; + assign y = 1'sb1; +endmodule