VIS

src/ntk/ntkNode.c File Reference

#include "ntkInt.h"
#include "baig.h"
Include dependency graph for ntkNode.c:

Go to the source code of this file.

Defines

#define UNASSIGNED_OUTPUT_INDEX   -1
#define LATCH_DATA   0
#define LATCH_INITIAL   1

Functions

static void NetworkAddCombOutput (Ntk_Network_t *network, Ntk_Node_t *node)
char * Ntk_NodeReadName (Ntk_Node_t *node)
Ntk_Network_t * Ntk_NodeReadNetwork (Ntk_Node_t *node)
Var_Variable_t * Ntk_NodeReadVariable (Ntk_Node_t *node)
Tbl_Table_t * Ntk_NodeReadTable (Ntk_Node_t *node)
mAigEdge_t Ntk_NodeReadMAigId (Ntk_Node_t *node)
void Ntk_NodeSetMAigId (Ntk_Node_t *node, mAigEdge_t mAigId)
void Ntk_NodeSetTable (Ntk_Node_t *node, Tbl_Table_t *table)
int Ntk_NodeReadOutputIndex (Ntk_Node_t *node)
int Ntk_NodeReadMddId (Ntk_Node_t *node)
void Ntk_NodeSetMddId (Ntk_Node_t *node, int id)
void * Ntk_NodeReadUndef (Ntk_Node_t *node)
void Ntk_NodeSetUndef (Ntk_Node_t *node, void *value)
boolean Ntk_NodeTestIsPrimaryInput (Ntk_Node_t *node)
boolean Ntk_NodeTestIsPseudoInput (Ntk_Node_t *node)
boolean Ntk_NodeTestIsInput (Ntk_Node_t *node)
boolean Ntk_NodeTestIsUndefined (Ntk_Node_t *node)
boolean Ntk_NodeTestIsLatch (Ntk_Node_t *node)
boolean Ntk_NodeTestIsNextStateNode (Ntk_Node_t *node)
boolean Ntk_NodeTestIsShadow (Ntk_Node_t *node)
boolean Ntk_NodeTestIsCombInput (Ntk_Node_t *node)
boolean Ntk_NodeTestIsCombOutput (Ntk_Node_t *node)
boolean Ntk_NodeTestIsCombinational (Ntk_Node_t *node)
boolean Ntk_NodeTestIsPrimaryOutput (Ntk_Node_t *node)
boolean Ntk_NodeTestIsLatchDataInput (Ntk_Node_t *node)
boolean Ntk_NodeTestIsLatchInitialInput (Ntk_Node_t *node)
boolean Ntk_NodeTestIsConstant (Ntk_Node_t *node)
Ntk_Node_t * Ntk_NodeReadShadow (Ntk_Node_t *node)
Ntk_Node_t * Ntk_ShadowReadOrigin (Ntk_Node_t *shadow)
Ntk_Node_t * Ntk_LatchReadDataInput (Ntk_Node_t *node)
Ntk_Node_t * Ntk_LatchReadInitialInput (Ntk_Node_t *node)
int Ntk_NodeReadNumFanins (Ntk_Node_t *node)
int Ntk_NodeReadNumFanouts (Ntk_Node_t *node)
Ntk_Node_t * Ntk_NodeReadFaninNode (Ntk_Node_t *node, int faninIndex)
int Ntk_NodeReadFaninIndex (Ntk_Node_t *node, Ntk_Node_t *faninNode)
array_t * Ntk_NodeReadFanins (Ntk_Node_t *node)
array_t * Ntk_NodeReadFanouts (Ntk_Node_t *node)
void Ntk_NodeSetFanins (Ntk_Node_t *node, array_t *faninArray)
void Ntk_NodeSetFanouts (Ntk_Node_t *node, array_t *fanoutArray)
char * Ntk_NodeObtainTypeAsString (Ntk_Node_t *node)
void Ntk_NodePrint (FILE *fp, Ntk_Node_t *node, boolean printIo, boolean printTableStats)
Ntk_Node_t * Ntk_NodeCreateInNetwork (Ntk_Network_t *network, char *name, Var_Variable_t *variable)
void Ntk_NodeDeclareAsCombinational (Ntk_Node_t *node, Tbl_Table_t *table, array_t *inputNames, int outputIndex)
void Ntk_NodeDeclareAsLatch (Ntk_Node_t *latch, char *dataName, char *initName)
void Ntk_NodeDeclareAsPrimaryInput (Ntk_Node_t *node)
void Ntk_NodeDeclareAsPseudoInput (Ntk_Node_t *node, Tbl_Table_t *table, int outputIndex)
void Ntk_NodeDeclareAsPrimaryOutput (Ntk_Node_t *node)
void Ntk_NodeDeclareAsShadow (Ntk_Node_t *shadow, Ntk_Node_t *origin)
void Ntk_NodeFree (Ntk_Node_t *node)

Variables

static char rcsid[] UNUSED = "$Id: ntkNode.c,v 1.15 2009/04/11 01:56:10 fabio Exp $"

Define Documentation

#define LATCH_DATA   0

Definition at line 41 of file ntkNode.c.

#define LATCH_INITIAL   1

