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

Description

This module represents the core of the Blarney HDL, upon which all hardware description features are built. It provides untyped bit vectors, i.e. bit vectors whose width is not specified in the type. Hardware developers should not use these untyped primitives directly (unless they know what they are doing), because width-mistmatches are not checked. Any bit-vector can be evaluated symbolically, using a feature similar to Observable Sharing [1], to produce a netlist, i.e. a graph whose nodes are primitive component instances and whose edges are connections.

  1. K. Claessen, D. Sands. Observable Sharing for Functional Circuit Description, ASIAN 1999.
Synopsis

Untyped bit vectors

data BV Source #

An untyped bit vector output wire from a primitive component instance

Constructors

BV 

Fields

makePrim :: Prim -> [BV] -> [OutputName] -> [BV] Source #

Helper function for creating an instance of a primitive component

makePrim0 :: Prim -> [BV] -> BV Source #

Create instance of primitive component with no output

makePrim1 :: Prim -> [BV] -> BV Source #

Create instance of primitive component which has one output

Bit-vector primitives

constBV :: Width -> Integer -> BV Source #

Constant bit vector of given width

dontCareBV :: Width -> BV Source #

Don't care of given width

addBV :: BV -> BV -> BV Source #

Adder

subBV :: BV -> BV -> BV Source #

Subtractor

mulBV :: BV -> BV -> BV Source #

Multiplier (input and output widths are same)

fullMulBV :: Bool -> BV -> BV -> BV Source #

Multiplier (full precision, i.e. output width is 2x input width)

divBV :: BV -> BV -> BV Source #

Quotient

modBV :: BV -> BV -> BV Source #

Remainder

invBV :: BV -> BV Source #

Bitwise not

andBV :: BV -> BV -> BV Source #

Bitwise and

orBV :: BV -> BV -> BV Source #

Bitwise or

xorBV :: BV -> BV -> BV Source #

Bitwise xor

leftBV :: BV -> BV -> BV Source #

Left shift

rightBV :: BV -> BV -> BV Source #

Right shift

arithRightBV :: BV -> BV -> BV Source #

Right shift

equalBV :: BV -> BV -> BV Source #

Equality comparator

notEqualBV :: BV -> BV -> BV Source #

Disequality comparator

lessThanBV :: BV -> BV -> BV Source #

Less-than comparator

lessThanEqBV :: BV -> BV -> BV Source #

Less-than-or-equal comparator

replicateBV :: Int -> BV -> BV Source #

Replicate a bit

zeroExtendBV :: OutputWidth -> BV -> BV Source #

Zero-extend a bit vector

signExtendBV :: OutputWidth -> BV -> BV Source #

Sign-extend a bit vector

selectBV :: (BitIndex, BitIndex) -> BV -> BV Source #

Bit selection

concatBV :: BV -> BV -> BV Source #

Bit vector concatenation

muxBV :: BV -> [BV] -> BV Source #

Multiplexer

idBV :: BV -> BV Source #

Identity function

testPlusArgsBV :: String -> BV Source #

Test plusargs

inputPinBV :: Width -> String -> BV Source #

Input pin (named Verilog pin)

regBV :: Width -> BV -> BV -> BV Source #

Register of given width with initial value

regEnBV :: Width -> BV -> BV -> BV -> BV Source #

Register of given width with initial value and enable wire

mergeWritesBV :: MergeStrategy -> Width -> [(BV, BV)] -> BV Source #

Merge a list of inputs together

regFileReadBV :: RegFileInfo -> BV -> BV Source #

Read from register file

getInitBV :: BV -> InitVal Source #

Get the value of a constant bit vector, which may involve bit manipulations. Used to determine the initial value of a register.

ramBV :: OutputWidth -> Maybe String -> (BV, BV, BV, BV, Maybe BV) -> BV Source #

Single-port block RAM. Inputs: address, data, write-enable, read-enable, optional byte-enable

dualRamBV :: OutputWidth -> Maybe String -> (BV, BV, BV, BV, BV, Maybe BV) -> BV Source #

Simple dual-port block RAM. Inputs: read address, write address, data, write-enable, read-enable, optional byte-enable

trueDualRamBV :: OutputWidth -> Maybe String -> (BV, BV, BV, BV, Maybe BV) -> (BV, BV, BV, BV, Maybe BV) -> (BV, BV) Source #

True dual-port block RAM. Inputs (x2): address, data, write-enable, read-enable, optional byte-enable

Other misc helpers

bvPrimOutWidth :: BV -> OutputWidth Source #

helper to get the OutputWidth of the Prim of a BV

lookupParam :: [Param] -> String -> String Source #

Given a parameter name, return the parameter value

addBVNameHint :: BV -> NameHint -> BV Source #

Add a name hint to the BV

addBVNameHints :: BV -> NameHints -> BV Source #

Add name hints to the BV