forked from clash-lang/clash-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClash.hs
More file actions
63 lines (51 loc) · 1.74 KB
/
Copy pathClash.hs
File metadata and controls
63 lines (51 loc) · 1.74 KB
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
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -Wno-unused-top-binds #-}
module Main where
#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,domainConfs) <- 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) domainConfs bindingsMap (Just b) primMap tcm tupTcm
(ghcTypeToHWType WORD_SIZE_IN_BITS True) evaluator topEntities Nothing
defClashOpts{opt_cachehdl = False, opt_dbgLevel = DebugSilent}
(startTime,prepTime)
main :: IO ()
main = genVHDL "./examples/FIR.hs"