clash-lib-1.8.1: Clash: a functional hardware description language - As a library

Copyright | (C) 2012-2016 University of Twente 2017 Myrtle Software Ltd 2017-2018 Google Inc. 2020-2023 QBayLogic B.V. 2022-2023 Google Inc.
License | BSD2 (see the file LICENSE)
Maintainer | QBayLogic B.V. <devops@qbaylogic.com>
Safe Haskell | Safe-Inferred
Language | Haskell2010

Clash.Netlist.Types

Description

Type and instance definitions for Netlist modules

Synopsis

- data Declaration where
  - Assignment !Identifier !Usage !Expr
  - CondAssignment !Identifier !HWType !Expr !HWType [(Maybe Literal, Expr)]
  - InstDecl EntityOrComponent (Maybe Text) [Attr Text] !Identifier !Identifier [(Expr, HWType, Expr)] PortMap
  - BlackBoxD !Text [BlackBoxTemplate] [BlackBoxTemplate] [((Text, Text), BlackBox)] !BlackBox BlackBoxContext
  - CompDecl !Text [(Text, PortDirection, HWType)]
  - NetDecl' (Maybe Comment) !Identifier HWType (Maybe Expr)
  - TickDecl CommentOrDirective
  - Seq [Seq]
  - ConditionalDecl !Text [Declaration]
  - pattern NetDecl :: Maybe Comment -> Identifier -> HWType -> Declaration
- type Size = Int
- data Bit
  - = H
  - | L
  - | U
  - | Z
- data Seq
  - = AlwaysClocked ActiveEdge Expr [Seq]
  - | Initial [Seq]
  - | AlwaysComb [Seq]
  - | SeqDecl Declaration
  - | Branch !Expr !HWType [(Maybe Literal, [Seq])]
- data Literal
  - = NumLit !Integer
  - | BitLit !Bit
  - | BitVecLit !Integer !Integer
  - | BoolLit !Bool
  - | VecLit [Literal]
  - | StringLit !String
- data Expr
  - = Literal !(Maybe (HWType, Size)) !Literal
  - | DataCon !HWType !Modifier [Expr]
  - | Identifier !Identifier !(Maybe Modifier)
  - | DataTag !HWType !(Either Identifier Identifier)
  - | BlackBoxE !Text [BlackBoxTemplate] [BlackBoxTemplate] [((Text, Text), BlackBox)] !BlackBox !BlackBoxContext !Bool
  - | ToBv (Maybe Identifier) HWType Expr
  - | FromBv (Maybe Identifier) HWType Expr
  - | IfThenElse Expr Expr Expr
  - | Noop
- data Usage
  - = Cont
  - | Proc Blocking
- type Comment = Text
- data Identifier
  - = RawIdentifier !Text (Maybe Identifier) !CallStack
  - | UniqueIdentifier {
    - i_baseName :: !Text
    - i_baseNameCaseFold :: !Text
    - i_extensionsRev :: [Word]
    - i_idType :: !IdentifierType
    - i_hdl :: !HDL
    - i_provenance :: !CallStack
    }
- data Component = Component {
  - componentName :: !Identifier
  - inputs :: [(Identifier, HWType)]
  - outputs :: [(Usage, (Identifier, HWType), Maybe Expr)]
  - declarations :: [Declaration]
  }
- data Declaration
  - = Assignment !Identifier !Usage !Expr
  - | CondAssignment !Identifier !HWType !Expr !HWType [(Maybe Literal, Expr)]
  - | InstDecl EntityOrComponent (Maybe Text) [Attr Text] !Identifier !Identifier [(Expr, HWType, Expr)] PortMap
  - | BlackBoxD !Text [BlackBoxTemplate] [BlackBoxTemplate] [((Text, Text), BlackBox)] !BlackBox BlackBoxContext
  - | CompDecl !Text [(Text, PortDirection, HWType)]
  - | NetDecl' (Maybe Comment) !Identifier HWType (Maybe Expr)
  - | TickDecl CommentOrDirective
  - | Seq [Seq]
  - | ConditionalDecl !Text [Declaration]
- data HWType
  - = Void (Maybe HWType)
  - | String
  - | Integer
  - | Bool
  - | Bit
  - | BitVector !Size
  - | Index !Integer
  - | Signed !Size
  - | Unsigned !Size
  - | Vector !Size !HWType
  - | MemBlob !Size !Size
  - | RTree !Size !HWType
  - | Sum !Text [Text]
  - | Product !Text (Maybe [Text]) [HWType]
  - | SP !Text [(Text, [HWType])]
  - | Clock !DomainName
  - | ClockN !DomainName
  - | Reset !DomainName
  - | Enable !DomainName
  - | BiDirectional !PortDirection !HWType
  - | CustomSP !Text !DataRepr' !Size [(ConstrRepr', Text, [HWType])]
  - | CustomSum !Text !DataRepr' !Size [(ConstrRepr', Text)]
  - | CustomProduct !Text !DataRepr' !Size (Maybe [Text]) [(FieldAnn, HWType)]
  - | Annotated [Attr Text] !HWType
  - | KnownDomain !DomainName !Integer !ActiveEdge !ResetKind !InitBehavior !ResetPolarity
  - | FileType
- data IdentifierSet = IdentifierSet {
  - is_allowEscaped :: !Bool
  - is_lowerCaseBasicIds :: !PreserveCase
  - is_hdl :: !HDL
  - is_freshCache :: !FreshCache
  - is_store :: !(HashSet Identifier)
  }
- class HasIdentifierSet s where
  - identifierSet :: Lens' s IdentifierSet
- type UsageMap = Map Text Usage
- type IdentifierText = Text
- data BlackBox
  - = BBTemplate BlackBoxTemplate
  - | BBFunction BBName BBHash TemplateFunction
- data FilteredHWType = FilteredHWType HWType [[(IsVoid, FilteredHWType)]]
- type HWMap = Map Type (Either String FilteredHWType)
- data SomeBackend where
  - SomeBackend :: Backend backend => backend -> SomeBackend
- data TopEntityT = TopEntityT {
  - topId :: Id
  - topAnnotation :: Maybe TopEntity
  - topIsTestBench :: Bool
  }
- data TemplateFunction where
  - TemplateFunction :: [Int] -> (BlackBoxContext -> Bool) -> (forall s. Backend s => BlackBoxContext -> State s Doc) -> TemplateFunction
- type ComponentMap = OMap Unique (ComponentMeta, Component)
- data ComponentMeta = ComponentMeta {
  - cmWereVoids :: [Bool]
  - cmLoc :: SrcSpan
  - cmScope :: IdentifierSet
  - cmUsage :: UsageMap
  }
- data PreserveCase
  - = PreserveCase
  - | ToLower
- newtype NetlistMonad a = NetlistMonad {
  - runNetlist :: StateT NetlistState (ReaderT NetlistEnv IO) a
  }
- data BlackBoxContext = Context {
  - bbName :: Text
  - bbResults :: [(Expr, HWType)]
  - bbInputs :: [(Expr, HWType, Bool)]
  - bbFunctions :: IntMap [(Either BlackBox (Identifier, [Declaration]), Usage, [BlackBoxTemplate], [BlackBoxTemplate], [((Text, Text), BlackBox)], BlackBoxContext)]
  - bbQsysIncName :: [IdentifierText]
  - bbLevel :: Int
  - bbCompName :: Identifier
  - bbCtxName :: Maybe IdentifierText
  }
- data Modifier
  - = Indexed (HWType, Int, Int)
  - | DC (HWType, Int)
  - | VecAppend
  - | RTreeAppend
  - | Sliced (HWType, Int, Int)
  - | Nested Modifier Modifier
- class Monad m => IdentifierSetMonad m where
  - identifierSetM :: (IdentifierSet -> IdentifierSet) -> m IdentifierSet
- data IdentifierType
  - = Basic
  - | Extended
- type FreshCache = HashMap Text (IntMap Word)
- data NetlistId
  - = NetlistId Identifier Type
  - | CoreId Id
  - | MultiId [Id]
- data DeclarationType
  - = Concurrent
  - | Sequential
- data CommentOrDirective
  - = Comment Comment
  - | Directive Directive
- data Blocking
  - = NonBlocking
  - | Blocking
- data ExpandedTopEntity a = ExpandedTopEntity {
  - et_inputs :: [Maybe (ExpandedPortName a)]
  - et_output :: Maybe (ExpandedPortName a)
  }
- data ExpandedPortName a
  - = ExpandedPortName HWType a
  - | ExpandedPortProduct Text HWType [ExpandedPortName a]
- data NetlistState = NetlistState {
  - _bindings :: BindingMap
  - _components :: ComponentMap
  - _typeTranslator :: CustomReprs -> TyConMap -> Type -> State HWMap (Maybe (Either String FilteredHWType))
  - _curCompNm :: !(Identifier, SrcSpan)
  - _seenIds :: IdentifierSet
  - _seenComps :: IdentifierSet
  - _seenPrimitives :: Set Text
  - _componentNames :: VarEnv Identifier
  - _topEntityAnns :: VarEnv TopEntityT
  - _hdlDir :: FilePath
  - _curBBlvl :: Int
  - _isTestBench :: Bool
  - _backEndITE :: Bool
  - _backend :: SomeBackend
  - _htyCache :: HWMap
  - _usages :: UsageMap
  }
- data NetlistEnv = NetlistEnv {
  - _clashEnv :: ClashEnv
  - _prefixName :: Text
  - _suffixName :: Text
  - _setName :: Maybe Text
  }
