clash-prelude-0.99.2: CAES Language for Synchronous Hardware - Prelude library

Copyright(C) 2013-2016 University of Twente
LicenseBSD2 (see the file LICENSE)
MaintainerChristiaan Baaij <christiaan.baaij@gmail.com>
Safe HaskellTrustworthy
LanguageHaskell2010
ExtensionsMagicHash

Clash.Sized.BitVector

Contents

Description

 
Synopsis

Bit

data Bit #

Bit

Instances
Bounded Bit # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

minBound :: Bit #

maxBound :: Bit #

Enum Bit # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

succ :: Bit -> Bit #

pred :: Bit -> Bit #

toEnum :: Int -> Bit #

fromEnum :: Bit -> Int #

enumFrom :: Bit -> [Bit] #

enumFromThen :: Bit -> Bit -> [Bit] #

enumFromTo :: Bit -> Bit -> [Bit] #

enumFromThenTo :: Bit -> Bit -> Bit -> [Bit] #

Eq Bit # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

(==) :: Bit -> Bit -> Bool #

(/=) :: Bit -> Bit -> Bool #

Integral Bit # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

quot :: Bit -> Bit -> Bit #

rem :: Bit -> Bit -> Bit #

div :: Bit -> Bit -> Bit #

mod :: Bit -> Bit -> Bit #

quotRem :: Bit -> Bit -> (Bit, Bit) #

divMod :: Bit -> Bit -> (Bit, Bit) #

toInteger :: Bit -> Integer #

Data Bit # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Bit -> c Bit #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Bit #

toConstr :: Bit -> Constr #

dataTypeOf :: Bit -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Bit) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Bit) #

gmapT :: (forall b. Data b => b -> b) -> Bit -> Bit #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Bit -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Bit -> r #

gmapQ :: (forall d. Data d => d -> u) -> Bit -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Bit -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Bit -> m Bit #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Bit -> m Bit #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Bit -> m Bit #

Num Bit # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

(+) :: Bit -> Bit -> Bit #

(-) :: Bit -> Bit -> Bit #

(*) :: Bit -> Bit -> Bit #

negate :: Bit -> Bit #

abs :: Bit -> Bit #

signum :: Bit -> Bit #

fromInteger :: Integer -> Bit #

Ord Bit # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

compare :: Bit -> Bit -> Ordering #

(<) :: Bit -> Bit -> Bool #

(<=) :: Bit -> Bit -> Bool #

(>) :: Bit -> Bit -> Bool #

(>=) :: Bit -> Bit -> Bool #

max :: Bit -> Bit -> Bit #

min :: Bit -> Bit -> Bit #

Real Bit # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

toRational :: Bit -> Rational #

Show Bit # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

showsPrec :: Int -> Bit -> ShowS #

show :: Bit -> String #

showList :: [Bit] -> ShowS #

Lift Bit # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

lift :: Bit -> Q Exp #

Bits Bit # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

(.&.) :: Bit -> Bit -> Bit #

(.|.) :: Bit -> Bit -> Bit #

xor :: Bit -> Bit -> Bit #

complement :: Bit -> Bit #

shift :: Bit -> Int -> Bit #

rotate :: Bit -> Int -> Bit #

zeroBits :: Bit #

bit :: Int -> Bit #

setBit :: Bit -> Int -> Bit #

clearBit :: Bit -> Int -> Bit #

complementBit :: Bit -> Int -> Bit #

testBit :: Bit -> Int -> Bool #

bitSizeMaybe :: Bit -> Maybe Int #

bitSize :: Bit -> Int #

isSigned :: Bit -> Bool #

shiftL :: Bit -> Int -> Bit #

unsafeShiftL :: Bit -> Int -> Bit #

shiftR :: Bit -> Int -> Bit #

unsafeShiftR :: Bit -> Int -> Bit #

rotateL :: Bit -> Int -> Bit #

rotateR :: Bit -> Int -> Bit #

popCount :: Bit -> Int #

FiniteBits Bit # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Default Bit # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

def :: Bit #

NFData Bit # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

rnf :: Bit -> () #

ShowX Bit # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

showsPrecX :: Int -> Bit -> ShowS #

showX :: Bit -> String #

showListX :: [Bit] -> ShowS #

BitPack Bit # 
Instance details

Defined in Clash.Class.BitPack

Associated Types

type BitSize Bit :: Nat #

Bundle Bit # 
Instance details

Defined in Clash.Signal.Bundle

Associated Types

type Unbundled domain Bit = (res :: *) #

Methods

bundle :: Unbundled domain Bit -> Signal domain Bit #

unbundle :: Signal domain Bit -> Unbundled domain Bit #

type BitSize Bit # 
Instance details

Defined in Clash.Class.BitPack

