Safe Haskell | None |
---|---|

Language | Haskell2010 |

- data Signal a
- signal :: a -> Signal a
- register :: a -> Signal a -> Signal a
- class Pack a where
- (<^) :: Applicative f => f a -> (a -> b -> c) -> f b -> f c
- (^>) :: Applicative f => (f a -> f b) -> f a -> f b
- simulate :: (Signal a -> Signal b) -> [a] -> [b]
- simulateP :: (Pack a, Pack b) => (SignalP a -> SignalP b) -> [a] -> [b]
- sample :: Signal a -> [a]
- sampleN :: Int -> Signal a -> [a]
- fromList :: [a] -> Signal a

# Implicitly clocked synchronous signal

A synchronized signal with samples of type `a`

, implicitly synchronized to
an unnamed global clock

# Basic circuit functions

signal :: a -> Signal a Source

Create a constant `Signal`

from a combinational value

`>>>`

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

Isomorphism between a `Signal`

of a product type (e.g. a tuple) and a
product type of `Signal`

s.

Instances of `Pack`

must satisfy the following laws:

pack . unpack =`id`

unpack . pack =`id`

Nothing

pack :: SignalP a -> Signal a Source

Example:

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

However:

pack :: Signal Bit -> Signal Bit

unpack :: Signal a -> SignalP a Source

Example:

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

However:

unpack :: Signal Bit -> Signal Bit

Pack Bool | |

Pack Double | |

Pack Float | |

Pack Int | |

Pack Integer | |

Pack () | |

Pack Bit | |

Pack (Maybe a) | |

Pack (Signed n) | |

Pack (Unsigned n) | |

Pack (Either a b) | |

Pack (a, b) | |

Pack (Vec n a) | |

Pack (a, b, c) | |

Pack (Fixed frac rep size) | |

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) |

(<^) :: 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)

`>>>`

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

(^>) :: 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)

`>>>`

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