File: Clock.hs

package info (click to toggle)
haskell-copilot 4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 164 kB
  • sloc: haskell: 631; makefile: 6
file content (28 lines) | stat: -rw-r--r-- 614 bytes parent folder | download | duplicates (2)
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
-- Copyright © 2019 National Institute of Aerospace / Galois, Inc.

-- | Example showing usage of clocks to generate periodically recurring truth
-- values.

module Main where

import Language.Copilot
import Copilot.Library.Clocks

-- | We need to force a type for the argument of `period`.
p :: Word8
p = 5

-- | Both have the same period, but a different phase.
clkStream :: Stream Bool
clkStream  = clk (period p) (phase 0)

clkStream' :: Stream Bool
clkStream' = clk (period p) (phase 2)

spec :: Spec
spec = do
  observer "clk"  clkStream
  observer "clk'" clkStream'

main :: IO ()
main = interpret 30 spec