ACT Library
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
act_connection Class Reference

Connections. More...

#include <value.h>

Public Member Functions

 act_connection (act_connection *_parent=NULL)
 
ActIdtoid ()
 
bool isglobal ()
 
ActNamespacegetnsifglobal ()
 
bool isPrimary ()
 
bool isPrimary (int i)
 
act_connectiongetsubconn (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 ()
 
ValueIdxgetvx ()
 
unsigned int getctype ()
 
act_connectionprimary ()
 
Type::direction getDir ()
 
bool disconnect ()
 
bool disconnectable ()
 
void Print (FILE *fp)
 

Public Attributes

ValueIdxvx
 
act_connectionparent
 
act_connectionup
 
act_connectionnext
 
act_connection ** a
 

Detailed Description

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

bool x[4], y[4];
x = y

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:

bool x[4], y[4], z;
x = y;
x[3] = z;

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:

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.

Constructor & Destructor Documentation

◆ act_connection()

act_connection::act_connection ( act_connection _parent = NULL)

Constuctor

Parameters
_parentis the parent pointer, if any

Member Function Documentation

◆ disconnect()

bool act_connection::disconnect ( )

Disconnect: only works for non-primary connections.

Returns
true on success, false otherwise

◆ disconnectable()

bool act_connection::disconnectable ( )

Check to see if this connection is disconnectable

Returns
true if this can be disconnected, false otherwise

◆ getctype()

unsigned int act_connection::getctype ( )

A connection type can be identified as one of four possibilies

  • 0 = standard "x"
  • 1 = array element "x[i]"
  • 2 = port "x.y"
  • 3 = array element + port "x[i].y"
Returns
the connection type for this pointer

◆ getDir()

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.

Returns
the direction flag for this connection

◆ getnsifglobal()

ActNamespace * act_connection::getnsifglobal ( )

get namespace for a global signal, if any

◆ getsubconn()

act_connection * act_connection::getsubconn ( int  idx,
int  sz 
)

Return a subconnection pointer, allocating slots if necessary.

Parameters
szis the # of subconnections possible for this object
idxis index of subconnection
Returns
the sub-connection slot

◆ getvx()

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.

Returns
the ValueIdx pointer for this connection

◆ hasAnyConnection()

bool act_connection::hasAnyConnection ( )

Check if there are any connections to this particular instance

Returns
true if there are either direct connections or connections to an part of the instance

◆ hasDirectconnections() [1/2]

bool act_connection::hasDirectconnections ( )
inline

Check to see if there are direct connections to this particular connection pointer. This is done by looking at the connection ring.

Returns
true if there are direct connections, false otherwise

◆ hasDirectconnections() [2/2]

bool act_connection::hasDirectconnections ( int  i)
inline

This checks to see if there are any direct connections to the i-th subconnection for this instance

Parameters
iis the sub-connection index to inspect
Returns
true if there are any direct connections to the i-th subconnection, false otherwise.

◆ hasSubconnections() [1/2]

bool act_connection::hasSubconnections ( )
inline
Returns
true if this is a complex object (array or user-defined) with potential subconnections to it, false otherwise

◆ hasSubconnections() [2/2]

bool act_connection::hasSubconnections ( int  i)
inline

Check to see if there are sub-connections registered for the i-th sub-connection within this object

Parameters
iis the sub-connection index to inspect
Returns
true if there are sub-connetions at position i, false otherwise

◆ isglobal()

bool act_connection::isglobal ( )

returns true if this is a global signal

◆ isPrimary() [1/2]

bool act_connection::isPrimary ( )
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.

Returns
true if this is a primary connection, false otherwise

◆ isPrimary() [2/2]

bool act_connection::isPrimary ( int  i)
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.

Parameters
iis the index of the sub-connection
Returns
true if the i-th sub-connection is a primary connection, false otherwise.

◆ myoffset()

int act_connection::myoffset ( )
inline

For sub-connection pointers (note that the parent must be non-NULL!), return my offset within my parent.

Returns
my sub-connection offset within my parent

◆ numSubconnections()

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.

Returns
the number of potential sub-connections

◆ numTotSubconnections()

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

Returns
the number of potential sub-connection slots

◆ primary()

act_connection * act_connection::primary ( )

Return the primary connection pointer for this one. This does the self-flattening operation for the union-find tree

Returns
primary connection pointer

◆ Print()

void act_connection::Print ( FILE *  fp)

Print the ActId corresponding to this connection pointer

Parameters
fpis the output file

◆ suboffset()

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.

Parameters
cis the sub-connection pointer to lookup
Returns
offset of subconnection c within current connection object

◆ toid()

ActId * act_connection::toid ( )

convert the connection pointer into a freshly allocated ActId name corresponding to this connection element.

Member Data Documentation

◆ a

act_connection** act_connection::a

slots for root arrays and root userdefs for sub-connections

◆ next

act_connection* act_connection::next

next pointer in the ring of connections used to find all other connections to this particular one.

◆ parent

act_connection* act_connection::parent

parent in the subconnection tree for id.id or id[val]

◆ up

act_connection* act_connection::up

up pointer in the union-find data structure

◆ vx

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.


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