FuncRet.hs 822 Bytes
Newer Older
1 2 3
{- sv2v
 - Author: Zachary Snow <zach@zachjs.com>
 -
4
 - Conversion which makes function `logic` and `reg` return types implicit
5 6 7
 -
 - Verilog-2005 restricts function return types to `integer`, `real`,
 - `realtime`, `time`, and implicit signed/dimensioned types.
8 9 10 11 12 13 14
 -}

module Convert.FuncRet (convert) where

import Convert.Traverse
import Language.SystemVerilog.AST

15 16
convert :: [AST] -> [AST]
convert = map $ traverseDescriptions $ traverseModuleItems convertFunction
17 18

convertFunction :: ModuleItem -> ModuleItem
19 20 21 22
convertFunction (MIPackageItem (Function ml t f decls stmts)) =
    MIPackageItem $ Function ml t' f decls stmts
    where
        t' = case t of
23 24
            IntegerVector TReg   sg rs -> Implicit sg rs
            IntegerVector TLogic sg rs -> Implicit sg rs
25
            _ -> t
26
convertFunction other = other