diff options
Diffstat (limited to 'src/aig/ntl/ntlWriteBlif.c')
-rw-r--r-- | src/aig/ntl/ntlWriteBlif.c | 81 |
1 files changed, 55 insertions, 26 deletions
diff --git a/src/aig/ntl/ntlWriteBlif.c b/src/aig/ntl/ntlWriteBlif.c index 51d41c26..f93e3fa1 100644 --- a/src/aig/ntl/ntlWriteBlif.c +++ b/src/aig/ntl/ntlWriteBlif.c @@ -40,15 +40,22 @@ SeeAlso [] ***********************************************************************/ -void Ioa_WriteBlifModel( FILE * pFile, Ntl_Mod_t * pModel ) +void Ioa_WriteBlifModel( FILE * pFile, Ntl_Mod_t * pModel, int fMain ) { Ntl_Obj_t * pObj; Ntl_Net_t * pNet; float Delay; - int i, k, fClockAdded = 0; + int i, k; fprintf( pFile, ".model %s\n", pModel->pName ); - if ( pModel->fKeep ) - fprintf( pFile, ".attrib keep\n" ); + if ( pModel->attrWhite || pModel->attrBox || pModel->attrComb || pModel->attrKeep ) + { + fprintf( pFile, ".attrib" ); + fprintf( pFile, " %s", pModel->attrWhite? "white": "black" ); + fprintf( pFile, " %s", pModel->attrBox? "box" : "logic" ); + fprintf( pFile, " %s", pModel->attrComb? "comb" : "seq" ); +// fprintf( pFile, " %s", pModel->attrKeep? "keep" : "sweep" ); + fprintf( pFile, "\n" ); + } fprintf( pFile, ".inputs" ); Ntl_ModelForEachPi( pModel, pObj, i ) fprintf( pFile, " %s", Ntl_ObjFanout0(pObj)->pName ); @@ -63,19 +70,25 @@ void Ioa_WriteBlifModel( FILE * pFile, Ntl_Mod_t * pModel ) for ( i = 0; i < Vec_IntSize(pModel->vDelays); i += 3 ) { fprintf( pFile, ".delay" ); - fprintf( pFile, " %s", Ntl_ObjFanout0(Ntl_ModelPi(pModel, Vec_IntEntry(pModel->vDelays,i)))->pName ); - fprintf( pFile, " %s", Ntl_ObjFanin0(Ntl_ModelPo(pModel, Vec_IntEntry(pModel->vDelays,i+1)))->pName ); + if ( Vec_IntEntry(pModel->vDelays,i) != -1 ) + fprintf( pFile, " %s", Ntl_ObjFanout0(Ntl_ModelPi(pModel, Vec_IntEntry(pModel->vDelays,i)))->pName ); + if ( Vec_IntEntry(pModel->vDelays,i+1) != -1 ) + fprintf( pFile, " %s", Ntl_ObjFanin0(Ntl_ModelPo(pModel, Vec_IntEntry(pModel->vDelays,i+1)))->pName ); fprintf( pFile, " %.3f", Aig_Int2Float(Vec_IntEntry(pModel->vDelays,i+2)) ); fprintf( pFile, "\n" ); } } - if ( pModel->vArrivals ) + if ( pModel->vTimeInputs ) { - for ( i = 0; i < Vec_IntSize(pModel->vArrivals); i += 2 ) + for ( i = 0; i < Vec_IntSize(pModel->vTimeInputs); i += 2 ) { - fprintf( pFile, ".input_arrival" ); - fprintf( pFile, " %s", Ntl_ObjFanout0(Ntl_ModelPi(pModel, Vec_IntEntry(pModel->vArrivals,i)))->pName ); - Delay = Aig_Int2Float(Vec_IntEntry(pModel->vArrivals,i+1)); + if ( fMain ) + fprintf( pFile, ".input_arrival" ); + else + fprintf( pFile, ".input_required" ); + if ( Vec_IntEntry(pModel->vTimeInputs,i) != -1 ) + fprintf( pFile, " %s", Ntl_ObjFanout0(Ntl_ModelPi(pModel, Vec_IntEntry(pModel->vTimeInputs,i)))->pName ); + Delay = Aig_Int2Float(Vec_IntEntry(pModel->vTimeInputs,i+1)); if ( Delay == -TIM_ETERNITY ) fprintf( pFile, " -inf" ); else if ( Delay == TIM_ETERNITY ) @@ -85,13 +98,17 @@ void Ioa_WriteBlifModel( FILE * pFile, Ntl_Mod_t * pModel ) fprintf( pFile, "\n" ); } } - if ( pModel->vRequireds ) + if ( pModel->vTimeOutputs ) { - for ( i = 0; i < Vec_IntSize(pModel->vRequireds); i += 2 ) + for ( i = 0; i < Vec_IntSize(pModel->vTimeOutputs); i += 2 ) { - fprintf( pFile, ".output_required" ); - fprintf( pFile, " %s", Ntl_ObjFanin0(Ntl_ModelPo(pModel, Vec_IntEntry(pModel->vRequireds,i)))->pName ); - Delay = Aig_Int2Float(Vec_IntEntry(pModel->vRequireds,i+1)); + if ( fMain ) + fprintf( pFile, ".output_required" ); + else + fprintf( pFile, ".output_arrival" ); + if ( Vec_IntEntry(pModel->vTimeOutputs,i) != -1 ) + fprintf( pFile, " %s", Ntl_ObjFanin0(Ntl_ModelPo(pModel, Vec_IntEntry(pModel->vTimeOutputs,i)))->pName ); + Delay = Aig_Int2Float(Vec_IntEntry(pModel->vTimeOutputs,i+1)); if ( Delay == -TIM_ETERNITY ) fprintf( pFile, " -inf" ); else if ( Delay == TIM_ETERNITY ) @@ -117,13 +134,27 @@ void Ioa_WriteBlifModel( FILE * pFile, Ntl_Mod_t * pModel ) fprintf( pFile, ".latch" ); fprintf( pFile, " %s", Ntl_ObjFanin0(pObj)->pName ); fprintf( pFile, " %s", Ntl_ObjFanout0(pObj)->pName ); - if ( pObj->LatchId >> 2 ) - fprintf( pFile, " %d", pObj->LatchId >> 2 ); - if ( Ntl_ObjFanin(pObj, 1) != NULL ) - fprintf( pFile, " %s", Ntl_ObjFanin(pObj, 1)->pName ); - else if ( pObj->LatchId >> 2 ) - fprintf( pFile, " clock99" ), fClockAdded = 1; - fprintf( pFile, " %d", pObj->LatchId & 3 ); + assert( pObj->LatchId.regType == 0 || pObj->LatchId.regClass == 0 ); + if ( pObj->LatchId.regType ) + { + if ( pObj->LatchId.regType == 1 ) + fprintf( pFile, " fe" ); + else if ( pObj->LatchId.regType == 2 ) + fprintf( pFile, " re" ); + else if ( pObj->LatchId.regType == 3 ) + fprintf( pFile, " ah" ); + else if ( pObj->LatchId.regType == 4 ) + fprintf( pFile, " al" ); + else if ( pObj->LatchId.regType == 5 ) + fprintf( pFile, " as" ); + else + assert( 0 ); + } + else if ( pObj->LatchId.regClass ) + fprintf( pFile, " %d", pObj->LatchId.regClass ); + if ( pObj->pClock ) + fprintf( pFile, " %s", pObj->pClock->pName ); + fprintf( pFile, " %d", pObj->LatchId.regInit ); fprintf( pFile, "\n" ); } else if ( Ntl_ObjIsBox(pObj) ) @@ -136,8 +167,6 @@ void Ioa_WriteBlifModel( FILE * pFile, Ntl_Mod_t * pModel ) fprintf( pFile, "\n" ); } } - if ( fClockAdded ) - fprintf( pFile, ".names clock99\n 0\n" ); fprintf( pFile, ".end\n\n" ); } @@ -167,7 +196,7 @@ void Ioa_WriteBlif( Ntl_Man_t * p, char * pFileName ) fprintf( pFile, "# Benchmark \"%s\" written by ABC-8 on %s\n", p->pName, Ioa_TimeStamp() ); // write the models Ntl_ManForEachModel( p, pModel, i ) - Ioa_WriteBlifModel( pFile, pModel ); + Ioa_WriteBlifModel( pFile, pModel, i==0 ); // close the file fclose( pFile ); } |