Copyright | (C) 2012-2016 University of Twente 2017 Myrtle Software Ltd 2017-2018 Google Inc. |
---|---|
License | BSD2 (see the file LICENSE) |
Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com> |
Safe Haskell | None |
Language | Haskell2010 |
Type and instance definitions for Netlist modules
Synopsis
- data Declaration where
- Assignment !Identifier !Expr
- CondAssignment !Identifier !HWType !Expr !HWType [(Maybe Literal, Expr)]
- InstDecl EntityOrComponent (Maybe Comment) !Identifier !Identifier [(Expr, HWType, Expr)] [(Expr, PortDirection, HWType, Expr)]
- BlackBoxD !Text [BlackBoxTemplate] [BlackBoxTemplate] [((Text, Text), BlackBox)] !BlackBox BlackBoxContext
- NetDecl' (Maybe Comment) WireOrReg !Identifier (Either Identifier HWType) (Maybe Expr)
- TickDecl Comment
- Seq [Seq]
- pattern NetDecl :: Maybe Comment -> Identifier -> HWType -> Declaration
- newtype NetlistMonad a = NetlistMonad {
- runNetlist :: StateT NetlistState (ReaderT NetlistEnv IO) a
- data BlackBox
- 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
- | ConvBV (Maybe Identifier) HWType Bool Expr
- | IfThenElse Expr Expr Expr
- | Noop
- data Component = Component {
- componentName :: !Identifier
- inputs :: [(Identifier, HWType)]
- outputs :: [(WireOrReg, (Identifier, HWType), Maybe Expr)]
- declarations :: [Declaration]
- data Declaration
- = Assignment !Identifier !Expr
- | CondAssignment !Identifier !HWType !Expr !HWType [(Maybe Literal, Expr)]
- | InstDecl EntityOrComponent (Maybe Comment) !Identifier !Identifier [(Expr, HWType, Expr)] [(Expr, PortDirection, HWType, Expr)]
- | BlackBoxD !Text [BlackBoxTemplate] [BlackBoxTemplate] [((Text, Text), BlackBox)] !BlackBox BlackBoxContext
- | NetDecl' (Maybe Comment) WireOrReg !Identifier (Either Identifier HWType) (Maybe Expr)
- | TickDecl Comment
- | Seq [Seq]
- data HWType
- = Void (Maybe HWType)
- | String
- | Integer
- | Bool
- | Bit
- | BitVector !Size
- | Index !Integer
- | Signed !Size
- | Unsigned !Size
- | Vector !Size !HWType
- | RTree !Size !HWType
- | Sum !Identifier [Identifier]
- | Product !Identifier (Maybe [Text]) [HWType]
- | SP !Identifier [(Identifier, [HWType])]
- | Clock !Identifier
- | Reset !Identifier
- | BiDirectional !PortDirection !HWType
- | CustomSP !Identifier !DataRepr' !Size [(ConstrRepr', Identifier, [HWType])]
- | CustomSum !Identifier !DataRepr' !Size [(ConstrRepr', Identifier)]
- | CustomProduct !Identifier !DataRepr' !Size (Maybe [Text]) [(FieldAnn, HWType)]
- | Annotated [Attr'] !HWType
- | KnownDomain !Identifier !Integer !ActiveEdge !ResetKind !InitBehavior !ResetPolarity
- | FileType
- type Identifier = Text
- data DeclarationType
- data NetlistId
- data TemplateFunction where
- TemplateFunction :: [Int] -> (BlackBoxContext -> Bool) -> (forall s. Backend s => BlackBoxContext -> State s Doc) -> TemplateFunction
- type BBHash = Int
- type BBName = String
- data BlackBoxContext = Context {
- bbName :: Text
- bbResult :: (Expr, HWType)
- bbInputs :: [(Expr, HWType, Bool)]
- bbFunctions :: IntMap [(Either BlackBox (Identifier, [Declaration]), WireOrReg, [BlackBoxTemplate], [BlackBoxTemplate], [((Text, Text), BlackBox)], BlackBoxContext)]
- bbQsysIncName :: [Identifier]
- bbLevel :: Int
- bbCompName :: Identifier
- bbCtxName :: Maybe Identifier
- data Bit
- data Literal
- data Modifier
- data PortDirection
- data WireOrReg
- data EntityOrComponent
- data Seq
- = AlwaysClocked ActiveEdge Expr [Seq]
- | Initial [Seq]
- | AlwaysComb [Seq]
- | SeqDecl Declaration
- | Branch !Expr !HWType [(Maybe Literal, [Seq])]
- data FilteredHWType = FilteredHWType HWType [[(IsVoid, FilteredHWType)]]
- type IsVoid = Bool
- type Size = Int
- type Comment = Text
- data SomeBackend where
- SomeBackend :: Backend backend => backend -> SomeBackend
- data ComponentPrefix = ComponentPrefix {}
- data NetlistState = NetlistState {
- _bindings :: BindingMap
- _varCount :: !Int
- _components :: VarEnv ([Bool], SrcSpan, HashMap Identifier Word, Component)
- _primitives :: CompiledPrimMap
- _typeTranslator :: CustomReprs -> TyConMap -> Type -> State HWMap (Maybe (Either String FilteredHWType))
- _tcCache :: TyConMap
- _curCompNm :: !(Identifier, SrcSpan)
- _intWidth :: Int
- _mkIdentifierFn :: IdType -> Identifier -> Identifier
- _extendIdentifierFn :: IdType -> Identifier -> Identifier -> Identifier
- _seenIds :: HashMap Identifier Word
- _seenComps :: HashMap Identifier Word
- _seenPrimitives :: Set Text
- _componentNames :: VarEnv Identifier
- _topEntityAnns :: VarEnv TopEntityT
- _hdlDir :: FilePath
- _curBBlvl :: Int
- _componentPrefix :: ComponentPrefix
- _customReprs :: CustomReprs
- _clashOpts :: ClashOpts
- _isTestBench :: Bool
- _backEndITE :: Bool
- _backend :: SomeBackend
- _htyCache :: HWMap
- data NetlistEnv = NetlistEnv {}
- type HWMap = HashMap Type (Either String FilteredHWType)
- data TopEntityT = TopEntityT {
- topId :: Id
- topAnnotation :: Maybe TopEntity
- associatedTestbench :: Maybe Id
- pattern NetDecl :: Maybe Comment -> Identifier -> HWType -> Declaration
- hwTypeAttrs :: HWType -> [Attr']
- toBit :: Integer -> Integer -> Bit
- netlistId :: (Identifier -> r) -> (Id -> r) -> NetlistId -> [r]
- netlistId1 :: HasCallStack => (Identifier -> r) -> (Id -> r) -> NetlistId -> r
- netlistTypes :: NetlistId -> [Type]
- netlistTypes1 :: HasCallStack => NetlistId -> Type
- emptyBBContext :: Text -> BlackBoxContext
- prefixName :: Lens' NetlistEnv Identifier
- setName :: Lens' NetlistEnv (Maybe Identifier)
- suffixName :: Lens' NetlistEnv Identifier
- backEndITE :: Lens' NetlistState Bool
- backend :: Lens' NetlistState SomeBackend
- bindings :: Lens' NetlistState BindingMap
- clashOpts :: Lens' NetlistState ClashOpts
- componentNames :: Lens' NetlistState (VarEnv Identifier)
- componentPrefix :: Lens' NetlistState ComponentPrefix
- components :: Lens' NetlistState (VarEnv ([Bool], SrcSpan, HashMap Identifier Word, Component))
- curBBlvl :: Lens' NetlistState Int
- curCompNm :: Lens' NetlistState (Identifier, SrcSpan)
- customReprs :: Lens' NetlistState CustomReprs
- extendIdentifierFn :: Lens' NetlistState (IdType -> Identifier -> Identifier -> Identifier)
- hdlDir :: Lens' NetlistState FilePath
- htyCache :: Lens' NetlistState HWMap
- intWidth :: Lens' NetlistState Int
- isTestBench :: Lens' NetlistState Bool
- mkIdentifierFn :: Lens' NetlistState (IdType -> Identifier -> Identifier)
- primitives :: Lens' NetlistState CompiledPrimMap
- seenComps :: Lens' NetlistState (HashMap Identifier Word)
- seenIds :: Lens' NetlistState (HashMap Identifier Word)
- seenPrimitives :: Lens' NetlistState (Set Text)
- tcCache :: Lens' NetlistState TyConMap
- topEntityAnns :: Lens' NetlistState (VarEnv TopEntityT)
- typeTranslator :: Lens' NetlistState (CustomReprs -> TyConMap -> Type -> State HWMap (Maybe (Either String FilteredHWType)))
- varCount :: Lens' NetlistState Int
Documentation
data Declaration Source #
Internals of a Component
Assignment | Signal assignment |
| |
CondAssignment | Conditional signal assignment: |
InstDecl | Instantiation of another component: |
| |
BlackBoxD | Instantiation of blackbox declaration |
| |
NetDecl' | Signal declaration |
| |
TickDecl Comment | HDL tick corresponding to a Core tick | Sequential statement |
Seq [Seq] |
pattern NetDecl | |
|
Instances
Show Declaration Source # | |
Defined in Clash.Netlist.Types showsPrec :: Int -> Declaration -> ShowS # show :: Declaration -> String # showList :: [Declaration] -> ShowS # | |
NFData Declaration Source # | |
Defined in Clash.Netlist.Types rnf :: Declaration -> () # |
newtype NetlistMonad a Source #
Monad that caches generated components (StateT) and remembers hidden inputs of components that are being generated (WriterT)
Instances
Instances
Show BlackBox Source # | |
Generic BlackBox Source # | |
Binary BlackBox Source # | |
NFData BlackBox Source # | |
Defined in Clash.Netlist.Types | |
type Rep BlackBox Source # | |
Defined in Clash.Netlist.Types type Rep BlackBox = D1 ('MetaData "BlackBox" "Clash.Netlist.Types" "clash-lib-1.2.5-inplace" '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)))) |
Expression used in RHS of a declaration
Literal !(Maybe (HWType, Size)) !Literal | Literal expression |
DataCon !HWType !Modifier [Expr] | DataCon application |
Identifier !Identifier !(Maybe Modifier) | Signal reference |
DataTag !HWType !(Either Identifier Identifier) |
|
BlackBoxE | Instantiation of a BlackBox expression |
| |
ConvBV (Maybe Identifier) HWType Bool Expr | |
IfThenElse Expr Expr Expr | |
Noop | Do nothing |
Component: base unit of a Netlist
Component | |
|
data Declaration Source #
Internals of a Component
Assignment | Signal assignment |
| |
CondAssignment | Conditional signal assignment: |
InstDecl | Instantiation of another component: |
| |
BlackBoxD | Instantiation of blackbox declaration |
| |
NetDecl' | Signal declaration |
| |
TickDecl Comment | HDL tick corresponding to a Core tick | Sequential statement |
Seq [Seq] |
Instances
Show Declaration Source # | |
Defined in Clash.Netlist.Types showsPrec :: Int -> Declaration -> ShowS # show :: Declaration -> String # showList :: [Declaration] -> ShowS # | |
NFData Declaration Source # | |
Defined in Clash.Netlist.Types rnf :: Declaration -> () # |
Representable hardware types
Void (Maybe HWType) | Empty type. |
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 |
RTree !Size !HWType | RTree type |
Sum !Identifier [Identifier] | Sum type: Name and Constructor names |
Product !Identifier (Maybe [Text]) [HWType] | Product type: Name, field names, and field types. Field names will be populated when using records. |
SP !Identifier [(Identifier, [HWType])] | Sum-of-Product type: Name and Constructor names + field types |
Clock !Identifier | Clock type corresponding to domain Identifier |
Reset !Identifier | Reset type corresponding to domain Identifier |
BiDirectional !PortDirection !HWType | Tagging type indicating a bidirectional (inout) port |
CustomSP !Identifier !DataRepr' !Size [(ConstrRepr', Identifier, [HWType])] | Same as Sum-Of-Product, but with a user specified bit representation. For more info, see: Clash.Annotations.BitRepresentations. |
CustomSum !Identifier !DataRepr' !Size [(ConstrRepr', Identifier)] | Same as Sum, but with a user specified bit representation. For more info, see: Clash.Annotations.BitRepresentations. |
CustomProduct !Identifier !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'] !HWType | Annotated with HDL attributes |
KnownDomain !Identifier !Integer !ActiveEdge !ResetKind !InitBehavior !ResetPolarity | Domain name, period, active edge, reset kind, initial value behavior |
FileType | File type for simulation-level I/O |
Instances
type Identifier = Text Source #
Signal reference
Netlist-level identifier
data TemplateFunction where Source #
TemplateFunction :: [Int] -> (BlackBoxContext -> Bool) -> (forall s. Backend s => BlackBoxContext -> State s Doc) -> TemplateFunction |
Instances
Binary TemplateFunction Source # | NB: serialisation doesn't preserve the embedded function |
Defined in Clash.Netlist.Types | |
NFData TemplateFunction Source # | |
Defined in Clash.Netlist.Types rnf :: TemplateFunction -> () # |
data BlackBoxContext Source #
Context used to fill in the holes of a BlackBox template
Context | |
|
Instances
Show BlackBoxContext Source # | |
Defined in Clash.Netlist.Types showsPrec :: Int -> BlackBoxContext -> ShowS # show :: BlackBoxContext -> String # showList :: [BlackBoxContext] -> ShowS # |
Literals used in an expression
Expression Modifier
Indexed (HWType, Int, Int) | Index the expression: (Type of expression,DataCon tag,Field Tag) |
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 |
data PortDirection Source #
Instances
data EntityOrComponent Source #
Instances
Show EntityOrComponent Source # | |
Defined in Clash.Netlist.Types showsPrec :: Int -> EntityOrComponent -> ShowS # show :: EntityOrComponent -> String # showList :: [EntityOrComponent] -> ShowS # |
Sequential statements
AlwaysClocked | Clocked sequential statements |
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 | |
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.
FilteredHWType HWType [[(IsVoid, FilteredHWType)]] |
Instances
Eq FilteredHWType Source # | |
Defined in Clash.Netlist.Types (==) :: FilteredHWType -> FilteredHWType -> Bool # (/=) :: FilteredHWType -> FilteredHWType -> Bool # | |
Show FilteredHWType Source # | |
Defined in Clash.Netlist.Types showsPrec :: Int -> FilteredHWType -> ShowS # show :: FilteredHWType -> String # showList :: [FilteredHWType] -> ShowS # |
data SomeBackend where Source #
Existentially quantified backend
SomeBackend :: Backend backend => backend -> SomeBackend |
data ComponentPrefix Source #
ComponentPrefix | |
|
Instances
Show ComponentPrefix Source # | |
Defined in Clash.Netlist.Types showsPrec :: Int -> ComponentPrefix -> ShowS # show :: ComponentPrefix -> String # showList :: [ComponentPrefix] -> ShowS # |
data NetlistState Source #
State of the NetlistMonad
NetlistState | |
|
Instances
MonadState NetlistState NetlistMonad Source # | |
Defined in Clash.Netlist.Types get :: NetlistMonad NetlistState # put :: NetlistState -> NetlistMonad () # state :: (NetlistState -> (a, NetlistState)) -> NetlistMonad a # |
data NetlistEnv Source #
Environment of the NetlistMonad
NetlistEnv | |
|
Instances
MonadReader NetlistEnv NetlistMonad Source # | |
Defined in Clash.Netlist.Types ask :: NetlistMonad NetlistEnv # local :: (NetlistEnv -> NetlistEnv) -> NetlistMonad a -> NetlistMonad a # reader :: (NetlistEnv -> a) -> NetlistMonad a # |
data TopEntityT Source #
Structure describing a top entity: it's id, its port annotations, and associated testbench.
TopEntityT | |
|
Instances
:: Maybe Comment | Note; will be inserted as a comment in target hdl |
-> Identifier | Name of signal |
-> HWType | Type of signal |
-> Declaration |
hwTypeAttrs :: HWType -> [Attr'] Source #
Extract hardware attributes from Annotated. Returns an empty list if non-Annotated given or if Annotated has an empty list of attributes.
:: (Identifier -> r) | Eliminator for Identifiers generated in the NetlistMonad |
-> (Id -> r) | Eliminator for original Core Identifiers |
-> NetlistId | |
-> [r] |
Eliminator for NetlistId
:: HasCallStack | |
=> (Identifier -> r) | Eliminator for Identifiers generated in the NetlistMonad |
-> (Id -> r) | Eliminator for original Core Identifiers |
-> NetlistId | |
-> r |
netlistTypes :: NetlistId -> [Type] Source #
Return the type(s) of a NetListId
, returns multiple types when given a
MultiId
netlistTypes1 :: HasCallStack => NetlistId -> Type Source #
emptyBBContext :: Text -> BlackBoxContext Source #
setName :: Lens' NetlistEnv (Maybe Identifier) Source #
components :: Lens' NetlistState (VarEnv ([Bool], SrcSpan, HashMap Identifier Word, Component)) Source #
customReprs :: Lens' NetlistState CustomReprs Source #
extendIdentifierFn :: Lens' NetlistState (IdType -> Identifier -> Identifier -> Identifier) Source #
mkIdentifierFn :: Lens' NetlistState (IdType -> Identifier -> Identifier) Source #
typeTranslator :: Lens' NetlistState (CustomReprs -> TyConMap -> Type -> State HWMap (Maybe (Either String FilteredHWType))) Source #