blob: 337ad2e1c60c5ade6edf01eaa120c2b25a7ed9d9 (
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
60
61
62
63
64
65
|
{-|
Module : VeriFuzz.XST
Description : Xst (ise) simulator implementation.
Copyright : (c) 2018-2019, Yann Herklotz Grave
License : BSD-3
Maintainer : ymherklotz [at] gmail [dot] com
Stability : experimental
Portability : POSIX
Xst (ise) simulator implementation.
-}
{-# LANGUAGE QuasiQuotes #-}
module VeriFuzz.XST where
import Prelude hiding (FilePath)
import Shelly
import Text.Shakespeare.Text (st)
import VeriFuzz.CodeGen
import VeriFuzz.Internal
data Xst = Xst { xstPath :: {-# UNPACK #-} !FilePath
, netgenPath :: {-# UNPACK #-} !FilePath
}
deriving (Eq, Show)
instance Tool Xst where
toText _ = "xst"
instance Synthesisor Xst where
runSynth = runSynthXst
defaultXst :: Xst
defaultXst = Xst "xst" "netgen"
runSynthXst :: Xst -> SourceInfo -> FilePath -> Sh ()
runSynthXst sim (SourceInfo top src) outf = do
dir <- pwd
writefile xstFile $ xstSynthConfig top
writefile prjFile [st|verilog work "rtl.v"|]
writefile "rtl.v" $ genSource src
echoP "XST: run"
_ <- logger dir "xst" $ timeout (xstPath sim) ["-ifn", toTextIgnore xstFile]
echoP "XST: netgen"
_ <- logger dir "netgen" $ run
(netgenPath sim)
[ "-w"
, "-ofmt"
, "verilog"
, toTextIgnore $ modFile <.> "ngc"
, toTextIgnore outf
]
echoP "XST: clean"
noPrint $ run_
"sed"
[ "-i"
, "/^`ifndef/,/^`endif/ d; s/ *Timestamp: .*//;"
, toTextIgnore outf
]
echoP "XST: done"
where
modFile = fromText top
xstFile = modFile <.> "xst"
prjFile = modFile <.> "prj"
|