mirror of https://github.com/zachjs/sv2v.git
fix package resolution of nested typedefs (resolves #11)
This commit is contained in:
parent
737791aebd
commit
fabdc08493
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module top (dat_i, dat_o);
|
||||
input wire [16:0] dat_i;
|
||||
output wire [1:0] dat_o;
|
||||
endmodule
|
||||
Loading…
Reference in New Issue