2019-02-18 05:39:01 +01:00
|
|
|
{- sv2v
|
|
|
|
|
- Author: Zachary Snow <zach@zachjs.com>
|
|
|
|
|
-
|
|
|
|
|
- SystemVerilog to Verilog conversion
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
module Convert (convert) where
|
|
|
|
|
|
|
|
|
|
import Language.SystemVerilog.AST
|
|
|
|
|
|
2019-02-18 07:38:16 +01:00
|
|
|
import qualified Convert.AlwaysKW
|
|
|
|
|
import qualified Convert.Logic
|
2019-02-18 09:59:17 +01:00
|
|
|
import qualified Convert.Typedef
|
2019-02-18 05:39:01 +01:00
|
|
|
|
2019-02-18 09:59:17 +01:00
|
|
|
type Phase = AST -> AST
|
2019-02-18 05:39:01 +01:00
|
|
|
|
2019-02-18 07:38:16 +01:00
|
|
|
phases :: [Phase]
|
|
|
|
|
phases =
|
|
|
|
|
[ Convert.AlwaysKW.convert
|
|
|
|
|
, Convert.Logic.convert
|
2019-02-18 09:59:17 +01:00
|
|
|
, Convert.Typedef.convert
|
2019-02-18 07:38:16 +01:00
|
|
|
]
|
2019-02-18 05:39:01 +01:00
|
|
|
|
2019-02-18 07:38:16 +01:00
|
|
|
run :: Phase
|
|
|
|
|
run = foldr (.) id phases
|
2019-02-18 05:39:01 +01:00
|
|
|
|
2019-02-18 07:38:16 +01:00
|
|
|
convert :: Phase
|
2019-02-18 09:59:17 +01:00
|
|
|
convert descriptions =
|
|
|
|
|
let descriptions' = run descriptions
|
2019-02-18 07:38:16 +01:00
|
|
|
in
|
2019-02-18 09:59:17 +01:00
|
|
|
if descriptions == descriptions'
|
|
|
|
|
then descriptions
|
|
|
|
|
else convert descriptions'
|