Definition at line 42 of file ntkNode.c.

#define UNASSIGNED_OUTPUT_INDEX   -1

Definition at line 40 of file ntkNode.c.


Function Documentation

static void NetworkAddCombOutput ( Ntk_Network_t *  network,
Ntk_Node_t *  node 
) [static]

AutomaticStart

Function********************************************************************

Synopsis [Adds a node to the network's list of combinational outputs.]

Description [Adds a node to the network's list of combinational outputs. If the list already contains the node, then nothing is done. List membership is maintained via a hash table.]

SideEffects []

SeeAlso [Ntk_NetworkForEachCombOutput]

Definition at line 1477 of file ntkNode.c.

{
  if (!st_is_member(network->combOutputsTable, (char *) node)) {
    st_insert(network->combOutputsTable, (char *) node, (char *) 0);
    lsNewEnd(network->combOutputs, (lsGeneric) node, LS_NH);
  }
}

Here is the caller graph for this function:

Ntk_Node_t* Ntk_LatchReadDataInput ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns the of data input of a latch.]

Description [Returns the data input of a latch. The data input determines the value of the latch output at the next clock. It is an error to call this function on a node that is not a latch.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsLatch]

Definition at line 760 of file ntkNode.c.

{
  Ntk_Node_t *data;
  
  assert(node != NIL(Ntk_Node_t));
  assert(node->type == NtkLatch_c);
  data = array_fetch(Ntk_Node_t *, node->fanins, LATCH_DATA);
  
  return (data);
}
Ntk_Node_t* Ntk_LatchReadInitialInput ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns the initial input of a latch.]

Description [Returns the initial input of a latch. The initial value of the latch is determined by the value of the initial input. It is an error to call this function on a node that is not a latch.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsLatch]

Definition at line 787 of file ntkNode.c.

{
  Ntk_Node_t *initial;
  
  assert(node != NIL(Ntk_Node_t));
  assert(node->type == NtkLatch_c);
  initial = array_fetch(Ntk_Node_t *, node->fanins, LATCH_INITIAL);
  
  return (initial);
}

Here is the caller graph for this function:

Ntk_Node_t* Ntk_NodeCreateInNetwork ( Ntk_Network_t *  network,
char *  name,
Var_Variable_t *  variable 
)

Function********************************************************************

Synopsis [Creates a node in a network with a name and a variable.]

Description [Creates a node in a network. The name, network, and variable fields are initialized with the supplied values (a copy of name is made first, a copy of the variable is not made). The fanins and fanouts fields are initialized with empty arrays. All other fields are initialized to NULL or UNASSIGNED values. A non-NULL name, non-NULL network, and non-NULL variable are required. This is the only way to allocate a node; in other words, a node can only exist with a name and a variable, within the context of a network.]

