/**CFile*********************************************************************** FileName [eqvMisc.c] PackageName [eqv] Synopsis [This file provides some miscellaneous functions for the eqv package.] Description [] SeeAlso [] Author [Shaz Qadeer] 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.] ******************************************************************************/ #include "eqvInt.h" static char rcsid[] UNUSED = "$Id: eqvMisc.c,v 1.10 2009/04/11 01:40:06 fabio Exp $"; /*---------------------------------------------------------------------------*/ /* Constant declarations */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* Type declarations */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* Structure declarations */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* Variable declarations */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* Macro declarations */ /*---------------------------------------------------------------------------*/ /**AutomaticStart*************************************************************/ /*---------------------------------------------------------------------------*/ /* Static function prototypes */ /*---------------------------------------------------------------------------*/ static boolean NodesMatchUp(Ntk_Node_t *node1, Ntk_Node_t *node2); /**AutomaticEnd***************************************************************/ /*---------------------------------------------------------------------------*/ /* Definition of exported functions */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* Definition of internal functions */ /*---------------------------------------------------------------------------*/ /**Function******************************************************************** Synopsis [This function returns a hash table of corresponding primary input nodes in network1 and network2.] Description [The hash table returned by the function contains corresponding primary input nodes in network1 and network2. The correspondence is based on the names of the nodes. The following conditions constitute an error: 1) the number of primary inputs in the two networks is different. 2) there is no primary input in network2 by the same name as one occurring in network1. 3) the two primary inputs in network1 and network2 having the same names have different variable types. If an error occurs, NULL is returned.] SideEffects [] SeeAlso [] ******************************************************************************/ st_table * MapPrimaryInputsByName( Ntk_Network_t *network1, Ntk_Network_t *network2) { lsGen gen1, gen2; Ntk_Node_t *node1, *node2; Var_Variable_t *var1, *var2; char *name1, *name2; boolean flag = FALSE; boolean equivalent = TRUE; boolean causeOfError = TRUE; st_table *inputMap; int numValues; int i; if(Ntk_NetworkReadNumPrimaryInputs(network1) != Ntk_NetworkReadNumPrimaryInputs(network2)) { error_append("Different number of primary inputs in the two networks\n"); return NIL(st_table); } inputMap = st_init_table(st_ptrcmp, st_ptrhash); Ntk_NetworkForEachPrimaryInput(network1, gen1, node1) { name1 = Ntk_NodeReadName(node1); Ntk_NetworkForEachPrimaryInput(network2, gen2, node2) { name2 = Ntk_NodeReadName(node2); if (strcmp(name1, name2) == 0) { boolean a, b; var1 = Ntk_NodeReadVariable(node1); var2 = Ntk_NodeReadVariable(node2); a = Var_VariableTestIsEnumerative(var1); b = Var_VariableTestIsEnumerative(var2); if((a && !b) || (!a && b)) { error_append("Input "); error_append(name1); error_append(" and "); error_append(name2); error_append(" have different variable types\n"); causeOfError = FALSE; } else { numValues = Var_VariableReadNumValues(var1); if(a && b) { if(numValues == Var_VariableReadNumValues(var2)) { st_insert(inputMap, (char *) node1, (char *) node2); flag = TRUE; } else { error_append("Input "); error_append(name1); error_append(" and "); error_append(name2); error_append(" have different range of values\n"); causeOfError = FALSE; } } else {/* both are symbolic */ boolean flag2 = TRUE; for(i=0; i