The beginnings of a Prelude of commonly-used circuits. By no means exhaustive, but a useful start.

- type Word n = Vec n Bit
- andG :: Generic a => a -> Bit
- orG :: Generic a => a -> Bit
- delay :: Generic a => a -> a -> a
- delayEn :: Generic a => a -> Bit -> a -> a
- (?) :: Generic a => Bit -> (a, a) -> a
- nameList :: Int -> String -> [Bit]
- nameWord :: N n => String -> Word n
- select :: [Bit] -> [[Bit]] -> [Bit]
- selectG :: Generic a => [Bit] -> [a] -> a
- pick :: [(Bit, [Bit])] -> [Bit]
- pickG :: Generic a => [(Bit, a)] -> a
- decode :: [Bit] -> [Bit]
- decodeTwos :: [Bit] -> [Bit]
- encode :: [Bit] -> [Bit]
- tally :: [Bit] -> [Bit]
- oneHot :: N n => Int -> Word n
- tal :: [Bit] -> [Bit]
- tal' :: [Bit] -> [Bit]
- rotr :: [Bit] -> [Bit] -> [Bit]
- rotateRight :: [Bit] -> [[Bit]] -> [[Bit]]
- rotl :: [Bit] -> [Bit] -> [Bit]
- rotateLeft :: [Bit] -> [[Bit]] -> [[Bit]]
- dot :: [Bit] -> [Bit] -> Bit
- data RamInputs n m = RamInputs {}
- ram :: (N n, N m) => [Integer] -> RamAlgorithm -> RamInputs n m -> Word n
- dualRam :: (N n, N m) => [Integer] -> RamAlgorithm -> (RamInputs n m, RamInputs n m) -> (Word n, Word n)
- type Unsigned n = Word n
- newtype Signed n = Signed (Vec n Bit)
- natSub :: N n => Word n -> Word n -> Word n
- complement :: [Bit] -> [Bit]
- bitPlus :: Bit -> [Bit] -> [Bit]
- wordToInt :: Integral a => Word n -> a
- extend :: N n => Vec (S m) c -> Vec n c
- (===) :: Generic a => a -> a -> Bit
- (=/=) :: Generic a => a -> a -> Bit
- class Ordered a where
- tree1 :: (a -> a -> a) -> [a] -> a
- tree :: (a -> a -> a) -> a -> [a] -> a
- groupN :: Int -> [a] -> [[a]]
- halve :: [a] -> ([a], [a])

# Bit-vectors

# Generalised primitives

delayEn :: Generic a => a -> Bit -> a -> aSource

Generic register, with initialiser, with input-enable.

# Multiplexing

# Encoding and decoding

decodeTwos :: [Bit] -> [Bit]Source

Two's complement version of `decode`

.

# Rotation

rotateLeft :: [Bit] -> [[Bit]] -> [[Bit]]Source

Like `rotateRight`

except rotation is to the left.

# RAMs

ram :: (N n, N m) => [Integer] -> RamAlgorithm -> RamInputs n m -> Word nSource

RAM of any width and size, with intialiser.

dualRam :: (N n, N m) => [Integer] -> RamAlgorithm -> (RamInputs n m, RamInputs n m) -> (Word n, Word n)Source

Dual-port RAM of any width and size, with intialiser.

# Arithmetic

Signed bit-vectors.

natSub :: N n => Word n -> Word n -> Word nSource

Subtracts `b`

from `a`

, but if `b`

is larger than `a`

then
result is `0`

.

complement :: [Bit] -> [Bit]Source

Two's complement of a bit-list.

# Comparators

# Polymorphic functions over lists

tree1 :: (a -> a -> a) -> [a] -> aSource

Parallel reduce for a commutative an associative operator. Input list must be non-empty.