- data ComponentPrefix = ComponentPrefix {
  - componentPrefixTop :: Maybe Text
  - componentPrefixOther :: Maybe Text
  }
- type Directive = Text
- type IsVoid = Bool
- type DomainName = Text
- data PortDirection
  - = In
  - | Out
- data PortMap
  - = IndexedPortMap [(PortDirection, HWType, Expr)]
  - | NamedPortMap [(Expr, PortDirection, HWType, Expr)]
- data EntityOrComponent
  - = Entity
  - | Comp
  - | Empty
- type BBName = String
- type BBHash = Int
- pattern NetDecl :: Maybe Comment -> Identifier -> HWType -> Declaration
- backend :: Lens' NetlistState SomeBackend
- prefixName :: Lens' NetlistEnv Text
- suffixName :: Lens' NetlistEnv Text
- setName :: Lens' NetlistEnv (Maybe Text)
- components :: Lens' NetlistState ComponentMap
- intWidth :: Getter NetlistEnv Int
- usages :: Lens' NetlistState UsageMap
- findClocks :: Component -> [(Text, Text)]
- hwTypeDomain :: HWType -> Maybe DomainName
- bindings :: Lens' NetlistState BindingMap
- tcCache :: Getter NetlistEnv TyConMap
- customReprs :: Getter NetlistEnv CustomReprs
- typeTranslator :: Lens' NetlistState (CustomReprs -> TyConMap -> Type -> State HWMap (Maybe (Either String FilteredHWType)))
- primitives :: Getter NetlistEnv CompiledPrimMap
- toBit :: Integer -> Integer -> Bit
- curCompNm :: Lens' NetlistState (Identifier, SrcSpan)
- emptyBBContext :: Text -> BlackBoxContext
- identifierKey# :: Identifier -> ((Text, Bool), [Word])
- isBiDirectional :: (Identifier, HWType) -> Bool
- annotated :: [Attr Text] -> HWType -> HWType
- hwTypeAttrs :: HWType -> [Attr Text]
- lookupUsage :: Identifier -> UsageMap -> Maybe Usage
- isConstExpr :: Expr -> Bool
- netlistId1 :: HasCallStack => (Identifier -> r) -> (Id -> r) -> NetlistId -> r
- netlistTypes :: NetlistId -> [Type]
- netlistTypes1 :: HasCallStack => NetlistId -> Type
- clashEnv :: Lens' NetlistEnv ClashEnv
- clashOpts :: Getter NetlistEnv ClashOpts
- seenIds :: Lens' NetlistState IdentifierSet
- backEndITE :: Lens' NetlistState Bool
- componentNames :: Lens' NetlistState (VarEnv Identifier)
- curBBlvl :: Lens' NetlistState Int
- hdlDir :: Lens' NetlistState FilePath
- htyCache :: Lens' NetlistState HWMap
- isTestBench :: Lens' NetlistState Bool
- seenComps :: Lens' NetlistState IdentifierSet
- seenPrimitives :: Lens' NetlistState (Set Text)
- topEntityAnns :: Lens' NetlistState (VarEnv TopEntityT)

# Documentation

data Declaration Source #

Internals of a Component

Constructors

Assignment | Signal assignment

Fields

- !Identifier

  Signal to assign

- !Usage

  How the signal is assigned

- !Expr

  Assigned expression

CondAssignment | Conditional signal assignment:

Fields

- !Identifier

  Signal to assign

- !HWType

  Type of the result/alternatives

- !Expr

  Scrutinized expression

- !HWType

  Type of the scrutinee

- [(Maybe Literal, Expr)]

  List of: (Maybe expression scrutinized expression is compared with,RHS of alternative)

InstDecl | Instantiation of another component:

Fields

- EntityOrComponent

  Whether it's an entity or a component

- (Maybe Text)

  Library instance is defined in

- [Attr Text]

  Attributes to add to the generated code

- !Identifier

  The component's (or entity's) name

- !Identifier

  Instance label

- [(Expr, HWType, Expr)]

  List of parameters for this component (param name, param type, param value)

- PortMap

BlackBoxD | Instantiation of blackbox declaration

Fields

- !Text

  Primitive name

- [BlackBoxTemplate]

  VHDL only: add `library` declarations

- [BlackBoxTemplate]

  VHDL only: add `use` declarations

- [((Text, Text), BlackBox)]

  Intel Quartus only: create a `.qsys` file from given template

- !BlackBox

  Template tokens

- BlackBoxContext

  Context in which tokens should be rendered

CompDecl !Text [(Text, PortDirection, HWType)] | `component` declaration (VHDL). See this tutorial; refer to §4.5 of IEEE 1076-1993
NetDecl' | Signal declaration

Fields

- (Maybe Comment)

  Note; will be inserted as a comment in target hdl

- !Identifier

  Name of signal

- HWType

  Type of signal

- (Maybe Expr)

  Initial value ^ Signal declaration

TickDecl CommentOrDirective | HDL tick corresponding to a Core tick
Seq [Seq] | Sequential statement
ConditionalDecl | Compilation conditional on some preprocessor symbol, note that declarations here are ignored for VHDL. See here for a discussion https://github.com/clash-lang/clash-compiler/pull/1798#discussion_r648571862

Fields

- !Text

  condition text, for example `FORMAL`

- [Declaration]

Bundled Patterns

pattern NetDecl |

Fields

- :: Maybe Comment

  Note; will be inserted as a comment in target hdl

- -> Identifier

  Name of signal

- -> HWType

  Type of signal

- -> Declaration

#### Instances

Instances details

Show Declaration Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> Declaration -> ShowS Source # show :: Declaration -> String Source # showList :: [Declaration] -> ShowS Source #
NFData Declaration Source # |
Instance details Defined in Clash.Netlist.Types Methods rnf :: Declaration -> () Source #

type Size = Int Source #

Size indication of a type (e.g. bit-size or number of elements)

data Bit Source #

Bit literal

Constructors

H | High
L | Low
U | Undefined
Z | High-impedance

#### Instances

Instances details

Show Bit Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> Bit -> ShowS Source # show :: Bit -> String Source # showList :: [Bit] -> ShowS Source #
Eq Bit Source # |
Instance details Defined in Clash.Netlist.Types Methods (==) :: Bit -> Bit -> Bool Source # (/=) :: Bit -> Bit -> Bool Source #
Lift Bit Source # |
Instance details Defined in Clash.Netlist.Types Methods lift :: Quote m => Bit -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Bit -> Code m Bit Source #

data Seq Source #

Sequential statements

Constructors

AlwaysClocked | Clocked sequential statements

Fields

- ActiveEdge

  Edge of the clock the statement should be executed

- Expr

  Clock expression

- [Seq]

  Statements to be executed on the active clock edge | Statements running at simulator start

Initial [Seq] | Statements to run at simulator start | Statements to run always
AlwaysComb [Seq] | Statements to run always | Declaration in sequential form
SeqDecl Declaration | The declaration | Branching statement
Branch |

Fields

- !Expr

  Scrutinized expresson

- !HWType

  Type of the scrutinized expression

- [(Maybe Literal, [Seq])]

  List of: (Maybe match, RHS of Alternative)

#### Instances

Instances details

Show Seq Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> Seq -> ShowS Source # show :: Seq -> String Source # showList :: [Seq] -> ShowS Source #

data Literal Source #

Literals used in an expression

Constructors

NumLit !Integer | Number literal
BitLit !Bit | Bit literal
BitVecLit !Integer !Integer | BitVector literal
BoolLit !Bool | Boolean literal
VecLit [Literal] | Vector literal
StringLit !String | String literal

#### Instances

Instances details

Show Literal Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> Literal -> ShowS Source # show :: Literal -> String Source # showList :: [Literal] -> ShowS Source #
Eq Literal Source # |
Instance details Defined in Clash.Netlist.Types Methods (==) :: Literal -> Literal -> Bool Source # (/=) :: Literal -> Literal -> Bool Source #

data Expr Source #

Expression used in RHS of a declaration

Constructors

Literal !(Maybe (HWType, Size)) !Literal | Literal expression
DataCon !HWType !Modifier [Expr] | DataCon application
Identifier !Identifier !(Maybe Modifier) | Signal reference
DataTag !HWType !(Either Identifier Identifier) | `Left e`: tagToEnum#, `Right e`: dataToTag#
BlackBoxE | Instantiation of a BlackBox expression

Fields

- !Text

  Primitive name

- [BlackBoxTemplate]

  VHDL only: add `library` declarations

- [BlackBoxTemplate]

  VHDL only: add `use` declarations:

- [((Text, Text), BlackBox)]

  Intel/Quartus only: create a `.qsys` file from given template.

- !BlackBox

  Template tokens

- !BlackBoxContext

  Context in which tokens should be rendered

- !Bool

  Wrap in parentheses?

ToBv | Convert some type to a BitVector.

Fields

- (Maybe Identifier)

  Type prefix

- HWType

  Type to convert _from_

- Expr

  Expression to convert to BitVector

FromBv | Convert BitVector to some type.

Fields

- (Maybe Identifier)

  Type prefix

- HWType

  Type to convert _to_

- Expr

  BitVector to convert

IfThenElse Expr Expr Expr |
Noop | Do nothing

#### Instances

Instances details

