Commit 4ded2a59 by Zachary Snow

apply implicit port directions to tasks and functions

parent 61ccf3cb
......@@ -101,23 +101,6 @@ parseDTsAsPortDecls' pieces =
pieces' = filter (not . isAttr) pieces
propagateDirections :: Direction -> [Decl] -> [Decl]
propagateDirections dir (decl@(Variable _ InterfaceT{} _ _ _) : decls) =
decl : propagateDirections dir decls
propagateDirections lastDir (Variable currDir t x a e : decls) =
decl : propagateDirections dir decls
where
decl = Variable dir t x a e
dir = if currDir == Local then lastDir else currDir
propagateDirections lastDir (Net currDir n s t x a e : decls) =
decl : propagateDirections dir decls
where
decl = Net dir n s t x a e
dir = if currDir == Local then lastDir else currDir
propagateDirections dir (decl : decls) =
decl : propagateDirections dir decls
propagateDirections _ [] = []
portNames :: [Decl] -> [Identifier]
portNames = filter (not . null) . map portName
portName :: Decl -> Identifier
......@@ -141,6 +124,24 @@ parseDTsAsPortDecls' pieces =
wrapDecl :: [Attr] -> Decl -> ModuleItem
wrapDecl attrs decl = foldr MIAttr (MIPackageItem $ Decl decl) attrs
-- internal utility for carying forward port directions in a port list
propagateDirections :: Direction -> [Decl] -> [Decl]
propagateDirections dir (decl@(Variable _ InterfaceT{} _ _ _) : decls) =
decl : propagateDirections dir decls
propagateDirections lastDir (Variable currDir t x a e : decls) =
decl : propagateDirections dir decls
where
decl = Variable dir t x a e
dir = if currDir == Local then lastDir else currDir
propagateDirections lastDir (Net currDir n s t x a e : decls) =
decl : propagateDirections dir decls
where
decl = Net dir n s t x a e
dir = if currDir == Local then lastDir else currDir
propagateDirections dir (decl : decls) =
decl : propagateDirections dir decls
propagateDirections _ [] = []
-- internal utility for a simple list of port identifiers
parseDTsAsIdents :: [DeclToken] -> Maybe [Identifier]
parseDTsAsIdents [DTIdent _ x, DTEnd _ _] = Just [x]
......@@ -235,7 +236,7 @@ parseDTsAsIntantiation l0 delimTok =
-- [PUBLIC]: parser for comma-separated task/function port declarations
parseDTsAsTFDecls :: [DeclToken] -> [Decl]
parseDTsAsTFDecls = parseDTsAsDecls ModeDefault
parseDTsAsTFDecls = propagateDirections Input . parseDTsAsDecls ModeDefault
-- [PUBLIC]; used for "single" declarations, i.e., declarations appearing
......
module top;
task t(
integer inp,
output byte out1,
shortint out2
);
$display("t(inp = %0d)", inp);
out1 = inp;
out2 = inp;
endtask
initial begin
integer a;
byte b;
shortint c;
a = 5;
t(a, b, c);
$display("a = %0d, b = %0d, c = %0d", a, b, c);
end
endmodule
module top;
task t(
input reg [31:0] inp,
output reg [7:0] out1,
output reg [15:0] out2
);
begin
$display("t(inp = %0d)", inp);
out1 = inp;
out2 = inp;
end
endtask
initial begin : blk
reg [31:0] a;
reg [7:0] b;
reg [15:0] c;
a = 5;
t(a, b, c);
$display("a = %0d, b = %0d, c = %0d", a, b, c);
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