mirror of https://github.com/zachjs/sv2v.git
basic support for elaboration system tasks
This commit is contained in:
parent
1078603bfd
commit
2d034dcb73
|
|
@ -116,14 +116,33 @@ parseDTsAsPortDecls pieces =
|
|||
parseDTsAsModuleItems :: [DeclToken] -> [ModuleItem]
|
||||
parseDTsAsModuleItems tokens =
|
||||
forbidNonEqAsgn tokens $
|
||||
if any isInstance tokens
|
||||
then parseDTsAsIntantiations tokens
|
||||
else map (MIPackageItem . Decl) $ parseDTsAsDecl tokens
|
||||
if isElabTask $ head tokens then
|
||||
asElabTask tokens
|
||||
else if any isInstance tokens then
|
||||
parseDTsAsIntantiations tokens
|
||||
else
|
||||
map (MIPackageItem . Decl) $ parseDTsAsDecl tokens
|
||||
where
|
||||
isElabTask :: DeclToken -> Bool
|
||||
isElabTask (DTIdent x) = elem x elabTasks
|
||||
where elabTasks = ["$fatal", "$error", "$warning", "$info"]
|
||||
isElabTask _ = False
|
||||
isInstance :: DeclToken -> Bool
|
||||
isInstance (DTInstance _) = True
|
||||
isInstance _ = False
|
||||
|
||||
-- internal; approximates the behavior of the elaboration system tasks
|
||||
asElabTask :: [DeclToken] -> [ModuleItem]
|
||||
asElabTask [DTIdent name, DTInstance args] =
|
||||
if name == "$info"
|
||||
then [] -- just drop them for simplicity
|
||||
else [Instance "ThisModuleDoesNotExist" [] name' Nothing args]
|
||||
where name' = "__sv2v_elab_" ++ tail name
|
||||
asElabTask [DTIdent name] =
|
||||
asElabTask [DTIdent name, DTInstance []]
|
||||
asElabTask tokens =
|
||||
error $ "could not parse elaboration system task: " ++ show tokens
|
||||
|
||||
|
||||
-- internal; parser for module instantiations
|
||||
parseDTsAsIntantiations :: [DeclToken] -> [ModuleItem]
|
||||
|
|
@ -142,7 +161,8 @@ parseDTsAsIntantiations (DTIdent name : tokens) =
|
|||
[DTIdent a, DTRange (NonIndexed, s), DTInstance b] ->
|
||||
(a, Just s , b)
|
||||
[DTIdent a, DTInstance b] -> (a, Nothing, b)
|
||||
_ -> error $ "unrecognized instantiation: " ++ show inst
|
||||
_ -> error $ "unrecognized instantiation of " ++ name
|
||||
++ ": " ++ show inst
|
||||
follow = x `seq` if null toks' then [] else step (tail toks')
|
||||
(params, rest) =
|
||||
case head tokens of
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
module top;
|
||||
if (1 == 0)
|
||||
wire foo;
|
||||
else
|
||||
$info("foo");
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
module top;
|
||||
endmodule
|
||||
Loading…
Reference in New Issue