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

Language | Haskell2010 |

The Signal module serves as a representation for the combined shallow and
deep embeddings of sequential circuits. The shallow portion is reprented as a
stream, the deep portion as a (typed) entity. To allow for multiple clock
domains, the Signal type includes an extra type parameter. The type alias `Seq`

is for sequential logic in some implicit global clock domain.

- data Signal (c :: *) a = Signal (Stream (X a)) (D a)
- type Seq a = Signal CLK a
- shallowS :: Signal c a -> Stream (X a)
- deepS :: Signal c a -> D a
- deepMapS :: (D a -> D a) -> Signal c a -> Signal c a
- shallowMapS :: (Stream (X a) -> Stream (X a)) -> Signal c a -> Signal c a
- pureS :: Rep a => a -> Signal i a
- witnessS :: Rep a => Witness a -> Signal i a -> Signal i a
- mkDeepS :: D a -> Signal c a
- mkShallowS :: Clock c => Stream (X a) -> Signal c a
- undefinedS :: forall a sig clk. (Rep a, sig ~ Signal clk) => sig a
- commentS :: forall a sig clk. (Rep a, sig ~ Signal clk) => String -> sig a -> sig a
- idS :: forall a sig clk. (Rep a, sig ~ Signal clk) => Id -> sig a -> sig a
- primXS :: Rep a => X a -> String -> Signal i a
- primXS1 :: forall a b i. (Rep a, Rep b) => (X a -> X b) -> String -> Signal i a -> Signal i b
- primXS2 :: forall a b c i. (Rep a, Rep b, Rep c) => (X a -> X b -> X c) -> String -> Signal i a -> Signal i b -> Signal i c
- primXS3 :: forall a b c d i. (Rep a, Rep b, Rep c, Rep d) => (X a -> X b -> X c -> X d) -> String -> Signal i a -> Signal i b -> Signal i c -> Signal i d
- primS :: Rep a => a -> String -> Signal i a
- primS1 :: (Rep a, Rep b) => (a -> b) -> String -> Signal i a -> Signal i b
- primS2 :: (Rep a, Rep b, Rep c) => (a -> b -> c) -> String -> Signal i a -> Signal i b -> Signal i c
- primS3 :: (Rep a, Rep b, Rep c, Rep d) => (a -> b -> c -> d) -> String -> Signal i a -> Signal i b -> Signal i c -> Signal i d
- toS :: (Clock c, Rep a) => [a] -> Signal c a
- toS' :: (Clock c, Rep a) => [Maybe a] -> Signal c a
- toSX :: forall a c. (Clock c, Rep a) => [X a] -> Signal c a
- fromS :: Rep a => Signal c a -> [Maybe a]
- fromSX :: Rep a => Signal c a -> [X a]
- takeS :: (Rep a, Clock c) => Int -> Signal c a -> Signal c a
- cmpSignalRep :: forall a c. Rep a => Int -> Signal c a -> Signal c a -> Bool
- typeOfS :: forall w clk sig. (Rep w, sig ~ Signal clk) => sig w -> Type
- class Pack clk a where
- type Unpacked clk a

- mapPacked :: (Pack i a, Pack i b, sig ~ Signal i) => (Unpacked i a -> Unpacked i b) -> sig a -> sig b
- zipPacked :: (Pack i a, Pack i b, Pack i c, sig ~ Signal i) => (Unpacked i a -> Unpacked i b -> Unpacked i c) -> sig a -> sig b -> sig c
- unpackMatrix :: (Rep a, Size x, sig ~ Signal clk) => sig (Matrix x a) -> Matrix x (sig a)
- packMatrix :: (Rep a, Size x, sig ~ Signal clk) => Matrix x (sig a) -> sig (Matrix x a)
- delay :: forall a clk. (Rep a, Clock clk) => Signal clk a -> Signal clk a
- delays :: forall a clk. (Rep a, Clock clk) => Int -> Signal clk a -> Signal clk a
- register :: forall a clk. (Rep a, Clock clk) => a -> Signal clk a -> Signal clk a
- registers :: forall a clk. (Rep a, Clock clk) => Int -> a -> Signal clk a -> Signal clk a
- entityD :: forall a. Rep a => String -> D a
- entityD1 :: forall a1 a. (Rep a, Rep a1) => String -> D a1 -> D a
- entityD2 :: forall a1 a2 a. (Rep a, Rep a1, Rep a2) => String -> D a1 -> D a2 -> D a
- entityD3 :: forall a1 a2 a3 a. (Rep a, Rep a1, Rep a2, Rep a3) => String -> D a1 -> D a2 -> D a3 -> D a
- pureD :: Rep a => a -> D a
- pureXD :: Rep a => X a -> D a

# Documentation

data Signal (c :: *) a Source #

These are sequences of values over time. We assume edge triggered logic (checked at (typically) rising edge of clock) This clock is assumed known, based on who is consuming the list. Right now, it is global, but we think we can support multiple clocks with a bit of work.

(Bounded a, Rep a) => Bounded (Signal i a) Source # | |

(Rep a, Enum a) => Enum (Signal i a) Source # | |

(Rep a, Eq a) => Eq (Signal c a) Source # | |

(Eq a, Show a, Fractional a, Rep a) => Fractional (Signal i a) Source # | |

(Rep a, Integral a) => Integral (Signal i a) Source # | |

(Num a, Rep a) => Num (Signal i a) Source # | |

