Cerata
A library to generate structural hardware designs
cerata::Literal Class Reference

A Literal Node. More...

#include <literal.h>

+ Inheritance diagram for cerata::Literal:
+ Collaboration diagram for cerata::Literal:

Public Types

enum  StorageType { INT, UINT, STRING, BOOL }
 The storage type of the literal value.
 
- Public Types inherited from cerata::Node
enum  NodeID {
  NodeID::PORT, NodeID::SIGNAL, NodeID::PARAMETER, NodeID::LITERAL,
  NodeID::EXPRESSION
}
 Node type IDs with different properties. More...
 
- Public Types inherited from cerata::Object
enum  ID { NODE, ARRAY }
 Object type ID to conveniently cast the object during run-time. More...
 

Public Member Functions

void SetParent (Graph *graph) override
 Literal nodes are only owned by the literal pool, hence never have a parent graph.
 
std::shared_ptr< ObjectCopy () const override
 Create a copy of this Literal.
 
std::vector< Edge * > sources () const override
 A literal node has no inputs. This function returns an empty list.
 
std::vector< Edge * > sinks () const override
 Get the output edges of this Node.
 
std::string ToString () const override
 Convert the Literal value to a human-readable string.
 
StorageType storage_type () const
 Return the storage type of the literal.
 
- Public Member Functions inherited from cerata::MultiOutputNode
 MultiOutputNode (std::string name, Node::NodeID id, std::shared_ptr< Type > type)
 MultiOutputNode constructor.
 
std::vector< Edge * > sources () const override
 Return the incoming edges (in this case just the single input edge) that sources this Node.
 
std::vector< Edge * > sinks () const override
 The outgoing Edges that this Node sinks.
 
bool RemoveEdge (Edge *edge) override
 Remove an edge from this node.
 
bool AddEdge (const std::shared_ptr< Edge > &edge) override
 Add an output edge to this node.
 
std::shared_ptr< Edgeoutput (size_t i) const
 Return output edge i of this node.
 
size_t num_outputs () const
 Return the number of edges of this node.
 
- Public Member Functions inherited from cerata::Node
 Node (std::string name, NodeID id, std::shared_ptr< Type > type)
 Node constructor.
 
Typetype () const
 Return the node Type.
 
NodeSetType (const std::shared_ptr< Type > &type)
 Set the node Type.
 
NodeID node_id () const
 Return the node type ID.
 
bool Is (NodeID node_id) const
 Return whether this node is of a specific node type id.
 
virtual std::vector< Edge * > edges () const
 Return all edges this Node is on.
 
void SetArray (NodeArray *array)
 Set parent array.
 
std::optional< NodeArray * > array () const
 Return parent array, if any.
 
NodeReplace (Node *replacement)
 Replace some node with another node, reconnecting all original edges. Returns the replaced node.
 
virtual NodeCopyOnto (Graph *dst, const std::string &name, NodeMap *rebinding) const
 Copy node onto a graph, implicitly copying over and rebinding e.g. type generics of referenced nodes. More...
 
void AppendReferences (std::vector< Object * > *out) const override
 Return all objects referenced by this node. For default nodes, these are type generics only.
 
- Public Member Functions inherited from cerata::Object
 Object (std::string name, ID id)
 Cerata object constructor. More...
 
ID obj_id () const
 Return the object ID of this object.
 
bool IsNode () const
 Return true if this object is a node.
 
bool IsArray () const
 Return true if this object is an array.
 
virtual std::optional< Graph * > parent () const
 Return the parent graph of this object, if any. Returns empty option otherwise.
 
- 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.
 

Static Public Member Functions

static std::shared_ptr< LiteralMake (bool value)
 Create a boolean literal.
 
static std::shared_ptr< LiteralMake (int64_t value)
 Create an integer literal.
 
static std::shared_ptr< LiteralMake (std::string value)
 Create a string literal.
 

Protected Member Functions

 Literal (std::string name, const std::shared_ptr< Type > &type, StorageType st, std::string str_val, int64_t int_val, bool bool_val)
 Literal constructor.
 
 LITERAL_DECL_FACTORY (Bool, bool)
 Bools.
 
 LITERAL_DECL_FACTORY (Int, int64_t)
 Ints.
 
 LITERAL_DECL_FACTORY (String, std::string)
 Strings.
 

Protected Attributes

StorageType storage_type_
 The raw storage type of the literal node.
 
- Protected Attributes inherited from cerata::Node
NodeID node_id_
 Node type ID.
 
std::shared_ptr< Typetype_
 The Type of this Node.
 
std::optional< NodeArray * > array_ = {}
 Parent if this belongs to an array.
 
- Protected Attributes inherited from cerata::Object
ID obj_id_
 The object type ID.
 
std::optional< Graph * > parent_ = {}
 An optional parent Graph to which this Object belongs. Initially no value.
 

Additional Inherited Members

- Public Attributes inherited from cerata::MultiOutputNode
std::vector< std::shared_ptr< Edge > > outputs_
 The outgoing Edges that sink this Node.
 
- Public Attributes inherited from cerata::Object
std::unordered_map< std::string, std::string > meta
 KV storage for metadata of tools or specific backend implementations.
 

Detailed Description

A Literal Node.

A literal node can be used to store some literal value. A literal node can, for example, be used for Vector Type widths or it can be connected to a Parameter Node, to give the Parameter its value.

Definition at line 36 of file literal.h.


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