blob: 778918da7889989c81fdd4941b8dfbbdac578cc6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
{-|
Module : Test.VeriFuzz.Simulator.Yosys
Description : Yosys simulator implementation.
Copyright : (c) 2018-2019, Yann Herklotz Grave
License : BSD-3
Maintainer : ymherklotz [at] gmail [dot] com
Stability : experimental
Portability : POSIX
Yosys simulator implementation.
-}
{-# LANGUAGE QuasiQuotes #-}
module Test.VeriFuzz.Simulator.Yosys where
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
import Data.Text (Text)
import qualified Data.Text as T
import Prelude hiding (FilePath)
import Shelly
import Test.VeriFuzz.Simulator.General
import Test.VeriFuzz.Verilog.AST
import Test.VeriFuzz.Verilog.CodeGen
import Text.Shakespeare.Text (st)
data Yosys = Yosys { yosysPath :: FilePath }
instance Simulator Yosys where
toText _ = "yosys"
instance Simulate Yosys where
runSim = runSimYosys
instance Synthesize Yosys where
runSynth = runSynthYosys
writeSimFile :: Yosys -- ^ Simulator instance
-> ModDecl -- ^ Current module
-> FilePath -- ^ Output sim file
-> Sh ()
writeSimFile sim mod file = do
writefile "rtl.v" $ genSource mod
writefile file [st|read_verilog rtl.v; proc;;
rename mod mod_rtl
|]
runSimYosys :: Yosys -> ModDecl -> [ByteString] -> Sh Int
runSimYosys sim ver tb = return 0
runSynthYosys :: Yosys -> ModDecl -> FilePath -> Sh ()
runSynthYosys sim mod outf = do
writefile inpf $ genSource mod
run_ (yosysPath sim) ["-q", "-l", "synth.log", "-b", "verilog -noattr", "-o", out, "-S", inp]
where
inpf = "rtl.v"
inp = toTextIgnore inpf
out = toTextIgnore outf
|