Cerata
A library to generate structural hardware designs
|
A bit type. More...
#include <type.h>
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< Type > | Copy (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... | |
![]() | |
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< TypeMapper > | GenerateMapper (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< Type > | Copy () const |
Make a copy of the type without rebinding. More... | |
std::shared_ptr< Type > | operator() (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< Type > | operator() (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... | |
![]() | |
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 | |
![]() | |
enum | ID { BIT, VECTOR, INTEGER, STRING, BOOLEAN, RECORD } |
The Type ID. Used for convenient type checking. More... | |
![]() | |
std::unordered_map< std::string, std::string > | meta |
KV storage for metadata of tools or specific backend implementations. | |
![]() | |
ID | id_ |
Type ID. | |
std::vector< std::shared_ptr< TypeMapper > > | mappers_ |
A list of mappers that can map this type to another type. | |
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.
Implements cerata::Type.