Show Expr Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> Expr -> ShowS Source # show :: Expr -> String Source # showList :: [Expr] -> ShowS Source #
NFData Expr Source # |
Instance details Defined in Clash.Netlist.Types Methods rnf :: Expr -> () Source #

data Usage Source #

The usage of a signal refers to how the signal is written to in netlist. This is used to determine if the signal should be a `wire` or `reg` in (System)Verilog, or a `signal` or `variable` in VHDL.

Constructors

Cont | Continuous assignment, which occurs in a concurrent context.
Proc Blocking | Procedural assignment, which occurs in a sequential context.

#### Instances

Instances details

FromJSON Usage Source # |
Instance details Defined in Clash.Netlist.Types Methods parseJSON :: Value -> Parser Usage Source # parseJSONList :: Value -> Parser [Usage] Source #
Semigroup Usage Source # |
Instance details Defined in Clash.Netlist.Types Methods (<>) :: Usage -> Usage -> Usage Source # sconcat :: NonEmpty Usage -> Usage Source # stimes :: Integral b => b -> Usage -> Usage Source #
Generic Usage Source # |
Instance details Defined in Clash.Netlist.Types Associated Types type Rep Usage :: Type -> Type Source # Methods from :: Usage -> Rep Usage x Source # to :: Rep Usage x -> Usage Source #
Show Usage Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> Usage -> ShowS Source # show :: Usage -> String Source # showList :: [Usage] -> ShowS Source #
Binary Usage Source # |
Instance details Defined in Clash.Netlist.Types Methods put :: Usage -> Put Source # get :: Get Usage Source # putList :: [Usage] -> Put Source #
NFData Usage Source # |
Instance details Defined in Clash.Netlist.Types Methods rnf :: Usage -> () Source #
Eq Usage Source # |
Instance details Defined in Clash.Netlist.Types Methods (==) :: Usage -> Usage -> Bool Source # (/=) :: Usage -> Usage -> Bool Source #
Hashable Usage Source # |
Instance details Defined in Clash.Netlist.Types Methods hashWithSalt :: Int -> Usage -> Int Source # hash :: Usage -> Int Source #
type Rep Usage Source # |
Instance details Defined in Clash.Netlist.Types type Rep Usage = D1 ('MetaData "Usage" "Clash.Netlist.Types" "clash-lib-1.8.1-9u9U7p5PpHf8vtRevUOpPF" 'False) (C1 ('MetaCons "Cont" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Proc" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Blocking)))

type Comment = Text Source #

data Identifier Source #

HDL identifier. Consists of a base name and a number of extensions. An identifier with a base name of "foo" and a list of extensions [1, 2] will be rendered as "foo_1_2".

Note: The Eq instance of Identifier is case insensitive! E.g., two identifiers with base names `fooBar` and `FoObAR` are considered the same. However, identifiers are stored case preserving. This means Clash won't generate two identifiers with differing case, but it will try to keep capitalization.

The goal of this data structure is to greatly simplify how Clash deals with identifiers internally. Any Identifier should be trivially printable to any HDL.

NB: use the functions in Clash.Netlist.Id. Don't use these constructors directly.

Constructors

RawIdentifier | Unparsed identifier. Used for things such as port names, which should appear in the HDL exactly as the user specified.

Fields

- !Text

  An identifier exactly as given by the user

- (Maybe Identifier)

  Parsed version of raw identifier. Will not be populated if this identifier was created with an unsafe function.

- !CallStack

  Stores where this identifier was generated. Tracking is only enabled is `debugIsOn`, otherwise this field will be populated by an empty callstack.

UniqueIdentifier | Parsed and sanitized identifier. See various fields for more information on its invariants.

Fields

- i_baseName :: !Text

  Base name of identifier. `make` makes sure this field:

  - does not end in `_num` where `num` is a digit.
  - is solely made up of printable ASCII characters
  - has no leading or trailing whitespace
- i_baseNameCaseFold :: !Text

  Same as `i_baseName`, but can be used for equality testing that doesn't depend on capitalization.

- i_extensionsRev :: [Word]

  Extensions applied to base identifier. E.g., an identifier with a base name of `foo` and an extension of [6, 5] would render as `foo_5_6`. Note that extensions are stored in reverse order for easier manipulation.

- i_idType :: !IdentifierType

  See `IdentifierType`.

- i_hdl :: !HDL

  HDL this identifier is generated for.

- i_provenance :: !CallStack

  Stores where this identifier was generated. Tracking is only enabled is `debugIsOn`, otherwise this field will be populated by an empty callstack.

#### Instances

Instances details

Generic Identifier Source # |
Instance details Defined in Clash.Netlist.Types Associated Types type Rep Identifier :: Type -> Type Source # Methods from :: Identifier -> Rep Identifier x Source # to :: Rep Identifier x -> Identifier Source #
Show Identifier Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> Identifier -> ShowS Source # show :: Identifier -> String Source # showList :: [Identifier] -> ShowS Source #
NFData Identifier Source # |
Instance details Defined in Clash.Netlist.Types Methods rnf :: Identifier -> () Source #
Eq Identifier Source # |
Instance details Defined in Clash.Netlist.Types Methods (==) :: Identifier -> Identifier -> Bool Source # (/=) :: Identifier -> Identifier -> Bool Source #
Ord Identifier Source # |

Instance details

Defined in Clash.Netlist.Types

Methods

compare :: Identifier -> Identifier -> Ordering Source #

(<) :: Identifier -> Identifier -> Bool Source #

(<=) :: Identifier -> Identifier -> Bool Source #

(>) :: Identifier -> Identifier -> Bool Source #

(>=) :: Identifier -> Identifier -> Bool Source #

max :: Identifier -> Identifier -> Identifier Source #

min :: Identifier -> Identifier -> Identifier Source #

Hashable Identifier Source # |
Instance details Defined in Clash.Netlist.Types Methods hashWithSalt :: Int -> Identifier -> Int Source # hash :: Identifier -> Int Source #
Pretty Identifier Source # |
Instance details Defined in Clash.Netlist.Id.Internal Methods pretty :: Identifier -> Doc ann Source # prettyList :: [Identifier] -> Doc ann Source #
type Rep Identifier Source # |

Instance details

Defined in Clash.Netlist.Types

type Rep Identifier = D1 ('MetaData "Identifier" "Clash.Netlist.Types" "clash-lib-1.8.1-9u9U7p5PpHf8vtRevUOpPF" 'False) (C1 ('MetaCons "RawIdentifier" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Identifier)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 CallStack))) :+: C1 ('MetaCons "UniqueIdentifier" 'PrefixI 'True) ((S1 ('MetaSel ('Just "i_baseName") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: (S1 ('MetaSel ('Just "i_baseNameCaseFold") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "i_extensionsRev") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Word]))) :*: (S1 ('MetaSel ('Just "i_idType") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IdentifierType) :*: (S1 ('MetaSel ('Just "i_hdl") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HDL) :*: S1 ('MetaSel ('Just "i_provenance") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 CallStack)))))

data Component Source #

Component: base unit of a Netlist

Constructors

Component |

Fields

- componentName :: !Identifier

  Name of the component

- inputs :: [(Identifier, HWType)]

  Input ports

- outputs :: [(Usage, (Identifier, HWType), Maybe Expr)]

  Output ports

- declarations :: [Declaration]

  Internal declarations

#### Instances

Instances details

Generic Component Source # |
Instance details Defined in Clash.Netlist.Types Associated Types type Rep Component :: Type -> Type Source # Methods from :: Component -> Rep Component x Source # to :: Rep Component x -> Component Source #
Show Component Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> Component -> ShowS Source # show :: Component -> String Source # showList :: [Component] -> ShowS Source #
NFData Component Source # |
Instance details Defined in Clash.Netlist.Types Methods rnf :: Component -> () Source #
type Rep Component Source # |

Instance details

Defined in Clash.Netlist.Types

