From b09305204d82a4d5a842ba960ec14e9641cb8060 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 10 Mar 2025 20:13:53 -0700 Subject: [PATCH] Minor bug fixes. --- src/base/wlc/wlcBlast.c | 9 +++- src/map/if/ifCom.c | 111 ++++++++++++++++++++++++++++++++++++++++ src/map/if/ifLibBox.c | 3 +- src/misc/tim/tim.h | 1 + src/misc/tim/timMan.c | 8 +-- 5 files changed, 126 insertions(+), 6 deletions(-) diff --git a/src/base/wlc/wlcBlast.c b/src/base/wlc/wlcBlast.c index 271b52d99..1b066ef4c 100644 --- a/src/base/wlc/wlcBlast.c +++ b/src/base/wlc/wlcBlast.c @@ -1513,9 +1513,12 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Wlc_BstPar_t * pParIn ) nRange2 = 0; // create new box - if ( vTables == NULL ) + if ( vTables == NULL ) { Tim_ManSetDelayTables( pManTime, (vTables = Vec_PtrAlloc(100)) ); + Vec_PtrPush( vTables, NULL ); + } Tim_ManCreateBox( pManTime, curPo, nRange0 + nRange1 + nRange2, curPi, nRange, Vec_PtrSize(vTables), 0 ); + Tim_ManBoxSetCopy( pManTime, Tim_ManBoxNum(pManTime)-1, Tim_ManBoxNum(pManTime)-1 ); curPi += nRange; curPo += nRange0 + nRange1 + nRange2; @@ -2105,8 +2108,10 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Wlc_BstPar_t * pParIn ) assert( pObj->Type == WLC_OBJ_FF ); // create new box - if ( vTables == NULL ) + if ( vTables == NULL ) { Tim_ManSetDelayTables( pManTime, (vTables = Vec_PtrAlloc(100)) ); + Vec_PtrPush( vTables, NULL ); + } Tim_ManCreateBox( pManTime, curPo, nRangeIn, curPi, nRange, Vec_PtrSize(vTables), 0 ); curPi += nRange; curPo += nRangeIn; diff --git a/src/map/if/ifCom.c b/src/map/if/ifCom.c index dd6477d11..a2f54ae35 100644 --- a/src/map/if/ifCom.c +++ b/src/map/if/ifCom.c @@ -32,6 +32,8 @@ static int If_CommandReadLut ( Abc_Frame_t * pAbc, int argc, char **argv ); static int If_CommandPrintLut( Abc_Frame_t * pAbc, int argc, char **argv ); static int If_CommandReadBox ( Abc_Frame_t * pAbc, int argc, char **argv ); static int If_CommandPrintBox( Abc_Frame_t * pAbc, int argc, char **argv ); +static int If_CommandWriteBox( Abc_Frame_t * pAbc, int argc, char **argv ); +static int If_CommandPrintTim( Abc_Frame_t * pAbc, int argc, char **argv ); //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// @@ -59,6 +61,8 @@ void If_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "FPGA mapping", "read_box", If_CommandReadBox, 0 ); Cmd_CommandAdd( pAbc, "FPGA mapping", "print_box", If_CommandPrintBox, 0 ); + Cmd_CommandAdd( pAbc, "FPGA mapping", "write_box", If_CommandWriteBox, 0 ); + Cmd_CommandAdd( pAbc, "FPGA mapping", "print_tim", If_CommandPrintTim, 0 ); } /**Function************************************************************* @@ -362,6 +366,113 @@ usage: return 1; /* error exit */ } +/**Function************************************************************* + + Synopsis [Command procedure to read LUT libraries.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int If_CommandWriteBox( Abc_Frame_t * pAbc, int argc, char **argv ) +{ + FILE * pOut, * pErr; + Abc_Ntk_t * pNet; + int fVerbose; + int c; + + pNet = Abc_FrameReadNtk(pAbc); + pOut = Abc_FrameReadOut(pAbc); + pErr = Abc_FrameReadErr(pAbc); + + fVerbose = 1; + Extra_UtilGetoptReset(); + while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF ) + { + switch (c) + { + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + break; + default: + goto usage; + } + } + + if ( argc != globalUtilOptind+1 ) + goto usage; + + If_LibBoxWrite( argv[globalUtilOptind], (If_LibBox_t *)Abc_FrameReadLibBox() ); + return 0; + +usage: + fprintf( pErr, "\nusage: write_box [-vh] \n"); + fprintf( pErr, "\t write the current box library into a file\n" ); + fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") ); + fprintf( pErr, "\t-h : print the command usage\n"); + fprintf( pErr, "\t : the output file name\n"); + return 1; /* error exit */ +} + + +/**Function************************************************************* + + Synopsis [Command procedure to read LUT libraries.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int If_CommandPrintTim( Abc_Frame_t * pAbc, int argc, char **argv ) +{ + Gia_Man_t * pGia = Abc_FrameReadGia(pAbc); + int c, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF ) + { + switch (c) + { + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + break; + default: + goto usage; + } + } + if ( pGia == NULL ) + { + Abc_Print( -1, "There is no AIG in the &-space.\n" ); + return 1; + } + if ( pGia->pManTime == NULL ) + { + Abc_Print( -1, "The current AIG does not have a timing manager.\n" ); + return 1; + } + Tim_ManPrint( (Tim_Man_t *)pGia->pManTime ); + if ( fVerbose ) + Tim_ManPrintBoxCopy( (Tim_Man_t *)pGia->pManTime ); + return 0; + +usage: + Abc_Print( -2, "\nusage: print_tim [-vh]\n"); + Abc_Print( -2, "\t print the timing manager\n" ); + Abc_Print( -2, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") ); + Abc_Print( -2, "\t-h : print the command usage\n"); + return 1; /* error exit */ +} //////////////////////////////////////////////////////////////////////// /// END OF FILE /// diff --git a/src/map/if/ifLibBox.c b/src/map/if/ifLibBox.c index 443dbd3f4..55a859ceb 100644 --- a/src/map/if/ifLibBox.c +++ b/src/map/if/ifLibBox.c @@ -345,7 +345,7 @@ void If_LibBoxPrint( FILE * pFile, If_LibBox_t * p ) If_LibBoxForEachBox( p, pBox, i ) { fprintf( pFile, "%s %d %d %d %d\n", pBox->pName, pBox->Id, !pBox->fBlack, pBox->nPis, pBox->nPos ); - for ( j = 0; j < pBox->nPos; j++, printf("\n") ) + for ( j = 0; j < pBox->nPos; j++, fprintf(pFile, "\n") ) for ( k = 0; k < pBox->nPis; k++ ) if ( pBox->pDelays[j * pBox->nPis + k] == -ABC_INFINITY ) fprintf( pFile, " - " ); @@ -364,6 +364,7 @@ void If_LibBoxWrite( char * pFileName, If_LibBox_t * p ) } If_LibBoxPrint( pFile, p ); fclose( pFile ); + printf( "Finished writing box library into file \"%s\".\n", pFileName ); } /**Function************************************************************* diff --git a/src/misc/tim/tim.h b/src/misc/tim/tim.h index 06019f56b..a01d53e32 100644 --- a/src/misc/tim/tim.h +++ b/src/misc/tim/tim.h @@ -140,6 +140,7 @@ extern float * Tim_ManGetReqTimes( Tim_Man_t * p ); extern void Tim_ManStop( Tim_Man_t * p ); extern void Tim_ManStopP( Tim_Man_t ** p ); extern void Tim_ManPrint( Tim_Man_t * p ); +extern void Tim_ManPrintBoxCopy( Tim_Man_t * p ); extern void Tim_ManPrintStats( Tim_Man_t * p, int nAnd2Delay ); extern int Tim_ManCiNum( Tim_Man_t * p ); extern int Tim_ManCoNum( Tim_Man_t * p ); diff --git a/src/misc/tim/timMan.c b/src/misc/tim/timMan.c index 151bf91d1..7e112669e 100644 --- a/src/misc/tim/timMan.c +++ b/src/misc/tim/timMan.c @@ -564,10 +564,10 @@ void Tim_ManPrint( Tim_Man_t * p ) if ( Tim_ManBoxNum(p) > 0 ) Tim_ManForEachBox( p, pBox, i ) { - printf( "*** Box %5d : I =%4d. O =%4d. I1 =%6d. O1 =%6d. Table =%4d\n", + printf( "*** Box %5d : I =%4d. O =%4d. I1 =%6d. O1 =%6d. Table =%4d. Copy = %d.\n", i, pBox->nInputs, pBox->nOutputs, Tim_ManBoxInputFirst(p, i), Tim_ManBoxOutputFirst(p, i), - pBox->iDelayTable ); + pBox->iDelayTable, pBox->iCopy ); // print box inputs pPrev = Tim_ManBoxInput( p, pBox, 0 ); @@ -591,7 +591,7 @@ void Tim_ManPrint( Tim_Man_t * p ) Tim_ManBoxForEachOutput( p, pBox, pObj, k ) printf( "box-out%3d : arrival = %5.3f required = %5.3f\n", k, pObj->timeArr, pObj->timeReq ); - if ( i > 2 ) + if ( i == 7 ) break; } @@ -611,6 +611,8 @@ void Tim_ManPrint( Tim_Man_t * p ) printf( "%5s", "-" ); else printf( "%5.0f", pTable[3+j*TableX+k] ); + if ( i == 7 ) + break; } printf( "\n" ); }