2019-02-26 21:03:49 +01:00
|
|
|
{-# LANGUAGE DeriveDataTypeable #-}
|
|
|
|
|
{- sv2v
|
|
|
|
|
- Author: Zachary Snow <zach@zachjs.com>
|
|
|
|
|
-
|
|
|
|
|
- Command line arguments.
|
|
|
|
|
-}
|
|
|
|
|
|
2019-02-28 20:06:35 +01:00
|
|
|
module Job where
|
2019-02-26 21:03:49 +01:00
|
|
|
|
|
|
|
|
import System.Console.CmdArgs
|
|
|
|
|
|
2019-03-08 17:02:40 +01:00
|
|
|
data Exclude
|
|
|
|
|
= Always
|
|
|
|
|
| Interface
|
|
|
|
|
| Logic
|
2019-08-29 01:48:25 +02:00
|
|
|
| Succinct
|
2019-03-08 17:02:40 +01:00
|
|
|
deriving (Show, Typeable, Data, Eq)
|
2019-02-26 21:03:49 +01:00
|
|
|
|
|
|
|
|
data Job = Job
|
2019-03-08 17:02:40 +01:00
|
|
|
{ exclude :: [Exclude]
|
2019-03-29 00:55:53 +01:00
|
|
|
, files :: [FilePath]
|
|
|
|
|
, incdir :: [FilePath]
|
2019-04-02 22:19:59 +02:00
|
|
|
, define :: [String]
|
2019-08-06 04:00:04 +02:00
|
|
|
, oneunit :: Bool
|
2019-08-29 01:48:25 +02:00
|
|
|
, verbose :: Bool
|
2019-02-26 21:03:49 +01:00
|
|
|
} deriving (Show, Typeable, Data)
|
|
|
|
|
|
|
|
|
|
defaultJob :: Job
|
|
|
|
|
defaultJob = Job
|
2019-03-08 17:02:40 +01:00
|
|
|
{ exclude = [] &= typ "CONV"
|
2019-08-08 04:10:03 +02:00
|
|
|
&= help "exclude a particular conversion (always, interface, or logic)"
|
2019-03-29 00:55:53 +01:00
|
|
|
, files = def &= args &= typ "FILES"
|
|
|
|
|
, incdir = def &= typDir &= help "add directory to include search path"
|
2019-08-08 04:10:03 +02:00
|
|
|
, define = def &= typ "NAME[=VALUE]" &= help ("define a macro for"
|
|
|
|
|
++ " preprocessing")
|
|
|
|
|
, oneunit = False &= help ("put all files in one compilation unit, so"
|
|
|
|
|
++ " macros from earlier files remain defined in later files")
|
2019-08-29 01:48:25 +02:00
|
|
|
, verbose = False &= help "retain certain conversion artifacts"
|
2019-02-26 21:03:49 +01:00
|
|
|
}
|
|
|
|
|
&= program "sv2v"
|
2019-04-19 01:33:16 +02:00
|
|
|
&= summary "sv2v v0.0.1, (C) 2019 Zachary Snow, 2011-2015 Tom Hawkins"
|
2019-02-26 21:03:49 +01:00
|
|
|
&= details [ "sv2v converts SystemVerilog to Verilog."
|
|
|
|
|
, "More info: https://github.com/zachjs/sv2v" ]
|
|
|
|
|
|
2019-02-28 20:06:35 +01:00
|
|
|
readJob :: IO Job
|
2019-08-29 01:48:25 +02:00
|
|
|
readJob = do
|
|
|
|
|
job <- cmdArgs defaultJob
|
|
|
|
|
return $ if verbose job
|
|
|
|
|
then job { exclude = Succinct : exclude job }
|
|
|
|
|
else job
|