clash-prelude-0.4: CAES Language for Synchronous Hardware - Prelude library

Safe HaskellNone
LanguageHaskell2010

CLaSH.Signal

Synopsis

Documentation

data Signal a Source

A synchronized signal with elements of type a

Instances

sample :: Signal a -> [a] Source

Get an infinite list of samples from a Signal

The elements in the list correspond to the values of the Signal at consecutive clock cycles

sample s == [s0, s1, s2, s3, ...

sampleN :: Int -> Signal a -> [a] Source

Get a list of n samples from a Signal

The elements in the list correspond to the values of the Signal at consecutive clock cycles

sampleN 3 s == [s0, s1, s2]

fromList :: [a] -> Signal a Source

Create a Signal from a list

Every element in the list will correspond to a value of the signal for one clock cycle.

sampleN 2 (fromList [1,2,3,4,5]) == [1,2]

signal :: a -> Signal a Source

Create a constant Signal from a combinational value

sample (signal 4) == [4, 4, 4, 4, ...

register :: a -> Signal a -> Signal a Source

register i s delays the values in Signal s for one cycle, and sets the value at time 0 to i

sampleN 3 (register 8 (fromList [1,2,3,4])) == [8,1,2]

simulate :: (Signal a -> Signal b) -> [a] -> [b] Source

Simulate a (Signal -> Signal) function given a list of samples

simulate (register 8) [1, 2, 3, ... == [8, 1, 2, 3, ...

class Pack a where Source

Conversion between a Signal of a product type (e.g. a tuple) and a product type of Signals

Associated Types

type SignalP a Source

Methods

pack :: SignalP a -> Signal a Source

pack :: (Signal a, Signal b) -> Signal (a,b)

However:

pack :: Signal Bit -> Signal Bit

unpack :: Signal a -> SignalP a Source

unpack :: Signal (a,b) -> (Signal a, Signal b)

However:

unpack :: Signal Bit -> Signal Bit

Instances

Pack Bool 
Pack Double 
Pack Float 
Pack Int 
Pack Integer 
Pack () 
Pack Bit 
Pack (Signed n) 
Pack (Unsigned n) 
Pack (a, b) 
Pack (Vec n a) 
Pack (UFixed i f) 
Pack (SFixed i f) 
Pack (a, b, c) 
Pack (a, b, c, d) 
Pack (a, b, c, d, e) 
Pack (a, b, c, d, e, f) 
Pack (a, b, c, d, e, f, g) 
Pack (a, b, c, d, e, f, g, h) 

simulateP :: (Pack a, Pack b) => (SignalP a -> SignalP b) -> [a] -> [b] Source

Simulate a (SignalP -> SignalP) function given a list of samples

simulateP (unpack . register (8,8) . pack) [(1,1), (2,2), (3,3), ... == [(8,8), (1,1), (2,2), (3,3), ...

(<^) :: Applicative f => f a -> (a -> b -> c) -> f b -> f c Source

Operator lifting, use in conjunction with '(^>)'

add2 :: Signal Int -> Signal Int
add2 x = x <^(+)^> (signal 2)

simulate add2 [1,2,3,... == [3,4,5,...

(^>) :: Applicative f => (f a -> f b) -> f a -> f b Source

Operator lifting, use in conjunction with '(<^)'

add2 :: Signal Int -> Signal Int
add2 x = x <^(+)^> (signal 2)

simulate add2 [1,2,3,... == [3,4,5,...