| Copyright | (C) 2013-2016 University of Twente 2016-2019 Myrtle Software Ltd 2021-2024 QBayLogic B.V. |
|---|---|
| License | BSD2 (see the file LICENSE) |
| Maintainer | QBayLogic B.V. <devops@qbaylogic.com> |
| Safe Haskell | Unsafe |
| Language | Haskell2010 |
| Extensions |
|
Clash.Sized.Internal.Index
Description
Synopsis
- data Index (n :: Nat) = I {}
- fromSNat :: forall (m :: Nat) (n :: Natural). (KnownNat m, (n + 1) <= m) => SNat n -> Index m
- size# :: forall (n :: Nat). (KnownNat n, 1 <= n) => Index n -> Int
- pack# :: forall (n :: Nat). Index n -> BitVector (CLog 2 n)
- unpack# :: forall (n :: Nat). (KnownNat n, 1 <= n) => BitVector (CLog 2 n) -> Index n
- eq# :: forall (n :: Nat). Index n -> Index n -> Bool
- neq# :: forall (n :: Nat). Index n -> Index n -> Bool
- lt# :: forall (n :: Nat). Index n -> Index n -> Bool
- ge# :: forall (n :: Nat). Index n -> Index n -> Bool
- gt# :: forall (n :: Nat). Index n -> Index n -> Bool
- le# :: forall (n :: Nat). Index n -> Index n -> Bool
- toEnum# :: forall (n :: Nat). KnownNat n => Int -> Index n
- fromEnum# :: forall (n :: Nat). KnownNat n => Index n -> Int
- enumFrom# :: forall (n :: Nat). KnownNat n => Index n -> [Index n]
- enumFromThen# :: forall (n :: Nat). KnownNat n => Index n -> Index n -> [Index n]
- enumFromTo# :: forall (n :: Nat). Index n -> Index n -> [Index n]
- enumFromThenTo# :: forall (n :: Nat). Index n -> Index n -> Index n -> [Index n]
- maxBound# :: forall (n :: Nat). KnownNat n => Index n
- (+#) :: forall (n :: Nat). KnownNat n => Index n -> Index n -> Index n
- (-#) :: forall (n :: Nat). KnownNat n => Index n -> Index n -> Index n
- (*#) :: forall (n :: Nat). KnownNat n => Index n -> Index n -> Index n
- negate# :: forall (n :: Nat). KnownNat n => Index n -> Index n
- fromInteger# :: forall (n :: Nat). KnownNat n => Integer -> Index n
- plus# :: forall (m :: Nat) (n :: Nat). Index m -> Index n -> Index ((m + n) - 1)
- minus# :: forall (m :: Nat) (n :: Nat). Index m -> Index n -> Index ((m + n) - 1)
- times# :: forall (m :: Nat) (n :: Nat). Index m -> Index n -> Index (((m - 1) * (n - 1)) + 1)
- quot# :: forall (n :: Nat). Index n -> Index n -> Index n
- rem# :: forall (n :: Nat). Index n -> Index n -> Index n
- toInteger# :: forall (n :: Nat). Index n -> Integer
- resize# :: forall (m :: Nat) (n :: Nat). KnownNat m => Index n -> Index m
Datatypes
data Index (n :: Nat) Source #
Arbitrarily-bounded unsigned integer represented by ceil(log_2(n)) bits
Given an upper bound n, an Index n number has a range of: [0 .. n-1]
>>>maxBound :: Index 87>>>minBound :: Index 80>>>read (show (maxBound :: Index 8)) :: Index 87>>>1 + 2 :: Index 83>>>2 + 6 :: Index 8*** Exception: X: Clash.Sized.Index: result 8 is out of bounds: [0..7] ...>>>1 - 3 :: Index 8*** Exception: X: Clash.Sized.Index: result -2 is out of bounds: [0..7] ...>>>2 * 3 :: Index 86>>>2 * 4 :: Index 8*** Exception: X: Clash.Sized.Index: result 8 is out of bounds: [0..7] ...
NB: The usual Haskell method of converting an integral numeric type to
another, fromIntegral, is not well suited for Clash as it will go through
Integer which is arbitrarily bounded in HDL. Instead use
bitCoerce and the Resize class.
Index has the type role
>>>:i Indextype role Index nominal ...
as it is not safe to coerce between Indexes with different ranges. To
change the size, use the functions in the Resize class.
Constructors
| I | The constructor, |
Fields | |
Instances
| Resize Index Source # | |||||
Defined in Clash.Sized.Internal.Index Methods resize :: forall (a :: Nat) (b :: Nat). (KnownNat a, KnownNat b) => Index a -> Index b Source # extend :: forall (a :: Nat) (b :: Nat). (KnownNat a, KnownNat b) => Index a -> Index (b + a) Source # zeroExtend :: forall (a :: Nat) (b :: Nat). (KnownNat a, KnownNat b) => Index a -> Index (b + a) Source # signExtend :: forall (a :: Nat) (b :: Nat). (KnownNat a, KnownNat b) => Index a -> Index (b + a) Source # truncateB :: forall (a :: Nat) (b :: Natural). KnownNat a => Index (a + b) -> Index a Source # | |||||
| KnownNat n => Lift (Index n :: Type) Source # | |||||
| KnownNat n => Arbitrary (Index n) Source # | |||||
| KnownNat n => CoArbitrary (Index n) Source # | |||||
Defined in Clash.Sized.Internal.Index | |||||
| KnownNat n => PrintfArg (Index n) Source # | |||||
Defined in Clash.Sized.Internal.Index | |||||
| AutoReg (Index n) Source # | |||||
| (KnownNat n, 1 <= n) => BitPack (Index n) Source # | |||||
| (1 <= n, KnownNat n) => Counter (Index n) Source # | |||||
| KnownNat m => Exp (Index m) Source # | |||||
| (KnownNat n, 1 <= n) => SaturatingNum (Index n) Source # | |||||
| (KnownNat n, 1 <= n) => Parity (Index n) Source # | |||||
| Bundle (Index n) Source # | |||||
| Bundle (Index n) Source # | |||||
| NFDataX (Index n) Source # | |||||
Defined in Clash.Sized.Internal.Index | |||||
| ShowX (Index n) Source # | |||||
| KnownNat n => Default (Index n) Source # | |||||
Defined in Clash.Sized.Internal.Index | |||||
| NFData (Index n) Source # | |||||
Defined in Clash.Sized.Internal.Index | |||||
| (KnownNat n, 1 <= n) => Bits (Index n) Source # | |||||
Defined in Clash.Sized.Internal.Index Methods (.&.) :: Index n -> Index n -> Index n # (.|.) :: Index n -> Index n -> Index n # xor :: Index n -> Index n -> Index n # complement :: Index n -> Index n # shift :: Index n -> Int -> Index n # rotate :: Index n -> Int -> Index n # setBit :: Index n -> Int -> Index n # clearBit :: Index n -> Int -> Index n # complementBit :: Index n -> Int -> Index n # testBit :: Index n -> Int -> Bool # bitSizeMaybe :: Index n -> Maybe Int # shiftL :: Index n -> Int -> Index n # unsafeShiftL :: Index n -> Int -> Index n # shiftR :: Index n -> Int -> Index n # unsafeShiftR :: Index n -> Int -> Index n # rotateL :: Index n -> Int -> Index n # | |||||
| (KnownNat n, 1 <= n) => FiniteBits (Index n) Source # | |||||
Defined in Clash.Sized.Internal.Index Methods finiteBitSize :: Index n -> Int # countLeadingZeros :: Index n -> Int # countTrailingZeros :: Index n -> Int # | |||||
| KnownNat n => Data (Index n) Source # | |||||
Defined in Clash.Sized.Internal.Index Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Index n -> c (Index n) gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Index n) dataTypeOf :: Index n -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Index n)) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Index n)) gmapT :: (forall b. Data b => b -> b) -> Index n -> Index n gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Index n -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Index n -> r gmapQ :: (forall d. Data d => d -> u) -> Index n -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Index n -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Index n -> m (Index n) gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Index n -> m (Index n) gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Index n -> m (Index n) | |||||
| KnownNat n => Bounded (Index n) Source # | |||||
| KnownNat n => Enum (Index n) Source # | The functions: | ||||
| Generic (Index n) Source # | |||||
Defined in Clash.Sized.Internal.Index Associated Types
| |||||
| KnownNat n => Ix (Index n) Source # | |||||
Defined in Clash.Sized.Internal.Index | |||||
| KnownNat n => Num (Index n) Source # | Operators report an error on overflow and underflow NB: | ||||
| KnownNat n => Read (Index n) Source # | None of the | ||||
| KnownNat n => Integral (Index n) Source # | NB: | ||||
Defined in Clash.Sized.Internal.Index | |||||
| KnownNat n => Real (Index n) Source # | |||||
Defined in Clash.Sized.Internal.Index Methods toRational :: Index n -> Rational # | |||||
| Show (Index n) Source # | |||||
| Eq (Index n) Source # | |||||
| Ord (Index n) Source # | |||||
Defined in Clash.Sized.Internal.Index | |||||
| ExtendingNum (Index m) (Index n) Source # | |||||
| type Unbundled dom d (Index n) Source # | |||||
Defined in Clash.Signal.Delayed.Bundle | |||||
| type TryDomain t (Index n) Source # | |||||
Defined in Clash.Class.HasDomain.HasSingleDomain | |||||
| type Unbundled dom (Index n) Source # | |||||
Defined in Clash.Signal.Bundle | |||||
| type BitSize (Index n) Source # | |||||
Defined in Clash.Sized.Internal.Index | |||||
| type Rep (Index n) Source # | |||||
Defined in Clash.Sized.Internal.Index | |||||
| type ExpResult (Index m) n Source # | |||||
| type AResult (Index m) (Index n) Source # | |||||
| type MResult (Index m) (Index n) Source # | |||||
Construction
fromSNat :: forall (m :: Nat) (n :: Natural). (KnownNat m, (n + 1) <= m) => SNat n -> Index m Source #
Accessors
Length information
Type classes
BitPack
Eq
Ord
Enum
Enum (not synthesizable)
Bounded
Num
ExtendingNum
times# :: forall (m :: Nat) (n :: Nat). Index m -> Index n -> Index (((m - 1) * (n - 1)) + 1) Source #