Copyright | (c) Matthew Naylor 2019 (c) Alexandre Joannou 2019-2021 |
---|---|
License | MIT |
Maintainer | mattfn@gmail.com |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
The module defines the RTL monad, supporting:
- Mutable wires, registers and register files.
- Conditional statements.
- Simulation-time I/O.
- Module input and output declarations.
Synopsis
- type RTL = ReaderT RTL_R (StateT RTL_S (WriterT RTL_W Identity))
- evalPureRTL :: RTL a -> String -> a
- evalRTLRoots :: RTL a -> [BV]
- whenRTL :: Bit 1 -> RTL a -> RTL a
- ifThenElseRTL :: Bits a => Bit 1 -> RTL a -> RTL a -> RTL a
- switch :: Bits a => a -> [(a, RTL ())] -> RTL ()
- (-->) :: a -> RTL () -> (a, RTL ())
- withNameHint :: NameHint -> RTL a -> RTL a
- data Reg a = Reg {}
- writeReg :: Bits a => Reg a -> a -> RTL ()
- data Wire a = Wire {}
- writeWire :: Bits a => Wire a -> a -> RTL ()
- makeReg :: Bits a => a -> RTL (Reg a)
- makeRegU :: Bits a => RTL (Reg a)
- makeDReg :: Bits a => a -> RTL (Reg a)
- makeWire :: Bits a => a -> RTL (Wire a)
- makeWireU :: Bits a => RTL (Wire a)
- class Displayable a where
- display :: Displayable a => a
- display_ :: Displayable a => a
- finish :: RTL ()
- assert :: Bit 1 -> String -> RTL ()
- input :: KnownNat n => String -> RTL (Bit n)
- output :: String -> Bit n -> RTL ()
- inputBV :: String -> Width -> RTL BV
- outputBV :: String -> BV -> RTL ()
- data RegFileRTL a d = RegFileRTL {}
- makeRegFileInit :: forall a d. (Bits a, Bits d) => String -> RTL (RegFileRTL a d)
- makeRegFile :: forall a d. (Bits a, Bits d) => RTL (RegFileRTL a d)
- addRoots :: [BV] -> RTL ()
RTL monad
type RTL = ReaderT RTL_R (StateT RTL_S (WriterT RTL_W Identity)) Source #
The RTL monad, for register-transfer-level descriptions
evalPureRTL :: RTL a -> String -> a Source #
evalRTLRoots :: RTL a -> [BV] Source #
Conditional statements
Block naming statements
Mutable variables: registers and wires
Register variables
Wire variables
makeDReg :: Bits a => a -> RTL (Reg a) Source #
A DReg holds the assigned value only for one cycle. At all other times, it has the given default value.
Simulation-time statements
class Displayable a where Source #
To support a display statement with variable number of arguments
Instances
a ~ () => Displayable (Action a) # | Display statement |
Displayable (RTL a) # | Base case |
(FShow b, Displayable a) => Displayable (b -> a) # | Recursive case |
display :: Displayable a => a Source #
Display statement
display_ :: Displayable a => a Source #
Display statement (without new line)
Assertions
External inputs and outputs
Register files
makeRegFileInit :: forall a d. (Bits a, Bits d) => String -> RTL (RegFileRTL a d) Source #
Create register file with initial contents
makeRegFile :: forall a d. (Bits a, Bits d) => RTL (RegFileRTL a d) Source #
Create uninitialised register file