type Rep Component = D1 ('MetaData "Component" "Clash.Netlist.Types" "clash-lib-1.8.1-9u9U7p5PpHf8vtRevUOpPF" 'False) (C1 ('MetaCons "Component" 'PrefixI 'True) ((S1 ('MetaSel ('Just "componentName") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Identifier) :*: S1 ('MetaSel ('Just "inputs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(Identifier, HWType)])) :*: (S1 ('MetaSel ('Just "outputs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(Usage, (Identifier, HWType), Maybe Expr)]) :*: S1 ('MetaSel ('Just "declarations") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Declaration]))))

data Declaration Source #

Internals of a Component

Constructors

Assignment | Signal assignment

Fields

- !Identifier

  Signal to assign

- !Usage

  How the signal is assigned

- !Expr

  Assigned expression

CondAssignment | Conditional signal assignment:

Fields

- !Identifier

  Signal to assign

- !HWType

  Type of the result/alternatives

- !Expr

  Scrutinized expression

- !HWType

  Type of the scrutinee

- [(Maybe Literal, Expr)]

  List of: (Maybe expression scrutinized expression is compared with,RHS of alternative)

InstDecl | Instantiation of another component:

Fields

- EntityOrComponent

  Whether it's an entity or a component

- (Maybe Text)

  Library instance is defined in

- [Attr Text]

  Attributes to add to the generated code

- !Identifier

  The component's (or entity's) name

- !Identifier

  Instance label

- [(Expr, HWType, Expr)]

  List of parameters for this component (param name, param type, param value)

- PortMap

BlackBoxD | Instantiation of blackbox declaration

Fields

- !Text

  Primitive name

- [BlackBoxTemplate]

  VHDL only: add `library` declarations

- [BlackBoxTemplate]

  VHDL only: add `use` declarations

- [((Text, Text), BlackBox)]

  Intel Quartus only: create a `.qsys` file from given template

- !BlackBox

  Template tokens

- BlackBoxContext

  Context in which tokens should be rendered

CompDecl !Text [(Text, PortDirection, HWType)] | `component` declaration (VHDL). See this tutorial; refer to §4.5 of IEEE 1076-1993
NetDecl' | Signal declaration

Fields

- (Maybe Comment)

  Note; will be inserted as a comment in target hdl

- !Identifier

  Name of signal

- HWType

  Type of signal

- (Maybe Expr)

  Initial value ^ Signal declaration

TickDecl CommentOrDirective | HDL tick corresponding to a Core tick
Seq [Seq] | Sequential statement
ConditionalDecl | Compilation conditional on some preprocessor symbol, note that declarations here are ignored for VHDL. See here for a discussion https://github.com/clash-lang/clash-compiler/pull/1798#discussion_r648571862

Fields

- !Text

  condition text, for example `FORMAL`

- [Declaration]

#### Instances

Instances details

Show Declaration Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> Declaration -> ShowS Source # show :: Declaration -> String Source # showList :: [Declaration] -> ShowS Source #
NFData Declaration Source # |
Instance details Defined in Clash.Netlist.Types Methods rnf :: Declaration -> () Source #

data HWType Source #

Representable hardware types

Constructors

Void (Maybe HWType) | Empty type. `Just Size` for "empty" Vectors so we can still have primitives that can traverse e.g. Vectors of unit and know the length of that vector.
String | String type
Integer | Integer type (for parameters only)
Bool | Boolean type
Bit | Bit type
BitVector !Size | BitVector of a specified size
Index !Integer | Unsigned integer with specified (exclusive) upper bounder
Signed !Size | Signed integer of a specified size
Unsigned !Size | Unsigned integer of a specified size
Vector !Size !HWType | Vector type
MemBlob !Size !Size | MemBlob type
RTree !Size !HWType | RTree type
Sum !Text [Text] | Sum type: Name and Constructor names
Product !Text (Maybe [Text]) [HWType] | Product type: Name, field names, and field types. Field names will be populated when using records.
SP !Text [(Text, [HWType])] | Sum-of-Product type: Name and Constructor names + field types
Clock !DomainName | Clock type corresponding to domain DomainName
ClockN !DomainName | ClockN type corresponding to domain DomainName
Reset !DomainName | Reset type corresponding to domain DomainName
Enable !DomainName | Enable type corresponding to domain DomainName
BiDirectional !PortDirection !HWType | Tagging type indicating a bidirectional (inout) port
CustomSP !Text !DataRepr' !Size [(ConstrRepr', Text, [HWType])] | Same as Sum-Of-Product, but with a user specified bit representation. For more info, see: Clash.Annotations.BitRepresentations.
CustomSum !Text !DataRepr' !Size [(ConstrRepr', Text)] | Same as Sum, but with a user specified bit representation. For more info, see: Clash.Annotations.BitRepresentations.
CustomProduct !Text !DataRepr' !Size (Maybe [Text]) [(FieldAnn, HWType)] | Same as Product, but with a user specified bit representation. For more info, see: Clash.Annotations.BitRepresentations.
Annotated [Attr Text] !HWType | Annotated with HDL attributes
KnownDomain !DomainName !Integer !ActiveEdge !ResetKind !InitBehavior !ResetPolarity | Domain name, period, active edge, reset kind, initial value behavior
FileType | File type for simulation-level I/O

#### Instances

Instances details

Generic HWType Source # |
Instance details Defined in Clash.Netlist.Types Associated Types type Rep HWType :: Type -> Type Source # Methods from :: HWType -> Rep HWType x Source # to :: Rep HWType x -> HWType Source #
Show HWType Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> HWType -> ShowS Source # show :: HWType -> String Source # showList :: [HWType] -> ShowS Source #
NFData HWType Source # |
Instance details Defined in Clash.Netlist.Types Methods rnf :: HWType -> () Source #
Eq HWType Source # |
Instance details Defined in Clash.Netlist.Types Methods (==) :: HWType -> HWType -> Bool Source # (/=) :: HWType -> HWType -> Bool Source #
Ord HWType Source # |
Instance details Defined in Clash.Netlist.Types Methods compare :: HWType -> HWType -> Ordering Source # (<) :: HWType -> HWType -> Bool Source # (<=) :: HWType -> HWType -> Bool Source # (>) :: HWType -> HWType -> Bool Source # (>=) :: HWType -> HWType -> Bool Source # max :: HWType -> HWType -> HWType Source # min :: HWType -> HWType -> HWType Source #
Hashable HWType Source # |
Instance details Defined in Clash.Netlist.Types Methods hashWithSalt :: Int -> HWType -> Int Source # hash :: HWType -> Int Source #
type Rep HWType Source # |

Instance details

Defined in Clash.Netlist.Types

type Rep HWType = D1 ('MetaData "HWType" "Clash.Netlist.Types" "clash-lib-1.8.1-9u9U7p5PpHf8vtRevUOpPF" 'False) ((((C1 ('MetaCons "Void" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe HWType))) :+: (C1 ('MetaCons "String" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Integer" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Bool" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Bit" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BitVector" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Size))))) :+: ((C1 ('MetaCons "Index" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Integer)) :+: (C1 ('MetaCons "Signed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Size)) :+: C1 ('MetaCons "Unsigned" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Size)))) :+: ((C1 ('MetaCons "Vector" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Size) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HWType)) :+: C1 ('MetaCons "MemBlob" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Size) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Size))) :+: (C1 ('MetaCons "RTree" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Size) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HWType)) :+: C1 ('MetaCons "Sum" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text])))))) :+: (((C1 ('MetaCons "Product" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe [Text])) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [HWType]))) :+: (C1 ('MetaCons "SP" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(Text, [HWType])])) :+: C1 ('MetaCons "Clock" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DomainName)))) :+: (C1 ('MetaCons "ClockN" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DomainName)) :+: (C1 ('MetaCons "Reset" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DomainName)) :+: C1 ('MetaCons "Enable" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DomainName))))) :+: ((C1 ('MetaCons "BiDirectional" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PortDirection) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HWType)) :+: (C1 ('MetaCons "CustomSP" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DataRepr')) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Size) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(ConstrRepr', Text, [HWType])]))) :+: C1 ('MetaCons "CustomSum" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DataRepr')) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Size) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(ConstrRepr', Text)]))))) :+: ((C1 ('MetaCons "CustomProduct" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DataRepr')) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Size) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe [Text])) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(FieldAnn, HWType)])))) :+: C1 ('MetaCons "Annotated" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Attr Text]) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HWType))) :+: (C1 ('MetaCons "KnownDomain" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DomainName) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Integer) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ActiveEdge))) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ResetKind) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 InitBehavior) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ResetPolarity)))) :+: C1 ('MetaCons "FileType" 'PrefixI 'False) (U1 :: Type -> Type))))))

data IdentifierSet Source #

A collection of unique identifiers. Allows for fast fresh identifier generation.

NB: use the functions in Clash.Netlist.Id. Don't use the constructor directly.

Constructors

IdentifierSet |

Fields

- is_allowEscaped :: !Bool

  Allow escaped ids? If set to False, "make" will always behave like "makeBasic".

- is_lowerCaseBasicIds :: !PreserveCase

  Force all generated basic identifiers to lowercase.

- is_hdl :: !HDL

  HDL to generate fresh identifiers for

- is_freshCache :: !FreshCache

  Maps an `i_baseNameCaseFold` to a map mapping the number of extensions (in `i_extensionsRev`) to the maximum word at that basename/level. For example, if a set would contain the identifiers:

  foo, foo_1, foo_2, bar_5, bar_7_8

  the map would look like:

  (foo, [(0, 0), (1, 2)
    ), (bar, [(1, 5), (2, 8)])]

  This mapping makes sure we can quickly generate fresh identifiers. For example, generating a new id for "foo_1" would be a matter of looking up the base name in this map, concluding that the maximum identifier with this basename and this number of extensions is "foo_2", subsequently generating "foo_3".

  Note that an identifier with no extensions is also stored in this map for practical purposes, but the maximum ext is invalid.

- is_store :: !(HashSet Identifier)

  Identifier store

#### Instances

Instances details

Generic IdentifierSet Source # |
Instance details Defined in Clash.Netlist.Types Associated Types type Rep IdentifierSet :: Type -> Type Source # Methods from :: IdentifierSet -> Rep IdentifierSet x Source # to :: Rep IdentifierSet x -> IdentifierSet Source #
Show IdentifierSet Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> IdentifierSet -> ShowS Source # show :: IdentifierSet -> String Source # showList :: [IdentifierSet] -> ShowS Source #
HasIdentifierSet IdentifierSet Source # |
Instance details Defined in Clash.Netlist.Types Methods identifierSet :: Lens' IdentifierSet IdentifierSet Source #
NFData IdentifierSet Source # |
Instance details Defined in Clash.Netlist.Types Methods rnf :: IdentifierSet -> () Source #
type Rep IdentifierSet Source # |

Instance details

Defined in Clash.Netlist.Types

type Rep IdentifierSet = D1 ('MetaData "IdentifierSet" "Clash.Netlist.Types" "clash-lib-1.8.1-9u9U7p5PpHf8vtRevUOpPF" 'False) (C1 ('MetaCons "IdentifierSet" 'PrefixI 'True) ((S1 ('MetaSel ('Just "is_allowEscaped") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "is_lowerCaseBasicIds") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PreserveCase)) :*: (S1 ('MetaSel ('Just "is_hdl") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HDL) :*: (S1 ('MetaSel ('Just "is_freshCache") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FreshCache) :*: S1 ('MetaSel ('Just "is_store") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (HashSet Identifier))))))

class HasIdentifierSet s where Source #

Structures that hold an `IdentifierSet`

Methods

identifierSet :: Lens' s IdentifierSet Source #

#### Instances

Instances details

HasIdentifierSet SystemVerilogState Source # |
Instance details Defined in Clash.Backend.SystemVerilog Methods identifierSet :: Lens' SystemVerilogState IdentifierSet Source #
HasIdentifierSet VHDLState Source # |
Instance details Defined in Clash.Backend.VHDL Methods identifierSet :: Lens' VHDLState IdentifierSet Source #
HasIdentifierSet VerilogState Source # |
Instance details Defined in Clash.Backend.Verilog Methods identifierSet :: Lens' VerilogState IdentifierSet Source #
HasIdentifierSet IdentifierSet Source # |
Instance details Defined in Clash.Netlist.Types Methods identifierSet :: Lens' IdentifierSet IdentifierSet Source #
Backend backend => HasIdentifierSet (BlockState backend) Source # |
Instance details Defined in Clash.Primitives.DSL Methods identifierSet :: Lens' (BlockState backend) IdentifierSet Source #
HasIdentifierSet s => HasIdentifierSet (s, a) Source # |
Instance details Defined in Clash.Netlist.Types Methods identifierSet :: Lens' (s, a) IdentifierSet Source #

type UsageMap = Map Text Usage Source #

type IdentifierText = Text Source #

data BlackBox Source #

Constructors

BBTemplate BlackBoxTemplate |
BBFunction BBName BBHash TemplateFunction |

#### Instances

Instances details

Generic BlackBox Source # |
Instance details Defined in Clash.Netlist.Types Associated Types type Rep BlackBox :: Type -> Type Source # Methods from :: BlackBox -> Rep BlackBox x Source # to :: Rep BlackBox x -> BlackBox Source #
Show BlackBox Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> BlackBox -> ShowS Source # show :: BlackBox -> String Source # showList :: [BlackBox] -> ShowS Source #
Binary BlackBox Source # |
Instance details Defined in Clash.Netlist.Types Methods put :: BlackBox -> Put Source # get :: Get BlackBox Source # putList :: [BlackBox] -> Put Source #
NFData BlackBox Source # |
Instance details Defined in Clash.Netlist.Types Methods rnf :: BlackBox -> () Source #
type Rep BlackBox Source # |

Instance details

Defined in Clash.Netlist.Types

type Rep BlackBox = D1 ('MetaData "BlackBox" "Clash.Netlist.Types" "clash-lib-1.8.1-9u9U7p5PpHf8vtRevUOpPF" 'False) (C1 ('MetaCons "BBTemplate" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BlackBoxTemplate)) :+: C1 ('MetaCons "BBFunction" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BBName) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BBHash) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TemplateFunction))))

data FilteredHWType Source #

Tree structure indicating which constructor fields were filtered from a type due to them being void. We need this information to generate stable and/or user-defined port mappings.

Constructors

FilteredHWType HWType [[(IsVoid, FilteredHWType)]] |

#### Instances

Instances details

Show FilteredHWType Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> FilteredHWType -> ShowS Source # show :: FilteredHWType -> String Source # showList :: [FilteredHWType] -> ShowS Source #
Eq FilteredHWType Source # |
Instance details Defined in Clash.Netlist.Types Methods (==) :: FilteredHWType -> FilteredHWType -> Bool Source # (/=) :: FilteredHWType -> FilteredHWType -> Bool Source #

type HWMap = Map Type (Either String FilteredHWType) Source #

data SomeBackend where Source #

Existentially quantified backend

Constructors

SomeBackend :: Backend backend => backend -> SomeBackend |

data TopEntityT Source #

Structure describing a top entity: it's id and its port annotations.

Constructors

TopEntityT |

Fields

- topId :: Id

  Id of top entity

- topAnnotation :: Maybe TopEntity

  (Maybe) a topentity annotation

- topIsTestBench :: Bool

  Whether this entity is a test bench

#### Instances

Instances details

Generic TopEntityT Source # |
Instance details Defined in Clash.Netlist.Types Associated Types type Rep TopEntityT :: Type -> Type Source # Methods from :: TopEntityT -> Rep TopEntityT x Source # to :: Rep TopEntityT x -> TopEntityT Source #
Show TopEntityT Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> TopEntityT -> ShowS Source # show :: TopEntityT -> String Source # showList :: [TopEntityT] -> ShowS Source #
Binary TopEntityT Source # |
Instance details Defined in Clash.Annotations.TopEntity.Extra Methods put :: TopEntityT -> Put Source # get :: Get TopEntityT Source # putList :: [TopEntityT] -> Put Source #
NFData TopEntityT Source # |
Instance details Defined in Clash.Annotations.TopEntity.Extra Methods rnf :: TopEntityT -> () Source #
Eq TopEntityT Source # |
Instance details Defined in Clash.Netlist.Types Methods (==) :: TopEntityT -> TopEntityT -> Bool Source # (/=) :: TopEntityT -> TopEntityT -> Bool Source #
Hashable TopEntityT Source # |
Instance details Defined in Clash.Annotations.TopEntity.Extra Methods hashWithSalt :: Int -> TopEntityT -> Int Source # hash :: TopEntityT -> Int Source #
type Rep TopEntityT Source # |

Instance details

Defined in Clash.Netlist.Types

type Rep TopEntityT = D1 ('MetaData "TopEntityT" "Clash.Netlist.Types" "clash-lib-1.8.1-9u9U7p5PpHf8vtRevUOpPF" 'False) (C1 ('MetaCons "TopEntityT" 'PrefixI 'True) (S1 ('MetaSel ('Just "topId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Id) :*: (S1 ('MetaSel ('Just "topAnnotation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe TopEntity)) :*: S1 ('MetaSel ('Just "topIsTestBench") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool))))

data TemplateFunction where Source #

Constructors

TemplateFunction |

Fields

- :: [Int]

  Used arguments

- -> (BlackBoxContext -> Bool)

  Validation function. Should return `False` if function can't render given a certain context.

- -> (forall s. Backend s => BlackBoxContext -> State s Doc)

  Render function

- -> TemplateFunction

#### Instances

Instances details

Binary TemplateFunction Source # | NB: serialisation doesn't preserve the embedded function
Instance details Defined in Clash.Netlist.Types Methods put :: TemplateFunction -> Put Source # get :: Get TemplateFunction Source # putList :: [TemplateFunction] -> Put Source #
NFData TemplateFunction Source # |
Instance details Defined in Clash.Netlist.Types Methods rnf :: TemplateFunction -> () Source #

type ComponentMap = OMap Unique (ComponentMeta, Component) Source #

data ComponentMeta Source #

Constructors

ComponentMeta |

Fields

- cmWereVoids :: [Bool]
- cmLoc :: SrcSpan
- cmScope :: IdentifierSet
- cmUsage :: UsageMap

#### Instances

Instances details

Generic ComponentMeta Source # |
Instance details Defined in Clash.Netlist.Types Associated Types type Rep ComponentMeta :: Type -> Type Source # Methods from :: ComponentMeta -> Rep ComponentMeta x Source # to :: Rep ComponentMeta x -> ComponentMeta Source #
Show ComponentMeta Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> ComponentMeta -> ShowS Source # show :: ComponentMeta -> String Source # showList :: [ComponentMeta] -> ShowS Source #
NFData ComponentMeta Source # |
Instance details Defined in Clash.Netlist.Types Methods rnf :: ComponentMeta -> () Source #
type Rep ComponentMeta Source # |

Instance details

Defined in Clash.Netlist.Types

type Rep ComponentMeta = D1 ('MetaData "ComponentMeta" "Clash.Netlist.Types" "clash-lib-1.8.1-9u9U7p5PpHf8vtRevUOpPF" 'False) (C1 ('MetaCons "ComponentMeta" 'PrefixI 'True) ((S1 ('MetaSel ('Just "cmWereVoids") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Bool]) :*: S1 ('MetaSel ('Just "cmLoc") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SrcSpan)) :*: (S1 ('MetaSel ('Just "cmScope") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IdentifierSet) :*: S1 ('MetaSel ('Just "cmUsage") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UsageMap))))

data PreserveCase Source #

Whether to preserve casing in ids or converted everything to lowercase. Influenced by '-fclash-lower-case-basic-identifiers'

Constructors

PreserveCase |
ToLower |

#### Instances

Instances details

Generic PreserveCase Source # |
Instance details Defined in Clash.Netlist.Types Associated Types type Rep PreserveCase :: Type -> Type Source # Methods from :: PreserveCase -> Rep PreserveCase x Source # to :: Rep PreserveCase x -> PreserveCase Source #
Show PreserveCase Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> PreserveCase -> ShowS Source # show :: PreserveCase -> String Source # showList :: [PreserveCase] -> ShowS Source #
Binary PreserveCase Source # |
Instance details Defined in Clash.Netlist.Types Methods put :: PreserveCase -> Put Source # get :: Get PreserveCase Source # putList :: [PreserveCase] -> Put Source #
NFData PreserveCase Source # |
Instance details Defined in Clash.Netlist.Types Methods rnf :: PreserveCase -> () Source #
Eq PreserveCase Source # |
Instance details Defined in Clash.Netlist.Types Methods (==) :: PreserveCase -> PreserveCase -> Bool Source # (/=) :: PreserveCase -> PreserveCase -> Bool Source #
Hashable PreserveCase Source # |
Instance details Defined in Clash.Netlist.Types Methods hashWithSalt :: Int -> PreserveCase -> Int Source # hash :: PreserveCase -> Int Source #
type Rep PreserveCase Source # |
Instance details Defined in Clash.Netlist.Types type Rep PreserveCase = D1 ('MetaData "PreserveCase" "Clash.Netlist.Types" "clash-lib-1.8.1-9u9U7p5PpHf8vtRevUOpPF" 'False) (C1 ('MetaCons "PreserveCase" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ToLower" 'PrefixI 'False) (U1 :: Type -> Type))

newtype NetlistMonad a Source #

Monad that caches generated components (StateT) and remembers hidden inputs of components that are being generated (WriterT)

Constructors

NetlistMonad |

Fields

- runNetlist :: StateT NetlistState (ReaderT NetlistEnv IO) a

#### Instances

Instances details

MonadFail NetlistMonad Source # |
Instance details Defined in Clash.Netlist.Types Methods fail :: String -> NetlistMonad a Source #
MonadIO NetlistMonad Source # |
Instance details Defined in Clash.Netlist.Types Methods liftIO :: IO a -> NetlistMonad a Source #
Applicative NetlistMonad Source # |
Instance details Defined in Clash.Netlist.Types Methods pure :: a -> NetlistMonad a Source # (<*>) :: NetlistMonad (a -> b) -> NetlistMonad a -> NetlistMonad b Source # liftA2 :: (a -> b -> c) -> NetlistMonad a -> NetlistMonad b -> NetlistMonad c Source # (*>) :: NetlistMonad a -> NetlistMonad b -> NetlistMonad b Source # (<*) :: NetlistMonad a -> NetlistMonad b -> NetlistMonad a Source #
Functor NetlistMonad Source # |
Instance details Defined in Clash.Netlist.Types Methods fmap :: (a -> b) -> NetlistMonad a -> NetlistMonad b Source # (<$) :: a -> NetlistMonad b -> NetlistMonad a Source #
Monad NetlistMonad Source # |
Instance details Defined in Clash.Netlist.Types Methods (>>=) :: NetlistMonad a -> (a -> NetlistMonad b) -> NetlistMonad b Source # (>>) :: NetlistMonad a -> NetlistMonad b -> NetlistMonad b Source # return :: a -> NetlistMonad a Source #
IdentifierSetMonad NetlistMonad Source # |
Instance details Defined in Clash.Netlist.Types Methods identifierSetM :: (IdentifierSet -> IdentifierSet) -> NetlistMonad IdentifierSet Source #
MonadReader NetlistEnv NetlistMonad Source # |
Instance details Defined in Clash.Netlist.Types Methods ask :: NetlistMonad NetlistEnv Source # local :: (NetlistEnv -> NetlistEnv) -> NetlistMonad a -> NetlistMonad a Source # reader :: (NetlistEnv -> a) -> NetlistMonad a Source #
MonadState NetlistState NetlistMonad Source # |
Instance details Defined in Clash.Netlist.Types Methods get :: NetlistMonad NetlistState Source # put :: NetlistState -> NetlistMonad () Source # state :: (NetlistState -> (a, NetlistState)) -> NetlistMonad a Source #

data BlackBoxContext Source #

Context used to fill in the holes of a BlackBox template

Constructors

Context |

Fields

- bbName :: Text

  Blackbox function name (for error reporting)

- bbResults :: [(Expr, HWType)]

  Result names and types. Will typically be a list with a single item. Multiple result targets will be used for "multi result primitives". See `setupMultiResultPrim`.

- bbInputs :: [(Expr, HWType, Bool)]

  Argument names, types, and whether it is a literal

- bbFunctions :: IntMap [(Either BlackBox (Identifier, [Declaration]), Usage, [BlackBoxTemplate], [BlackBoxTemplate], [((Text, Text), BlackBox)], BlackBoxContext)]

  Function arguments (subset of inputs):

  - ( Blackbox Template , Whether the result should be reg or a wire (Verilog only) , Partial Blackbox Context )
- bbQsysIncName :: [IdentifierText]
- bbLevel :: Int

  The scoping level this context is associated with, ensures that `~ARGN[k][n]` holes are only filled with values from this context if `k` is equal to the scoping level of this context.

- bbCompName :: Identifier

  The component the BlackBox is instantiated in

- bbCtxName :: Maybe IdentifierText

  The "context name", name set by `setName`, defaults to the name of the closest binder

#### Instances

Instances details

Show BlackBoxContext Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> BlackBoxContext -> ShowS Source # show :: BlackBoxContext -> String Source # showList :: [BlackBoxContext] -> ShowS Source #

data Modifier Source #

Expression Modifier

Constructors

Indexed (HWType, Int, Int) | Index the expression: (Type of expression, DataCon tag, Field Tag). Note that the type of the expression is the type we are slicing from, not the type returned by the index operation.
DC (HWType, Int) | See expression in a DataCon context: (Type of the expression, DataCon tag)
VecAppend | See the expression in the context of a Vector append operation
RTreeAppend | See the expression in the context of a Tree append operation
Sliced (HWType, Int, Int) | Slice the identifier of the given type from start to end
Nested Modifier Modifier |

#### Instances

Instances details

Show Modifier Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> Modifier -> ShowS Source # show :: Modifier -> String Source # showList :: [Modifier] -> ShowS Source #

class Monad m => IdentifierSetMonad m where Source #

An IdentifierSetMonad supports unique name generation for Clash Netlist

Methods

identifierSetM :: (IdentifierSet -> IdentifierSet) -> m IdentifierSet Source #

#### Instances

Instances details

IdentifierSetMonad NetlistMonad Source # |
Instance details Defined in Clash.Netlist.Types Methods identifierSetM :: (IdentifierSet -> IdentifierSet) -> NetlistMonad IdentifierSet Source #
HasIdentifierSet s => IdentifierSetMonad (State s) Source # |
Instance details Defined in Clash.Netlist.Types Methods identifierSetM :: (IdentifierSet -> IdentifierSet) -> State s IdentifierSet Source #
HasIdentifierSet s => IdentifierSetMonad (State s) Source # |
Instance details Defined in Clash.Netlist.Types Methods identifierSetM :: (IdentifierSet -> IdentifierSet) -> State s IdentifierSet Source #
IdentifierSetMonad m => IdentifierSetMonad (Ap m) Source # |
Instance details Defined in Clash.Netlist.Types Methods identifierSetM :: (IdentifierSet -> IdentifierSet) -> Ap m IdentifierSet Source #

data IdentifierType Source #

Constructors

Basic | A basic identifier: does not have to be escaped in order to be a valid identifier in HDL.
Extended | An extended identifier: has to be escaped, wrapped, or otherwise postprocessed before writhing it to HDL.

#### Instances

Instances details

Generic IdentifierType Source # |
Instance details Defined in Clash.Netlist.Types Associated Types type Rep IdentifierType :: Type -> Type Source # Methods from :: IdentifierType -> Rep IdentifierType x Source # to :: Rep IdentifierType x -> IdentifierType Source #
Show IdentifierType Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> IdentifierType -> ShowS Source # show :: IdentifierType -> String Source # showList :: [IdentifierType] -> ShowS Source #
NFData IdentifierType Source # |
Instance details Defined in Clash.Netlist.Types Methods rnf :: IdentifierType -> () Source #
Eq IdentifierType Source # |
Instance details Defined in Clash.Netlist.Types Methods (==) :: IdentifierType -> IdentifierType -> Bool Source # (/=) :: IdentifierType -> IdentifierType -> Bool Source #
type Rep IdentifierType Source # |
Instance details Defined in Clash.Netlist.Types type Rep IdentifierType = D1 ('MetaData "IdentifierType" "Clash.Netlist.Types" "clash-lib-1.8.1-9u9U7p5PpHf8vtRevUOpPF" 'False) (C1 ('MetaCons "Basic" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Extended" 'PrefixI 'False) (U1 :: Type -> Type))

type FreshCache = HashMap Text (IntMap Word) Source #

See `is_freshCache`

data NetlistId Source #

Netlist-level identifier

Constructors

NetlistId Identifier Type | Identifier generated in the NetlistMonad, always derived from another `NetlistId`
CoreId Id | An original Core identifier
MultiId [Id] | A split identifier (into several sub-identifiers), needed to assign expressions of types that have to be split apart (e.g. tuples of Files)

#### Instances

Instances details

Show NetlistId Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> NetlistId -> ShowS Source # show :: NetlistId -> String Source # showList :: [NetlistId] -> ShowS Source #
Eq NetlistId Source # |
Instance details Defined in Clash.Netlist.Types Methods (==) :: NetlistId -> NetlistId -> Bool Source # (/=) :: NetlistId -> NetlistId -> Bool Source #

data DeclarationType Source #

Type of declaration, concurrent or sequential

Constructors

Concurrent |
Sequential |

data CommentOrDirective Source #

Constructors

Comment Comment |
Directive Directive |

#### Instances

Instances details

Show CommentOrDirective Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> CommentOrDirective -> ShowS Source # show :: CommentOrDirective -> String Source # showList :: [CommentOrDirective] -> ShowS Source #

data Blocking Source #

Procedural assignment in HDL can be blocking or non-blocking. This determines when the assignment takes place in simulation. The name refers to whether evaluation of the remaining statements in a process is blocked until the assignment is performed or not.

See Also:

IEEE 1364-2001, sections 9.2.1 and 9.2.2 IEEE 1076-1993, sections 8.4 and 8.5

Constructors

NonBlocking | A non-blocking assignment means the new value is not observed until the next time step in simulation. Using the signal later in the process will continue to return the old value.
Blocking | A blocking assignment means the new value is observed immediately. Using the signal later in the process will return the new value.

#### Instances

Instances details

Semigroup Blocking Source # |
Instance details Defined in Clash.Netlist.Types Methods (<>) :: Blocking -> Blocking -> Blocking Source # sconcat :: NonEmpty Blocking -> Blocking Source # stimes :: Integral b => b -> Blocking -> Blocking Source #
Generic Blocking Source # |
Instance details Defined in Clash.Netlist.Types Associated Types type Rep Blocking :: Type -> Type Source # Methods from :: Blocking -> Rep Blocking x Source # to :: Rep Blocking x -> Blocking Source #
Show Blocking Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> Blocking -> ShowS Source # show :: Blocking -> String Source # showList :: [Blocking] -> ShowS Source #
Binary Blocking Source # |
Instance details Defined in Clash.Netlist.Types Methods put :: Blocking -> Put Source # get :: Get Blocking Source # putList :: [Blocking] -> Put Source #
NFData Blocking Source # |
Instance details Defined in Clash.Netlist.Types Methods rnf :: Blocking -> () Source #
Eq Blocking Source # |
Instance details Defined in Clash.Netlist.Types Methods (==) :: Blocking -> Blocking -> Bool Source # (/=) :: Blocking -> Blocking -> Bool Source #
Hashable Blocking Source # |
Instance details Defined in Clash.Netlist.Types Methods hashWithSalt :: Int -> Blocking -> Int Source # hash :: Blocking -> Int Source #
type Rep Blocking Source # |
Instance details Defined in Clash.Netlist.Types type Rep Blocking = D1 ('MetaData "Blocking" "Clash.Netlist.Types" "clash-lib-1.8.1-9u9U7p5PpHf8vtRevUOpPF" 'False) (C1 ('MetaCons "NonBlocking" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Blocking" 'PrefixI 'False) (U1 :: Type -> Type))

data ExpandedTopEntity a Source #

Same as TopEntity, but with all port names that end up in HDL specified

Constructors

ExpandedTopEntity |

Fields

- et_inputs :: [Maybe (ExpandedPortName a)]

  Inputs with fully expanded port names. Nothing if port is void.

- et_output :: Maybe (ExpandedPortName a)

  Output with fully expanded port names. Nothing if port is void or BiDirectionalOut.

#### Instances

Instances details

Foldable ExpandedTopEntity Source # |

Instance details

Defined in Clash.Netlist.Types

Methods

fold :: Monoid m => ExpandedTopEntity m -> m Source #

foldMap :: Monoid m => (a -> m) -> ExpandedTopEntity a -> m Source #

foldMap' :: Monoid m => (a -> m) -> ExpandedTopEntity a -> m Source #

foldr :: (a -> b -> b) -> b -> ExpandedTopEntity a -> b Source #

foldr' :: (a -> b -> b) -> b -> ExpandedTopEntity a -> b Source #

foldl :: (b -> a -> b) -> b -> ExpandedTopEntity a -> b Source #

foldl' :: (b -> a -> b) -> b -> ExpandedTopEntity a -> b Source #

foldr1 :: (a -> a -> a) -> ExpandedTopEntity a -> a Source #

foldl1 :: (a -> a -> a) -> ExpandedTopEntity a -> a Source #

toList :: ExpandedTopEntity a -> [a] Source #

null :: ExpandedTopEntity a -> Bool Source #

length :: ExpandedTopEntity a -> Int Source #

elem :: Eq a => a -> ExpandedTopEntity a -> Bool Source #

maximum :: Ord a => ExpandedTopEntity a -> a Source #

minimum :: Ord a => ExpandedTopEntity a -> a Source #

sum :: Num a => ExpandedTopEntity a -> a Source #

product :: Num a => ExpandedTopEntity a -> a Source #

Traversable ExpandedTopEntity Source # |

Instance details

Defined in Clash.Netlist.Types

Methods

traverse :: Applicative f => (a -> f b) -> ExpandedTopEntity a -> f (ExpandedTopEntity b) Source #

sequenceA :: Applicative f => ExpandedTopEntity (f a) -> f (ExpandedTopEntity a) Source #

mapM :: Monad m => (a -> m b) -> ExpandedTopEntity a -> m (ExpandedTopEntity b) Source #

sequence :: Monad m => ExpandedTopEntity (m a) -> m (ExpandedTopEntity a) Source #

Functor ExpandedTopEntity Source # |
Instance details Defined in Clash.Netlist.Types Methods fmap :: (a -> b) -> ExpandedTopEntity a -> ExpandedTopEntity b Source # (<$) :: a -> ExpandedTopEntity b -> ExpandedTopEntity a Source #
Show a => Show (ExpandedTopEntity a) Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> ExpandedTopEntity a -> ShowS Source # show :: ExpandedTopEntity a -> String Source # showList :: [ExpandedTopEntity a] -> ShowS Source #

data ExpandedPortName a Source #

See ExpandedTopEntity

Constructors

ExpandedPortName HWType a | Same as PortName, but fully expanded
ExpandedPortProduct | Same as PortProduct, but fully expanded

Fields

- Text

  Name hint. Can be used to create intermediate signal names.

- HWType

  Type of product

- [ExpandedPortName a]

  Product fields

#### Instances

Instances details

Foldable ExpandedPortName Source # |

Instance details

Defined in Clash.Netlist.Types

Methods

fold :: Monoid m => ExpandedPortName m -> m Source #

foldMap :: Monoid m => (a -> m) -> ExpandedPortName a -> m Source #

foldMap' :: Monoid m => (a -> m) -> ExpandedPortName a -> m Source #

foldr :: (a -> b -> b) -> b -> ExpandedPortName a -> b Source #

foldr' :: (a -> b -> b) -> b -> ExpandedPortName a -> b Source #

foldl :: (b -> a -> b) -> b -> ExpandedPortName a -> b Source #

foldl' :: (b -> a -> b) -> b -> ExpandedPortName a -> b Source #

foldr1 :: (a -> a -> a) -> ExpandedPortName a -> a Source #

foldl1 :: (a -> a -> a) -> ExpandedPortName a -> a Source #

toList :: ExpandedPortName a -> [a] Source #

null :: ExpandedPortName a -> Bool Source #

length :: ExpandedPortName a -> Int Source #

elem :: Eq a => a -> ExpandedPortName a -> Bool Source #

maximum :: Ord a => ExpandedPortName a -> a Source #

minimum :: Ord a => ExpandedPortName a -> a Source #

sum :: Num a => ExpandedPortName a -> a Source #

product :: Num a => ExpandedPortName a -> a Source #

Traversable ExpandedPortName Source # |

Instance details

Defined in Clash.Netlist.Types

Methods

traverse :: Applicative f => (a -> f b) -> ExpandedPortName a -> f (ExpandedPortName b) Source #

sequenceA :: Applicative f => ExpandedPortName (f a) -> f (ExpandedPortName a) Source #

mapM :: Monad m => (a -> m b) -> ExpandedPortName a -> m (ExpandedPortName b) Source #

sequence :: Monad m => ExpandedPortName (m a) -> m (ExpandedPortName a) Source #

Functor ExpandedPortName Source # |
Instance details Defined in Clash.Netlist.Types Methods fmap :: (a -> b) -> ExpandedPortName a -> ExpandedPortName b Source # (<$) :: a -> ExpandedPortName b -> ExpandedPortName a Source #
Show a => Show (ExpandedPortName a) Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> ExpandedPortName a -> ShowS Source # show :: ExpandedPortName a -> String Source # showList :: [ExpandedPortName a] -> ShowS Source #

data NetlistState Source #

State of the NetlistMonad

Constructors

NetlistState |

Fields

- _bindings :: BindingMap

  Global binders

- _components :: ComponentMap

  Cached components. Is an insertion ordered map to preserve a topologically sorted component list for the manifest file.

- _typeTranslator :: CustomReprs -> TyConMap -> Type -> State HWMap (Maybe (Either String FilteredHWType))

  Hardcoded Type -> HWType translator

- _curCompNm :: !(Identifier, SrcSpan)
- _seenIds :: IdentifierSet

  All names currently in scope.

- _seenComps :: IdentifierSet

  Components (to be) generated during this netlist run. This is always a subset of `seenIds`. Reason d'etre: we currently generate components in a top down manner. E.g. given:

  - A
  - - B
  - - C

  we would generate component `A` first. Before trying to generate `B` and `C`. `A` might introduce a number of signal declarations. The names of these signals can't clash with the name of component `B`, hence we need to pick a name for B unique w.r.t. all these signal names. If we would postpone generating a unqiue name for `B` til _after_ generating all the signal names, the signal names would get all the "nice" names. E.g., a signal would be called "foo", thereby forcing the component `B` to be called "foo_1". Ideally, we'd use the "nice" names for components, and the "ugly" names for signals. To achieve this, we generate all the component names up front and subsequently store them in `_seenComps`.

- _seenPrimitives :: Set Text

  Keeps track of invocations of ´mkPrimitive´. It is currently used to filter duplicate warning invocations for dubious blackbox instantiations, see GitHub pull request #286.

- _componentNames :: VarEnv Identifier

  Names of components (to be) generated during this netlist run. Includes top entity names.

- _topEntityAnns :: VarEnv TopEntityT
- _hdlDir :: FilePath
- _curBBlvl :: Int

  The current scoping level assigned to black box contexts

- _isTestBench :: Bool

  Whether we're compiling a testbench (suppresses some warnings)

- _backEndITE :: Bool

  Whether the backend supports ifThenElse expressions

- _backend :: SomeBackend

  The current HDL backend

- _htyCache :: HWMap
- _usages :: UsageMap

  The current way signals are assigned in netlist. This is used to determine how signals are rendered in HDL (i.e. wire/reg in Verilog, or signal/variable in VHDL).

#### Instances

Instances details

HasUsageMap NetlistState Source # |
Instance details Defined in Clash.Netlist.Types Methods usageMap :: Lens' NetlistState UsageMap Source #
MonadState NetlistState NetlistMonad Source # |
Instance details Defined in Clash.Netlist.Types Methods get :: NetlistMonad NetlistState Source # put :: NetlistState -> NetlistMonad () Source # state :: (NetlistState -> (a, NetlistState)) -> NetlistMonad a Source #

data NetlistEnv Source #

Environment of the NetlistMonad

Constructors

NetlistEnv |

Fields

- _clashEnv :: ClashEnv
- _prefixName :: Text

  Prefix for instance/register names

- _suffixName :: Text

  Postfix for instance/register names

- _setName :: Maybe Text

  (Maybe) user given instance/register name

#### Instances

Instances details

MonadReader NetlistEnv NetlistMonad Source # |
Instance details Defined in Clash.Netlist.Types Methods ask :: NetlistMonad NetlistEnv Source # local :: (NetlistEnv -> NetlistEnv) -> NetlistMonad a -> NetlistMonad a Source # reader :: (NetlistEnv -> a) -> NetlistMonad a Source #

data ComponentPrefix Source #

Constructors

ComponentPrefix |

Fields

- componentPrefixTop :: Maybe Text

  Prefix for top-level components

- componentPrefixOther :: Maybe Text

  Prefix for all other components

#### Instances

Instances details

Show ComponentPrefix Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> ComponentPrefix -> ShowS Source # show :: ComponentPrefix -> String Source # showList :: [ComponentPrefix] -> ShowS Source #

type Directive = Text Source #

type IsVoid = Bool Source #

type DomainName = Text Source #

data PortDirection Source #

Constructors

In |
Out |

#### Instances

Instances details

Generic PortDirection Source # |
Instance details Defined in Clash.Netlist.Types Associated Types type Rep PortDirection :: Type -> Type Source # Methods from :: PortDirection -> Rep PortDirection x Source # to :: Rep PortDirection x -> PortDirection Source #
Show PortDirection Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> PortDirection -> ShowS Source # show :: PortDirection -> String Source # showList :: [PortDirection] -> ShowS Source #
NFData PortDirection Source # |
Instance details Defined in Clash.Netlist.Types Methods rnf :: PortDirection -> () Source #
Eq PortDirection Source # |
Instance details Defined in Clash.Netlist.Types Methods (==) :: PortDirection -> PortDirection -> Bool Source # (/=) :: PortDirection -> PortDirection -> Bool Source #
Ord PortDirection Source # |

Instance details

Defined in Clash.Netlist.Types

Methods

compare :: PortDirection -> PortDirection -> Ordering Source #

(<) :: PortDirection -> PortDirection -> Bool Source #

(<=) :: PortDirection -> PortDirection -> Bool Source #

(>) :: PortDirection -> PortDirection -> Bool Source #

(>=) :: PortDirection -> PortDirection -> Bool Source #

max :: PortDirection -> PortDirection -> PortDirection Source #

min :: PortDirection -> PortDirection -> PortDirection Source #

Hashable PortDirection Source # |
Instance details Defined in Clash.Netlist.Types Methods hashWithSalt :: Int -> PortDirection -> Int Source # hash :: PortDirection -> Int Source #
type Rep PortDirection Source # |
Instance details Defined in Clash.Netlist.Types type Rep PortDirection = D1 ('MetaData "PortDirection" "Clash.Netlist.Types" "clash-lib-1.8.1-9u9U7p5PpHf8vtRevUOpPF" 'False) (C1 ('MetaCons "In" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Out" 'PrefixI 'False) (U1 :: Type -> Type))

data PortMap Source #

Specifies how to wire up a component instance

Constructors

IndexedPortMap [(PortDirection, HWType, Expr)] | Port map based on port positions (port direction, type, assignment) HDL Example: bytemaster bytemaster_ds ( clk_1 , rst_1 , bitCtrl_0 );
NamedPortMap [(Expr, PortDirection, HWType, Expr)] | Port map based on port names (port name, port direction, type, assignment) HDL Example: bytemaster bytemaster_ds ( .clk (clk_1) , .rst (rst_1) , .bitCtrl (bitCtrl_0) );

#### Instances

Instances details

Show PortMap Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> PortMap -> ShowS Source # show :: PortMap -> String Source # showList :: [PortMap] -> ShowS Source #

data EntityOrComponent Source #

Constructors

Entity |
Comp |
Empty |

#### Instances

Instances details

Show EntityOrComponent Source # |
Instance details Defined in Clash.Netlist.Types Methods showsPrec :: Int -> EntityOrComponent -> ShowS Source # show :: EntityOrComponent -> String Source # showList :: [EntityOrComponent] -> ShowS Source #

type BBName = String Source #

type BBHash = Int Source #

pattern NetDecl Source #

Arguments

:: Maybe Comment | Note; will be inserted as a comment in target hdl
-> Identifier | Name of signal
-> HWType | Type of signal
-> Declaration |

backend :: Lens' NetlistState SomeBackend Source #

prefixName :: Lens' NetlistEnv Text Source #

suffixName :: Lens' NetlistEnv Text Source #

setName :: Lens' NetlistEnv (Maybe Text) Source #

components :: Lens' NetlistState ComponentMap Source #

intWidth :: Getter NetlistEnv Int Source #

usages :: Lens' NetlistState UsageMap Source #

findClocks :: Component -> [(Text, Text)] Source #

Find the name and domain name of each clock argument of a component.

This will not consider `ClockN` to be a clock argument, which means only the positive phase of a differential pair will be added to `sdcClock`.

hwTypeDomain :: HWType -> Maybe DomainName Source #

bindings :: Lens' NetlistState BindingMap Source #

tcCache :: Getter NetlistEnv TyConMap Source #

customReprs :: Getter NetlistEnv CustomReprs Source #

typeTranslator :: Lens' NetlistState (CustomReprs -> TyConMap -> Type -> State HWMap (Maybe (Either String FilteredHWType))) Source #

primitives :: Getter NetlistEnv CompiledPrimMap Source #

toBit Source #

Arguments

:: Integer | mask
-> Integer | value
-> Bit |

curCompNm :: Lens' NetlistState (Identifier, SrcSpan) Source #

emptyBBContext :: Text -> BlackBoxContext Source #

identifierKey# :: Identifier -> ((Text, Bool), [Word]) Source #

isBiDirectional :: (Identifier, HWType) -> Bool Source #

Check if an input port is really an inout port.

annotated :: [Attr Text] -> HWType -> HWType Source #

Smart constructor for `Annotated`. Wraps the given type in an `Annotated` if the attribute list is non-empty. If it is empty, it will return the given `HWType` unchanged.

hwTypeAttrs :: HWType -> [Attr Text] Source #

Extract hardware attributes from Annotated. Returns an empty list if non-Annotated given or if Annotated has an empty list of attributes.

lookupUsage :: Identifier -> UsageMap -> Maybe Usage Source #

isConstExpr :: Expr -> Bool Source #

netlistId1 Source #

Arguments

:: HasCallStack |
=> (Identifier -> r) | Eliminator for Identifiers generated in the NetlistMonad
-> (Id -> r) | Eliminator for original Core Identifiers
-> NetlistId |
-> r |

Eliminator for `NetlistId`, fails on `MultiId`

netlistTypes :: NetlistId -> [Type] Source #

Return the type(s) of a `NetListId`, returns multiple types when given a `MultiId`

netlistTypes1 :: HasCallStack => NetlistId -> Type Source #

Return the type of a `NetlistId`, fails on `MultiId`

clashEnv :: Lens' NetlistEnv ClashEnv Source #

clashOpts :: Getter NetlistEnv ClashOpts Source #

seenIds :: Lens' NetlistState IdentifierSet Source #

backEndITE :: Lens' NetlistState Bool Source #

componentNames :: Lens' NetlistState (VarEnv Identifier) Source #

curBBlvl :: Lens' NetlistState Int Source #

hdlDir :: Lens' NetlistState FilePath Source #

htyCache :: Lens' NetlistState HWMap Source #

isTestBench :: Lens' NetlistState Bool Source #

seenComps :: Lens' NetlistState IdentifierSet Source #

seenPrimitives :: Lens' NetlistState (Set Text) Source #

topEntityAnns :: Lens' NetlistState (VarEnv TopEntityT) Source #