SideEffects [The node is added to the network's information.]

SeeAlso [Ntk_NodeFree]

Definition at line 1129 of file ntkNode.c.

{
  Ntk_Node_t *node = ALLOC(Ntk_Node_t, 1);

  assert(network != NIL(Ntk_Network_t));
  assert(name != NIL(char));
  assert(variable != NIL(Var_Variable_t));
  
  node->name                  = util_strsav(name);
  node->network               = network;
  node->variable              = variable;
  node->type                  = NtkUnassigned_c;
  node->fanins                = array_alloc(Ntk_Node_t *, 0);
  node->fanouts               = array_alloc(Ntk_Node_t *, 0);
  node->table                 = NIL(Tbl_Table_t);
  node->outputIndex           = UNASSIGNED_OUTPUT_INDEX;
  node->mddId                 = NTK_UNASSIGNED_MDD_ID;
  node->mAigId                = -1;
  node->shadowInfo.shadow     = NIL(Ntk_Node_t);
  node->outputFlag            = 0;
  node->constant              = 0;
  node->latchDataInput        = 0;
  node->latchInitialInput     = 0;
  node->undef                 = NIL(void);

  /*
   * Update the state of the network. Note: it's important to use node->name
   * here, rather than just name, because we don't own name.
   */
  st_insert(network->actualNameToNode, (char *) node->name, (char *) node);
  lsNewEnd(network->nodes, (lsGeneric) node, LS_NH);

  return (node);
}

Here is the caller graph for this function:

void Ntk_NodeDeclareAsCombinational ( Ntk_Node_t *  node,
Tbl_Table_t *  table,
array_t *  inputNames,
int  outputIndex 
)

Function********************************************************************

Synopsis [Declares a node as combinational and sets the table.]

Description [Declares a node as combinational using the column of table corresponding to outputIndex as the function of the node. This function does not make a copy of the table; instead, it just sets a pointer to it. However, it's assumed that the table will own the table, and the table is freed when the node is freed. Connections are made to the nodes corresponding to the inputs in the table. The node for the ith table input is found by calling Ntk_NetworkFindNodeByName with the ith entry of inputNames. The order of the fanins of node returned by Ntk_NodeForEachFanin are guaranteed to be the same as the order of the corresponding input columns in the table.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsPrimaryInput Ntk_NodeDeclareAsPrimaryOutput]

Definition at line 1189 of file ntkNode.c.

{
  int            i;
  Ntk_Network_t *network = node->network;

  assert(node->type == NtkUnassigned_c);
  
  node->type        = NtkCombinational_c;
  node->table       = table;
  node->outputIndex = outputIndex;

  /*
   * If it can be determined that the corresponding output column of table can
   * take assume just a single value, then set the constant flag. 
   */
  if (Tbl_TableTestIsConstant(table, outputIndex)) {
    node->constant = 1;
  }
  
  /*
   * Create a connection to each input of table. 
   */
  for (i = 0; i < array_n(inputNames); i++) {
    char        *faninName = array_fetch(char *, inputNames, i);
    Ntk_Node_t  *fanin     = Ntk_NetworkFindNodeByName(network, faninName);

    assert(fanin != NIL(Ntk_Node_t));

    /*
     * Make the connections between node and fanin.  Note: it is critical
     * that the fanins of node are added to node->fanins in the same order
     * they appear in the table.
     */
    array_insert_last(Ntk_Node_t *, fanin->fanouts, node);
    array_insert_last(Ntk_Node_t *, node->fanins, fanin);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Ntk_NodeDeclareAsLatch ( Ntk_Node_t *  latch,
char *  dataName,
char *  initName 
)

Function********************************************************************

Synopsis [Declares a node as a latch.]

Description [Declares a node as a latch. Makes connections to the data and initial input nodes. The data node is taken as that one found by calling Ntk_NetworkFindNodeByName with the name "dataName"; likewise for the initial node. Adds the node to the end of the latch list of the node's network, and the combinational input list. This function does not automatically create a shadow node for the latch (i.e. a node to store information about the next state variable of the latch); to do this, use Ntk_NodeCreateInNetwork and Ntk_NodeDeclareAsShadow.]

SideEffects []

SeeAlso [Ntk_LatchReadDataInput Ntk_LatchReadInitialInput]

Definition at line 1251 of file ntkNode.c.

{
  Ntk_Node_t    *dataNode;
  Ntk_Node_t    *initNode;
  Ntk_Network_t *network = latch->network;
  
  assert(latch->type == NtkUnassigned_c);
  latch->type = NtkLatch_c;

  /*
   * Get the nodes corresponding to dataName and initName.
   */
  dataNode = Ntk_NetworkFindNodeByName(network, dataName);
  initNode = Ntk_NetworkFindNodeByName(network, initName);
  assert(dataNode != NIL(Ntk_Node_t));
  assert(initNode != NIL(Ntk_Node_t));

  /*
   * Make the necessary connections. Note the predefined locations of the data
   * and initial inputs in the fanin array of latch.
   */
  array_insert(Ntk_Node_t *, latch->fanins, LATCH_DATA, dataNode);
  array_insert(Ntk_Node_t *, latch->fanins, LATCH_INITIAL, initNode);

  array_insert_last(Ntk_Node_t *, dataNode->fanouts, latch);
  array_insert_last(Ntk_Node_t *, initNode->fanouts, latch);

  /*
   * Set the special flags in the data and init nodes, and add them to the
   * list of combinational outputs.
   */
  dataNode->latchDataInput = 1;
  NetworkAddCombOutput(network, dataNode);

  initNode->latchInitialInput = 1;
  NetworkAddCombOutput(network, initNode);

  /*
   * Add the latch to the appropriate lists in network.
   */
  lsNewEnd(network->latches,    (lsGeneric) latch, LS_NH);
  lsNewEnd(network->combInputs, (lsGeneric) latch, LS_NH);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Ntk_NodeDeclareAsPrimaryInput ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Declares a node as a primary input.]

Description [Declares a node as a primary input. Adds node to the relevant node lists maintained by the node's network.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsPrimaryOutput]

Definition at line 1312 of file ntkNode.c.

{
  assert(node->type == NtkUnassigned_c);
  node->type = NtkPrimaryInput_c;

  lsNewEnd(node->network->primaryInputs, (lsGeneric) node, LS_NH);
  lsNewEnd(node->network->inputs,        (lsGeneric) node, LS_NH);
  lsNewEnd(node->network->combInputs,    (lsGeneric) node, LS_NH);
}

Here is the caller graph for this function:

void Ntk_NodeDeclareAsPrimaryOutput ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Declares a node as a primary output.]

Description [Declares a node as a primary output. Node can be of any type, except type shadow.]

SideEffects []

SeeAlso [Ntk_TestIsPrimaryOutput]

Definition at line 1375 of file ntkNode.c.

{
  assert(node->type != NtkShadow_c);
  node->outputFlag = 1;
  lsNewEnd(node->network->primaryOutputs, (lsGeneric) node, LS_NH);
  NetworkAddCombOutput(node->network, node);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Ntk_NodeDeclareAsPseudoInput ( Ntk_Node_t *  node,
Tbl_Table_t *  table,
int  outputIndex 
)

Function********************************************************************

Synopsis [Declares a node as a pseudo input.]

Description [Declares a node as a pseudo input. The function of a pseudo input is given by the column of table corresponding to outputIndex. This function does not make a copy of the table; instead, it just sets a pointer to it. However, it's assumed that the table will own the table, and the table is freed when the node is freed. Adds node to the relevant node lists maintained by the node's network.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsPrimaryInput]

Definition at line 1341 of file ntkNode.c.

{
  assert(node->type == NtkUnassigned_c);

  node->type        = NtkPseudoInput_c;
  node->table       = table;
  node->outputIndex = outputIndex;
  
  if (Tbl_TableTestIsConstant(table, outputIndex)) {
    node->constant = 1;
  }
  
  lsNewEnd(node->network->pseudoInputs, (lsGeneric) node, LS_NH);
  lsNewEnd(node->network->inputs,       (lsGeneric) node, LS_NH);
  lsNewEnd(node->network->combInputs,   (lsGeneric) node, LS_NH);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Ntk_NodeDeclareAsShadow ( Ntk_Node_t *  shadow,
Ntk_Node_t *  origin 
)

Function********************************************************************

Synopsis [Declares a node as a shadow node.]

Description [Declares a node as a shadow node. A shadow node is used to associate extra information with a node, in particular another MDD id. Any "origin" node can have a shadow node, except a node which itself is of type shadow. This function makes the bidirectional link between the shadow and origin nodes.]

SideEffects []

SeeAlso [Ntk_NodeTestIsShadow Ntk_ShadowReadOrigin Ntk_NodeReadShadow]

Definition at line 1401 of file ntkNode.c.

{
  assert(shadow->type == NtkUnassigned_c);
  assert(origin->type != NtkShadow_c);
  
  shadow->type = NtkShadow_c;

  shadow->shadowInfo.origin = origin;
  origin->shadowInfo.shadow = shadow;
}

Here is the caller graph for this function:

void Ntk_NodeFree ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Frees all the memory local to the node.]

Description [Frees all the memory local to the node, including the node itself. Does not free the nodes in the fanin and fanout of node, nor does it free the network of node. Also, this function does not update the lists maintained by the network to reflect that this node no longer exists, nor does it update the fanin and fanout lists of neighboring nodes.]

SideEffects []

SeeAlso [Ntk_NodeCreateInNetwork]

Definition at line 1431 of file ntkNode.c.

{
  FREE(node->name);
  array_free(node->fanins);
  array_free(node->fanouts);
  Tbl_TableFree(node->table);
  
  /*
   * Unassign a few key fields for safety's sake.
   */
  node->name              = NIL(char);
  node->network           = NIL(Ntk_Network_t);
  node->variable          = NIL(Var_Variable_t);
  node->type              = NtkUnassigned_c;
  node->fanins            = NIL(array_t);
  node->fanouts           = NIL(array_t);
  node->table             = NIL(Tbl_Table_t);
  node->mddId             = NTK_UNASSIGNED_MDD_ID;

  FREE(node);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* Ntk_NodeObtainTypeAsString ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns a string giving a node's type.]

Description [Returns a string giving a node's type. The return string can be one of the following: "latch", "shadow", "primary-input", "pseudo-input", "combinational", or "unassigned". It is the user's responsibility to free this string.]

SideEffects []

SeeAlso [Ntk_NodePrint]

Definition at line 1004 of file ntkNode.c.

{
  char *typeString;

  assert(node != NIL(Ntk_Node_t));
  switch(node->type) {
      case NtkLatch_c:
        typeString = util_strsav("latch");
        break;
      case NtkShadow_c:
        typeString = util_strsav("shadow");
        break;
      case NtkPrimaryInput_c:
        typeString = util_strsav("primary-input");
        break;
      case NtkPseudoInput_c:
        typeString = util_strsav("pseudo-input");
        break;
      case NtkCombinational_c:
        typeString = util_strsav("combinational");
        break;
      case NtkUnassigned_c:
        typeString = util_strsav("unassigned");
        break;
      default:
        fail("Unexpected type");
  }
  return (typeString);
}

Here is the caller graph for this function:

void Ntk_NodePrint ( FILE *  fp,
Ntk_Node_t *  node,
boolean  printIo,
boolean  printTableStats 
)

Function********************************************************************

Synopsis [Prints information about a node.]

Description [Prints the node's name, MDD id, type, and attributes. In addition, if printIo is TRUE, prints the name of each fanin node and each fanout node. And if printTableStats is TRUE, print table statistics for those nodes having a table.]

SideEffects []

SeeAlso [Ntk_NetworkPrint]

Definition at line 1051 of file ntkNode.c.

{
  int         i;
  Ntk_Node_t *fanin;
  Ntk_Node_t *fanout;
  char       *typeString = Ntk_NodeObtainTypeAsString(node);
  

  /*
   * Print the node's name, MDD id, type, and attributes.
   */
  (void) fprintf(fp, "%s: mdd=%d, %s;%s%s%s%s%s%s\n",
                 Ntk_NodeReadName(node),
                 Ntk_NodeReadMddId(node),
                 typeString,
                 (Ntk_NodeTestIsPrimaryOutput(node) ? " output" : ""),
                 (Ntk_NodeTestIsConstant(node) ? " constant" : ""),
                 (Ntk_NodeTestIsLatchDataInput(node) ? " data-input" : ""),
                 (Ntk_NodeTestIsLatchInitialInput(node) ? " initial-input" : ""),
                 (Ntk_NodeTestIsCombInput(node) ? " comb-input" : ""),
                 (Ntk_NodeTestIsCombOutput(node) ? " comb-output" : "")
                 );

  FREE(typeString);
  
  if (printIo) {
    /*
     * Print the name of each fanin.
     */
    (void) fprintf(fp, "Fanins:  ");
    Ntk_NodeForEachFanin(node, i, fanin) {
      if (i != 0) (void) fprintf(fp, ",");
      (void) fprintf(fp, " %s", Ntk_NodeReadName(fanin));
    }
    (void) fprintf(fp, "\n");

    /*
     * Print the name of each fanout.
     */
    (void) fprintf(fp, "Fanouts: ");
    Ntk_NodeForEachFanout(node, i, fanout) {
      if (i != 0) (void) fprintf(fp, ",");
      (void) fprintf(fp, " %s", Ntk_NodeReadName(fanout));
    }
    (void) fprintf(fp, "\n");
  }

  if (printTableStats) {
    if (Ntk_NodeTestIsCombinational(node) || Ntk_NodeTestIsPseudoInput(node)) {
      Tbl_TablePrintStats(Ntk_NodeReadTable(node), fp);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int Ntk_NodeReadFaninIndex ( Ntk_Node_t *  node,
Ntk_Node_t *  faninNode 
)

Function********************************************************************

Synopsis [Returns the fanin index of node corresponding to faninNode.]

Description [Returns the fanin index of node corresponding to faninNode. If faninNode is not a fanin of node, then returns NTK_UNDEFINED_FANIN_INDEX.]

SideEffects []

SeeAlso [Ntk_NodeReadFaninNode]

Definition at line 875 of file ntkNode.c.

{
  int         i;
  Ntk_Node_t *tempNode;
  
  assert(node != NIL(Ntk_Node_t));
  Ntk_NodeForEachFanin(node, i, tempNode) {
    if (tempNode == faninNode) {
      return (i);
    }
  }

  return (NTK_UNDEFINED_FANIN_INDEX);
}

Here is the caller graph for this function:

Ntk_Node_t* Ntk_NodeReadFaninNode ( Ntk_Node_t *  node,
int  faninIndex 
)

Function********************************************************************

Synopsis [Returns the fanin of node corresponding to faninIndex.]

Description [Returns the fanin of node corresponding to faninIndex. Fanins are numbered starting from 0.]

SideEffects []

SeeAlso [Ntk_NodeReadFaninIndex]

Definition at line 849 of file ntkNode.c.

{
  Ntk_Node_t *faninNode;
  
  assert(node != NIL(Ntk_Node_t));
  assert((faninIndex >= 0) && (faninIndex < Ntk_NodeReadNumFanins(node)));
  faninNode = array_fetch(Ntk_Node_t *, node->fanins, faninIndex);
  return (faninNode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

array_t* Ntk_NodeReadFanins ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns the array of fanins of a node.]

Description [Returns the array of fanins of a node. The user must not free or modify this array in any way.]

SideEffects []

SeeAlso [Ntk_NodeReadNumFanins]

Definition at line 906 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->fanins);
}

Here is the caller graph for this function:

array_t* Ntk_NodeReadFanouts ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns the array of fanouts of a node.]

Description [Returns the array of fanouts of a node. The user must not free or modify this array in any way.]

SideEffects []

SeeAlso [Ntk_NodeReadNumFanouts]

Definition at line 927 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->fanouts);
}

Here is the caller graph for this function:

mAigEdge_t Ntk_NodeReadMAigId ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns the AndInv Id of a node.]

Description [Returns the AndInv Id of the node in the AndInv graph.]

SideEffects []

SeeAlso []

Definition at line 170 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->mAigId);
}

Here is the caller graph for this function:

int Ntk_NodeReadMddId ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns the MDD id of a node.]

Description [Returns the MDD id of a node. Whether or not a node has an MDD id depends on which nodes were assigned an id in Ord_NetworkOrderVariables. Returns NTK_UNASSIGNED_MDD_ID if node does not have an assigned MDD id. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ord_NetworkOrderVariables Ntk_NodeSetMddId]

Definition at line 270 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->mddId);
}
char* Ntk_NodeReadName ( Ntk_Node_t *  node)

AutomaticEnd Function********************************************************************

Synopsis [Returns the name of a node.]

Description [Returns the (actual) name of a node. User must not free this string. Every node must have a non-NULL name. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeCreateInNetwork]

Definition at line 75 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->name);
}
Ntk_Network_t* Ntk_NodeReadNetwork ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns the network of a node.]