(Ord a, Rep a) => Ord (Signal i a) Source # | |

(Rep a, Real a) => Real (Signal i a) Source # | |

Rep a => Show (Signal c a) Source # | |

(Show a, Bits a, Rep a) => Bits (Signal i a) Source # | |

(Show a, FiniteBits a, Rep a) => FiniteBits (Signal i a) Source # | |

Dual (Signal c a) Source # | |

witnessS :: Rep a => Witness a -> Signal i a -> Signal i a Source #

A `Signal`

witness identity function. Useful when typing things.

mkDeepS :: D a -> Signal c a Source #

Inject a deep value into a Signal. The shallow portion of the Signal will be an error, if it is every used.

mkShallowS :: Clock c => Stream (X a) -> Signal c a Source #

Inject a shallow value into a Signal. The deep portion of the Signal will be an Error if it is ever used.

undefinedS :: forall a sig clk. (Rep a, sig ~ Signal clk) => sig a Source #

Create a Signal with undefined for both the deep and shallow elements.

commentS :: forall a sig clk. (Rep a, sig ~ Signal clk) => String -> sig a -> sig a Source #

Attach a comment to a `Signal`

.

primXS :: Rep a => X a -> String -> Signal i a Source #

create a zero-arity Signal value from an `X`

value.

primXS1 :: forall a b i. (Rep a, Rep b) => (X a -> X b) -> String -> Signal i a -> Signal i b Source #

create an arity-1 Signal function from an `X`

function.

primXS2 :: forall a b c i. (Rep a, Rep b, Rep c) => (X a -> X b -> X c) -> String -> Signal i a -> Signal i b -> Signal i c Source #

create an arity-2 Signal function from an `X`

function.

primXS3 :: forall a b c d i. (Rep a, Rep b, Rep c, Rep d) => (X a -> X b -> X c -> X d) -> String -> Signal i a -> Signal i b -> Signal i c -> Signal i d Source #

create an arity-3 Signal function from an `X`

function.

primS1 :: (Rep a, Rep b) => (a -> b) -> String -> Signal i a -> Signal i b Source #

create an arity-1 Signal function from a function.

primS2 :: (Rep a, Rep b, Rep c) => (a -> b -> c) -> String -> Signal i a -> Signal i b -> Signal i c Source #

create an arity-2 Signal function from a function.

primS3 :: (Rep a, Rep b, Rep c, Rep d) => (a -> b -> c -> d) -> String -> Signal i a -> Signal i b -> Signal i c -> Signal i d Source #

create an arity-3 Signal function from a function.

toS :: (Clock c, Rep a) => [a] -> Signal c a Source #

Convert a list of values into a Signal. The shallow portion of the resulting Signal will begin with the input list, then an infinite stream of X unknowns.

toS' :: (Clock c, Rep a) => [Maybe a] -> Signal c a Source #

Convert a list of values into a Signal. The input list is wrapped with a Maybe, and any Nothing elements are mapped to X's unknowns.

toSX :: forall a c. (Clock c, Rep a) => [X a] -> Signal c a Source #

Convert a list of X values to a Signal. Pad the end with an infinite list of X unknowns.

fromS :: Rep a => Signal c a -> [Maybe a] Source #

Convert a Signal of values into a list of Maybe values.

fromSX :: Rep a => Signal c a -> [X a] Source #

Convret a Signal of values into a list of representable values.

takeS :: (Rep a, Clock c) => Int -> Signal c a -> Signal c a Source #

take the first n elements of a `Signal`

; the rest is undefined.

cmpSignalRep :: forall a c. Rep a => Int -> Signal c a -> Signal c a -> Bool Source #

Compare the first depth elements of two Signals.

typeOfS :: forall w clk sig. (Rep w, sig ~ Signal clk) => sig w -> Type Source #

Return the Lava type of a representable signal.

class Pack clk a where Source #

The Pack class allows us to move between signals containing compound data and signals containing the elements of the compound data. This is done by commuting the signal type constructor with the type constructor representing the compound data. For example, if we have a value x :: Signal sig => sig (a,b), then 'unpack x' converts this to a (sig a, sig b). Dually, pack takes (sig a,sig b) to sig (a,b).

mapPacked :: (Pack i a, Pack i b, sig ~ Signal i) => (Unpacked i a -> Unpacked i b) -> sig a -> sig b Source #

Given a function over unpacked (composite) signals, turn it into a function over packed signals.

zipPacked :: (Pack i a, Pack i b, Pack i c, sig ~ Signal i) => (Unpacked i a -> Unpacked i b -> Unpacked i c) -> sig a -> sig b -> sig c Source #

Lift a binary function operating over unpacked signals into a function over a pair of packed signals.

delay :: forall a clk. (Rep a, Clock clk) => Signal clk a -> Signal clk a Source #

a delay is a register with no defined default / initial value.

delays :: forall a clk. (Rep a, Clock clk) => Int -> Signal clk a -> Signal clk a Source #

delays generates a serial sequence of n delays.

register :: forall a clk. (Rep a, Clock clk) => a -> Signal clk a -> Signal clk a Source #

A register is a state element with a reset. The reset is supplied by the clock domain in the Signal.

registers :: forall a clk. (Rep a, Clock clk) => Int -> a -> Signal clk a -> Signal clk a Source #

registers generates a serial sequence of n registers, all with the same initial value.