clash-prelude-1.3.0: 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

Clash.Sized.Unsigned

Description

 
Synopsis

Documentation

data Unsigned (n :: Nat) Source #

Arbitrary-width unsigned integer represented by n bits

Given n bits, an Unsigned n number has a range of: [0 .. 2^n-1]

NB: The Num operators perform wrap-around on overflow. If you want saturation on overflow, check out the SaturatingNum class.

>>> maxBound :: Unsigned 3
7
>>> minBound :: Unsigned 3
0
>>> read (show (maxBound :: Unsigned 3)) :: Unsigned 3
7
>>> 1 + 2 :: Unsigned 3
3
>>> 2 + 6 :: Unsigned 3
0
>>> 1 - 3 :: Unsigned 3
6
>>> 2 * 3 :: Unsigned 3
6
>>> 2 * 4 :: Unsigned 3
0
>>> (2 :: Unsigned 3) `mul` (4 :: Unsigned 3) :: Unsigned 6
8
>>> (2 :: Unsigned 3) `add` (6 :: Unsigned 3) :: Unsigned 4
8
>>> satAdd SatSymmetric 2 6 :: Unsigned 3
7
>>> satSub SatSymmetric 2 3 :: Unsigned 3
0

Unsigned has the type role

>>> :i Unsigned
type role Unsigned nominal
...

as it is not safe to coerce between different width Unsigned. To change the width, use the functions in the Resize class.

Instances

Instances details
Resize Unsigned Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Methods

resize :: forall (a :: Nat) (b :: Nat). (KnownNat a, KnownNat b) => Unsigned a -> Unsigned b Source #

extend :: forall (a :: Nat) (b :: Nat). (KnownNat a, KnownNat b) => Unsigned a -> Unsigned (b + a) Source #

zeroExtend :: forall (a :: Nat) (b :: Nat). (KnownNat a, KnownNat b) => Unsigned a -> Unsigned (b + a) Source #

signExtend :: forall (a :: Nat) (b :: Nat). (KnownNat a, KnownNat b) => Unsigned a -> Unsigned (b + a) Source #

truncateB :: forall (a :: Nat) (b :: Nat). KnownNat a => Unsigned (a + b) -> Unsigned a Source #

KnownNat n => Lift (Unsigned n :: Type) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Methods

lift :: Unsigned n -> Q Exp #

liftTyped :: Unsigned n -> Q (TExp (Unsigned n)) #

