forked from clash-lang/clash-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClash.hs
61 lines (50 loc) · 1.69 KB
/
Clash.hs
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
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -Wno-unused-top-binds #-}
#include "MachDeps.h"
#define HDLSYN Other
import Clash.Driver
import Clash.Driver.Types
import Clash.GHC.Evaluator
import Clash.GHC.GenerateBindings
import Clash.GHC.NetlistTypes
import Clash.Backend
import Clash.Backend.SystemVerilog
import Clash.Backend.VHDL
import Clash.Backend.Verilog
import Clash.Netlist.BlackBox.Types
import Clash.Annotations.BitRepresentation.Internal (buildCustomReprs)
import Clash.Util
import Control.DeepSeq
import qualified Data.Time.Clock as Clock
import Util (OverridingBool(..))
genSystemVerilog
:: String
-> IO ()
genSystemVerilog = doHDL (initBackend WORD_SIZE_IN_BITS HDLSYN True Nothing :: SystemVerilogState)
genVHDL
:: String
-> IO ()
genVHDL = doHDL (initBackend WORD_SIZE_IN_BITS HDLSYN True Nothing :: VHDLState)
genVerilog
:: String
-> IO ()
genVerilog = doHDL (initBackend WORD_SIZE_IN_BITS HDLSYN True Nothing :: VerilogState)
doHDL
:: HasCallStack
=> Backend s
=> s
-> String
-> IO ()
doHDL b src = do
startTime <- Clock.getCurrentTime
pd <- primDirs b
(bindingsMap,tcm,tupTcm,topEntities,primMap,reprs) <- generateBindings Auto pd ["."] [] (hdlKind b) src Nothing
prepTime <- startTime `deepseq` bindingsMap `deepseq` tcm `deepseq` reprs `deepseq` Clock.getCurrentTime
let prepStartDiff = reportTimeDiff prepTime startTime
putStrLn $ "Loading dependencies took " ++ prepStartDiff
generateHDL (buildCustomReprs reprs) bindingsMap (Just b) primMap tcm tupTcm
(ghcTypeToHWType WORD_SIZE_IN_BITS True) reduceConstant topEntities
defClashOpts{opt_cachehdl = False, opt_dbgLevel = DebugSilent}
(startTime,prepTime)
main :: IO ()
main = genVHDL "./examples/FIR.hs"