Cerata
A library to generate structural hardware designs
cerata::Bit Struct Reference

A bit type. More...

#include <type.h>

+ Inheritance diagram for cerata::Bit:
+ Collaboration diagram for cerata::Bit:

Public Member Functions

bool IsPhysical () const override
 Return true if the Type has an immediate physical representation, false otherwise.
 
bool IsGeneric () const override
 Return true if the Type is a generic type.
 
bool IsNested () const override
 Return true if the Type is a nested, false otherwise.
 
 Bit (std::string name)
 Bit type constructor.
 
std::optional< Node * > width () const override
 Bit width returns integer literal 1.
 
std::shared_ptr< TypeCopy (const NodeMap &rebinding) const override
 Make a copy of the type, and rebind any type generic nodes that are keys in the rebinding to their values. More...
 
- Public Member Functions inherited from cerata::Type
 Type (std::string name, ID id)
 Type constructor. More...
 
ID id () const
 Return the Type ID.
 
virtual bool IsEqual (const Type &other) const
 Determine if this Type is exactly equal to an other Type. More...
 
bool Is (ID type_id) const
 Return true if the Type ID is type_id, false otherwise.
 
std::string ToString (bool show_meta=false, bool show_mappers=false) const
 Return the Type ID as a human-readable string.
 
std::vector< std::shared_ptr< TypeMapper > > mappers () const
 Return possible type mappers.
 
void AddMapper (const std::shared_ptr< TypeMapper > &mapper, bool remove_existing=true)
 Add a type mapper.
 
std::optional< std::shared_ptr< TypeMapper > > GetMapper (Type *other, bool generate_implicit=true)
 Get a mapper to another type, if it exists. Generates one, if possible, when generate_implicit = true.
 
int RemoveMappersTo (Type *other)
 Remove all mappers to a specific type.
 
std::optional< std::shared_ptr< TypeMapper > > GetMapper (const std::shared_ptr< Type > &other)
 Get a mapper to another type, if it exists.
 
virtual bool CanGenerateMapper (const Type &other) const
 Check if a mapper can be generated to another specific type.
 
virtual std::shared_ptr< TypeMapperGenerateMapper (Type *other)
 Generate a new mapper to a specific other type. Should be checked with CanGenerateMapper first, or throws.
 
virtual std::vector< Node * > GetGenerics () const
 Obtain any nodes that this type uses as generics.
 
virtual std::vector< Type * > GetNested () const
 Obtain any nested types.
 
virtual std::shared_ptr< TypeCopy () const
 Make a copy of the type without rebinding. More...
 
std::shared_ptr< Typeoperator() (std::vector< Node * > nodes)
 Make a copy of the type, and rebind any type generic nodes in order of the GetGenerics call. More...
 
std::shared_ptr< Typeoperator() (const std::vector< std::shared_ptr< Node >> &nodes)
 Make a copy of the type, and rebind any type generic nodes in order of the GetGenerics call. More...
 
- Public Member Functions inherited from cerata::Named
 Named (std::string name)
 Named constructor.
 
std::string name () const
 Return the name of the object.
 
void SetName (std::string name)
 Change the name of the object.
 
virtual ~Named ()=default
 Destructor.
 

Additional Inherited Members

- Public Types inherited from cerata::Type
enum  ID {
  BIT, VECTOR, INTEGER, STRING,
  BOOLEAN, RECORD
}
 The Type ID. Used for convenient type checking. More...
 
- Public Attributes inherited from cerata::Type
std::unordered_map< std::string, std::string > meta
 KV storage for metadata of tools or specific backend implementations.
 
- Protected Attributes inherited from cerata::Type
ID id_
 Type ID.
 
std::vector< std::shared_ptr< TypeMapper > > mappers_
 A list of mappers that can map this type to another type.
 

Detailed Description

A bit type.

Definition at line 173 of file type.h.

Member Function Documentation

◆ Copy()

std::shared_ptr< Type > cerata::Bit::Copy ( const NodeMap rebinding) const
overridevirtual

Make a copy of the type, and rebind any type generic nodes that are keys in the rebinding to their values.

This is useful in case type generic nodes are on some instance graph and have to be copied over to a component graph, or vice versa. In that case, the new graph has to copy over these nodes and rebind the type generic nodes.

Returns
A copy of the type.

Implements cerata::Type.

Definition at line 391 of file type.cc.


The documentation for this struct was generated from the following files: