|
| 1 | +module T1033 where |
| 2 | + |
| 3 | +import Clash.Explicit.Prelude |
| 4 | +import Clash.Prelude (HiddenClock, hasClock) |
| 5 | +import Data.List |
| 6 | +import System.Environment |
| 7 | +import System.FilePath |
| 8 | +import qualified Prelude as P |
| 9 | + |
| 10 | +{-# ANN topEntity |
| 11 | + (Synthesize |
| 12 | + { t_name = "top" |
| 13 | + , t_inputs = |
| 14 | + [ PortName "theHiddenClock" |
| 15 | + , PortProduct "en_int" [PortName "theEnable", PortName "a"] |
| 16 | + , PortProduct "int_int_rst" [PortName "b", PortProduct "int_rst" []] |
| 17 | + ] |
| 18 | + , t_output = PortName "theOutput" |
| 19 | + } |
| 20 | + )#-} |
| 21 | +topEntity |
| 22 | + :: ( dom ~ System -- Check whether Clash skips eq constraints |
| 23 | + , HiddenClock dom ) -- Hidden* consists of some construct and a |
| 24 | + -- KnownDomain. We don't want them to split off. |
| 25 | + => (Enable dom, Signal dom Int) |
| 26 | + -- ^ We do want Enable/Signal to be split |
| 27 | + -> (Signal dom Int, (Signal dom Int, Reset dom)) |
| 28 | + -- ^ And we want to do that recursively |
| 29 | + -> Signal dom Int |
| 30 | +topEntity (en, a) (b, (c, rst)) = |
| 31 | + register hasClock rst en 0 (a + b + c) |
| 32 | + |
| 33 | +assertIn :: String -> String -> IO () |
| 34 | +assertIn needle haystack |
| 35 | + | needle `isInfixOf` haystack = return () |
| 36 | + | otherwise = P.error $ P.concat [ "Expected:\n\n ", needle |
| 37 | + , "\n\nIn:\n\n", haystack ] |
| 38 | + |
| 39 | +-- VHDL test |
| 40 | +main :: FilePath -> IO () |
| 41 | +main topFile = do |
| 42 | + content <- readFile topFile |
| 43 | + |
| 44 | + assertIn "theHiddenClock" content |
| 45 | + assertIn "en_int_theEnable" content |
| 46 | + assertIn "en_int_a" content |
| 47 | + assertIn "int_int_rst_b" content |
| 48 | + assertIn "int_int_rst_int_rst_0" content |
| 49 | + assertIn "int_int_rst_int_rst_1" content |
| 50 | + |
| 51 | +mainVHDL :: IO () |
| 52 | +mainVHDL = do |
| 53 | + [topFile] <- getArgs |
| 54 | + main (replaceFileName topFile "top/top.vhdl") |
| 55 | + |
| 56 | +mainVerilog :: IO () |
| 57 | +mainVerilog = do |
| 58 | + [topFile] <- getArgs |
| 59 | + main (replaceFileName topFile "top/top.v") |
| 60 | + |
| 61 | +mainSystemVerilog :: IO () |
| 62 | +mainSystemVerilog = do |
| 63 | + [topFile] <- getArgs |
| 64 | + main (replaceFileName topFile "top/top.sv") |
0 commit comments