Commit f3814761 by Zachary Snow

support nested interfaces

parent c5ef5ea9
...@@ -22,11 +22,19 @@ type Modules = Map.Map Identifier [(Identifier, Type)] ...@@ -22,11 +22,19 @@ type Modules = Map.Map Identifier [(Identifier, Type)]
convert :: [AST] -> [AST] convert :: [AST] -> [AST]
convert = convert =
traverseFiles (collectDescriptionsM collectDesc) converter map (filter $ not . isInterface) .
repeatedConverter
where where
converter (interfaces, modules) = repeatedConverter :: [AST] -> [AST]
filter (not . isInterface) . repeatedConverter files =
map (convertDescription interfaces modules) 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 -- we can only collect/map non-extern interfaces
collectDesc :: Description -> Writer (Interfaces, Modules) () collectDesc :: Description -> Writer (Interfaces, Modules) ()
collectDesc (orig @ (Part _ False kw _ name ports items)) = do collectDesc (orig @ (Part _ False kw _ name ports items)) = do
...@@ -216,8 +224,11 @@ prefixModuleItems prefix = ...@@ -216,8 +224,11 @@ prefixModuleItems prefix =
prefixLHS :: LHS -> LHS prefixLHS :: LHS -> LHS
prefixLHS (LHSIdent x) = LHSIdent (prefix x) prefixLHS (LHSIdent x) = LHSIdent (prefix x)
prefixLHS other = other prefixLHS other = other
prefixOtherItem :: ModuleItem -> ModuleItem
prefixOtherItem (MIPackageItem item) = prefixOtherItem (MIPackageItem item) =
MIPackageItem $ prefixPackageItem prefix 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 (Genvar x) = Genvar $ prefix x
prefixOtherItem other = other prefixOtherItem other = other
...@@ -235,6 +246,7 @@ prefixPackageItem _ other = other ...@@ -235,6 +246,7 @@ prefixPackageItem _ other = other
collectIdentsM :: ModuleItem -> Writer (Set.Set Identifier) () collectIdentsM :: ModuleItem -> Writer (Set.Set Identifier) ()
collectIdentsM (MIPackageItem (Function _ _ x _ _)) = tell $ Set.singleton x collectIdentsM (MIPackageItem (Function _ _ x _ _)) = tell $ Set.singleton x
collectIdentsM (MIPackageItem (Task _ 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 (Genvar x) = tell $ Set.singleton x
collectIdentsM item = collectDeclsM collectDecl item collectIdentsM item = collectDeclsM collectDecl item
where where
......
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
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
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