Skip to content

Commit 75adf12

Browse files
committed
Adding new feature to &nf.
1 parent 1c2b935 commit 75adf12

File tree

3 files changed

+99
-2
lines changed

3 files changed

+99
-2
lines changed

src/aig/gia/gia.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ struct Jf_Par_t_
387387
float Epsilon;
388388
float * pTimesArr;
389389
float * pTimesReq;
390+
char * ZFile;
390391
};
391392

392393
static inline unsigned Gia_ObjCutSign( unsigned ObjId ) { return (1 << (ObjId & 31)); }

src/aig/gia/giaNf.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2161,6 +2161,90 @@ void Nf_ManFixPoDrivers( Nf_Man_t * p )
21612161
//printf( "Fixed %d PO drivers.\n", Count );
21622162
}
21632163

2164+
/**Function*************************************************************
2165+
2166+
Synopsis [Dump matches.]
2167+
2168+
Description []
2169+
2170+
SideEffects []
2171+
2172+
SeeAlso []
2173+
2174+
***********************************************************************/
2175+
void Nf_ManDumpMatches( Nf_Man_t * p )
2176+
{
2177+
FILE * pFile = fopen( p->pPars->ZFile, "wb" );
2178+
Gia_Obj_t * pObj; int n, iObj;
2179+
// output matches
2180+
Gia_ManForEachCi( p->pGia, pObj, n )
2181+
fprintf( pFile, "%d input %.2f\n", Abc_Var2Lit(Gia_ObjId(p->pGia, pObj), 0), 0.0 );
2182+
Gia_ManForEachAnd( p->pGia, pObj, iObj ) {
2183+
assert( !Gia_ObjIsBuf(pObj) );
2184+
for ( n = 0; n < 2; n++ ) {
2185+
int c, * pCut, * pCutSet = Nf_ObjCutSet( p, iObj );
2186+
Nf_SetForEachCut( pCutSet, pCut, c ) {
2187+
if ( Abc_Lit2Var(Nf_CutFunc(pCut)) >= Vec_WecSize(p->vTt2Match) )
2188+
continue;
2189+
assert( !Nf_CutIsTriv(pCut, iObj) );
2190+
assert( Nf_CutSize(pCut) <= p->pPars->nLutSize );
2191+
assert( Abc_Lit2Var(Nf_CutFunc(pCut)) < Vec_WecSize(p->vTt2Match) );
2192+
int iFuncLit = Nf_CutFunc(pCut);
2193+
int fComplExt = Abc_LitIsCompl(iFuncLit);
2194+
Vec_Int_t * v = Vec_WecEntry( p->vTt2Match, Abc_Lit2Var(iFuncLit) );
2195+
int j, k, Info, Offset, iFanin, fComplF;
2196+
Vec_IntForEachEntryDouble( v, Info, Offset, j ) {
2197+
Nf_Cfg_t Cfg = Nf_Int2Cfg(Offset);
2198+
int fCompl = Cfg.fCompl ^ fComplExt;
2199+
if ( fCompl != n )
2200+
continue;
2201+
Mio_Cell2_t*pC = Nf_ManCell( p, Info );
2202+
assert( Nf_CutSize(pCut) == (int)pC->nFanins );
2203+
fprintf( pFile, "%d ", Abc_Var2Lit(iObj, n) );
2204+
fprintf( pFile, "%s ", pC->pName );
2205+
fprintf( pFile, "%.2f", pC->AreaF );
2206+
Nf_CutForEachVarCompl( pCut, Cfg, iFanin, fComplF, k )
2207+
fprintf( pFile, " %d", Abc_Var2Lit(iFanin, fComplF) );
2208+
fprintf( pFile, "\n" );
2209+
}
2210+
}
2211+
}
2212+
}
2213+
Gia_ManForEachCo( p->pGia, pObj, n )
2214+
fprintf( pFile, "%d output %.2f %d\n", Abc_Var2Lit(Gia_ObjId(p->pGia, pObj), 0), 0.0, Gia_ObjFaninLit0p(p->pGia, pObj) );
2215+
// output levels
2216+
extern int Gia_ManChoiceLevel( Gia_Man_t * p );
2217+
int LevelMax = Gia_ManChoiceLevel( p->pGia );
2218+
Gia_ManForEachCiId( p->pGia, iObj, n )
2219+
fprintf( pFile, "L%d %d\n", Abc_Var2Lit(iObj, 0), 0 );
2220+
Gia_ManForEachAnd( p->pGia, pObj, iObj )
2221+
fprintf( pFile, "L%d %d\n", Abc_Var2Lit(iObj, 0), Gia_ObjLevelId(p->pGia, iObj) );
2222+
Gia_ManForEachCoId( p->pGia, iObj, n )
2223+
fprintf( pFile, "L%d %d\n", Abc_Var2Lit(iObj, 0), LevelMax+1 );
2224+
// output mapping
2225+
Gia_ManForEachCiId( p->pGia, iObj, n )
2226+
if ( Nf_ObjMapRefNum(p, iObj, 1) )
2227+
fprintf( pFile, "M%d %s %.2f %d\n", Abc_Var2Lit(iObj, 1), p->pCells[3].pName, p->pCells[3].AreaF, Abc_Var2Lit(iObj, 0) );
2228+
Gia_ManForEachAnd( p->pGia, pObj, iObj )
2229+
for ( n = 0; n < 2; n++ )
2230+
if ( Nf_ObjMapRefNum(p, iObj, n) ) {
2231+
Nf_Mat_t * pM = Nf_ObjMatchBest(p, iObj, n);
2232+
if ( pM->fCompl ) {
2233+
fprintf( pFile, "M%d %s %.2f %d\n", Abc_Var2Lit(iObj, n), p->pCells[3].pName, p->pCells[3].AreaF, Abc_Var2Lit(iObj, !n) );
2234+
continue;
2235+
}
2236+
int k, iVar, fCompl, * pCut = Nf_CutFromHandle( Nf_ObjCutSet(p, iObj), pM->CutH );
2237+
Mio_Cell2_t*pC = Nf_ManCell( p, pM->Gate );
2238+
fprintf( pFile, "M%d ", Abc_Var2Lit(iObj, n) );
2239+
fprintf( pFile, "%s ", pC->pName );
2240+
fprintf( pFile, "%.2f", pC->AreaF );
2241+
Nf_CutForEachVarCompl( pCut, pM->Cfg, iVar, fCompl, k )
2242+
fprintf( pFile, " %d", Abc_Var2Lit(iVar, fCompl) );
2243+
fprintf( pFile, "\n" );
2244+
}
2245+
fclose( pFile );
2246+
}
2247+
21642248
/**Function*************************************************************
21652249
21662250
Synopsis [Deriving mapping.]
@@ -2216,6 +2300,8 @@ Gia_Man_t * Nf_ManDeriveMapping( Nf_Man_t * p )
22162300
}
22172301
// assert( Vec_IntCap(vMapping) == 16 || Vec_IntSize(vMapping) == Vec_IntCap(vMapping) );
22182302
p->pGia->vCellMapping = vMapping;
2303+
if ( p->pPars->ZFile )
2304+
Nf_ManDumpMatches( p );
22192305
return p->pGia;
22202306
}
22212307
void Nf_ManUpdateStats( Nf_Man_t * p )

src/base/abci/abc.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44574,7 +44574,7 @@ int Abc_CommandAbc9Nf( Abc_Frame_t * pAbc, int argc, char ** argv )
4457444574
Gia_Man_t * pNew; int c;
4457544575
Nf_ManSetDefaultPars( pPars );
4457644576
Extra_UtilGetoptReset();
44577-
while ( ( c = Extra_UtilGetopt( argc, argv, "KCFARLEDQWakpqfvwh" ) ) != EOF )
44577+
while ( ( c = Extra_UtilGetopt( argc, argv, "KCFARLEDQWZakpqfvwh" ) ) != EOF )
4457844578
{
4457944579
switch ( c )
4458044580
{
@@ -44694,6 +44694,15 @@ int Abc_CommandAbc9Nf( Abc_Frame_t * pAbc, int argc, char ** argv )
4469444694
if ( pPars->nVerbLimit < 0 )
4469544695
goto usage;
4469644696
break;
44697+
case 'Z':
44698+
if ( globalUtilOptind >= argc )
44699+
{
44700+
Abc_Print( -1, "Command line switch \"-Z\" should be followed by an output file name.\n" );
44701+
goto usage;
44702+
}
44703+
pPars->ZFile = argv[globalUtilOptind];
44704+
globalUtilOptind++;
44705+
break;
4469744706
case 'a':
4469844707
pPars->fAreaOnly ^= 1;
4469944708
break;
@@ -44747,7 +44756,7 @@ int Abc_CommandAbc9Nf( Abc_Frame_t * pAbc, int argc, char ** argv )
4474744756
sprintf(Buffer, "best possible" );
4474844757
else
4474944758
sprintf(Buffer, "%d", pPars->DelayTarget );
44750-
Abc_Print( -2, "usage: &nf [-KCFARLEDQ num] [-akpqfvwh]\n" );
44759+
Abc_Print( -2, "usage: &nf [-KCFARLEDQ num] [-Z file] [-akpqfvwh]\n" );
4475144760
Abc_Print( -2, "\t performs technology mapping of the network\n" );
4475244761
Abc_Print( -2, "\t-K num : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", pPars->nLutSizeMax, pPars->nLutSize );
4475344762
Abc_Print( -2, "\t-C num : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", pPars->nCutNumMax, pPars->nCutNum );
@@ -44758,6 +44767,7 @@ int Abc_CommandAbc9Nf( Abc_Frame_t * pAbc, int argc, char ** argv )
4475844767
Abc_Print( -2, "\t-E num : the area/edge tradeoff parameter (0 <= num <= 100) [default = %d]\n", pPars->nAreaTuner );
4475944768
Abc_Print( -2, "\t-D num : sets the delay constraint for the mapping [default = %s]\n", Buffer );
4476044769
Abc_Print( -2, "\t-Q num : internal parameter impacting area of the mapping [default = %d]\n", pPars->nReqTimeFlex );
44770+
Abc_Print( -2, "\t-Z file : the output file name to dump internal match info [default = unused]\n" );
4476144771
Abc_Print( -2, "\t-a : toggles SAT-based area-oriented mapping (experimental) [default = %s]\n", pPars->fAreaOnly? "yes": "no" );
4476244772
Abc_Print( -2, "\t-k : toggles coarsening the subject graph [default = %s]\n", pPars->fCoarsen? "yes": "no" );
4476344773
Abc_Print( -2, "\t-p : toggles pin permutation (more matches - better quality) [default = %s]\n", pPars->fPinPerm? "yes": "no" );

0 commit comments

Comments
 (0)