Description [Returns the network to which node belongs. User must not free this network. Every node must have a non-NULL network. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeCreateInNetwork]

Definition at line 97 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->network);
}

Here is the caller graph for this function:

int Ntk_NodeReadNumFanins ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns the number of fanins of a node.]

SideEffects []

SeeAlso [Ntk_NodeReadNumFanouts]

Definition at line 810 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (array_n(node->fanins));
}

Here is the caller graph for this function:

int Ntk_NodeReadNumFanouts ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns the number of fanouts of a node.]

SideEffects []

SeeAlso [Ntk_NodeReadNumFanins]

Definition at line 828 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (array_n(node->fanouts));
}

Here is the caller graph for this function:

int Ntk_NodeReadOutputIndex ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns the output index of a node.]

Description [Returns the output column of the node's table that defines the node's function. It is an error to call this function on a NULL node or a node of type other than combinational or pseudo input.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsCombinational Ntk_NodeDeclareAsPrimaryInput Ntk_NodeReadTable]

Definition at line 246 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  assert((node->type == NtkCombinational_c) || (node->type == NtkPseudoInput_c));
  return (node->outputIndex);
}

Here is the caller graph for this function:

Ntk_Node_t* Ntk_NodeReadShadow ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns the shadow of a node.]

Description [Returns the shadow of a node if one exists, else returns NULL. A shadow node can serve as a placeholder for an extra MDD variable, such as a next state variable. It is an error to call this function on a node that is a shadow.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsShadow Ntk_ShadowReadOrigin Ntk_NodeTestIsShadow]

