 |
Cerata
A library to generate structural hardware designs
|
23 #include "cerata/node.h"
24 #include "cerata/port.h"
25 #include "cerata/type.h"
26 #include "cerata/signal.h"
53 std::shared_ptr<Object>
Copy()
const override;
59 std::shared_ptr<Node>
Append(
bool increment_size =
true);
75 std::shared_ptr<Node>
base()
const {
return base_; }
80 out->push_back(
size_.get());
81 size_->AppendReferences(out);
83 base_->AppendReferences(out);
96 std::vector<std::shared_ptr<Node>>
nodes_;
115 std::shared_ptr<SignalArray>
signal_array(
const std::string &name,
116 const std::shared_ptr<Type> &type,
117 const std::shared_ptr<Node>& size,
128 std::shared_ptr<Object>
Copy()
const override;
132 std::shared_ptr<PortArray>
port_array(
const std::string &name,
133 const std::shared_ptr<Type> &type,
134 const std::shared_ptr<Node> &size,
139 std::shared_ptr<PortArray>
port_array(
const std::shared_ptr<Port> &base_node,
140 const std::shared_ptr<Node> &size);
void AppendReferences(std::vector< Object * > *out) const override
Append all objects that this object owns to the output.
Node::NodeID node_id_
The type ID of the nodes in this NodeArray.
Type * type() const
Return the type of the nodes in the NodeArray.
void SetParent(Graph *new_parent) override
Set the parent of this NodeArray base node and array nodes.
std::vector< Node * > nodes() const
Return all nodes of this NodeArray.
An array of signal nodes.
SignalArray(const std::shared_ptr< Signal > &base, const std::shared_ptr< Node > &size)
SignalArray constructor.
NodeArray * CopyOnto(Graph *dst, const std::string &name, NodeMap *rebinding)
Copy the NodeArray onto a graph, but not the array nodes. Creates a new size node set to zero.
std::shared_ptr< Node > base_
A node representing the template for each of the element nodes.
std::shared_ptr< Node > Append(bool increment_size=true)
Append a node to this array, optionally incrementing the size node. Returns a pointer to that node.
A terminator structure to enable terminator sanity checks.
size_t num_nodes() const
Return the number of element nodes.
Node::NodeID node_id()
Return the type ID of the nodes in this NodeArray.
A graph representing a hardware structure.
std::vector< T * > ToRawPointers(const std::vector< std::shared_ptr< T >> &list)
Convert a list of shared pointers to raw pointers.
Contains every Cerata class, function, etc...
std::vector< std::shared_ptr< Node > > nodes_
The nodes contained by this array.
std::shared_ptr< Object > Copy() const override
Deep-copy the NodeArray, but not the array nodes. Resets the size node to an integer literal of 0.
std::unordered_map< const Node *, Node * > NodeMap
A mapping from one object to another object, used in e.g. type generic rebinding.
std::string ToString() const
Return a human-readable representation of this NodeArray.
std::string name() const
Return the name of the object.
NodeID
Node type IDs with different properties.
PortArray(const std::shared_ptr< Port > &base, const std::shared_ptr< Node > &size)
Construct a new port array.
A Cerata Object on a graph.
std::shared_ptr< Node > base() const
Return the base node of this NodeArray.
size_t IndexOf(const Node &n) const
Return the index of a specific node.
std::shared_ptr< Object > Copy() const override
Make a copy of this port array.
std::shared_ptr< ClockDomain > default_domain()
Return a static default clock domain.
Node * operator[](size_t i) const
Return element node i.
void SetSize(const std::shared_ptr< Node > &size)
Set the size node.
void IncrementSize()
Increment the size of the ArrayNode.
std::shared_ptr< SignalArray > signal_array(const std::string &name, const std::shared_ptr< Type > &type, const std::shared_ptr< Node > &size, const std::shared_ptr< ClockDomain > &domain)
Construct a new node array and return a shared pointer to it.
void SetType(const std::shared_ptr< Type > &type)
Set the type of the base node and array nodes.
std::shared_ptr< Node > size_
A node representing the number of concatenated edges.
Node * size() const
Return the size node.
NodeArray(std::string name, Node::NodeID id, std::shared_ptr< Node > base, const std::shared_ptr< Node > &size)
ArrayNode constructor.
Node * node(size_t i) const
Return element node i.
std::shared_ptr< PortArray > port_array(const std::string &name, const std::shared_ptr< Type > &type, const std::shared_ptr< Node > &size, Port::Dir dir, const std::shared_ptr< ClockDomain > &domain)
Get a smart pointer to a new ArrayPort.