Cerata
A library to generate structural hardware designs
|
#include <type.h>
Public Types | |
enum | ID { BIT, VECTOR, INTEGER, STRING, BOOLEAN, RECORD } |
The Type ID. Used for convenient type checking. More... | |
Public Member Functions | |
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. | |
virtual bool | IsPhysical () const =0 |
Return true if the Type has an immediate physical representation, false otherwise. | |
virtual bool | IsNested () const =0 |
Return true if the Type is a nested, false otherwise. | |
virtual bool | IsGeneric () const =0 |
Return true if the Type is a generic type. | |
virtual std::optional< Node * > | width () const |
Return the width of the type, if it is synthesizable. | |
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 NodeMap &rebinding) const =0 |
Make a copy of the type, and rebind any type generic nodes that are keys in the rebinding to their values. More... | |
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. | |
Public Attributes | |
std::unordered_map< std::string, std::string > | meta |
KV storage for metadata of tools or specific backend implementations. | |
Protected Attributes | |
ID | id_ |
Type ID. | |
std::vector< std::shared_ptr< TypeMapper > > | mappers_ |
A list of mappers that can map this type to another type. | |
A Type.
Types can logically be classified as follows.
Physical:
Generic:
Nested:
enum cerata::Type::ID |
|
explicit |
|
inlinevirtual |
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.
Implemented in cerata::Record, cerata::Vector, cerata::String, cerata::Integer, cerata::Boolean, and cerata::Bit.
|
virtual |
Determine if this Type is exactly equal to an other Type.
other | The other type. |
Reimplemented in cerata::Record, and cerata::Vector.