Commit 4ce177c0 by Zachary Snow

multipack conversion visits exprs within types

parent 9bab0448
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
### Bug Fixes ### Bug Fixes
* Fixed crash when converting multi-dimensional arrays or arrays of structs or
unions used in certain expressions involving unbased unsized literals
* Fixed module-level localparams being needlessly inlined when forming longest * Fixed module-level localparams being needlessly inlined when forming longest
static prefixes, which could cause deep recursion and run out of memory on static prefixes, which could cause deep recursion and run out of memory on
some designs some designs
......
...@@ -153,7 +153,14 @@ traverseLHSM = traverseNestedLHSsM traverseLHSSingleM ...@@ -153,7 +153,14 @@ traverseLHSM = traverseNestedLHSsM traverseLHSSingleM
return lhs' return lhs'
convertExprM :: Expr -> Scoper TypeInfo Expr convertExprM :: Expr -> Scoper TypeInfo Expr
convertExprM = embedScopes convertExpr convertExprM =
traverseExprTypesM convertTypeM >=>
embedScopes convertExpr
convertTypeM :: Type -> Scoper TypeInfo Type
convertTypeM =
traverseNestedTypesM $ traverseTypeExprsM $
traverseNestedExprsM convertExprM
convertExpr :: Scopes TypeInfo -> Expr -> Expr convertExpr :: Scopes TypeInfo -> Expr -> Expr
convertExpr scopes = convertExpr scopes =
......
module mod(inp, out);
parameter COUNT = 4;
typedef struct packed {
logic a, b, c;
} struct_t;
typedef union packed {
logic [2:0] raw;
struct_t fields;
} union_t;
input union_t [COUNT - 1:0] inp;
output logic [COUNT - 1:0] out;
for (genvar i = 0; i < COUNT; i += 1)
always_comb
if ((inp[i].raw & 3'b011) != '0)
out[i] = inp[i].fields.a ^ inp[i].fields.b;
endmodule
module mod(inp, out);
parameter COUNT = 1;
input wire [COUNT * 3 - 1:0] inp;
output reg [COUNT - 1:0] out;
genvar i;
generate
for (i = 0; i < COUNT; i = i + 1)
always @*
if (inp[i * 3] | inp[i * 3 + 1])
out[i] = inp[i * 3 + 2] ^ inp[i * 3 + 1];
endgenerate
endmodule
module top;
localparam COUNT = 4;
reg [COUNT * 3 - 1:0] inp;
wire [COUNT - 1:0] out;
mod #(COUNT) m(inp, out);
initial begin : blk
integer i;
$monitor("%2d %b %b", $time, inp, out);
for (i = 0; i < 2 ** (COUNT * 3); i = i + 1)
#1 inp = i;
end
endmodule
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