type BitSize Bit = 1
type Unbundled domain Bit # 
Instance details

Defined in Clash.Signal.Bundle

type Unbundled domain Bit = Signal domain Bit

Construction

Initialisation

high :: Bit #

logic '1'

low :: Bit #

logic '0'

BitVector

data BitVector (n :: Nat) #

A vector of bits.

  • Bit indices are descending
  • Num instance performs unsigned arithmetic.
Instances
Resize BitVector # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

resize :: (KnownNat a, KnownNat b) => BitVector a -> BitVector b #

extend :: (KnownNat a, KnownNat b) => BitVector a -> BitVector (b + a) #

zeroExtend :: (KnownNat a, KnownNat b) => BitVector a -> BitVector (b + a) #

signExtend :: (KnownNat a, KnownNat b) => BitVector a -> BitVector (b + a) #

truncateB :: KnownNat a => BitVector (a + b) -> BitVector a #

KnownNat n => Bounded (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

KnownNat n => Enum (BitVector n) #

The functions: enumFrom, enumFromThen, enumFromTo, and enumFromThenTo, are not synthesisable.

Instance details

Defined in Clash.Sized.Internal.BitVector

Eq (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

(==) :: BitVector n -> BitVector n -> Bool #

(/=) :: BitVector n -> BitVector n -> Bool #

KnownNat n => Integral (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

KnownNat n => Data (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BitVector n -> c (BitVector n) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (BitVector n) #

toConstr :: BitVector n -> Constr #

dataTypeOf :: BitVector n -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (BitVector n)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (BitVector n)) #

gmapT :: (forall b. Data b => b -> b) -> BitVector n -> BitVector n #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BitVector n -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BitVector n -> r #

gmapQ :: (forall d. Data d => d -> u) -> BitVector n -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> BitVector n -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> BitVector n -> m (BitVector n) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BitVector n -> m (BitVector n) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BitVector n -> m (BitVector n) #

KnownNat n => Num (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Ord (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

KnownNat n => Real (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

KnownNat n => Show (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

KnownNat n => Lift (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

lift :: BitVector n -> Q Exp #

KnownNat n => Arbitrary (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

arbitrary :: Gen (BitVector n) #

shrink :: BitVector n -> [BitVector n] #

KnownNat n => CoArbitrary (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

coarbitrary :: BitVector n -> Gen b -> Gen b #

KnownNat n => Bits (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

KnownNat n => FiniteBits (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Default (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

def :: BitVector n #

NFData (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Methods

rnf :: BitVector n -> () #

KnownNat n => Ixed (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

KnownNat n => SaturatingNum (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

KnownNat n => ShowX (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

BitPack (BitVector n) # 
Instance details

Defined in Clash.Class.BitPack

Associated Types

type BitSize (BitVector n) :: Nat #

Bundle (BitVector n) # 
Instance details

Defined in Clash.Signal.Bundle

Associated Types

type Unbundled domain (BitVector n) = (res :: *) #

Methods

bundle :: Unbundled domain (BitVector n) -> Signal domain (BitVector n) #

unbundle :: Signal domain (BitVector n) -> Unbundled domain (BitVector n) #

(KnownNat m, KnownNat n) => ExtendingNum (BitVector m) (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

Associated Types

type AResult (BitVector m) (BitVector n) :: * #

type MResult (BitVector m) (BitVector n) :: * #

type Unbundled domain (BitVector n) # 
Instance details

Defined in Clash.Signal.Bundle

type Unbundled domain (BitVector n) = Signal domain (BitVector n)
type Index (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

type Index (BitVector n) = Int
type IxValue (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

type IxValue (BitVector n) = Bit
type BitSize (BitVector n) # 
Instance details

Defined in Clash.Class.BitPack

type BitSize (BitVector n) = n
type AResult (BitVector m) (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

type AResult (BitVector m) (BitVector n) = BitVector (Max m n + 1)
type MResult (BitVector m) (BitVector n) # 
Instance details

Defined in Clash.Sized.Internal.BitVector

type MResult (BitVector m) (BitVector n) = BitVector (m + n)

Accessors

Length information

Construction

bLit :: KnownNat n => String -> Q (TExp (BitVector n)) #

Create a binary literal

>>> $$(bLit "1001") :: BitVector 4
1001
>>> $$(bLit "1001") :: BitVector 3
001

NB: You can also just write:

>>> 0b1001 :: BitVector 4
1001

The advantage of bLit is that you can use computations to create the string literal:

>>> import qualified Data.List as List
>>> $$(bLit (List.replicate 4 '1')) :: BitVector 4
1111

Concatenation

(++#) :: KnownNat m => BitVector n -> BitVector m -> BitVector (n + m) #

Concatenate two BitVectors