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

Copyright | (C) 2018 Google Inc. 2022 LUMI GUIDE FIETSDETECTIE B.V.
License | BSD2 (see the file LICENSE)
Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com>
Safe Haskell | None
Language | Haskell2010

Clash.Annotations.BitRepresentation.Internal

Description

Synopsis

- buildCustomReprs :: [DataRepr'] -> CustomReprs
- dataReprAnnToDataRepr' :: DataReprAnn -> DataRepr'
- constrReprToConstrRepr' :: Int -> ConstrRepr -> ConstrRepr'
- getConstrRepr :: Text -> CustomReprs -> Maybe ConstrRepr'
- uncheckedGetConstrRepr :: HasCallStack => Text -> CustomReprs -> ConstrRepr'
- getDataRepr :: Type' -> CustomReprs -> Maybe DataRepr'
- thTypeToType' :: Type -> Type'
- data ConstrRepr' = ConstrRepr' {
  - crName :: Text
  - crPosition :: Int
  - crMask :: BitMask
  - crValue :: Value
  - crFieldAnns :: [FieldAnn]
  }
- data DataRepr' = DataRepr' {
  - drType :: Type'
  - drSize :: Size
  - drConstrs :: [ConstrRepr']
  }
- data Type'
  - = AppTy' Type' Type'
  - | ConstTy' Text
  - | LitTy' Integer
  - | SymLitTy' Text
- type CustomReprs = (Map Type' DataRepr', Map Text ConstrRepr')

# Documentation

buildCustomReprs :: [DataRepr'] -> CustomReprs Source #

Create indices based on names of constructors and data types

dataReprAnnToDataRepr' :: DataReprAnn -> DataRepr' Source #

constrReprToConstrRepr' :: Int -> ConstrRepr -> ConstrRepr' Source #

getConstrRepr :: Text -> CustomReprs -> Maybe ConstrRepr' Source #

Lookup constructor representation based on name

uncheckedGetConstrRepr :: HasCallStack => Text -> CustomReprs -> ConstrRepr' Source #

Unchecked version of getConstrRepr

getDataRepr :: Type' -> CustomReprs -> Maybe DataRepr' Source #

Lookup data type representation based on name

thTypeToType' :: Type -> Type' Source #

Convert template haskell type to simple representation of type

data ConstrRepr' Source #

Internal version of ConstrRepr

Constructors

ConstrRepr' |

Fields

- crName :: Text

  Qualified name of constructor

- crPosition :: Int

  Syntactical position in the custom representations definition

- crMask :: BitMask

  Mask needed to determine constructor

- crValue :: Value

  Value after applying mask

- crFieldAnns :: [FieldAnn]

  Indicates where fields are stored

#### Instances

Instances details

NFData ConstrRepr' Source # |
Instance details Defined in Clash.Annotations.BitRepresentation.Internal Methods rnf :: ConstrRepr' -> () Source #
Generic ConstrRepr' Source # |

Instance details

Defined in Clash.Annotations.BitRepresentation.Internal

Associated Types

type Rep ConstrRepr' |

Instance details

Defined in Clash.Annotations.BitRepresentation.Internal

type Rep ConstrRepr' = D1 ('MetaData "ConstrRepr'" "Clash.Annotations.BitRepresentation.Internal" "clash-prelude-1.8.4-1CKHk9HHRNIGPqhYHQsmcW" 'False) (C1 ('MetaCons "ConstrRepr'" 'PrefixI 'True) ((S1 ('MetaSel ('Just "crName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "crPosition") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :*: (S1 ('MetaSel ('Just "crMask") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BitMask) :*: (S1 ('MetaSel ('Just "crValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value) :*: S1 ('MetaSel ('Just "crFieldAnns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [FieldAnn])))))

Methods

from :: ConstrRepr' -> Rep ConstrRepr' x Source #

to :: Rep ConstrRepr' x -> ConstrRepr' Source #

Show ConstrRepr' Source # |
Instance details Defined in Clash.Annotations.BitRepresentation.Internal Methods showsPrec :: Int -> ConstrRepr' -> ShowS Source # show :: ConstrRepr' -> String Source # showList :: [ConstrRepr'] -> ShowS Source #
Eq ConstrRepr' Source # |
Instance details Defined in Clash.Annotations.BitRepresentation.Internal Methods (==) :: ConstrRepr' -> ConstrRepr' -> Bool Source # (/=) :: ConstrRepr' -> ConstrRepr' -> Bool Source #
Ord ConstrRepr' Source # |

Instance details

Defined in Clash.Annotations.BitRepresentation.Internal

Methods

compare :: ConstrRepr' -> ConstrRepr' -> Ordering Source #

(<) :: ConstrRepr' -> ConstrRepr' -> Bool Source #

(<=) :: ConstrRepr' -> ConstrRepr' -> Bool Source #

(>) :: ConstrRepr' -> ConstrRepr' -> Bool Source #

(>=) :: ConstrRepr' -> ConstrRepr' -> Bool Source #

max :: ConstrRepr' -> ConstrRepr' -> ConstrRepr' Source #

min :: ConstrRepr' -> ConstrRepr' -> ConstrRepr' Source #

Hashable ConstrRepr' Source # |
Instance details Defined in Clash.Annotations.BitRepresentation.Internal Methods hashWithSalt :: Int -> ConstrRepr' -> Int Source # hash :: ConstrRepr' -> Int Source #
type Rep ConstrRepr' Source # |

Instance details

Defined in Clash.Annotations.BitRepresentation.Internal

type Rep ConstrRepr' = D1 ('MetaData "ConstrRepr'" "Clash.Annotations.BitRepresentation.Internal" "clash-prelude-1.8.4-1CKHk9HHRNIGPqhYHQsmcW" 'False) (C1 ('MetaCons "ConstrRepr'" 'PrefixI 'True) ((S1 ('MetaSel ('Just "crName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "crPosition") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :*: (S1 ('MetaSel ('Just "crMask") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BitMask) :*: (S1 ('MetaSel ('Just "crValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value) :*: S1 ('MetaSel ('Just "crFieldAnns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [FieldAnn])))))

data DataRepr' Source #

Internal version of DataRepr

Constructors

DataRepr' |

Fields

- drType :: Type'

  Simple representation of data type

- drSize :: Size

  Size of data type

- drConstrs :: [ConstrRepr']

  Constructors

#### Instances

Instances details

NFData DataRepr' Source # |
Instance details Defined in Clash.Annotations.BitRepresentation.Internal Methods rnf :: DataRepr' -> () Source #
Generic DataRepr' Source # |

Instance details

Defined in Clash.Annotations.BitRepresentation.Internal

Associated Types

type Rep DataRepr' |

Instance details

Defined in Clash.Annotations.BitRepresentation.Internal

type Rep DataRepr' = D1 ('MetaData "DataRepr'" "Clash.Annotations.BitRepresentation.Internal" "clash-prelude-1.8.4-1CKHk9HHRNIGPqhYHQsmcW" 'False) (C1 ('MetaCons "DataRepr'" 'PrefixI 'True) (S1 ('MetaSel ('Just "drType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Type') :*: (S1 ('MetaSel ('Just "drSize") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Size) :*: S1 ('MetaSel ('Just "drConstrs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ConstrRepr']))))

Methods

from :: DataRepr' -> Rep DataRepr' x Source #

to :: Rep DataRepr' x -> DataRepr' Source #

Show DataRepr' Source # |
Instance details Defined in Clash.Annotations.BitRepresentation.Internal Methods showsPrec :: Int -> DataRepr' -> ShowS Source # show :: DataRepr' -> String Source # showList :: [DataRepr'] -> ShowS Source #
Eq DataRepr' Source # |
Instance details Defined in Clash.Annotations.BitRepresentation.Internal Methods (==) :: DataRepr' -> DataRepr' -> Bool Source # (/=) :: DataRepr' -> DataRepr' -> Bool Source #
Ord DataRepr' Source # |

Instance details

Defined in Clash.Annotations.BitRepresentation.Internal

Methods

compare :: DataRepr' -> DataRepr' -> Ordering Source #

(<) :: DataRepr' -> DataRepr' -> Bool Source #

(<=) :: DataRepr' -> DataRepr' -> Bool Source #

(>) :: DataRepr' -> DataRepr' -> Bool Source #

(>=) :: DataRepr' -> DataRepr' -> Bool Source #

max :: DataRepr' -> DataRepr' -> DataRepr' Source #

min :: DataRepr' -> DataRepr' -> DataRepr' Source #

Hashable DataRepr' Source # |
Instance details Defined in Clash.Annotations.BitRepresentation.Internal Methods hashWithSalt :: Int -> DataRepr' -> Int Source # hash :: DataRepr' -> Int Source #
type Rep DataRepr' Source # |

Instance details

Defined in Clash.Annotations.BitRepresentation.Internal

type Rep DataRepr' = D1 ('MetaData "DataRepr'" "Clash.Annotations.BitRepresentation.Internal" "clash-prelude-1.8.4-1CKHk9HHRNIGPqhYHQsmcW" 'False) (C1 ('MetaCons "DataRepr'" 'PrefixI 'True) (S1 ('MetaSel ('Just "drType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Type') :*: (S1 ('MetaSel ('Just "drSize") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Size) :*: S1 ('MetaSel ('Just "drConstrs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ConstrRepr']))))

data Type' Source #

Simple version of template haskell type. Used internally to match on.

Constructors

AppTy' Type' Type' | Type application
ConstTy' Text | Qualified name of type
LitTy' Integer | Numeral literal (used in BitVector 10, for example)
SymLitTy' Text | Symbol literal (used in for example (Signal System Int))

#### Instances

Instances details

NFData Type' Source # |
Instance details Defined in Clash.Annotations.BitRepresentation.Internal Methods rnf :: Type' -> () Source #
Generic Type' Source # |

Instance details

Defined in Clash.Annotations.BitRepresentation.Internal

Associated Types

type Rep Type' |

Instance details

Defined in Clash.Annotations.BitRepresentation.Internal

type Rep Type' = D1 ('MetaData "Type'" "Clash.Annotations.BitRepresentation.Internal" "clash-prelude-1.8.4-1CKHk9HHRNIGPqhYHQsmcW" 'False) ((C1 ('MetaCons "AppTy'" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Type') :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Type')) :+: C1 ('MetaCons "ConstTy'" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) :+: (C1 ('MetaCons "LitTy'" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer)) :+: C1 ('MetaCons "SymLitTy'" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))))

Methods

from :: Type' -> Rep Type' x Source #

to :: Rep Type' x -> Type' Source #

Show Type' Source # |
Instance details Defined in Clash.Annotations.BitRepresentation.Internal Methods showsPrec :: Int -> Type' -> ShowS Source # show :: Type' -> String Source # showList :: [Type'] -> ShowS Source #
Eq Type' Source # |
Instance details Defined in Clash.Annotations.BitRepresentation.Internal Methods (==) :: Type' -> Type' -> Bool Source # (/=) :: Type' -> Type' -> Bool Source #
Ord Type' Source # |
Instance details Defined in Clash.Annotations.BitRepresentation.Internal Methods compare :: Type' -> Type' -> Ordering Source # (<) :: Type' -> Type' -> Bool Source # (<=) :: Type' -> Type' -> Bool Source # (>) :: Type' -> Type' -> Bool Source # (>=) :: Type' -> Type' -> Bool Source # max :: Type' -> Type' -> Type' Source # min :: Type' -> Type' -> Type' Source #
Hashable Type' Source # |
Instance details Defined in Clash.Annotations.BitRepresentation.Internal Methods hashWithSalt :: Int -> Type' -> Int Source # hash :: Type' -> Int Source #
type Rep Type' Source # |

Instance details

Defined in Clash.Annotations.BitRepresentation.Internal

type Rep Type' = D1 ('MetaData "Type'" "Clash.Annotations.BitRepresentation.Internal" "clash-prelude-1.8.4-1CKHk9HHRNIGPqhYHQsmcW" 'False) ((C1 ('MetaCons "AppTy'" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Type') :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Type')) :+: C1 ('MetaCons "ConstTy'" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) :+: (C1 ('MetaCons "LitTy'" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer)) :+: C1 ('MetaCons "SymLitTy'" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))))

type CustomReprs = (Map Type' DataRepr', Map Text ConstrRepr') Source #

Convenience type for index built by buildCustomReprs