Definition at line 712 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  assert(node->type != NtkShadow_c);
  return (node->shadowInfo.shadow);
}

Here is the caller graph for this function:

Tbl_Table_t* Ntk_NodeReadTable ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns the table of a node.]

Description [Returns the table which defines the function of this node. User must not free this table. Every combinational node and every pseudo input has a table. It is an error to call this function on a NULL node or a node that isn't combinational or a pseudo input.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsCombinational Ntk_NodeDeclareAsPseudoInput Ntk_NodeSetTable]

Definition at line 150 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  assert((node->type == NtkCombinational_c) || (node->type == NtkPseudoInput_c));
  return (node->table);
}

Here is the caller graph for this function:

void* Ntk_NodeReadUndef ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns the undef field of a node.]

Description [Returns the undef field of a node. There is no restriction on how this field is used. However, you should use extreme caution to make sure that you are not using this field to store more that one thing at a given time (if you can't be sure, then use a hash table). It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeSetUndef]

Definition at line 337 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->undef);
}

Here is the caller graph for this function:

Var_Variable_t* Ntk_NodeReadVariable ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns the variable of a node.]

Description [Returns the multi-valued variable at the output of a node. User must not free this variable. Every node must have a non-NULL variable. The returned variable actually belongs to the hierarchy manager from which the node's network was derived. However, in the context of the network, the only information contained in the variable that should be used, is the information relating to the number (and name, if symbolic) of values. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeCreateInNetwork Var_VariableReadNumValues Var_VariableReadIndexFromSymbolicValue Var_VariableReadSymbolicValueFromIndex Var_VariableTestIsSymbolic Var_VariableTestIsEnumerative]

Definition at line 126 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->variable);
}
void Ntk_NodeSetFanins ( Ntk_Node_t *  node,
array_t *  faninArray 
)

