/**Function************************************************************* Synopsis [Registers the cube string with the network.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ char * Mio_SopRegister( Mem_Flex_t * pMan, char * pName ) { char * pRegName; if ( pName == NULL ) return NULL; pRegName = Mem_FlexEntryFetch( pMan, strlen(pName) + 1 ); strcpy( pRegName, pName ); return pRegName; }
void Wlc_ObjAddFanins( Wlc_Ntk_t * p, Wlc_Obj_t * pObj, Vec_Int_t * vFanins ) { assert( pObj->nFanins == 0 ); pObj->nFanins = Vec_IntSize(vFanins); if ( Wlc_ObjHasArray(pObj) ) pObj->pFanins[0] = (int *)Mem_FlexEntryFetch( p->pMemFanin, Vec_IntSize(vFanins) * sizeof(int) ); memcpy( Wlc_ObjFanins(pObj), Vec_IntArray(vFanins), sizeof(int) * Vec_IntSize(vFanins) ); // special treatment of CONST, SELECT and TABLE if ( pObj->Type == WLC_OBJ_CONST ) pObj->nFanins = 0; else if ( pObj->Type == WLC_OBJ_BIT_SELECT || pObj->Type == WLC_OBJ_TABLE ) pObj->nFanins = 1; }
ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// // these symbols (and no other) can appear in the formulas #define MIO_SYMB_AND '*' #define MIO_SYMB_AND2 '&' #define MIO_SYMB_OR '+' #define MIO_SYMB_OR2 '|' #define MIO_SYMB_XOR '^' #define MIO_SYMB_NOT '!' #define MIO_SYMB_AFTNOT '\'' #define MIO_SYMB_OPEN '(' #define MIO_SYMB_CLOSE ')' //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// /**Function************************************************************* Synopsis [Registers the cube string with the network.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ char * Mio_SopRegister( Mem_Flex_t * pMan, char * pName ) { char * pRegName; if ( pName == NULL ) return NULL; pRegName = Mem_FlexEntryFetch( pMan, strlen(pName) + 1 ); strcpy( pRegName, pName ); return pRegName; }
/**Function************************************************************* Synopsis [Duplicate the MV variable.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Abc_NtkSetMvVarValues( Abc_Obj_t * pObj, int nValues ) { Mem_Flex_t * pFlex; struct temp { int nValues; char ** pNames; } * pVarStruct; assert( nValues > 1 ); // skip binary signals if ( nValues == 2 ) return; // skip already assigned signals if ( Abc_ObjMvVar(pObj) != NULL ) return; // create the structure pFlex = (Mem_Flex_t *)Abc_NtkMvVarMan( pObj->pNtk ); pVarStruct = (struct temp *)Mem_FlexEntryFetch( pFlex, sizeof(struct temp) ); pVarStruct->nValues = nValues; pVarStruct->pNames = NULL; Abc_ObjSetMvVar( pObj, pVarStruct ); }
/**Function************************************************************* Synopsis [Adds a gate to the circuit.] Description [The meaning of the parameters are: type: the type of the gate to be added name: the name of the gate to be added, name should be unique in a circuit. nofi: number of fanins of the gate to be added; fanins: the name array of fanins of the gate to be added.] SideEffects [] SeeAlso [] ***********************************************************************/ int ABC_AddGate( ABC_Manager mng, enum GateType type, char * name, int nofi, char ** fanins, int dc_attr ) { Abc_Obj_t * pObj = NULL; // Suppress "might be used uninitialized" Abc_Obj_t * pFanin; char * pSop = NULL; // Suppress "might be used uninitialized" char * pNewName; int i; // save the name in the local memory manager pNewName = Mem_FlexEntryFetch( mng->pMmNames, strlen(name) + 1 ); strcpy( pNewName, name ); name = pNewName; // consider different cases, create the node, and map the node into the name switch( type ) { case CSAT_BPI: case CSAT_BPPI: if ( nofi != 0 ) { printf( "ABC_AddGate: The PI/PPI gate \"%s\" has fanins.\n", name ); return 0; } // create the PI pObj = Abc_NtkCreatePi( mng->pNtk ); stmm_insert( mng->tNode2Name, (char *)pObj, name ); break; case CSAT_CONST: case CSAT_BAND: case CSAT_BNAND: case CSAT_BOR: case CSAT_BNOR: case CSAT_BXOR: case CSAT_BXNOR: case CSAT_BINV: case CSAT_BBUF: // create the node pObj = Abc_NtkCreateNode( mng->pNtk ); // create the fanins for ( i = 0; i < nofi; i++ ) { if ( !stmm_lookup( mng->tName2Node, fanins[i], (char **)&pFanin ) ) { printf( "ABC_AddGate: The fanin gate \"%s\" is not in the network.\n", fanins[i] ); return 0; } Abc_ObjAddFanin( pObj, pFanin ); } // create the node function switch( type ) { case CSAT_CONST: if ( nofi != 0 ) { printf( "ABC_AddGate: The constant gate \"%s\" has fanins.\n", name ); return 0; } pSop = Abc_SopCreateConst1( (Mem_Flex_t *)mng->pNtk->pManFunc ); break; case CSAT_BAND: if ( nofi < 1 ) { printf( "ABC_AddGate: The AND gate \"%s\" no fanins.\n", name ); return 0; } pSop = Abc_SopCreateAnd( (Mem_Flex_t *)mng->pNtk->pManFunc, nofi, NULL ); break; case CSAT_BNAND: if ( nofi < 1 ) { printf( "ABC_AddGate: The NAND gate \"%s\" no fanins.\n", name ); return 0; } pSop = Abc_SopCreateNand( (Mem_Flex_t *)mng->pNtk->pManFunc, nofi ); break; case CSAT_BOR: if ( nofi < 1 ) { printf( "ABC_AddGate: The OR gate \"%s\" no fanins.\n", name ); return 0; } pSop = Abc_SopCreateOr( (Mem_Flex_t *)mng->pNtk->pManFunc, nofi, NULL ); break; case CSAT_BNOR: if ( nofi < 1 ) { printf( "ABC_AddGate: The NOR gate \"%s\" no fanins.\n", name ); return 0; } pSop = Abc_SopCreateNor( (Mem_Flex_t *)mng->pNtk->pManFunc, nofi ); break; case CSAT_BXOR: if ( nofi < 1 ) { printf( "ABC_AddGate: The XOR gate \"%s\" no fanins.\n", name ); return 0; } if ( nofi > 2 ) { printf( "ABC_AddGate: The XOR gate \"%s\" has more than two fanins.\n", name ); return 0; } pSop = Abc_SopCreateXor( (Mem_Flex_t *)mng->pNtk->pManFunc, nofi ); break; case CSAT_BXNOR: if ( nofi < 1 ) { printf( "ABC_AddGate: The XNOR gate \"%s\" no fanins.\n", name ); return 0; } if ( nofi > 2 ) { printf( "ABC_AddGate: The XNOR gate \"%s\" has more than two fanins.\n", name ); return 0; } pSop = Abc_SopCreateNxor( (Mem_Flex_t *)mng->pNtk->pManFunc, nofi ); break; case CSAT_BINV: if ( nofi != 1 ) { printf( "ABC_AddGate: The inverter gate \"%s\" does not have exactly one fanin.\n", name ); return 0; } pSop = Abc_SopCreateInv( (Mem_Flex_t *)mng->pNtk->pManFunc ); break; case CSAT_BBUF: if ( nofi != 1 ) { printf( "ABC_AddGate: The buffer gate \"%s\" does not have exactly one fanin.\n", name ); return 0; } pSop = Abc_SopCreateBuf( (Mem_Flex_t *)mng->pNtk->pManFunc ); break; default : break; } Abc_ObjSetData( pObj, pSop ); break; case CSAT_BPPO: case CSAT_BPO: if ( nofi != 1 ) { printf( "ABC_AddGate: The PO/PPO gate \"%s\" does not have exactly one fanin.\n", name ); return 0; } // create the PO pObj = Abc_NtkCreatePo( mng->pNtk ); stmm_insert( mng->tNode2Name, (char *)pObj, name ); // connect to the PO fanin if ( !stmm_lookup( mng->tName2Node, fanins[0], (char **)&pFanin ) ) { printf( "ABC_AddGate: The fanin gate \"%s\" is not in the network.\n", fanins[0] ); return 0; } Abc_ObjAddFanin( pObj, pFanin ); break; default: printf( "ABC_AddGate: Unknown gate type.\n" ); break; } // map the name into the node if ( stmm_insert( mng->tName2Node, name, (char *)pObj ) ) { printf( "ABC_AddGate: The same gate \"%s\" is added twice.\n", name ); return 0; } return 1; }