Commit 4b5e3232 by Zachary Snow

support for localparam type

parent 9aa8d5a5
......@@ -147,22 +147,15 @@ convert files =
where
Part attrs extern kw ml m p items = part
m' = moduleInstanceName m typeMap
items' = map rewriteDecl items
rewriteDecl :: ModuleItem -> ModuleItem
rewriteDecl (MIPackageItem (Decl (ParamType Parameter x _))) =
MIPackageItem $ Typedef (typeMap' Map.! x) x
items' = map (traverseDecls rewriteDecl) items
rewriteDecl :: Decl -> Decl
rewriteDecl (ParamType Parameter x _) =
ParamType Localparam x (Just $ typeMap' Map.! x)
rewriteDecl other = other
explodedTypeMap = Map.mapWithKey prepareTypeIdents typeMap
typeMap' = Map.map fst explodedTypeMap
additionalParamItems = concatMap makeAddedParams $
Map.toList $ Map.map snd explodedTypeMap
-- TODO FIXME: Typedef conversion must be made to handle
-- ParamTypes!
-----items' = map (traverseDecls rewriteDecl) items
-----rewriteDecl :: Decl -> Decl
-----rewriteDecl (ParamType Parameter x _) =
----- ParamType Localparam x (Just $ typeMap Map.! x)
-----rewriteDecl other = other
makeAddedParams :: (Identifier, IdentSet) -> [ModuleItem]
makeAddedParams (paramName, identSet) =
......
......@@ -70,6 +70,10 @@ traverseDeclM decl = do
case decl' of
Variable{} -> return decl'
Param{} -> return decl'
ParamType Localparam x (Just t) -> do
t' <- traverseNestedTypesM traverseTypeM t
insertElem x t'
return $ CommentDecl $ "removed localparam type " ++ x
ParamType{} -> return decl'
CommentDecl{} -> return decl'
......
module top;
localparam type T = logic;
initial begin
$display("A %0d", $bits(T));
begin
localparam type T = logic [1:0];
$display("B %0d", $bits(T));
begin
localparam type T = T [1:0];
$display("C %0d", $bits(T));
end
$display("B %0d", $bits(T));
end
$display("A %0d", $bits(T));
end
endmodule
module top;
initial begin
$display("A %0d", 1);
$display("B %0d", 2);
$display("C %0d", 4);
$display("B %0d", 2);
$display("A %0d", 1);
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