Function********************************************************************

Synopsis [Sets the array of fanins of a node.]

Description [Sets the array of fanins of a node. This function must be used with UTMOST caution. Use this only when you know EXACTLY what you are doing.]

SideEffects [Old fanin array is deleted.]

SeeAlso [Ntk_NodeReadNumFanins Ntk_NodeReadFanins]

Definition at line 948 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  if (node->fanins)
    array_free(node->fanins);
  
  node->fanins = faninArray;

  return;
}

Here is the caller graph for this function:

void Ntk_NodeSetFanouts ( Ntk_Node_t *  node,
array_t *  fanoutArray 
)

Function********************************************************************

Synopsis [Sets the array of fanouts of a node.]

Description [Sets the array of fanouts of a node. This function must be used with UTMOST caution. Use this only when you know EXACTLY what you are doing.]

SideEffects [Old fanout array is deleted.]

SeeAlso [Ntk_NodeReadNumFanouts Ntk_NodeReadFanouts]

Definition at line 975 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  if (node->fanouts)
    array_free(node->fanouts);
  
  node->fanouts = fanoutArray;

  return;
}

Here is the caller graph for this function:

void Ntk_NodeSetMAigId ( Ntk_Node_t *  node,
mAigEdge_t  mAigId 
)

Function********************************************************************

Synopsis [Sets the AndInv Id of a node.]

Description [Setss the AndInv Id of the node to a given vlaue.]

SideEffects []

SeeAlso []

Definition at line 190 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  node->mAigId = mAigId;
}

Here is the caller graph for this function:

void Ntk_NodeSetMddId ( Ntk_Node_t *  node,
int  id 
)

Function********************************************************************

Synopsis [Sets the MDD id of a node.]

