kansas-lava-0.2.4.5: Kansas Lava is a hardware simulator and VHDL generator.

Safe Haskell None Haskell2010

Language.KansasLava.Signal

Description

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.

Synopsis

# 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.

Constructors

 Signal (Stream (X a)) (D a)

Instances

 (Bounded a, Rep a) => Bounded (Signal i a) Source # MethodsminBound :: Signal i a #maxBound :: Signal i a # (Rep a, Enum a) => Enum (Signal i a) Source # Methodssucc :: Signal i a -> Signal i a #pred :: Signal i a -> Signal i a #toEnum :: Int -> Signal i a #fromEnum :: Signal i a -> Int #enumFrom :: Signal i a -> [Signal i a] #enumFromThen :: Signal i a -> Signal i a -> [Signal i a] #enumFromTo :: Signal i a -> Signal i a -> [Signal i a] #enumFromThenTo :: Signal i a -> Signal i a -> Signal i a -> [Signal i a] # (Rep a, Eq a) => Eq (Signal c a) Source # Methods(==) :: Signal c a -> Signal c a -> Bool #(/=) :: Signal c a -> Signal c a -> Bool # (Eq a, Show a, Fractional a, Rep a) => Fractional (Signal i a) Source # Methods(/) :: Signal i a -> Signal i a -> Signal i a #recip :: Signal i a -> Signal i a #fromRational :: Rational -> Signal i a # (Rep a, Integral a) => Integral (Signal i a) Source # Methodsquot :: Signal i a -> Signal i a -> Signal i a #rem :: Signal i a -> Signal i a -> Signal i a #div :: Signal i a -> Signal i a -> Signal i a #mod :: Signal i a -> Signal i a -> Signal i a #quotRem :: Signal i a -> Signal i a -> (Signal i a, Signal i a) #divMod :: Signal i a -> Signal i a -> (Signal i a, Signal i a) #toInteger :: Signal i a -> Integer # (Num a, Rep a) => Num (Signal i a) Source # Methods(+) :: Signal i a -> Signal i a -> Signal i a #(-) :: Signal i a -> Signal i a -> Signal i a #(*) :: Signal i a -> Signal i a -> Signal i a #negate :: Signal i a -> Signal i a #abs :: Signal i a -> Signal i a #signum :: Signal i a -> Signal i a #fromInteger :: Integer -> Signal i a # (Ord a, Rep a) => Ord (Signal i a) Source # Methodscompare :: Signal i a -> Signal i a -> Ordering #(<) :: Signal i a -> Signal i a -> Bool #(<=) :: Signal i a -> Signal i a -> Bool #(>) :: Signal i a -> Signal i a -> Bool #(>=) :: Signal i a -> Signal i a -> Bool #max :: Signal i a -> Signal i a -> Signal i a #min :: Signal i a -> Signal i a -> Signal i a # (Rep a, Real a) => Real (Signal i a) Source # MethodstoRational :: Signal i a -> Rational # Rep a => Show (Signal c a) Source # MethodsshowsPrec :: Int -> Signal c a -> ShowS #show :: Signal c a -> String #showList :: [Signal c a] -> ShowS # (Show a, Bits a, Rep a) => Bits (Signal i a) Source # Methods(.&.) :: Signal i a -> Signal i a -> Signal i a #(.|.) :: Signal i a -> Signal i a -> Signal i a #xor :: Signal i a -> Signal i a -> Signal i a #complement :: Signal i a -> Signal i a #shift :: Signal i a -> Int -> Signal i a #rotate :: Signal i a -> Int -> Signal i a #zeroBits :: Signal i a #bit :: Int -> Signal i a #setBit :: Signal i a -> Int -> Signal i a #clearBit :: Signal i a -> Int -> Signal i a #complementBit :: Signal i a -> Int -> Signal i a #testBit :: Signal i a -> Int -> Bool #bitSizeMaybe :: Signal i a -> Maybe Int #bitSize :: Signal i a -> Int #isSigned :: Signal i a -> Bool #shiftL :: Signal i a -> Int -> Signal i a #unsafeShiftL :: Signal i a -> Int -> Signal i a #shiftR :: Signal i a -> Int -> Signal i a #unsafeShiftR :: Signal i a -> Int -> Signal i a #rotateL :: Signal i a -> Int -> Signal i a #rotateR :: Signal i a -> Int -> Signal i a #popCount :: Signal i a -> Int # (Show a, FiniteBits a, Rep a) => FiniteBits (Signal i a) Source # MethodsfiniteBitSize :: Signal i a -> Int #countLeadingZeros :: Signal i a -> Int #countTrailingZeros :: Signal i a -> Int # Dual (Signal c a) Source # Methodsdual :: Signal c a -> Signal c a -> Signal c a Source #

