Commit 682620b2 by Zachary Snow

struct conversion includes exprs in decls

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