From fedd3efbe770630fc355223c5ced3faa54f435e5 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Fri, 28 Dec 2018 19:21:29 +0100 Subject: Add simulator module --- src/Test/VeriFuzz/Simulator/Yosys.hs | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/Test/VeriFuzz/Simulator/Yosys.hs (limited to 'src/Test/VeriFuzz/Simulator/Yosys.hs') diff --git a/src/Test/VeriFuzz/Simulator/Yosys.hs b/src/Test/VeriFuzz/Simulator/Yosys.hs new file mode 100644 index 0000000..33752c4 --- /dev/null +++ b/src/Test/VeriFuzz/Simulator/Yosys.hs @@ -0,0 +1,57 @@ +{-| +Module : Test.VeriFuzz.Simulator.Yosys +Description : Yosys simulator implementation. +Copyright : (c) Yann Herklotz Grave 2018 +License : GPL-3 +Maintainer : ymherklotz@gmail.com +Stability : experimental +Portability : POSIX + +Yosys simulator implementation. +-} + +{-# LANGUAGE QuasiQuotes #-} + +module Test.VeriFuzz.Simulator.Yosys where + +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 -> [Int] -> 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 -- cgit