type Seq a = Signal CLK a Source #

Signal in some implicit clock domain.

shallowS :: Signal c a -> Stream (X a) Source #

Extract the shallow portion of a Signal.

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

Extract the deep portion of a Signal.

deepMapS :: (D a -> D a) -> Signal c a -> Signal c a Source #

shallowMapS :: (Stream (X a) -> Stream (X a)) -> Signal c a -> Signal c a Source #

pureS :: Rep a => a -> Signal i a Source #

A pure Signal.

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.

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

idS create an identity function, with a given Id tag.

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.

primS :: Rep a => a -> String -> Signal i a Source #

create a zero-arity Signal value from a value.

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

Minimal complete definition

Associated Types

type Unpacked clk a Source #

Pull the sig type *out* of the compound data type.

Methods

pack :: Unpacked clk a -> Signal clk a Source #

Push the sign type *into* the compound data type.

unpack :: Signal clk a -> Unpacked clk a Source #

Instances

 Rep a => Pack i (Maybe a) Source # Associated Typestype Unpacked i (Maybe a) :: * Source # Methodspack :: Unpacked i (Maybe a) -> Signal i (Maybe a) Source #unpack :: Signal i (Maybe a) -> Unpacked i (Maybe a) Source # (Rep a, Size ix) => Pack clk (Matrix ix a) Source # Associated Typestype Unpacked clk (Matrix ix a) :: * Source # Methodspack :: Unpacked clk (Matrix ix a) -> Signal clk (Matrix ix a) Source #unpack :: Signal clk (Matrix ix a) -> Unpacked clk (Matrix ix a) Source # (Rep a, Rep b) => Pack i (a, b) Source # Associated Typestype Unpacked i (a, b) :: * Source # Methodspack :: Unpacked i (a, b) -> Signal i (a, b) Source #unpack :: Signal i (a, b) -> Unpacked i (a, b) Source # (Rep a, Rep b, Rep c) => Pack i (a, b, c) Source # Associated Typestype Unpacked i (a, b, c) :: * Source # Methodspack :: Unpacked i (a, b, c) -> Signal i (a, b, c) Source #unpack :: Signal i (a, b, c) -> Unpacked i (a, b, c) Source #

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.

unpackMatrix :: (Rep a, Size x, sig ~ Signal clk) => sig (Matrix x a) -> Matrix x (sig a) Source #

packMatrix :: (Rep a, Size x, sig ~ Signal clk) => Matrix x (sig a) -> sig (Matrix x a) Source #

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.

entityD :: forall a. Rep a => String -> D a Source #

entityD1 :: forall a1 a. (Rep a, Rep a1) => String -> D a1 -> D a Source #

entityD2 :: forall a1 a2 a. (Rep a, Rep a1, Rep a2) => String -> D a1 -> D a2 -> D a Source #

entityD3 :: forall a1 a2 a3 a. (Rep a, Rep a1, Rep a2, Rep a3) => String -> D a1 -> D a2 -> D a3 -> D a Source #

pureD :: Rep a => a -> D a Source #

pureXD :: Rep a => X a -> D a Source #