mirror of https://github.com/zachjs/sv2v.git
added single finish for all elaboration fatals
This commit is contained in:
parent
74b80c1552
commit
924defc319
|
|
@ -10,7 +10,39 @@ import Convert.Traverse
|
|||
import Language.SystemVerilog.AST
|
||||
|
||||
convert :: [AST] -> [AST]
|
||||
convert = map $ traverseDescriptions $ traverseModuleItems convertModuleItem
|
||||
convert = map $ traverseDescriptions traverseDescription
|
||||
|
||||
elaborationFatalIdent :: Identifier
|
||||
elaborationFatalIdent = "_sv2v_elaboration_fatal"
|
||||
|
||||
elaborationFatalCancelCode :: Expr
|
||||
elaborationFatalCancelCode = RawNum (-1)
|
||||
|
||||
elaborationFatalDecl :: ModuleItem
|
||||
elaborationFatalDecl = MIPackageItem $ Decl $ Variable Local t elaborationFatalIdent [] elaborationFatalCancelCode
|
||||
where t = IntegerAtom TInteger Unspecified
|
||||
|
||||
elaborationFatalCheck :: ModuleItem
|
||||
elaborationFatalCheck = Initial (Block Seq "" [] [
|
||||
zeroDelay,
|
||||
If NoCheck checkCancelCode finishCall Null
|
||||
]) where
|
||||
zeroDelay = Timing (Delay (RawNum 0)) Null
|
||||
checkCancelCode = BinOpA Ne [] (Ident elaborationFatalIdent) elaborationFatalCancelCode
|
||||
finishCall = Subroutine (Ident "$finish") (Args [(Ident elaborationFatalIdent)] [])
|
||||
|
||||
traverseDescription :: Description -> Description
|
||||
traverseDescription (Part att ext kw lif name pts items) =
|
||||
traverseModuleItems convertModuleItem $
|
||||
Part att ext kw lif name pts $
|
||||
if hasElaborationFatal
|
||||
then elaborationFatalDecl : items ++ [elaborationFatalCheck]
|
||||
else items
|
||||
where
|
||||
hasElaborationFatal = any isElabTaskFatal items
|
||||
isElabTaskFatal (ElabTask SeverityFatal _) = True
|
||||
isElabTaskFatal _ = False
|
||||
traverseDescription description = traverseModuleItems convertModuleItem description
|
||||
|
||||
convertModuleItem :: ModuleItem -> ModuleItem
|
||||
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ numberBitLength (Based size _ _ _ _) =
|
|||
then max 32 $ negate size
|
||||
else size
|
||||
|
||||
-- get whether or not a number is signed
|
||||
-- get whether or not a number is sized
|
||||
numberIsSized :: Number -> Bool
|
||||
numberIsSized UnbasedUnsized{} = False
|
||||
numberIsSized (Decimal size _ _) = size > 0
|
||||
|
|
@ -359,9 +359,7 @@ instance Show Number where
|
|||
show (UnbasedUnsized bit) =
|
||||
'\'' : show bit
|
||||
show (Decimal (-32) True value) =
|
||||
if value < 0
|
||||
then error $ "illegal decimal: " ++ show value
|
||||
else show value
|
||||
show value
|
||||
show (Decimal size signed value) =
|
||||
if size == 0
|
||||
then error $ "illegal decimal literal: "
|
||||
|
|
|
|||
Loading…
Reference in New Issue