aboutsummaryrefslogtreecommitdiffstats
path: root/src/VeriFuzz/Sim/XST.hs
diff options
context:
space:
mode:
authorYann Herklotz <git@ymhg.org>2019-04-02 19:47:32 +0100
committerYann Herklotz <git@ymhg.org>2019-04-02 19:47:32 +0100
commitfd4b0b5152f94cd406f2e5de86ce7ed0a4d2cbd0 (patch)
tree673439d49fa095bf3ae9b7bbbca5f30d7ff20838 /src/VeriFuzz/Sim/XST.hs
parentc0c799ab3f79c370e4c33b8f824489ce8b1c96ec (diff)
downloadverismith-fd4b0b5152f94cd406f2e5de86ce7ed0a4d2cbd0.tar.gz
verismith-fd4b0b5152f94cd406f2e5de86ce7ed0a4d2cbd0.zip
Large refactor with passing tests
Diffstat (limited to 'src/VeriFuzz/Sim/XST.hs')
-rw-r--r--src/VeriFuzz/Sim/XST.hs70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/VeriFuzz/Sim/XST.hs b/src/VeriFuzz/Sim/XST.hs
new file mode 100644
index 0000000..359b587
--- /dev/null
+++ b/src/VeriFuzz/Sim/XST.hs
@@ -0,0 +1,70 @@
+{-|
+Module : VeriFuzz.Sim.XST
+Description : XST (ise) simulator implementation.
+Copyright : (c) 2018-2019, Yann Herklotz
+License : BSD-3
+Maintainer : ymherklotz [at] gmail [dot] com
+Stability : experimental
+Portability : POSIX
+
+XST (ise) simulator implementation.
+-}
+
+{-# LANGUAGE QuasiQuotes #-}
+
+module VeriFuzz.Sim.XST
+ ( XST(..)
+ , defaultXST
+ )
+where
+
+import Prelude hiding (FilePath)
+import Shelly
+import Text.Shakespeare.Text (st)
+import VeriFuzz.Sim.Internal
+import VeriFuzz.Sim.Template
+import VeriFuzz.Verilog.CodeGen
+
+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"