mirror of https://github.com/zachjs/sv2v.git
support for localparam type
This commit is contained in:
parent
9aa8d5a5d3
commit
4b5e3232b9
|
|
@ -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'
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
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
|
||||
Loading…
Reference in New Issue