Commit fabdc084 by Zachary Snow

fix package resolution of nested typedefs (resolves #11)

parent 737791ae
......@@ -83,11 +83,14 @@ prefixPackageItem packageName idents item =
Decl (Parameter a x b) -> Decl (Parameter a (prefix x) b)
Decl (Localparam a x b) -> Decl (Localparam a (prefix x) b)
other -> other
convertType (Alias Nothing x rs) = Alias Nothing (prefix x) rs
convertType other = other
convertExpr (Ident x) = Ident $ prefix x
convertExpr other = other
convertLHS (LHSIdent x) = LHSIdent $ prefix x
convertLHS other = other
converter =
(traverseTypes $ traverseNestedTypes convertType) .
(traverseExprs $ traverseNestedExprs convertExpr) .
(traverseLHSs $ traverseNestedLHSs convertLHS )
MIPackageItem item'' = converter $ MIPackageItem item'
......@@ -137,7 +140,7 @@ traverseModuleItem existingItemNames packages (MIPackageItem (Import x y)) =
traverseModuleItem _ _ item =
(traverseExprs $ traverseNestedExprs traverseExpr) $
(traverseStmts traverseStmt) $
(traverseTypes traverseType) $
(traverseTypes $ traverseNestedTypes traverseType) $
item
where
......
package foo_pkg;
typedef struct packed {
logic [7:0] rsvd;
logic [7:0] parity;
} user_t;
typedef struct packed {
logic valid;
user_t user;
} inp_t;
typedef struct packed {
logic valid;
logic opcode;
} out_t;
endpackage
module top (
input foo_pkg::inp_t dat_i,
output foo_pkg::out_t dat_o
);
endmodule
module top (dat_i, dat_o);
input wire [16:0] dat_i;
output wire [1:0] dat_o;
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