mirror of https://github.com/zachjs/sv2v.git
Basic build setup!
This commit is contained in:
parent
b46009af53
commit
8bd58e961f
|
|
@ -8,7 +8,6 @@ module Data.BitVec
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.Bits
|
import Data.Bits
|
||||||
import Data.Semigroup
|
|
||||||
|
|
||||||
data BitVec = BitVec Int Integer deriving (Show, Eq)
|
data BitVec = BitVec Int Integer deriving (Show, Eq)
|
||||||
|
|
||||||
|
|
@ -18,13 +17,13 @@ instance Num BitVec where
|
||||||
BitVec w1 v1 * BitVec w2 v2 = bitVec (max w1 w2) (v1 * v2)
|
BitVec w1 v1 * BitVec w2 v2 = bitVec (max w1 w2) (v1 * v2)
|
||||||
abs = id
|
abs = id
|
||||||
signum (BitVec _ v) = if v == 0 then bitVec 1 0 else bitVec 1 1
|
signum (BitVec _ v) = if v == 0 then bitVec 1 0 else bitVec 1 1
|
||||||
fromInteger i = bitVec (width i) i
|
fromInteger i = bitVec (wid i) i
|
||||||
where
|
where
|
||||||
width :: Integer -> Int
|
wid :: Integer -> Int
|
||||||
width a
|
wid a
|
||||||
| a == 0 = 0
|
| a == 0 = 0
|
||||||
| a == -1 = 1
|
| a == -1 = 1
|
||||||
| otherwise = 1 + width (shiftR a 1)
|
| otherwise = 1 + wid (shiftR a 1)
|
||||||
|
|
||||||
instance Bits BitVec where
|
instance Bits BitVec where
|
||||||
BitVec w1 v1 .&. BitVec w2 v2 = bitVec (max w1 w2) (v1 .&. v2)
|
BitVec w1 v1 .&. BitVec w2 v2 = bitVec (max w1 w2) (v1 .&. v2)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
Lex.hs
|
||||||
|
Parse.hs
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
.PHONY: all sv2v clean
|
||||||
|
|
||||||
|
all: sv2v
|
||||||
|
|
||||||
|
Language/SystemVerilog/Parser/Lex.hs: Language/SystemVerilog/Parser/Lex.x
|
||||||
|
alex -g Language/SystemVerilog/Parser/Lex.x -o Language/SystemVerilog/Parser/Lex.hs
|
||||||
|
|
||||||
|
Language/SystemVerilog/Parser/Parse.hs: Language/SystemVerilog/Parser/Parse.y
|
||||||
|
happy -agc Language/SystemVerilog/Parser/Parse.y -o Language/SystemVerilog/Parser/Parse.hs
|
||||||
|
|
||||||
|
sv2v: Language/SystemVerilog/Parser/Lex.hs Language/SystemVerilog/Parser/Parse.hs
|
||||||
|
cabal install
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f Language/SystemVerilog/Parser/Lex.hs
|
||||||
|
rm -f Language/SystemVerilog/Parser/Parse.hs
|
||||||
|
|
@ -45,8 +45,11 @@ library
|
||||||
executable sv2v
|
executable sv2v
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
main-is: sv2v.hs
|
main-is: sv2v.hs
|
||||||
Build-Depends:
|
build-depends:
|
||||||
|
array,
|
||||||
base
|
base
|
||||||
|
other-modules:
|
||||||
|
Language.SystemVerilog.Parser
|
||||||
ghc-options:
|
ghc-options:
|
||||||
-O3
|
-O3
|
||||||
-threaded
|
-threaded
|
||||||
|
|
@ -58,4 +61,3 @@ executable sv2v
|
||||||
source-repository head
|
source-repository head
|
||||||
type: git
|
type: git
|
||||||
location: git://github.com/zachjs/sv2v.git
|
location: git://github.com/zachjs/sv2v.git
|
||||||
|
|
||||||
|
|
|
||||||
16
sv2v.hs
16
sv2v.hs
|
|
@ -1,15 +1,21 @@
|
||||||
{- sv2v
|
{- sv2v
|
||||||
Author: Zachary Snow <zach@zachjs.com>
|
- Author: Zachary Snow <zach@zachjs.com>
|
||||||
|
-
|
||||||
conversion entry point
|
- conversion entry point
|
||||||
-}
|
-}
|
||||||
|
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.Exit
|
import System.Exit
|
||||||
|
import System.Environment
|
||||||
|
|
||||||
|
import Language.SystemVerilog.Parser
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
let res = Left "unimplemented"
|
[filePath] <- getArgs
|
||||||
|
content <- readFile filePath
|
||||||
|
let ast = parseFile [] filePath content
|
||||||
|
let res = Left ast
|
||||||
case res of
|
case res of
|
||||||
Left err -> do
|
Left err -> do
|
||||||
hPrint stderr err
|
hPrint stderr err
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue