clash-prelude-1.8.4: Clash: a functional hardware description language - Prelude library

Copyright | (C) 2019 Myrtle Software Ltd 2024 QBayLogic B.V.
License | BSD2 (see the file LICENSE)
Maintainer | QBayLogic B.V. <devops@qaylogic.com>
Safe Haskell | None
Language | Haskell2010

Clash.Class.Exp

Description

Synopsis

- class Exp a
- type family ExpResult a (n :: Nat)
- (^) :: forall (n :: Nat). Exp a => a -> SNat n -> ExpResult a n
- expIndex# :: forall (m :: Nat) (n :: Nat). KnownNat m => Index m -> SNat n -> Index (Max 2 (m ^ n))
- expSigned# :: forall (m :: Nat) (n :: Nat). KnownNat m => Signed m -> SNat n -> Signed (Max 2 (m * n))
- expUnsigned# :: forall (m :: Nat) (n :: Nat). KnownNat m => Unsigned m -> SNat n -> Unsigned (Max 1 (m * n))

# Documentation

class Exp a Source #

Type class implementing exponentiation with explicitly resizing results.

Minimal complete definition

(^)

#### Instances

Instances details

KnownNat m => Exp (Index m) Source # |
Instance details Defined in Clash.Class.Exp Methods (^) :: forall (n :: Nat). Index m -> SNat n -> ExpResult (Index m) n Source #
KnownNat m => Exp (Signed m) Source # |
Instance details Defined in Clash.Class.Exp Methods (^) :: forall (n :: Nat). Signed m -> SNat n -> ExpResult (Signed m) n Source #
KnownNat m => Exp (Unsigned m) Source # |
Instance details Defined in Clash.Class.Exp Methods (^) :: forall (n :: Nat). Unsigned m -> SNat n -> ExpResult (Unsigned m) n Source #

type family ExpResult a (n :: Nat) Source #

#### Instances

Instances details

type ExpResult (Index m) n Source # |
Instance details Defined in Clash.Class.Exp type ExpResult (Index m) n = Index (Max 2 (m ^ n))
type ExpResult (Signed m) n Source # |
Instance details Defined in Clash.Class.Exp type ExpResult (Signed m) n = Signed (Max 2 (m * n))
type ExpResult (Unsigned m) n Source # |
Instance details Defined in Clash.Class.Exp type ExpResult (Unsigned m) n = Unsigned (Max 1 (m * n))

(^) infixr 8 Source #

Arguments

:: forall (n :: Nat). Exp a |
=> a | Base
-> SNat n | Exponent
-> ExpResult a n | Resized result, guaranteed to not have overflown

Exponentiation with known exponent.

- Internal

expIndex# :: forall (m :: Nat) (n :: Nat). KnownNat m => Index m -> SNat n -> Index (Max 2 (m ^ n)) Source #

expSigned# :: forall (m :: Nat) (n :: Nat). KnownNat m => Signed m -> SNat n -> Signed (Max 2 (m * n)) Source #

expUnsigned# :: forall (m :: Nat) (n :: Nat). KnownNat m => Unsigned m -> SNat n -> Unsigned (Max 1 (m * n)) Source #