aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYann Herklotz <git@ymhg.org>2019-04-03 17:30:43 +0100
committerYann Herklotz <git@ymhg.org>2019-04-03 17:30:43 +0100
commit3eb5b42c118c555aea736b5ca9b685ecdf72bd14 (patch)
treef70736b977c09594c8a32de809f2dc5eb43faba3 /src
parent9b4ff9bf2a5356b0603fe46cc45f9724bfbef341 (diff)
downloadverismith-3eb5b42c118c555aea736b5ca9b685ecdf72bd14.tar.gz
verismith-3eb5b42c118c555aea736b5ca9b685ecdf72bd14.zip
Add Vivado module
Diffstat (limited to 'src')
-rw-r--r--src/VeriFuzz/Sim/Template.hs12
-rw-r--r--src/VeriFuzz/Sim/Vivado.hs48
2 files changed, 60 insertions, 0 deletions
diff --git a/src/VeriFuzz/Sim/Template.hs b/src/VeriFuzz/Sim/Template.hs
index 5226106..bd58b83 100644
--- a/src/VeriFuzz/Sim/Template.hs
+++ b/src/VeriFuzz/Sim/Template.hs
@@ -16,6 +16,7 @@ module VeriFuzz.Sim.Template
( yosysSatConfig
, yosysSimConfig
, xstSynthConfig
+ , vivadoSynthConfig
, sbyConfig
)
where
@@ -74,6 +75,17 @@ xstSynthConfig top = [st|run
|]
-- brittany-disable-next-binding
+vivadoSynthConfig :: Text -> Text -> Text
+vivadoSynthConfig top outf = [st|
+# CRITICAL WARNING: [Synth 8-5821] Potential divide by zero
+set_msg_config -id {Synth 8-5821} -new_severity {WARNING}
+
+read_verilog rtl.v
+synth_design -part xc7k70t -top #{top}
+write_verilog -force #{outf}
+|]
+
+-- brittany-disable-next-binding
sbyConfig :: (Tool a, Tool b) => FilePath -> a -> Maybe b -> SourceInfo -> Text
sbyConfig bd sim1 sim2 (SourceInfo top src) = [st|[options]
mode prove
diff --git a/src/VeriFuzz/Sim/Vivado.hs b/src/VeriFuzz/Sim/Vivado.hs
new file mode 100644
index 0000000..fef0c83
--- /dev/null
+++ b/src/VeriFuzz/Sim/Vivado.hs
@@ -0,0 +1,48 @@
+{-|
+Module : VeriFuzz.Sim.Vivado
+Description : Vivado Synthesisor implementation.
+Copyright : (c) 2019, Yann Herklotz Grave
+License : GPL-3
+Maintainer : ymherklotz [at] gmail [dot] com
+Stability : experimental
+Portability : POSIX
+
+Vivado Synthesisor implementation.
+-}
+
+module VeriFuzz.Sim.Vivado
+ ( Vivado(..)
+ , defaultVivado
+ )
+where
+
+import Prelude hiding (FilePath)
+import Shelly
+import VeriFuzz.Sim.Internal
+import VeriFuzz.Sim.Template
+import VeriFuzz.Verilog.CodeGen
+
+newtype Vivado = Vivado { vivadoPath :: FilePath }
+ deriving (Eq, Show)
+
+instance Tool Vivado where
+ toText _ = "vivado"
+
+instance Synthesisor Vivado where
+ runSynth = runSynthVivado
+
+defaultVivado :: Vivado
+defaultVivado = Vivado "vivado"
+
+runSynthVivado :: Vivado -> SourceInfo -> FilePath -> Sh ()
+runSynthVivado sim (SourceInfo top src) outf = do
+ dir <- pwd
+ writefile vivadoTcl . vivadoSynthConfig top $ toTextIgnore outf
+ writefile "rtl.v" $ genSource src
+ echoP "Vivado: run"
+ logger_ dir "vivado"
+ $ timeout
+ (vivadoPath sim)
+ ["-mode", "batch", "-source", toTextIgnore vivadoTcl]
+ echoP "Vivado: done"
+ where vivadoTcl = "vivado_" <> fromText top <.> "tcl"