Description [Sets the MDD id of a node. Any node can have its MDD id set. No check is made to see if node already has an MDD id. Use the constant NTK_UNASSIGNED_MDD_ID to indicate that the id is not set. If mddId is not NTK_UNASSIGNED_MDD_ID, then this mddId/node pair will be added to the network's mddId to node table, and any previous pair involving this node will be removed from the table. Note that this function does *not* register this mddId with the MDD manager; this must be done by calling mdd_create_variables. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeReadMddId Ord_NetworkOrderVariables Ntk_NetworkFindNodeByMddId]

Definition at line 298 of file ntkNode.c.

{
  Ntk_Network_t *network = node->network;
  char *entry;
  
  assert(node != NIL(Ntk_Node_t));

  /* If the node already has an assigned id, then clean it from the table. */
  if (node->mddId != NTK_UNASSIGNED_MDD_ID) {
    entry = (char *) (long) node->mddId;
    (void) st_delete(network->mddIdToNode, &entry, NIL(char *));
  }

  /* Set the new id, and add it to the table (if it's not unassigned). */
  node->mddId = id;
  if (id != NTK_UNASSIGNED_MDD_ID) {
    st_insert(network->mddIdToNode, (char *) (long) id, (char *) node);
  }
}

Here is the caller graph for this function:

void Ntk_NodeSetTable ( Ntk_Node_t *  node,
Tbl_Table_t *  table 
)

Function********************************************************************

Synopsis [Sets the table of the node to supplied table.]

Description [Sets the table of the node to supplied table. THIS FUNCTION SHOULD BE USED WITH UTMOST CAUTION. It is assumed that the reference count of the supplied table is appropriately incremented. If a table already exists in the node it is NOT deleted. It is the users responsibility to free memory associated with the old table. Every combinational node and every pseudo input has a table. It is an error to call this function on a NULL node or a node that isn't combinational or a pseudo input. No checks are done to ensure that the supplied table infact has an output column for the specified node or the variables corresponding to the input columns are indeed those of the fanin nodes.]

SideEffects [The old table pointed to by the node is NOT deleted.]

SeeAlso [Ntk_NodeDeclareAsCombinational Ntk_NodeDeclareAsPseudoInput Ntk_NodeReadTable]

Definition at line 220 of file ntkNode.c.

{

  assert(node != NIL(Ntk_Node_t));
  assert((node->type == NtkCombinational_c) || (node->type == NtkPseudoInput_c));

  node->table = table;
}

Here is the caller graph for this function:

void Ntk_NodeSetUndef ( Ntk_Node_t *  node,
void *  value 
)

Function********************************************************************

Synopsis [Sets the undef field of a node.]

Description [Sets the undef field of a node. There is no restriction on how this field is used. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeReadUndef]

Definition at line 359 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  node->undef = value;
}

Here is the caller graph for this function:

boolean Ntk_NodeTestIsCombinational ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns 1 if node is combinational, else returns 0.]

Description [Returns 1 if node is combinational, else returns 0. A node is combinational only if it has been so declared using Ntk_NodeDeclareAsCombinational. Combinational nodes have tables.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsCombinational]

Definition at line 596 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->type == NtkCombinational_c);
}

Here is the caller graph for this function:

boolean Ntk_NodeTestIsCombInput ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns 1 if node is a combinational input, else returns 0.]

Description [Returns 1 if node is a combinational input, else returns 0. A node is a combinational input if it is a primary input, a pseudo input, or a latch. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsPrimaryInput Ntk_NodeDeclareAsLatch Ntk_NodeDeclareAsPseudoInput]

Definition at line 547 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return ((node->type == NtkLatch_c)
          || (node->type == NtkPrimaryInput_c)
          || (node->type == NtkPseudoInput_c));
}

Here is the caller graph for this function:

boolean Ntk_NodeTestIsCombOutput ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns 1 if node is a combinational output, else returns 0.]

Description [Returns 1 if node is a combinational output, else returns 0. A node is a combinational output if it is a primary output, a data input to a latch, or an initial input to a latch. This is a constant time operation. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsPrimaryOutput Ntk_NodeDeclareAsLatch]

Definition at line 572 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (Ntk_NodeTestIsPrimaryOutput(node)
          || Ntk_NodeTestIsLatchDataInput(node)
          || Ntk_NodeTestIsLatchInitialInput(node));
}

Here is the call graph for this function:

Here is the caller graph for this function:

boolean Ntk_NodeTestIsConstant ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns 1 if node is a constant, else returns 0.]

Description [Returns 1 if node is a constant, else returns 0. A constant is a combinational node that has no inputs, and whose output can take exactly one of its values. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsCombinational]

Definition at line 689 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->constant);
}

Here is the caller graph for this function:

boolean Ntk_NodeTestIsInput ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns 1 if node is a primary or pseudo input, else returns 0.]

Description [Returns 1 if node is a primary or pseudo input, else returns 0. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsPrimaryInput Ntk_NodeDeclareAsPseudoInput Ntk_NodeTestIsPrimaryInput Ntk_NodeTestIsPseudoInput]

Definition at line 428 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return ((node->type == NtkPrimaryInput_c) || (node->type == NtkPseudoInput_c));
  
}

Here is the caller graph for this function:

boolean Ntk_NodeTestIsLatch ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns 1 if node is a latch, else returns 0.]

Description [Returns 1 if node is a latch, else returns 0. A node is a latch only if it has been so declared using Ntk_NodeDeclareAsLatch. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsLatch]

Definition at line 473 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->type == NtkLatch_c);
}
boolean Ntk_NodeTestIsLatchDataInput ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns 1 if node is a data input to a latch, else returns 0.]

