aboutsummaryrefslogtreecommitdiffstats
path: root/src/VeriFuzz/Icarus.hs
diff options
context:
space:
mode:
authorYann Herklotz Grave <git@yannherklotzgrave.com>2019-02-17 12:37:46 +0000
committerYann Herklotz Grave <git@yannherklotzgrave.com>2019-02-17 12:37:46 +0000
commit928a54419aeac611555b3c15493db00010cbb46e (patch)
tree576f1ca4ba287f03700b9526032126302c0474c1 /src/VeriFuzz/Icarus.hs
parent0ea6e208f2c3c41922f8334174fc8e81a21d67f4 (diff)
downloadverismith-928a54419aeac611555b3c15493db00010cbb46e.tar.gz
verismith-928a54419aeac611555b3c15493db00010cbb46e.zip
Indent by 4
Diffstat (limited to 'src/VeriFuzz/Icarus.hs')
-rw-r--r--src/VeriFuzz/Icarus.hs61
1 files changed, 32 insertions, 29 deletions
diff --git a/src/VeriFuzz/Icarus.hs b/src/VeriFuzz/Icarus.hs
index 45e932f..f848958 100644
--- a/src/VeriFuzz/Icarus.hs
+++ b/src/VeriFuzz/Icarus.hs
@@ -52,21 +52,24 @@ defaultIcarus = Icarus "iverilog" "vvp"
addDisplay :: [Stmnt] -> [Stmnt]
addDisplay s = concat $ transpose
- [s, replicate l $ TimeCtrl 1 Nothing, replicate l . SysTaskEnable $ Task "display" ["%b", Id "y"]]
- where l = length s
+ [ s
+ , replicate l $ TimeCtrl 1 Nothing
+ , replicate l . SysTaskEnable $ Task "display" ["%b", Id "y"]
+ ]
+ where l = length s
assignFunc :: [Port] -> ByteString -> Stmnt
assignFunc inp bs = NonBlockAssign . Assign conc Nothing . Number (B.length bs * 8) $ bsToI bs
- where conc = RegConcat (portToExpr <$> inp)
+ where conc = RegConcat (portToExpr <$> inp)
convert :: Text -> ByteString
convert =
- toStrict
- . (encode :: Integer -> L.ByteString)
- . maybe 0 fst
- . listToMaybe
- . readInt 2 (`elem` ("01" :: String)) digitToInt
- . T.unpack
+ toStrict
+ . (encode :: Integer -> L.ByteString)
+ . maybe 0 fst
+ . listToMaybe
+ . readInt 2 (`elem` ("01" :: String)) digitToInt
+ . T.unpack
mask :: Text -> Text
mask = T.replace "x" "0"
@@ -76,26 +79,26 @@ callback b t = b <> convert (mask t)
runSimIcarus :: Icarus -> ModDecl -> [ByteString] -> Sh ByteString
runSimIcarus sim m bss = do
- let tb = ModDecl
- "main"
- []
- []
- [ Initial
- $ fold (addDisplay $ assignFunc (m ^. modInPorts) <$> bss)
- <> (SysTaskEnable $ Task "finish" [])
- ]
- let newtb = instantiateMod m tb
- let modWithTb = VerilogSrc $ Description <$> [newtb, m]
- writefile "main.v" $ genSource modWithTb
- runSimWithFile sim "main.v" bss
+ let tb = ModDecl
+ "main"
+ []
+ []
+ [ Initial
+ $ fold (addDisplay $ assignFunc (m ^. modInPorts) <$> bss)
+ <> (SysTaskEnable $ Task "finish" [])
+ ]
+ let newtb = instantiateMod m tb
+ let modWithTb = VerilogSrc $ Description <$> [newtb, m]
+ writefile "main.v" $ genSource modWithTb
+ runSimWithFile sim "main.v" bss
runSimIcarusWithFile :: Icarus -> FilePath -> [ByteString] -> Sh ByteString
runSimIcarusWithFile sim f _ = do
- dir <- pwd
- echoP "Icarus: Compile"
- _ <- logger dir "icarus" $ run (icarusPath sim) ["-o", "main", toTextIgnore f]
- echoP "Icarus: Run"
- B.take 8 . BA.convert . (hash :: ByteString -> Digest SHA256) <$> logger
- dir
- "vvp"
- (runFoldLines (mempty :: ByteString) callback (vvpPath sim) ["main"])
+ dir <- pwd
+ echoP "Icarus: Compile"
+ _ <- logger dir "icarus" $ run (icarusPath sim) ["-o", "main", toTextIgnore f]
+ echoP "Icarus: Run"
+ B.take 8 . BA.convert . (hash :: ByteString -> Digest SHA256) <$> logger
+ dir
+ "vvp"
+ (runFoldLines (mempty :: ByteString) callback (vvpPath sim) ["main"])