mirror of https://github.com/zachjs/sv2v.git
support nested interfaces
This commit is contained in:
parent
c5ef5ea9e2
commit
f381476161
|
|
@ -22,11 +22,19 @@ type Modules = Map.Map Identifier [(Identifier, Type)]
|
|||
|
||||
convert :: [AST] -> [AST]
|
||||
convert =
|
||||
traverseFiles (collectDescriptionsM collectDesc) converter
|
||||
map (filter $ not . isInterface) .
|
||||
repeatedConverter
|
||||
where
|
||||
converter (interfaces, modules) =
|
||||
filter (not . isInterface) .
|
||||
map (convertDescription interfaces modules)
|
||||
repeatedConverter :: [AST] -> [AST]
|
||||
repeatedConverter files =
|
||||
if files == files'
|
||||
then files
|
||||
else repeatedConverter files'
|
||||
where
|
||||
files' =
|
||||
traverseFiles (collectDescriptionsM collectDesc)
|
||||
(map . uncurry convertDescription)
|
||||
files
|
||||
-- we can only collect/map non-extern interfaces
|
||||
collectDesc :: Description -> Writer (Interfaces, Modules) ()
|
||||
collectDesc (orig @ (Part _ False kw _ name ports items)) = do
|
||||
|
|
@ -216,8 +224,11 @@ prefixModuleItems prefix =
|
|||
prefixLHS :: LHS -> LHS
|
||||
prefixLHS (LHSIdent x) = LHSIdent (prefix x)
|
||||
prefixLHS other = other
|
||||
prefixOtherItem :: ModuleItem -> ModuleItem
|
||||
prefixOtherItem (MIPackageItem item) =
|
||||
MIPackageItem $ prefixPackageItem prefix item
|
||||
prefixOtherItem (Instance m params name rs ports) =
|
||||
Instance m params (prefix name) rs ports
|
||||
prefixOtherItem (Genvar x) = Genvar $ prefix x
|
||||
prefixOtherItem other = other
|
||||
|
||||
|
|
@ -235,6 +246,7 @@ prefixPackageItem _ other = other
|
|||
collectIdentsM :: ModuleItem -> Writer (Set.Set Identifier) ()
|
||||
collectIdentsM (MIPackageItem (Function _ _ x _ _)) = tell $ Set.singleton x
|
||||
collectIdentsM (MIPackageItem (Task _ x _ _)) = tell $ Set.singleton x
|
||||
collectIdentsM (Instance _ _ x _ _) = tell $ Set.singleton x
|
||||
collectIdentsM (Genvar x) = tell $ Set.singleton x
|
||||
collectIdentsM item = collectDeclsM collectDecl item
|
||||
where
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
module top;
|
||||
logic x = 1;
|
||||
foo f(x);
|
||||
endmodule
|
||||
|
||||
interface foo(input logic x);
|
||||
bar a(x);
|
||||
bar b(~x);
|
||||
endinterface
|
||||
|
||||
interface bar(input logic x);
|
||||
initial begin
|
||||
$display("bar got %b", x);
|
||||
end
|
||||
endinterface
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module top;
|
||||
wire x, f_x;
|
||||
wire f_a_x, f_b_x;
|
||||
assign x = 1;
|
||||
assign f_x = x;
|
||||
assign f_a_x = x;
|
||||
assign f_b_x = ~x;
|
||||
|
||||
initial begin
|
||||
$display("bar got %b", f_a_x);
|
||||
$display("bar got %b", f_b_x);
|
||||
end
|
||||
endmodule
|
||||
Loading…
Reference in New Issue