blarney-0.1.0.0
Copyright(c) Matthew Naylor 2019
(c) Alexandre Joannou 2019-2021
LicenseMIT
Maintainermattfn@gmail.com
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageGHC2021

Blarney.Core.RTL

Description

The module defines the RTL monad, supporting:

  1. Mutable wires, registers and register files.
  2. Conditional statements.
  3. Simulation-time I/O.
  4. Module input and output declarations.
Synopsis

RTL monad

type RTL = ReaderT RTL_R (StateT RTL_S (WriterT RTL_W Identity)) Source #

The RTL monad, for register-transfer-level descriptions

Conditional statements

whenRTL :: Bit 1 -> RTL a -> RTL a Source #

RTL conditional block with return value

ifThenElseRTL :: Bits a => Bit 1 -> RTL a -> RTL a -> RTL a Source #

If-then-else statement for RTL

switch :: Bits a => a -> [(a, RTL ())] -> RTL () Source #

RTL switch statement

(-->) :: a -> RTL () -> (a, RTL ()) infixl 0 Source #

Operator for switch statement alternatives

Block naming statements

withNameHint :: NameHint -> RTL a -> RTL a Source #

Set a name hint for an RTL block

Mutable variables: registers and wires

data Reg a Source #

Register variables

Constructors

Reg 

Fields

  • regId :: VarId

    Unique identifier

  • regVal :: a

    Current register value

Instances

Instances details
Assign Reg # 
Instance details

Defined in Blarney.Core.Module

Methods

(<==) :: Bits a => Reg a -> a -> Action () Source #

Val (Reg t) t #

Register read and write

Instance details

Defined in Blarney.Core.Module

Methods

val :: Reg t -> t Source #

writeReg :: Bits a => Reg a -> a -> RTL () Source #

Register assignment

data Wire a Source #

Wire variables

Constructors

Wire 

Fields

  • wireId :: VarId

    Unique identifier

  • wireVal :: a

    Current wire value

  • active :: Bit 1

    Is wire being assigned on this cycle?

Instances

Instances details
Assign Wire # 
Instance details

Defined in Blarney.Core.Module

Methods

(<==) :: Bits a => Wire a -> a -> Action () Source #

Val (Wire t) t #

Wire read and write

Instance details

Defined in Blarney.Core.Module

Methods

val :: Wire t -> t Source #

writeWire :: Bits a => Wire a -> a -> RTL () Source #

Wire assignment

makeReg :: Bits a => a -> RTL (Reg a) Source #

Create register with initial value

makeRegU :: Bits a => RTL (Reg a) Source #

Create wire with don't care initial value

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.

makeWire :: Bits a => a -> RTL (Wire a) Source #

Create wire with default value

makeWireU :: Bits a => RTL (Wire a) Source #

Create wire with don't care default value

Simulation-time statements

class Displayable a where Source #

To support a display statement with variable number of arguments

Methods

disp :: Format -> Format -> a Source #

Instances

Instances details
a ~ () => Displayable (Action a) #

Display statement

Instance details

Defined in Blarney.Core.Module

Methods

disp :: Format -> Format -> Action a Source #

Displayable (RTL a) #

Base case

Instance details

Defined in Blarney.Core.RTL

Methods

disp :: Format -> Format -> RTL a Source #

(FShow b, Displayable a) => Displayable (b -> a) #

Recursive case

Instance details

Defined in Blarney.Core.RTL

Methods

disp :: Format -> Format -> b -> a Source #

display :: Displayable a => a Source #

Display statement

display_ :: Displayable a => a Source #

Display statement (without new line)

finish :: RTL () Source #

Terminate simulator

Assertions

assert :: Bit 1 -> String -> RTL () Source #

Assert that a predicate holds

External inputs and outputs

input :: KnownNat n => String -> RTL (Bit n) Source #

RTL external input declaration

output :: String -> Bit n -> RTL () Source #

RTL external output declaration

inputBV :: String -> Width -> RTL BV Source #

RTL external input declaration (untyped)

outputBV :: String -> BV -> RTL () Source #

RTL external output declaration (untyped)

Register files

data RegFileRTL a d Source #

Register file interface

Constructors

RegFileRTL 

Fields

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

Add netlist roots

addRoots :: [BV] -> RTL () Source #

Add netlist roots