Defines what a Bit
is, the central abstract data type of the whole
library, along with lots of things you might like to do with bits.
See REDUCERON MEMO 23
- included in the package and available at
http://www.cs.york.ac.uk/fp/reduceron/ - for a tutorial.
- data Bit
- low :: Bit
- high :: Bit
- inv :: Bit -> Bit
- delayBit :: Bit -> Bit -> Bit
- delayBitEn :: Bit -> Bit -> Bit -> Bit
- and2 :: (Bit, Bit) -> Bit
- (<&>) :: Bit -> Bit -> Bit
- or2 :: (Bit, Bit) -> Bit
- (<|>) :: Bit -> Bit -> Bit
- xor2 :: (Bit, Bit) -> Bit
- (<#>) :: Bit -> Bit -> Bit
- xorcy :: (Bit, Bit) -> Bit
- eq2 :: (Bit, Bit) -> Bit
- (<=>) :: Bit -> Bit -> Bit
- muxBit :: Bit -> Bit -> Bit -> Bit
- muxcy :: Bit -> (Bit, Bit) -> Bit
- name :: String -> Bit
- data RamInps = RamInps {
- dataBus :: [Bit]
- addressBus :: [Bit]
- writeEnable :: Bit
- data RamAlgorithm
- primRam :: [Integer] -> RamAlgorithm -> RamInps -> [Bit]
- primDualRam :: [Integer] -> RamAlgorithm -> (RamInps, RamInps) -> ([Bit], [Bit])
- class Generic a where
- generic :: a -> BitContainer a
- type BitContainer a = (JList Bit, JList Bit -> a)
- cons :: a -> BitContainer a
- (><) :: Generic a => BitContainer (a -> b) -> a -> BitContainer b
- structure :: Generic a => a -> JList Bit
- bits :: Generic a => a -> [Bit]
- mapG :: Generic a => (Bit -> Bit) -> a -> a
- zipWithG :: Generic a => (Bit -> Bit -> Bit) -> a -> a -> a
- lazyZipWithG :: Generic a => (Bit -> Bit -> Bit) -> a -> a -> a
- boolToBit :: Bool -> Bit
- simulate :: Generic a => a -> [a]
- simulateN :: Generic a => Int -> a -> [a]
- simulateSeq :: (Generic a, Generic b) => (a -> b) -> [a] -> [b]
- bitToBool :: Bit -> Bool
- data Net = Net {
- netName :: String
- netParams :: [Parameter]
- netId :: InstanceId
- netNumOuts :: Int
- netInputs :: [Wire]
- data Netlist = Netlist {
- namedOutputs :: [(String, Wire)]
- nets :: [Net]
- netlist :: Generic a => a -> a -> IO Netlist
- makeComponent :: String -> [Bit] -> Int -> ([Signal] -> [Signal]) -> [Parameter] -> ([Bit] -> a) -> a
- type Signal = [Bool]
- type InstanceId = Int
- type OutputNumber = Int
- type Wire = (InstanceId, OutputNumber)
- data Parameter = String :-> String
- lookupParam :: [Parameter] -> String -> String
Documentation
The central ADT of Lava.
Standard logic gates
muxcy :: Bit -> (Bit, Bit) -> BitSource
Bit multiplexer - specifically a Xilinx Carry Logic bit multiplexer.
RAMs
Block RAM inputs; data-bus and address-bus can be of any width!
Use Lava.Prelude.RamInputs
for stronger type-safety.
RamInps | |
|
data RamAlgorithm Source
How should the RAM be built? Used by the Xilinx Core Generator - see Xilinx docs for details.
primRam :: [Integer] -> RamAlgorithm -> RamInps -> [Bit]Source
Single-port RAM with initialiser. Use Lava.Prelude.ram
for
stronger type-safety.
primDualRam :: [Integer] -> RamAlgorithm -> (RamInps, RamInps) -> ([Bit], [Bit])Source
Dual-port RAM with initialiser. Use Lava.Prelude.dualRam
for
stronger type-safety.
Generic operations over structures of bits
Generic structures of bits
generic :: a -> BitContainer aSource
Generic () | |
Generic Bit | |
Generic a => Generic [a] | |
Generic a => Generic (Maybe a) | |
Generic (Signed n) | |
Generic (Reg n) | |
Generic (Sig n) | |
(Generic a, Generic b) => Generic (Either a b) | |
(Generic a, Generic b) => Generic (a, b) | |
Generic a => Generic (Vec n a) | |
(Generic a, Generic b, Generic c) => Generic (a, b, c) | |
(Generic a, Generic b, Generic c, Generic d) => Generic (a, b, c, d) | |
(Generic a, Generic b, Generic c, Generic d, Generic e) => Generic (a, b, c, d, e) | |
(Generic a, Generic b, Generic c, Generic d, Generic e, Generic f) => Generic (a, b, c, d, e, f) | |
(Generic a, Generic b, Generic c, Generic d, Generic e, Generic f, Generic g) => Generic (a, b, c, d, e, f, g) | |
(Generic a, Generic b, Generic c, Generic d, Generic e, Generic f, Generic g, Generic h) => Generic (a, b, c, d, e, f, g, h) |
cons :: a -> BitContainer aSource
(><) :: Generic a => BitContainer (a -> b) -> a -> BitContainer bSource
structure :: Generic a => a -> JList BitSource
Extract a join-list of bits from any structure of bits.
mapG :: Generic a => (Bit -> Bit) -> a -> aSource
Map a function over bits across any structure of bits.
zipWithG :: Generic a => (Bit -> Bit -> Bit) -> a -> a -> aSource
Zip a function over bits across any two structures of bits. Assumes that the two structures have the same shape.
lazyZipWithG :: Generic a => (Bit -> Bit -> Bit) -> a -> a -> aSource
A lazier but less-defined version of zipWithG
.
Simulation
simulate :: Generic a => a -> [a]Source
Simulate a circuit, giving the output on each clock-cycle. Returns an infinite list.
simulateSeq :: (Generic a, Generic b) => (a -> b) -> [a] -> [b]Source
Simulate a circuit with a constant waveform specified as input.
bitToBool :: Bit -> BoolSource
Simulate a circuit returning a single bit, and convert result to a boolean.
Netlist generation
Primitive component creation
:: String | Component name |
-> [Bit] | Inputs |
-> Int | Number of outputs |
-> ([Signal] -> [Signal]) | Simulation function |
-> [Parameter] | Component parameters |
-> ([Bit] -> a) | Continuation (passed output bits) |
-> a | Result |
The programmer's interface to creating new primitive components.
See definition of and2
for an example.
type InstanceId = IntSource
Every primitive component instance has a unique number.
type OutputNumber = IntSource
Each output from a primitive component is numbered.
type Wire = (InstanceId, OutputNumber)Source
A wire is uniquely identified by a instance id and an output number.
Components may have compile-time parameters, for example whether a flip-flop initialises to high or low. A parameter has a name and a value, both represented as strings.
lookupParam :: [Parameter] -> String -> StringSource