KnownNat n => Bounded (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

KnownNat n => Enum (Unsigned n) Source #

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

Instance details

Defined in Clash.Sized.Internal.Unsigned

Eq (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Methods

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

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

KnownNat n => Integral (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

KnownNat n => Data (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Methods

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

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

toConstr :: Unsigned n -> Constr #

dataTypeOf :: Unsigned n -> DataType #

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

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

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

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

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

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

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

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

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

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

KnownNat n => Num (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Ord (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Methods

compare :: Unsigned n -> Unsigned n -> Ordering #

(<) :: Unsigned n -> Unsigned n -> Bool #

(<=) :: Unsigned n -> Unsigned n -> Bool #

(>) :: Unsigned n -> Unsigned n -> Bool #

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

max :: Unsigned n -> Unsigned n -> Unsigned n #

min :: Unsigned n -> Unsigned n -> Unsigned n #

KnownNat n => Read (Unsigned n) Source #

None of the Read class' methods are synthesizable.

Instance details

Defined in Clash.Sized.Internal.Unsigned

KnownNat n => Real (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Methods

toRational :: Unsigned n -> Rational #

Show (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Methods

showsPrec :: Int -> Unsigned n -> ShowS #

show :: Unsigned n -> String #

showList :: [Unsigned n] -> ShowS #

KnownNat n => Ix (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Generic (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Associated Types

type Rep (Unsigned n) :: Type -> Type #

Methods

from :: Unsigned n -> Rep (Unsigned n) x #

to :: Rep (Unsigned n) x -> Unsigned n #

KnownNat n => Arbitrary (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Methods

arbitrary :: Gen (Unsigned n) #

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

KnownNat n => CoArbitrary (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Methods

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

KnownNat n => PrintfArg (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

KnownNat n => Bits (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

KnownNat n => FiniteBits (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Default (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Methods

def :: Unsigned n #

NFData (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Methods

rnf :: Unsigned n -> () #

KnownNat n => Ixed (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Methods

ix :: Index (Unsigned n) -> Traversal' (Unsigned n) (IxValue (Unsigned n)) #

KnownNat n => SaturatingNum (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

NFDataX (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

ShowX (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

KnownNat n => BitPack (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Associated Types

type BitSize (Unsigned n) :: Nat Source #

KnownNat n => Parity (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

Methods

even :: Unsigned n -> Bool Source #

odd :: Unsigned n -> Bool Source #

Bundle (Unsigned n) Source # 
Instance details

Defined in Clash.Signal.Bundle

Associated Types

type Unbundled dom (Unsigned n) = (res :: Type) Source #

Methods

bundle :: forall (dom :: Domain). Unbundled dom (Unsigned n) -> Signal dom (Unsigned n) Source #

unbundle :: forall (dom :: Domain). Signal dom (Unsigned n) -> Unbundled dom (Unsigned n) Source #

Bundle (Unsigned n) Source # 
Instance details

Defined in Clash.Signal.Delayed.Bundle

Associated Types

type Unbundled dom d (Unsigned n) = (res :: Type) Source #

Methods

bundle :: forall (dom :: Domain) (d :: Nat). Unbundled dom d (Unsigned n) -> DSignal dom d (Unsigned n) Source #

unbundle :: forall (dom :: Domain) (d :: Nat). DSignal dom d (Unsigned n) -> Unbundled dom d (Unsigned n) Source #

AutoReg (Unsigned n) Source # 
Instance details

Defined in Clash.Class.AutoReg.Internal

Methods

autoReg :: forall (dom :: Domain). (HasCallStack, KnownDomain dom) => Clock dom -> Reset dom -> Enable dom -> Unsigned n -> Signal dom (Unsigned n) -> Signal dom (Unsigned n) Source #

KnownNat m => Exp (Unsigned m) Source # 
Instance details

Defined in Clash.Class.Exp

Associated Types

type ExpResult (Unsigned m) n Source #

Methods

(^) :: forall (n :: Nat). Unsigned m -> SNat n -> ExpResult (Unsigned m) n Source #

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

Defined in Clash.Sized.Internal.Unsigned

Associated Types

type AResult (Unsigned m) (Unsigned n) Source #

type MResult (Unsigned m) (Unsigned n) Source #

type Unbundled dom d (Unsigned n) Source # 
Instance details

Defined in Clash.Signal.Delayed.Bundle

type Unbundled dom d (Unsigned n) = DSignal dom d (Unsigned n)
type Unbundled dom (Unsigned n) Source # 
Instance details

Defined in Clash.Signal.Bundle

type Unbundled dom (Unsigned n) = Signal dom (Unsigned n)
type Rep (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

type Rep (Unsigned n) = D1 ('MetaData "Unsigned" "Clash.Sized.Internal.Unsigned" "clash-prelude-1.3.0-inplace" 'True) (C1 ('MetaCons "U" 'PrefixI 'True) (S1 ('MetaSel ('Just "unsafeToNatural") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Natural)))
type Index (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

type Index (Unsigned n) = Int
type IxValue (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

type IxValue (Unsigned n) = Bit
type BitSize (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

type BitSize (Unsigned n) = n
type ExpResult (Unsigned m) n Source # 
Instance details

Defined in Clash.Class.Exp

type ExpResult (Unsigned m) n = Unsigned (Max 1 (m * n))
type AResult (Unsigned m) (Unsigned n) Source # 
Instance details

Defined in Clash.Sized.Internal.Unsigned

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

Defined in Clash.Sized.Internal.Unsigned

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