Description [Returns 1 if node is a data input to a latch, else returns 0. Nodes of all types can be data inputs to latches. A node is declared as a data input to a latch by virtue of a call to Ntk_NodeDeclareAsLatch. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsLatch]

Definition at line 643 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->latchDataInput);
}

Here is the caller graph for this function:

boolean Ntk_NodeTestIsLatchInitialInput ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns 1 if node is an initial input to a latch, else returns 0.]

Description [Returns 1 if node is an initial input to a latch, else returns 0. Nodes of all types can be initial inputs to latches. The initial input to a latch gives the initial value of the latch. A node is declared as a initial input to a latch by virtue of a call to Ntk_NodeDeclareAsLatch. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsLatch]

Definition at line 667 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->latchInitialInput);
}

Here is the caller graph for this function:

boolean Ntk_NodeTestIsNextStateNode ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns 1 if node is a next state node, else returns 0.]

Description [Returns 1 if node is a next state node, else returns 0. A next state node is a shadow node whose origin node is a latch. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsShadow]

Definition at line 495 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  if (Ntk_NodeTestIsShadow(node)) {
    Ntk_Node_t *origin = Ntk_ShadowReadOrigin(node);
    if (Ntk_NodeTestIsLatch(origin)) {
      return (TRUE);
    }
  }
  
  return (FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

boolean Ntk_NodeTestIsPrimaryInput ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns 1 if node is a primary input, else returns 0.]

Description [Returns 1 if node is a primary input, else returns 0. A node is a primary input only if it has been so declared using Ntk_NodeDeclareAsPrimaryInput. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsPrimaryInput Ntk_NodeTestIsInput]

Definition at line 383 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->type == NtkPrimaryInput_c);
}

Here is the caller graph for this function:

boolean Ntk_NodeTestIsPrimaryOutput ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns 1 if node is a primary output, else returns 0.]

Description [Returns 1 if node is a primary output, else returns 0. Any node can be a primary output, except those of type shadow. A node is a primary output only if it has been so declared using Ntk_NodeDeclareAsPrimaryOutput. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsPrimaryOutput]

Definition at line 620 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->outputFlag);
}

Here is the caller graph for this function:

boolean Ntk_NodeTestIsPseudoInput ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns 1 if node is a pseudo input, else returns 0.]

Description [Returns 1 if node is a pseudo input, else returns 0. A node is a pseudo input only if it has been so declared using Ntk_NodeDeclareAsPseudoInput. A pseudo input has no fanins, but has a table defining its function. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsPseudoInput Ntk_NodeTestIsInput]

Definition at line 406 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->type == NtkPseudoInput_c);
}

Here is the caller graph for this function:

boolean Ntk_NodeTestIsShadow ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns 1 if node is a shadow node, else returns 0.]

Description [Returns 1 if node is a shadow node, else returns 0. A shadow node is used to associate extra information with a node, in particular another MDD id. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsShadow Ntk_ShadowReadOrigin Ntk_NodeReadShadow]

Definition at line 524 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->type == NtkShadow_c);
}

Here is the caller graph for this function:

boolean Ntk_NodeTestIsUndefined ( Ntk_Node_t *  node)

Function********************************************************************

Synopsis [Returns 1 if node is undefined, else returns 0.]

Description [Returns 1 if node is undefined, else returns 0. A node is undefined if it has been created but not declared as anything. It is an error to call this function on a NULL node.]

SideEffects []

SeeAlso [Ntk_NodeCreateInNetwork Ntk_NodeDeclareAsCombinational]

Definition at line 451 of file ntkNode.c.

{
  assert(node != NIL(Ntk_Node_t));
  return (node->type == NtkUnassigned_c);
}

Here is the caller graph for this function:

Ntk_Node_t* Ntk_ShadowReadOrigin ( Ntk_Node_t *  shadow)

Function********************************************************************

Synopsis [Returns the origin node of a shadow node.]

Description [Returns the origin node of a shadow node. The origin of a shadow node is that node that is "casting" the shadow. A shadow is used as a placeholder for a node, in particular a place to store an additional MDD variable. It is an error to call this function on a node that is not a shadow.]

SideEffects []

SeeAlso [Ntk_NodeDeclareAsShadow Ntk_NodeReadShadow Ntk_NodeTestIsShadow]

Definition at line 737 of file ntkNode.c.

{
  assert(shadow != NIL(Ntk_Node_t));
  assert(shadow->type == NtkShadow_c);
  return (shadow->shadowInfo.origin);
}

Here is the caller graph for this function:


Variable Documentation

char rcsid [] UNUSED = "$Id: ntkNode.c,v 1.15 2009/04/11 01:56:10 fabio Exp $" [static]

CFile***********************************************************************

FileName [ntkNode.c]

PackageName [ntk]

Synopsis [Routines to access the node data structure.]

Author [Adnan Aziz, Tom Shiple]

Copyright [Copyright (c) 1994-1996 The Regents of the Univ. of California. All rights reserved.

Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose, provided that the above copyright notice and the following two paragraphs appear in all copies of this software.

IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.]

Definition at line 35 of file ntkNode.c.