Commit 682620b2 by Zachary Snow

struct conversion includes exprs in decls

parent 3baa9cba
......@@ -31,7 +31,7 @@ convertDescription (description @ Part{}) =
Part attrs extern kw lifetime name ports (items ++ funcs)
where
description' @ (Part attrs extern kw lifetime name ports items) =
scopedConversion (traverseDeclM structs) traverseModuleItemM
scopedConversion traverseDeclM' traverseModuleItemM
traverseStmtM tfArgTypes description
-- collect information about this description
structs = execWriter $ collectModuleItemsM
......@@ -45,6 +45,12 @@ convertDescription (description @ Part{}) =
funcs = map packerFn $ filter isNeeded $ Map.keys structs
isNeeded tf = Set.member (packerFnName tf) calledPackedFuncs
-- helpers for the scoped traversal
traverseDeclM' :: Decl -> State Types Decl
traverseDeclM' decl = do
decl' <- traverseDeclM structs decl
res <- traverseModuleItemM $ MIPackageItem $ Decl decl'
let MIPackageItem (Decl decl'') = res
return decl''
traverseModuleItemM :: ModuleItem -> State Types ModuleItem
traverseModuleItemM item =
traverseLHSsM traverseLHSM item >>=
......
......@@ -5,10 +5,20 @@ endpackage
package foo_pkg;
typedef struct packed {
logic valid;
logic value;
} mask_t;
typedef struct packed {
logic valid;
logic [top_pkg::AW-1:0] user;
mask_t mask;
} boo_t;
endpackage
module top;
foo_pkg::boo_t foo;
assign foo = 19'b110_01001000_01110100;
wire [7:0] bar;
parameter FLAG = 1;
assign bar = FLAG ? foo.user[0+:8] : '1;
endmodule
module top;
localparam AW = 16;
wire [16:0] foo;
wire [AW+2:0] foo;
assign foo = 19'b110_01001000_01110100;
wire [7:0] bar;
parameter FLAG = 1;
assign bar = FLAG ? foo[2+:8] : 8'hFF;
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