ACT Library
|
Connections. More...
#include <value.h>
Public Member Functions | |
act_connection (act_connection *_parent=NULL) | |
ActId * | toid () |
bool | isglobal () |
ActNamespace * | getnsifglobal () |
bool | isPrimary () |
bool | isPrimary (int i) |
act_connection * | getsubconn (int idx, int sz) |
int | suboffset (act_connection *c) |
int | myoffset () |
bool | hasDirectconnections () |
bool | hasAnyConnection () |
bool | hasDirectconnections (int i) |
bool | hasSubconnections () |
bool | hasSubconnections (int i) |
int | numSubconnections () |
int | numTotSubconnections () |
ValueIdx * | getvx () |
unsigned int | getctype () |
act_connection * | primary () |
Type::direction | getDir () |
bool | disconnect () |
bool | disconnectable () |
void | Print (FILE *fp) |
Public Attributes | |
ValueIdx * | vx |
act_connection * | parent |
act_connection * | up |
act_connection * | next |
act_connection ** | a |
Connections.
This is the core data structure that maintains hierarchical connectivity information. An act_connection pointer is associated with a scope. Within the scope, the act_connection pointer can be used to identify the unique instance (or part of an instance) associated with an identifier within the scope.
When there is a parameter, we don't use connection pointers since we simply bind each parameter to its value.
For non-parameter types, we represent connections using a combination of a union-find tree (to make it cheap to find the canonical connection pointer), and a ring of connections (so that we can find all other instances/instance fragments that are connected together).
For simple connections (e.g. x = y, where x and y are bool types), the union-find + tree structure is easy to understand.
We also directly represent connections between user-defined types as well as arrays. So for example in the case of
we would represent this as a single connection between two arrays, rather than four element-wise connections between bools. We could also have situations such as:
In this case, we have both an array connection, as well as a connection to an individual element.
To represent complex connections, each instance has a potential connection tree. For an array like x
above, that means we have:
x
itselfx
. These are represented as an array of act_connection pointers within the connection structure for x
. Each element of the sub-connection array corresponds to an element of the array. The same idea is used for user-defined types. The sub-connection array corresponds to the port parameters from left to right. For an array of user-defined types, there are two levels of hierarchy: the first is for the array, and then the next is for the user-defined type.In a connection tree, the parent pointer can be used to go back up in the connection tree.
Connections are mainted in a manner that the root of the union-find tree is the canonical connection pointer for a particular connection. The rules for being canonical are as follows:
Subconnection pointers are allocated in a lazy fashion.
Connections to globals are special. This is because we do not replicate all the connection pointers on a per-instance basis. Instead, if a global signal is connected to a local one within a scope, then that is represented by a single connection—the representative for all instances of the entire user-defined type.
act_connection::act_connection | ( | act_connection * | _parent = NULL | ) |
Constuctor
_parent | is the parent pointer, if any |
bool act_connection::disconnect | ( | ) |
Disconnect: only works for non-primary connections.
bool act_connection::disconnectable | ( | ) |
Check to see if this connection is disconnectable
unsigned int act_connection::getctype | ( | ) |
A connection type can be identified as one of four possibilies
Type::direction act_connection::getDir | ( | ) |
This computes the direction flags for this connection pointer (in or out). This translates INOUT/OUTIN flags to the correct version given the context. It returns either Type::NONE, Type::IN, or Type::OUT.
ActNamespace * act_connection::getnsifglobal | ( | ) |
get namespace for a global signal, if any
act_connection * act_connection::getsubconn | ( | int | idx, |
int | sz | ||
) |
Return a subconnection pointer, allocating slots if necessary.
sz | is the # of subconnections possible for this object |
idx | is index of subconnection |
ValueIdx * act_connection::getvx | ( | ) |
The ValueIdx pointer for a connection is the primary instance corresponding to this particular connection pointer. For a simple instance, it is clear what it is. But for an array instance, this would be the ValueIdx for the parent. If this connection pointer corresponds to part of a user-defined type, it would be the ValueIdx for the parent as well. For arrays of user-defined types, it would be the ValueIdx in the parent's parent.
bool act_connection::hasAnyConnection | ( | ) |
Check if there are any connections to this particular instance
|
inline |
Check to see if there are direct connections to this particular connection pointer. This is done by looking at the connection ring.
|
inline |
This checks to see if there are any direct connections to the i-th subconnection for this instance
i | is the sub-connection index to inspect |
|
inline |
|
inline |
Check to see if there are sub-connections registered for the i-th sub-connection within this object
i | is the sub-connection index to inspect |
bool act_connection::isglobal | ( | ) |
returns true if this is a global signal
|
inline |
Check if this is a primary connection pointer: the canonical one for this connection. This is done by checking the up pointer in the union-find tree.
|
inline |
Check if the i-th sub-connection for this type is a primary connection. Note that the sub-connections may not exist so a non-NULL test is part of this function.
This should only be called if hasSubconnections() is true.
i | is the index of the sub-connection |
|
inline |
For sub-connection pointers (note that the parent must be non-NULL!), return my offset within my parent.
int act_connection::numSubconnections | ( | ) |
Return the number of potential sub-connection slots for this instance. This corresponds to the size of the array, or the number of port parameters for a user-defined type. If the lazily allocated array pointer is NULL, this returns 0. Use this to iterate over potential sub-connection slots.
int act_connection::numTotSubconnections | ( | ) |
This returns the number of subconnection slots that could exist for this particular instance. This is called by numSubconnections() when the array pointer is non-NULL
act_connection * act_connection::primary | ( | ) |
Return the primary connection pointer for this one. This does the self-flattening operation for the union-find tree
void act_connection::Print | ( | FILE * | fp | ) |
Print the ActId corresponding to this connection pointer
fp | is the output file |
int act_connection::suboffset | ( | act_connection * | c | ) |
Given a sub-connection slot, find the index in the sub-connection array that matches this one. NOTE: this is a slow call, since it does a linear search through the sub-connection pointer array. The act.suboffset_limit parameter is used to truncate the search, and print a warning.
c | is the sub-connection pointer to lookup |
ActId * act_connection::toid | ( | ) |
convert the connection pointer into a freshly allocated ActId name corresponding to this connection element.
act_connection** act_connection::a |
slots for root arrays and root userdefs for sub-connections
act_connection* act_connection::next |
next pointer in the ring of connections used to find all other connections to this particular one.
act_connection* act_connection::parent |
parent in the subconnection tree for id.id or id[val]
act_connection* act_connection::up |
up pointer in the union-find data structure
ValueIdx* act_connection::vx |
identifier that has been allocated within the scope of this connection that corresponds to this particular connection pointer. Note that this could be NULL for sub-connection elements. When a user-defined type is traversed, the vx pointer switches scope to the user-defined type self. This is done to speed up lookups.