Unsigned.hs 844 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
{- sv2v
 - Author: Zachary Snow <zach@zachjs.com>
 -
 - Conversion for `unsigned` types.
 -
 - Verilog-2005 makes `reg`, `wire`, etc. unsigned by default. Further, it does
 - not have the `unsigned` keyword. This conversion ensures we either mark a
 - data type as `signed` or leave the signing unspecified.
 -}

module Convert.Unsigned (convert) where

import Convert.Traverse
import Language.SystemVerilog.AST

convert :: [AST] -> [AST]
convert =
    map $
    traverseDescriptions $
    traverseModuleItems $
21
    traverseTypes $ traverseNestedTypes convertType
22 23

convertType :: Type -> Type
24
convertType (Implicit        Unsigned rs) = Implicit        Unspecified rs
25 26 27
convertType (IntegerVector t Unsigned rs) = IntegerVector t Unspecified rs
convertType (Net           t Unsigned rs) = Net           t Unspecified rs
convertType other = other