abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ioWriteBlif.c File Reference
#include "ioAbc.h"
#include "base/main/main.h"
#include "map/mio/mio.h"
#include "bool/kit/kit.h"
#include "map/if/if.h"

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START void 
Io_NtkWrite (FILE *pFile, Abc_Ntk_t *pNtk, int fWriteLatches, int fBb2Wb, int fSeq)
 DECLARATIONS ///. More...
 
static void Io_NtkWriteOne (FILE *pFile, Abc_Ntk_t *pNtk, int fWriteLatches, int fBb2Wb, int fSeq)
 
static void Io_NtkWritePis (FILE *pFile, Abc_Ntk_t *pNtk, int fWriteLatches)
 
static void Io_NtkWritePos (FILE *pFile, Abc_Ntk_t *pNtk, int fWriteLatches)
 
static void Io_NtkWriteSubckt (FILE *pFile, Abc_Obj_t *pNode)
 
static void Io_NtkWriteAsserts (FILE *pFile, Abc_Ntk_t *pNtk)
 
static void Io_NtkWriteNodeFanins (FILE *pFile, Abc_Obj_t *pNode)
 
static int Io_NtkWriteNode (FILE *pFile, Abc_Obj_t *pNode, int Length)
 
static void Io_NtkWriteLatch (FILE *pFile, Abc_Obj_t *pLatch)
 
void Io_WriteBlifLogic (Abc_Ntk_t *pNtk, char *FileName, int fWriteLatches)
 FUNCTION DEFINITIONS ///. More...
 
void Io_WriteBlif (Abc_Ntk_t *pNtk, char *FileName, int fWriteLatches, int fBb2Wb, int fSeq)
 
void Io_NtkWriteConvertedBox (FILE *pFile, Abc_Ntk_t *pNtk, int fSeq)
 
void Io_NtkWriteSubcktFanins (FILE *pFile, Abc_Obj_t *pNode)
 
int Io_NtkWriteNodeGate (FILE *pFile, Abc_Obj_t *pNode, int Length)
 
int Io_NtkWriteNodeSubckt (FILE *pFile, Abc_Obj_t *pNode, int Length)
 
void Io_WriteTimingInfo (FILE *pFile, Abc_Ntk_t *pNtk)
 
void Abc_NtkConvertBb2Wb (char *pFileNameIn, char *pFileNameOut, int fSeq, int fVerbose)
 
char * Io_NtkDeriveSop (Mem_Flex_t *pMem, word uTruth, int nVars, Vec_Int_t *vCover)
 
void Io_NtkWriteNodeInt (FILE *pFile, Abc_Obj_t *pNode, Vec_Int_t *vCover)
 
void Io_NtkWriteNodeIntStruct (FILE *pFile, Abc_Obj_t *pNode, Vec_Int_t *vCover, char *pStr)
 
void Io_NtkWriteModelIntStruct (FILE *pFile, Abc_Obj_t *pNode, Vec_Int_t *vCover, char *pStr)
 
void Io_WriteBlifInt (Abc_Ntk_t *pNtk, char *FileName, char *pLutStruct, int fUseHie)
 
void Io_WriteBlifSpecial (Abc_Ntk_t *pNtk, char *FileName, char *pLutStruct, int fUseHie)
 

Function Documentation

void Abc_NtkConvertBb2Wb ( char *  pFileNameIn,
char *  pFileNameOut,
int  fSeq,
int  fVerbose 
)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 742 of file ioWriteBlif.c.

743 {
744  FILE * pFile;
745  Abc_Ntk_t * pNetlist;
746  // check the files
747  pFile = fopen( pFileNameIn, "rb" );
748  if ( pFile == NULL )
749  {
750  printf( "Input file \"%s\" cannot be opened.\n", pFileNameIn );
751  return;
752  }
753  fclose( pFile );
754  // check the files
755  pFile = fopen( pFileNameOut, "wb" );
756  if ( pFile == NULL )
757  {
758  printf( "Output file \"%s\" cannot be opened.\n", pFileNameOut );
759  return;
760  }
761  fclose( pFile );
762  // derive AIG for signal correspondence
763  pNetlist = Io_ReadNetlist( pFileNameIn, Io_ReadFileType(pFileNameIn), 1 );
764  if ( pNetlist == NULL )
765  {
766  printf( "Reading input file \"%s\" has failed.\n", pFileNameIn );
767  return;
768  }
769  Io_WriteBlif( pNetlist, pFileNameOut, 1, 1, fSeq );
770  Abc_NtkDelete( pNetlist );
771 }
void Io_WriteBlif(Abc_Ntk_t *pNtk, char *FileName, int fWriteLatches, int fBb2Wb, int fSeq)
Definition: ioWriteBlif.c:84
Abc_Ntk_t * Io_ReadNetlist(char *pFileName, Io_FileType_t FileType, int fCheck)
Definition: ioUtil.c:98
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
Io_FileType_t Io_ReadFileType(char *pFileName)
DECLARATIONS ///.
Definition: ioUtil.c:46
char* Io_NtkDeriveSop ( Mem_Flex_t pMem,
word  uTruth,
int  nVars,
Vec_Int_t vCover 
)

Function*************************************************************

Synopsis [Transforms truth table into an SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 789 of file ioWriteBlif.c.

790 {
791  char * pSop;
792  int RetValue = Kit_TruthIsop( (unsigned *)&uTruth, nVars, vCover, 1 );
793  assert( RetValue == 0 || RetValue == 1 );
794  // check the case of constant cover
795  if ( Vec_IntSize(vCover) == 0 || (Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover,0) == 0) )
796  {
797  char * pStr0 = " 0\n", * pStr1 = " 1\n";
798  assert( RetValue == 0 );
799  return Vec_IntSize(vCover) == 0 ? pStr0 : pStr1;
800  }
801  // derive the AIG for that tree
802  pSop = Abc_SopCreateFromIsop( pMem, nVars, vCover );
803  if ( RetValue )
804  Abc_SopComplement( pSop );
805  return pSop;
806 }
ABC_DLL char * Abc_SopCreateFromIsop(Mem_Flex_t *pMan, int nVars, Vec_Int_t *vCover)
Definition: abcSop.c:416
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
FUNCTION DEFINITIONS ///.
Definition: kitIsop.c:55
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
ABC_DLL void Abc_SopComplement(char *pSop)
Definition: abcSop.c:600
#define assert(ex)
Definition: util_old.h:213
void Io_NtkWrite ( FILE *  pFile,
Abc_Ntk_t pNtk,
int  fWriteLatches,
int  fBb2Wb,
int  fSeq 
)
static

DECLARATIONS ///.

CFile****************************************************************

FileName [ioWriteBlif.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures to write BLIF files.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
ioWriteBlif.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Function*************************************************************

Synopsis [Write the network into a BLIF file with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 127 of file ioWriteBlif.c.

128 {
129  Abc_Ntk_t * pExdc;
130  assert( Abc_NtkIsNetlist(pNtk) );
131  // write the model name
132  fprintf( pFile, ".model %s\n", Abc_NtkName(pNtk) );
133  // write the network
134  Io_NtkWriteOne( pFile, pNtk, fWriteLatches, fBb2Wb, fSeq );
135  // write EXDC network if it exists
136  pExdc = Abc_NtkExdc( pNtk );
137  if ( pExdc )
138  {
139  fprintf( pFile, "\n" );
140  fprintf( pFile, ".exdc\n" );
141  Io_NtkWriteOne( pFile, pExdc, fWriteLatches, fBb2Wb, fSeq );
142  }
143  // finalize the file
144  fprintf( pFile, ".end\n" );
145 }
static Abc_Ntk_t * Abc_NtkExdc(Abc_Ntk_t *pNtk)
Definition: abc.h:272
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
static void Io_NtkWriteOne(FILE *pFile, Abc_Ntk_t *pNtk, int fWriteLatches, int fBb2Wb, int fSeq)
Definition: ioWriteBlif.c:199
static char * Abc_NtkName(Abc_Ntk_t *pNtk)
Definition: abc.h:270
#define assert(ex)
Definition: util_old.h:213
static void Io_NtkWriteAsserts ( FILE *  pFile,
Abc_Ntk_t pNtk 
)
static
void Io_NtkWriteConvertedBox ( FILE *  pFile,
Abc_Ntk_t pNtk,
int  fSeq 
)

Function*************************************************************

Synopsis [Write one network.]

Description []

SideEffects []

SeeAlso []

Definition at line 158 of file ioWriteBlif.c.

159 {
160  Abc_Obj_t * pObj;
161  int i, v;
162  if ( fSeq )
163  {
164  fprintf( pFile, ".attrib white box seq\n" );
165  }
166  else
167  {
168  fprintf( pFile, ".attrib white box comb\n" );
169  fprintf( pFile, ".delay 1\n" );
170  }
171  Abc_NtkForEachPo( pNtk, pObj, i )
172  {
173  // write the .names line
174  fprintf( pFile, ".names" );
175  Io_NtkWritePis( pFile, pNtk, 1 );
176  if ( fSeq )
177  fprintf( pFile, " %s_in\n", Abc_ObjName(Abc_ObjFanin0(pObj)) );
178  else
179  fprintf( pFile, " %s\n", Abc_ObjName(Abc_ObjFanin0(pObj)) );
180  for ( v = 0; v < Abc_NtkPiNum(pNtk); v++ )
181  fprintf( pFile, "1" );
182  fprintf( pFile, " 1\n" );
183  if ( fSeq )
184  fprintf( pFile, ".latch %s_in %s 1\n", Abc_ObjName(Abc_ObjFanin0(pObj)), Abc_ObjName(Abc_ObjFanin0(pObj)) );
185  }
186 }
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static void Io_NtkWritePis(FILE *pFile, Abc_Ntk_t *pNtk, int fWriteLatches)
Definition: ioWriteBlif.c:274
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
void Io_NtkWriteLatch ( FILE *  pFile,
Abc_Obj_t pLatch 
)
static

Function*************************************************************

Synopsis [Write the latch into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 433 of file ioWriteBlif.c.

434 {
435  Abc_Obj_t * pNetLi, * pNetLo;
436  int Reset;
437  pNetLi = Abc_ObjFanin0( Abc_ObjFanin0(pLatch) );
438  pNetLo = Abc_ObjFanout0( Abc_ObjFanout0(pLatch) );
439  Reset = (int)(ABC_PTRUINT_T)Abc_ObjData( pLatch );
440  // write the latch line
441  fprintf( pFile, ".latch" );
442  fprintf( pFile, " %10s", Abc_ObjName(pNetLi) );
443  fprintf( pFile, " %10s", Abc_ObjName(pNetLo) );
444  fprintf( pFile, " %d\n", Reset-1 );
445 }
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
static void * Abc_ObjData(Abc_Obj_t *pObj)
Definition: abc.h:336
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
void Io_NtkWriteModelIntStruct ( FILE *  pFile,
Abc_Obj_t pNode,
Vec_Int_t vCover,
char *  pStr 
)

Function*************************************************************

Synopsis [Write the node into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 1129 of file ioWriteBlif.c.

1130 {
1131  Abc_Obj_t * pNet;
1132  int nLeaves = Abc_ObjFaninNum(pNode);
1133  int i, nLutLeaf, nLutLeaf2, nLutRoot, Length;
1134 
1135  // write the header
1136  fprintf( pFile, "\n" );
1137  fprintf( pFile, ".model m%d\n", Abc_ObjId(pNode) );
1138  fprintf( pFile, ".inputs" );
1139  for ( i = 0; i < Abc_ObjFaninNum(pNode); i++ )
1140  fprintf( pFile, " %c", 'a' + i );
1141  fprintf( pFile, "\n" );
1142  fprintf( pFile, ".outputs o\n" );
1143 
1144  // quit if parameters are wrong
1145  Length = strlen(pStr);
1146  if ( Length != 2 && Length != 3 )
1147  {
1148  printf( "Wrong LUT struct (%s)\n", pStr );
1149  return;
1150  }
1151  for ( i = 0; i < Length; i++ )
1152  if ( pStr[i] - '0' < 3 || pStr[i] - '0' > 6 )
1153  {
1154  printf( "The LUT size (%d) should belong to {3,4,5,6}.\n", pStr[i] - '0' );
1155  return;
1156  }
1157 
1158  nLutLeaf = pStr[0] - '0';
1159  nLutLeaf2 = ( Length == 3 ) ? pStr[1] - '0' : 0;
1160  nLutRoot = pStr[Length-1] - '0';
1161  if ( nLeaves > nLutLeaf - 1 + (nLutLeaf2 ? nLutLeaf2 - 1 : 0) + nLutRoot )
1162  {
1163  printf( "The node size (%d) is too large for the LUT structure %s.\n", nLeaves, pStr );
1164  return;
1165  }
1166 
1167  // consider easy case
1168  if ( nLeaves <= Abc_MaxInt( nLutLeaf2, Abc_MaxInt(nLutLeaf, nLutRoot) ) )
1169  {
1170  // write the .names line
1171  fprintf( pFile, ".names" );
1172  Abc_ObjForEachFanin( pNode, pNet, i )
1173  fprintf( pFile, " %c", 'a' + i );
1174  // get the output name
1175  fprintf( pFile, " %s\n", "o" );
1176  // write the cubes
1177  fprintf( pFile, "%s", (char*)Abc_ObjData(pNode) );
1178  fprintf( pFile, ".end\n" );
1179  return;
1180  }
1181  else
1182  {
1183  extern int If_CluMinimumBase( word * t, int * pSupp, int nVarsAll, int * pnVars );
1184 
1185  static word TruthStore[16][1<<10] = {{0}}, * pTruths[16];
1186  word pCube[1<<10], pRes[1<<10], Func0, Func1, Func2;
1187  char pLut0[32], pLut1[32], pLut2[32] = {0}, * pSop;
1188 // int nVarsMin[3], pVars[3][20];
1189 
1190  if ( TruthStore[0][0] == 0 )
1191  {
1192  static word Truth6[6] = {
1193  ABC_CONST(0xAAAAAAAAAAAAAAAA),
1194  ABC_CONST(0xCCCCCCCCCCCCCCCC),
1195  ABC_CONST(0xF0F0F0F0F0F0F0F0),
1196  ABC_CONST(0xFF00FF00FF00FF00),
1197  ABC_CONST(0xFFFF0000FFFF0000),
1198  ABC_CONST(0xFFFFFFFF00000000)
1199  };
1200  int nVarsMax = 16;
1201  int nWordsMax = (1 << 10);
1202  int i, k;
1203  assert( nVarsMax <= 16 );
1204  for ( i = 0; i < nVarsMax; i++ )
1205  pTruths[i] = TruthStore[i];
1206  for ( i = 0; i < 6; i++ )
1207  for ( k = 0; k < nWordsMax; k++ )
1208  pTruths[i][k] = Truth6[i];
1209  for ( i = 6; i < nVarsMax; i++ )
1210  for ( k = 0; k < nWordsMax; k++ )
1211  pTruths[i][k] = ((k >> (i-6)) & 1) ? ~(word)0 : 0;
1212  }
1213 
1214  // collect variables
1215 // Abc_ObjForEachFanin( pNode, pNet, i )
1216 // pVars[0][i] = pVars[1][i] = pVars[2][i] = i;
1217 
1218  // derive truth table
1219  Abc_SopToTruthBig( (char*)Abc_ObjData(pNode), nLeaves, pTruths, pCube, pRes );
1220  if ( Kit_TruthIsConst0((unsigned *)pRes, nLeaves) || Kit_TruthIsConst1((unsigned *)pRes, nLeaves) )
1221  {
1222  fprintf( pFile, ".names %s\n %d\n", "o", Kit_TruthIsConst1((unsigned *)pRes, nLeaves) );
1223  fprintf( pFile, ".end\n" );
1224  return;
1225  }
1226 
1227 // Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
1228 // Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
1229 
1230  // perform decomposition
1231  if ( Length == 2 )
1232  {
1233  if ( !If_CluCheckExt( NULL, pRes, nLeaves, nLutLeaf, nLutRoot, pLut0, pLut1, &Func0, &Func1 ) )
1234  {
1235  Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
1236  Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
1237  printf( "Node \"%s\" is not decomposable. Writing BLIF has failed.\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1238  return;
1239  }
1240  }
1241  else
1242  {
1243  if ( !If_CluCheckExt3( NULL, pRes, nLeaves, nLutLeaf, nLutLeaf2, nLutRoot, pLut0, pLut1, pLut2, &Func0, &Func1, &Func2 ) )
1244  {
1245  Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
1246  Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
1247  printf( "Node \"%s\" is not decomposable. Writing BLIF has failed.\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1248  return;
1249  }
1250  }
1251 
1252  // write leaf node
1253  fprintf( pFile, ".names" );
1254  for ( i = 0; i < pLut1[0]; i++ )
1255  fprintf( pFile, " %c", 'a' + pLut1[2+i] );
1256  fprintf( pFile, " lut1\n" );
1257  // write SOP
1258  pSop = Io_NtkDeriveSop( (Mem_Flex_t *)Abc_ObjNtk(pNode)->pManFunc, Func1, pLut1[0], vCover );
1259  fprintf( pFile, "%s", pSop );
1260 
1261  if ( Length == 3 && pLut2[0] > 0 )
1262  {
1263  // write leaf node
1264  fprintf( pFile, ".names" );
1265  for ( i = 0; i < pLut2[0]; i++ )
1266  if ( pLut2[2+i] == nLeaves )
1267  fprintf( pFile, " lut1" );
1268  else
1269  fprintf( pFile, " %c", 'a' + pLut2[2+i] );
1270  fprintf( pFile, " lut2\n" );
1271  // write SOP
1272  pSop = Io_NtkDeriveSop( (Mem_Flex_t *)Abc_ObjNtk(pNode)->pManFunc, Func2, pLut2[0], vCover );
1273  fprintf( pFile, "%s", pSop );
1274  }
1275 
1276  // write root node
1277  fprintf( pFile, ".names" );
1278  for ( i = 0; i < pLut0[0]; i++ )
1279  if ( pLut0[2+i] == nLeaves )
1280  fprintf( pFile, " lut1" );
1281  else if ( pLut0[2+i] == nLeaves+1 )
1282  fprintf( pFile, " lut2" );
1283  else
1284  fprintf( pFile, " %c", 'a' + pLut0[2+i] );
1285  fprintf( pFile, " %s\n", "o" );
1286  // write SOP
1287  pSop = Io_NtkDeriveSop( (Mem_Flex_t *)Abc_ObjNtk(pNode)->pManFunc, Func0, pLut0[0], vCover );
1288  fprintf( pFile, "%s", pSop );
1289  fprintf( pFile, ".end\n" );
1290  }
1291 }
static ABC_NAMESPACE_IMPL_START int pTruths[13719]
DECLARATIONS ///.
Definition: rwrTemp.c:30
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
int If_CluCheckExt(void *p, word *pTruth, int nVars, int nLutLeaf, int nLutRoot, char *pLut0, char *pLut1, word *pFunc0, word *pFunc1)
Definition: ifDec16.c:2066
int If_CluCheckExt3(void *p, word *pTruth, int nVars, int nLutLeaf, int nLutLeaf2, int nLutRoot, char *pLut0, char *pLut1, char *pLut2, word *pFunc0, word *pFunc1, word *pFunc2)
Definition: ifDec16.c:2079
ABC_DLL void Abc_SopToTruthBig(char *pSop, int nInputs, word **pVars, word *pCube, word *pRes)
Definition: abcSop.c:1274
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Kit_TruthIsConst0(unsigned *pIn, int nVars)
Definition: kit.h:315
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition: kitDsd.c:490
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
void Extra_PrintHex(FILE *pFile, unsigned *pTruth, int nVars)
static int Kit_TruthIsConst1(unsigned *pIn, int nVars)
Definition: kit.h:323
int If_CluMinimumBase(word *t, int *pSupp, int nVarsAll, int *pnVars)
Definition: ifDec16.c:1532
static word Truth6[6]
Definition: ifDec07.c:52
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
else
Definition: sparse_int.h:55
char * Io_NtkDeriveSop(Mem_Flex_t *pMem, word uTruth, int nVars, Vec_Int_t *vCover)
Definition: ioWriteBlif.c:789
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
#define assert(ex)
Definition: util_old.h:213
static void * Abc_ObjData(Abc_Obj_t *pObj)
Definition: abc.h:336
int strlen()
static Abc_Ntk_t * Abc_ObjNtk(Abc_Obj_t *pObj)
Definition: abc.h:334
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
int Io_NtkWriteNode ( FILE *  pFile,
Abc_Obj_t pNode,
int  Length 
)
static

Function*************************************************************

Synopsis [Write the node into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 612 of file ioWriteBlif.c.

613 {
614  int RetValue = 0;
615  if ( Abc_NtkHasMapping(pNode->pNtk) )
616  {
617  // write the .gate line
618  fprintf( pFile, ".gate" );
619  RetValue = Io_NtkWriteNodeGate( pFile, pNode, Length );
620  fprintf( pFile, "\n" );
621  }
622  else
623  {
624  // write the .names line
625  fprintf( pFile, ".names" );
626  Io_NtkWriteNodeFanins( pFile, pNode );
627  fprintf( pFile, "\n" );
628  // write the cubes
629  fprintf( pFile, "%s", (char*)Abc_ObjData(pNode) );
630  }
631  return RetValue;
632 }
static void Io_NtkWriteNodeFanins(FILE *pFile, Abc_Obj_t *pNode)
Definition: ioWriteBlif.c:459
static int Abc_NtkHasMapping(Abc_Ntk_t *pNtk)
Definition: abc.h:256
Abc_Ntk_t * pNtk
Definition: abc.h:130
static void * Abc_ObjData(Abc_Obj_t *pObj)
Definition: abc.h:336
int Io_NtkWriteNodeGate(FILE *pFile, Abc_Obj_t *pNode, int Length)
Definition: ioWriteBlif.c:576
void Io_NtkWriteNodeFanins ( FILE *  pFile,
Abc_Obj_t pNode 
)
static

Function*************************************************************

Synopsis [Writes the primary input list.]

Description []

SideEffects []

SeeAlso []

Definition at line 459 of file ioWriteBlif.c.

460 {
461  Abc_Obj_t * pNet;
462  int LineLength;
463  int AddedLength;
464  int NameCounter;
465  char * pName;
466  int i;
467 
468  LineLength = 6;
469  NameCounter = 0;
470  Abc_ObjForEachFanin( pNode, pNet, i )
471  {
472  // get the fanin name
473  pName = Abc_ObjName(pNet);
474  // get the line length after the fanin name is written
475  AddedLength = strlen(pName) + 1;
476  if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
477  { // write the line extender
478  fprintf( pFile, " \\\n" );
479  // reset the line length
480  LineLength = 0;
481  NameCounter = 0;
482  }
483  fprintf( pFile, " %s", pName );
484  LineLength += AddedLength;
485  NameCounter++;
486  }
487 
488  // get the output name
489  pName = Abc_ObjName(Abc_ObjFanout0(pNode));
490  // get the line length after the output name is written
491  AddedLength = strlen(pName) + 1;
492  if ( NameCounter && LineLength + AddedLength > 75 )
493  { // write the line extender
494  fprintf( pFile, " \\\n" );
495  // reset the line length
496  LineLength = 0;
497  NameCounter = 0;
498  }
499  fprintf( pFile, " %s", pName );
500 }
#define IO_WRITE_LINE_LENGTH
MACRO DEFINITIONS ///.
Definition: ioAbc.h:71
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
int strlen()
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
int Io_NtkWriteNodeGate ( FILE *  pFile,
Abc_Obj_t pNode,
int  Length 
)

Function*************************************************************

Synopsis [Writes the primary input list.]

Description []

SideEffects []

SeeAlso []

Definition at line 576 of file ioWriteBlif.c.

577 {
578  static int fReport = 0;
579  Mio_Gate_t * pGate = (Mio_Gate_t *)pNode->pData;
580  Mio_Pin_t * pGatePin;
581  Abc_Obj_t * pNode2;
582  int i;
583  fprintf( pFile, " %-*s ", Length, Mio_GateReadName(pGate) );
584  for ( pGatePin = Mio_GateReadPins(pGate), i = 0; pGatePin; pGatePin = Mio_PinReadNext(pGatePin), i++ )
585  fprintf( pFile, "%s=%s ", Mio_PinReadName(pGatePin), Abc_ObjName( Abc_ObjFanin(pNode,i) ) );
586  assert ( i == Abc_ObjFaninNum(pNode) );
587  fprintf( pFile, "%s=%s", Mio_GateReadOutName(pGate), Abc_ObjName( Abc_ObjFanout0(pNode) ) );
588  if ( Mio_GateReadTwin(pGate) == NULL )
589  return 0;
590  pNode2 = Abc_NtkFetchTwinNode( pNode );
591  if ( pNode2 == NULL )
592  {
593  if ( !fReport )
594  fReport = 1, printf( "Warning: Missing second output of gate(s) \"%s\".\n", Mio_GateReadName(pGate) );
595  return 0;
596  }
597  fprintf( pFile, " %s=%s", Mio_GateReadOutName((Mio_Gate_t *)pNode2->pData), Abc_ObjName( Abc_ObjFanout0(pNode2) ) );
598  return 1;
599 }
Mio_Pin_t * Mio_GateReadPins(Mio_Gate_t *pGate)
Definition: mioApi.c:147
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
char * Mio_GateReadOutName(Mio_Gate_t *pGate)
Definition: mioApi.c:144
char * Mio_PinReadName(Mio_Pin_t *pPin)
Definition: mioApi.c:170
Mio_Pin_t * Mio_PinReadNext(Mio_Pin_t *pPin)
Definition: mioApi.c:179
Mio_Gate_t * Mio_GateReadTwin(Mio_Gate_t *pGate)
Definition: mioApi.c:150
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
ABC_DLL Abc_Obj_t * Abc_NtkFetchTwinNode(Abc_Obj_t *pNode)
Definition: abcMap.c:740
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
static Abc_Obj_t * Abc_ObjFanin(Abc_Obj_t *pObj, int i)
Definition: abc.h:372
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition: mioApi.c:143
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
void Io_NtkWriteNodeInt ( FILE *  pFile,
Abc_Obj_t pNode,
Vec_Int_t vCover 
)

Function*************************************************************

Synopsis [Write the node into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 819 of file ioWriteBlif.c.

820 {
821  Abc_Obj_t * pNet;
822  int i, nVars = Abc_ObjFaninNum(pNode);
823  if ( nVars > 7 )
824  {
825  printf( "Node \"%s\" has more than 7 inputs. Writing BLIF has failed.\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
826  return;
827  }
828 
829  fprintf( pFile, "\n" );
830  if ( nVars <= 4 )
831  {
832  // write the .names line
833  fprintf( pFile, ".names" );
834  Abc_ObjForEachFanin( pNode, pNet, i )
835  fprintf( pFile, " %s", Abc_ObjName(pNet) );
836  // get the output name
837  fprintf( pFile, " %s\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
838  // write the cubes
839  fprintf( pFile, "%s", (char*)Abc_ObjData(pNode) );
840  }
841  else
842  {
843  extern int If_Dec6PickBestMux( word t, word Cofs[2] );
844  extern int If_Dec7PickBestMux( word t[2], word c0r[2], word c1r[2] );
845  extern word If_Dec6MinimumBase( word uTruth, int * pSupp, int nVarsAll, int * pnVars );
846  extern void If_Dec7MinimumBase( word uTruth[2], int * pSupp, int nVarsAll, int * pnVars );
847  extern word If_Dec6Perform( word t, int fDerive );
848  extern word If_Dec7Perform( word t[2], int fDerive );
849 
850  char * pSop;
851  word z, uTruth6 = 0, uTruth7[2], Cofs6[2], Cofs7[2][2];
852  int c, iVar, nVarsMin[2], pVars[2][10];
853 
854  // collect variables
855  Abc_ObjForEachFanin( pNode, pNet, i )
856  pVars[0][i] = pVars[1][i] = i;
857 
858  // derive truth table
859  if ( nVars == 7 )
860  {
861  Abc_SopToTruth7( (char*)Abc_ObjData(pNode), nVars, uTruth7 );
862  iVar = If_Dec7PickBestMux( uTruth7, Cofs7[0], Cofs7[1] );
863  }
864  else
865  {
866  uTruth6 = Abc_SopToTruth( (char*)Abc_ObjData(pNode), nVars );
867  iVar = If_Dec6PickBestMux( uTruth6, Cofs6 );
868  }
869 
870  // perform MUX decomposition
871  if ( iVar >= 0 )
872  {
873  if ( nVars == 7 )
874  {
875  If_Dec7MinimumBase( Cofs7[0], pVars[0], nVars, &nVarsMin[0] );
876  If_Dec7MinimumBase( Cofs7[1], pVars[1], nVars, &nVarsMin[1] );
877  }
878  else
879  {
880  Cofs6[0] = If_Dec6MinimumBase( Cofs6[0], pVars[0], nVars, &nVarsMin[0] );
881  Cofs6[1] = If_Dec6MinimumBase( Cofs6[1], pVars[1], nVars, &nVarsMin[1] );
882  }
883  assert( nVarsMin[0] < 5 );
884  assert( nVarsMin[1] < 5 );
885  // write MUX
886  fprintf( pFile, ".names" );
887  fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanin(pNode,iVar)) );
888  fprintf( pFile, " %s_cascade0", Abc_ObjName(Abc_ObjFanout0(pNode)) );
889  fprintf( pFile, " %s_cascade1", Abc_ObjName(Abc_ObjFanout0(pNode)) );
890  fprintf( pFile, " %s\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
891  fprintf( pFile, "1-1 1\n01- 1\n" );
892  // write cofactors
893  for ( c = 0; c < 2; c++ )
894  {
895  pSop = Io_NtkDeriveSop( (Mem_Flex_t *)Abc_ObjNtk(pNode)->pManFunc,
896  (word)(nVars == 7 ? Cofs7[c][0] : Cofs6[c]), nVarsMin[c], vCover );
897  fprintf( pFile, ".names" );
898  for ( i = 0; i < nVarsMin[c]; i++ )
899  fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanin(pNode,pVars[c][i])) );
900  fprintf( pFile, " %s_cascade%d\n", Abc_ObjName(Abc_ObjFanout0(pNode)), c );
901  fprintf( pFile, "%s", pSop );
902  }
903  return;
904  }
905  assert( nVars == 6 || nVars == 7 );
906 
907  // try cascade decomposition
908  if ( nVars == 7 )
909  {
910  z = If_Dec7Perform( uTruth7, 1 );
911  //If_Dec7Verify( uTruth7, z );
912  }
913  else
914  {
915  z = If_Dec6Perform( uTruth6, 1 );
916  //If_Dec6Verify( uTruth6, z );
917  }
918  if ( z == 0 )
919  {
920  printf( "Node \"%s\" is not decomposable. Writing BLIF has failed.\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
921  return;
922  }
923 
924  // derive nodes
925  for ( c = 1; c >= 0; c-- )
926  {
927  // collect fanins
928  uTruth7[c] = ((c ? z >> 32 : z) & 0xffff);
929  uTruth7[c] |= (uTruth7[c] << 16);
930  uTruth7[c] |= (uTruth7[c] << 32);
931  for ( i = 0; i < 4; i++ )
932  pVars[c][i] = (z >> (c*32+16+4*i)) & 7;
933 
934  // minimize truth table
935  Cofs6[c] = If_Dec6MinimumBase( uTruth7[c], pVars[c], 4, &nVarsMin[c] );
936 
937  // write the nodes
938  fprintf( pFile, ".names" );
939  for ( i = 0; i < nVarsMin[c]; i++ )
940  if ( pVars[c][i] == 7 )
941  fprintf( pFile, " %s_cascade", Abc_ObjName(Abc_ObjFanout0(pNode)) );
942  else
943  fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanin(pNode,pVars[c][i])) );
944  fprintf( pFile, " %s%s\n", Abc_ObjName(Abc_ObjFanout0(pNode)), c? "" : "_cascade" );
945 
946  // write SOP
947  pSop = Io_NtkDeriveSop( (Mem_Flex_t *)Abc_ObjNtk(pNode)->pManFunc,
948  (word)Cofs6[c], nVarsMin[c], vCover );
949  fprintf( pFile, "%s", pSop );
950  }
951  }
952 }
word If_Dec7Perform(word t0[2], int fDerive)
Definition: ifDec07.c:460
int If_Dec6PickBestMux(word t, word Cofs[2])
Definition: ifDec07.c:637
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
word If_Dec6MinimumBase(word uTruth, int *pSupp, int nVarsAll, int *pnVars)
Definition: ifDec07.c:512
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
char * Io_NtkDeriveSop(Mem_Flex_t *pMem, word uTruth, int nVars, Vec_Int_t *vCover)
Definition: ioWriteBlif.c:789
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
int If_Dec7PickBestMux(word t[2], word c0r[2], word c1r[2])
Definition: ifDec07.c:654
ABC_DLL word Abc_SopToTruth(char *pSop, int nInputs)
Definition: abcSop.c:1163
ABC_DLL void Abc_SopToTruth7(char *pSop, int nInputs, word r[2])
Definition: abcSop.c:1214
word If_Dec6Perform(word t, int fDerive)
Definition: ifDec07.c:420
#define assert(ex)
Definition: util_old.h:213
static void * Abc_ObjData(Abc_Obj_t *pObj)
Definition: abc.h:336
static Abc_Ntk_t * Abc_ObjNtk(Abc_Obj_t *pObj)
Definition: abc.h:334
static Abc_Obj_t * Abc_ObjFanin(Abc_Obj_t *pObj, int i)
Definition: abc.h:372
void If_Dec7MinimumBase(word uTruth[2], int *pSupp, int nVarsAll, int *pnVars)
Definition: ifDec07.c:544
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
void Io_NtkWriteNodeIntStruct ( FILE *  pFile,
Abc_Obj_t pNode,
Vec_Int_t vCover,
char *  pStr 
)

Function*************************************************************

Synopsis [Write the node into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 965 of file ioWriteBlif.c.

966 {
967  Abc_Obj_t * pNet;
968  int nLeaves = Abc_ObjFaninNum(pNode);
969  int i, nLutLeaf, nLutLeaf2, nLutRoot, Length;
970 
971  // quit if parameters are wrong
972  Length = strlen(pStr);
973  if ( Length != 2 && Length != 3 )
974  {
975  printf( "Wrong LUT struct (%s)\n", pStr );
976  return;
977  }
978  for ( i = 0; i < Length; i++ )
979  if ( pStr[i] - '0' < 3 || pStr[i] - '0' > 6 )
980  {
981  printf( "The LUT size (%d) should belong to {3,4,5,6}.\n", pStr[i] - '0' );
982  return;
983  }
984 
985  nLutLeaf = pStr[0] - '0';
986  nLutLeaf2 = ( Length == 3 ) ? pStr[1] - '0' : 0;
987  nLutRoot = pStr[Length-1] - '0';
988  if ( nLeaves > nLutLeaf - 1 + (nLutLeaf2 ? nLutLeaf2 - 1 : 0) + nLutRoot )
989  {
990  printf( "The node size (%d) is too large for the LUT structure %s.\n", nLeaves, pStr );
991  return;
992  }
993 
994  // consider easy case
995  fprintf( pFile, "\n" );
996  if ( nLeaves <= Abc_MaxInt( nLutLeaf2, Abc_MaxInt(nLutLeaf, nLutRoot) ) )
997  {
998  // write the .names line
999  fprintf( pFile, ".names" );
1000  Abc_ObjForEachFanin( pNode, pNet, i )
1001  fprintf( pFile, " %s", Abc_ObjName(pNet) );
1002  // get the output name
1003  fprintf( pFile, " %s\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1004  // write the cubes
1005  fprintf( pFile, "%s", (char*)Abc_ObjData(pNode) );
1006  return;
1007  }
1008  else
1009  {
1010  extern int If_CluMinimumBase( word * t, int * pSupp, int nVarsAll, int * pnVars );
1011 
1012  static word TruthStore[16][1<<10] = {{0}}, * pTruths[16];
1013  word pCube[1<<10], pRes[1<<10], Func0, Func1, Func2;
1014  char pLut0[32], pLut1[32], pLut2[32] = {0}, * pSop;
1015 // int nVarsMin[3], pVars[3][20];
1016 
1017  if ( TruthStore[0][0] == 0 )
1018  {
1019  static word Truth6[6] = {
1020  ABC_CONST(0xAAAAAAAAAAAAAAAA),
1021  ABC_CONST(0xCCCCCCCCCCCCCCCC),
1022  ABC_CONST(0xF0F0F0F0F0F0F0F0),
1023  ABC_CONST(0xFF00FF00FF00FF00),
1024  ABC_CONST(0xFFFF0000FFFF0000),
1025  ABC_CONST(0xFFFFFFFF00000000)
1026  };
1027  int nVarsMax = 16;
1028  int nWordsMax = (1 << 10);
1029  int i, k;
1030  assert( nVarsMax <= 16 );
1031  for ( i = 0; i < nVarsMax; i++ )
1032  pTruths[i] = TruthStore[i];
1033  for ( i = 0; i < 6; i++ )
1034  for ( k = 0; k < nWordsMax; k++ )
1035  pTruths[i][k] = Truth6[i];
1036  for ( i = 6; i < nVarsMax; i++ )
1037  for ( k = 0; k < nWordsMax; k++ )
1038  pTruths[i][k] = ((k >> (i-6)) & 1) ? ~(word)0 : 0;
1039  }
1040 
1041  // collect variables
1042 // Abc_ObjForEachFanin( pNode, pNet, i )
1043 // pVars[0][i] = pVars[1][i] = pVars[2][i] = i;
1044 
1045  // derive truth table
1046  Abc_SopToTruthBig( (char*)Abc_ObjData(pNode), nLeaves, pTruths, pCube, pRes );
1047  if ( Kit_TruthIsConst0((unsigned *)pRes, nLeaves) || Kit_TruthIsConst1((unsigned *)pRes, nLeaves) )
1048  {
1049  fprintf( pFile, ".names %s\n %d\n", Abc_ObjName(Abc_ObjFanout0(pNode)), Kit_TruthIsConst1((unsigned *)pRes, nLeaves) );
1050  return;
1051  }
1052 
1053 // Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
1054 // Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
1055 
1056  // perform decomposition
1057  if ( Length == 2 )
1058  {
1059  if ( !If_CluCheckExt( NULL, pRes, nLeaves, nLutLeaf, nLutRoot, pLut0, pLut1, &Func0, &Func1 ) )
1060  {
1061  Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
1062  Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
1063  printf( "Node \"%s\" is not decomposable. Writing BLIF has failed.\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1064  return;
1065  }
1066  }
1067  else
1068  {
1069  if ( !If_CluCheckExt3( NULL, pRes, nLeaves, nLutLeaf, nLutLeaf2, nLutRoot, pLut0, pLut1, pLut2, &Func0, &Func1, &Func2 ) )
1070  {
1071  Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
1072  Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
1073  printf( "Node \"%s\" is not decomposable. Writing BLIF has failed.\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1074  return;
1075  }
1076  }
1077 
1078  // write leaf node
1079  fprintf( pFile, ".names" );
1080  for ( i = 0; i < pLut1[0]; i++ )
1081  fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanin(pNode,pLut1[2+i])) );
1082  fprintf( pFile, " %s_lut1\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1083  // write SOP
1084  pSop = Io_NtkDeriveSop( (Mem_Flex_t *)Abc_ObjNtk(pNode)->pManFunc, Func1, pLut1[0], vCover );
1085  fprintf( pFile, "%s", pSop );
1086 
1087  if ( Length == 3 && pLut2[0] > 0 )
1088  {
1089  // write leaf node
1090  fprintf( pFile, ".names" );
1091  for ( i = 0; i < pLut2[0]; i++ )
1092  if ( pLut2[2+i] == nLeaves )
1093  fprintf( pFile, " %s_lut1", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1094  else
1095  fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanin(pNode,pLut2[2+i])) );
1096  fprintf( pFile, " %s_lut2\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1097  // write SOP
1098  pSop = Io_NtkDeriveSop( (Mem_Flex_t *)Abc_ObjNtk(pNode)->pManFunc, Func2, pLut2[0], vCover );
1099  fprintf( pFile, "%s", pSop );
1100  }
1101 
1102  // write root node
1103  fprintf( pFile, ".names" );
1104  for ( i = 0; i < pLut0[0]; i++ )
1105  if ( pLut0[2+i] == nLeaves )
1106  fprintf( pFile, " %s_lut1", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1107  else if ( pLut0[2+i] == nLeaves+1 )
1108  fprintf( pFile, " %s_lut2", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1109  else
1110  fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanin(pNode,pLut0[2+i])) );
1111  fprintf( pFile, " %s\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1112  // write SOP
1113  pSop = Io_NtkDeriveSop( (Mem_Flex_t *)Abc_ObjNtk(pNode)->pManFunc, Func0, pLut0[0], vCover );
1114  fprintf( pFile, "%s", pSop );
1115  }
1116 }
static ABC_NAMESPACE_IMPL_START int pTruths[13719]
DECLARATIONS ///.
Definition: rwrTemp.c:30
int If_CluCheckExt(void *p, word *pTruth, int nVars, int nLutLeaf, int nLutRoot, char *pLut0, char *pLut1, word *pFunc0, word *pFunc1)
Definition: ifDec16.c:2066
int If_CluCheckExt3(void *p, word *pTruth, int nVars, int nLutLeaf, int nLutLeaf2, int nLutRoot, char *pLut0, char *pLut1, char *pLut2, word *pFunc0, word *pFunc1, word *pFunc2)
Definition: ifDec16.c:2079
ABC_DLL void Abc_SopToTruthBig(char *pSop, int nInputs, word **pVars, word *pCube, word *pRes)
Definition: abcSop.c:1274
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Kit_TruthIsConst0(unsigned *pIn, int nVars)
Definition: kit.h:315
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition: kitDsd.c:490
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
void Extra_PrintHex(FILE *pFile, unsigned *pTruth, int nVars)
static int Kit_TruthIsConst1(unsigned *pIn, int nVars)
Definition: kit.h:323
int If_CluMinimumBase(word *t, int *pSupp, int nVarsAll, int *pnVars)
Definition: ifDec16.c:1532
static word Truth6[6]
Definition: ifDec07.c:52
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
else
Definition: sparse_int.h:55
char * Io_NtkDeriveSop(Mem_Flex_t *pMem, word uTruth, int nVars, Vec_Int_t *vCover)
Definition: ioWriteBlif.c:789
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
#define assert(ex)
Definition: util_old.h:213
static void * Abc_ObjData(Abc_Obj_t *pObj)
Definition: abc.h:336
int strlen()
static Abc_Ntk_t * Abc_ObjNtk(Abc_Obj_t *pObj)
Definition: abc.h:334
static Abc_Obj_t * Abc_ObjFanin(Abc_Obj_t *pObj, int i)
Definition: abc.h:372
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
int Io_NtkWriteNodeSubckt ( FILE *  pFile,
Abc_Obj_t pNode,
int  Length 
)

Function*************************************************************

Synopsis [Write the node into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 645 of file ioWriteBlif.c.

646 {
647  int RetValue = 0;
648  fprintf( pFile, ".subckt" );
649  Io_NtkWriteSubcktFanins( pFile, pNode );
650  fprintf( pFile, "\n" );
651  return RetValue;
652 }
void Io_NtkWriteSubcktFanins(FILE *pFile, Abc_Obj_t *pNode)
Definition: ioWriteBlif.c:513
void Io_NtkWriteOne ( FILE *  pFile,
Abc_Ntk_t pNtk,
int  fWriteLatches,
int  fBb2Wb,
int  fSeq 
)
static

Function*************************************************************

Synopsis [Write one network.]

Description []

SideEffects []

SeeAlso []

Definition at line 199 of file ioWriteBlif.c.

200 {
201  ProgressBar * pProgress;
202  Abc_Obj_t * pNode, * pLatch;
203  int i, Length;
204 
205  // write the PIs
206  fprintf( pFile, ".inputs" );
207  Io_NtkWritePis( pFile, pNtk, fWriteLatches );
208  fprintf( pFile, "\n" );
209 
210  // write the POs
211  fprintf( pFile, ".outputs" );
212  Io_NtkWritePos( pFile, pNtk, fWriteLatches );
213  fprintf( pFile, "\n" );
214 
215  // write the blackbox
216  if ( Abc_NtkHasBlackbox( pNtk ) )
217  {
218  if ( fBb2Wb )
219  Io_NtkWriteConvertedBox( pFile, pNtk, fSeq );
220  else
221  fprintf( pFile, ".blackbox\n" );
222  return;
223  }
224 
225  // write the timing info
226  Io_WriteTimingInfo( pFile, pNtk );
227 
228  // write the latches
229  if ( fWriteLatches && !Abc_NtkIsComb(pNtk) )
230  {
231  fprintf( pFile, "\n" );
232  Abc_NtkForEachLatch( pNtk, pLatch, i )
233  Io_NtkWriteLatch( pFile, pLatch );
234  fprintf( pFile, "\n" );
235  }
236 
237  // write the subcircuits
238 // assert( Abc_NtkWhiteboxNum(pNtk) == 0 );
239  if ( Abc_NtkBlackboxNum(pNtk) > 0 || Abc_NtkWhiteboxNum(pNtk) > 0 )
240  {
241  fprintf( pFile, "\n" );
242  Abc_NtkForEachBlackbox( pNtk, pNode, i )
243  Io_NtkWriteSubckt( pFile, pNode );
244  fprintf( pFile, "\n" );
245  Abc_NtkForEachWhitebox( pNtk, pNode, i )
246  Io_NtkWriteSubckt( pFile, pNode );
247  fprintf( pFile, "\n" );
248  }
249 
250  // write each internal node
251  Length = Abc_NtkHasMapping(pNtk)? Mio_LibraryReadGateNameMax((Mio_Library_t *)pNtk->pManFunc) : 0;
252  pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
253  Abc_NtkForEachNode( pNtk, pNode, i )
254  {
255  Extra_ProgressBarUpdate( pProgress, i, NULL );
256  if ( Io_NtkWriteNode( pFile, pNode, Length ) ) // skip the next node
257  i++;
258  }
259  Extra_ProgressBarStop( pProgress );
260 }
static int Abc_NtkIsComb(Abc_Ntk_t *pNtk)
Definition: abc.h:297
static int Io_NtkWriteNode(FILE *pFile, Abc_Obj_t *pNode, int Length)
Definition: ioWriteBlif.c:612
void Io_WriteTimingInfo(FILE *pFile, Abc_Ntk_t *pNtk)
Definition: ioWriteBlif.c:665
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
#define Abc_NtkForEachWhitebox(pNtk, pObj, i)
Definition: abc.h:506
void Io_NtkWriteConvertedBox(FILE *pFile, Abc_Ntk_t *pNtk, int fSeq)
Definition: ioWriteBlif.c:158
static int Abc_NtkHasMapping(Abc_Ntk_t *pNtk)
Definition: abc.h:256
static int Abc_NtkWhiteboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:295
static void Io_NtkWritePis(FILE *pFile, Abc_Ntk_t *pNtk, int fWriteLatches)
Definition: ioWriteBlif.c:274
DECLARATIONS ///.
static int Abc_NtkHasBlackbox(Abc_Ntk_t *pNtk)
Definition: abc.h:258
#define Abc_NtkForEachBlackbox(pNtk, pObj, i)
Definition: abc.h:509
if(last==0)
Definition: sparse_int.h:34
static void Io_NtkWritePos(FILE *pFile, Abc_Ntk_t *pNtk, int fWriteLatches)
Definition: ioWriteBlif.c:336
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static void Io_NtkWriteSubckt(FILE *pFile, Abc_Obj_t *pNode)
Definition: ioWriteBlif.c:398
void Extra_ProgressBarStop(ProgressBar *p)
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static void Io_NtkWriteLatch(FILE *pFile, Abc_Obj_t *pLatch)
Definition: ioWriteBlif.c:433
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
int Mio_LibraryReadGateNameMax(Mio_Library_t *pLib)
Definition: mioApi.c:75
static int Abc_NtkBlackboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:296
void Io_NtkWritePis ( FILE *  pFile,
Abc_Ntk_t pNtk,
int  fWriteLatches 
)
static

Function*************************************************************

Synopsis [Writes the primary input list.]

Description []

SideEffects []

SeeAlso []

Definition at line 274 of file ioWriteBlif.c.

275 {
276  Abc_Obj_t * pTerm, * pNet;
277  int LineLength;
278  int AddedLength;
279  int NameCounter;
280  int i;
281 
282  LineLength = 7;
283  NameCounter = 0;
284 
285  if ( fWriteLatches )
286  {
287  Abc_NtkForEachPi( pNtk, pTerm, i )
288  {
289  pNet = Abc_ObjFanout0(pTerm);
290  // get the line length after this name is written
291  AddedLength = strlen(Abc_ObjName(pNet)) + 1;
292  if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
293  { // write the line extender
294  fprintf( pFile, " \\\n" );
295  // reset the line length
296  LineLength = 0;
297  NameCounter = 0;
298  }
299  fprintf( pFile, " %s", Abc_ObjName(pNet) );
300  LineLength += AddedLength;
301  NameCounter++;
302  }
303  }
304  else
305  {
306  Abc_NtkForEachCi( pNtk, pTerm, i )
307  {
308  pNet = Abc_ObjFanout0(pTerm);
309  // get the line length after this name is written
310  AddedLength = strlen(Abc_ObjName(pNet)) + 1;
311  if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
312  { // write the line extender
313  fprintf( pFile, " \\\n" );
314  // reset the line length
315  LineLength = 0;
316  NameCounter = 0;
317  }
318  fprintf( pFile, " %s", Abc_ObjName(pNet) );
319  LineLength += AddedLength;
320  NameCounter++;
321  }
322  }
323 }
#define IO_WRITE_LINE_LENGTH
MACRO DEFINITIONS ///.
Definition: ioAbc.h:71
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
int strlen()
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
void Io_NtkWritePos ( FILE *  pFile,
Abc_Ntk_t pNtk,
int  fWriteLatches 
)
static

Function*************************************************************

Synopsis [Writes the primary input list.]

Description []

SideEffects []

SeeAlso []

Definition at line 336 of file ioWriteBlif.c.

337 {
338  Abc_Obj_t * pTerm, * pNet;
339  int LineLength;
340  int AddedLength;
341  int NameCounter;
342  int i;
343 
344  LineLength = 8;
345  NameCounter = 0;
346 
347  if ( fWriteLatches )
348  {
349  Abc_NtkForEachPo( pNtk, pTerm, i )
350  {
351  pNet = Abc_ObjFanin0(pTerm);
352  // get the line length after this name is written
353  AddedLength = strlen(Abc_ObjName(pNet)) + 1;
354  if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
355  { // write the line extender
356  fprintf( pFile, " \\\n" );
357  // reset the line length
358  LineLength = 0;
359  NameCounter = 0;
360  }
361  fprintf( pFile, " %s", Abc_ObjName(pNet) );
362  LineLength += AddedLength;
363  NameCounter++;
364  }
365  }
366  else
367  {
368  Abc_NtkForEachCo( pNtk, pTerm, i )
369  {
370  pNet = Abc_ObjFanin0(pTerm);
371  // get the line length after this name is written
372  AddedLength = strlen(Abc_ObjName(pNet)) + 1;
373  if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
374  { // write the line extender
375  fprintf( pFile, " \\\n" );
376  // reset the line length
377  LineLength = 0;
378  NameCounter = 0;
379  }
380  fprintf( pFile, " %s", Abc_ObjName(pNet) );
381  LineLength += AddedLength;
382  NameCounter++;
383  }
384  }
385 }
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
#define IO_WRITE_LINE_LENGTH
MACRO DEFINITIONS ///.
Definition: ioAbc.h:71
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
int strlen()
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
void Io_NtkWriteSubckt ( FILE *  pFile,
Abc_Obj_t pNode 
)
static

Function*************************************************************

Synopsis [Write the latch into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 398 of file ioWriteBlif.c.

399 {
400  Abc_Ntk_t * pModel = (Abc_Ntk_t *)pNode->pData;
401  Abc_Obj_t * pTerm;
402  int i;
403  // write the subcircuit
404 // fprintf( pFile, ".subckt %s %s", Abc_NtkName(pModel), Abc_ObjName(pNode) );
405  fprintf( pFile, ".subckt %s", Abc_NtkName(pModel) );
406  // write pairs of the formal=actual names
407  Abc_NtkForEachPi( pModel, pTerm, i )
408  {
409  fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanout0(pTerm)) );
410  pTerm = Abc_ObjFanin( pNode, i );
411  fprintf( pFile, "=%s", Abc_ObjName(Abc_ObjFanin0(pTerm)) );
412  }
413  Abc_NtkForEachPo( pModel, pTerm, i )
414  {
415  fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanin0(pTerm)) );
416  pTerm = Abc_ObjFanout( pNode, i );
417  fprintf( pFile, "=%s", Abc_ObjName(Abc_ObjFanout0(pTerm)) );
418  }
419  fprintf( pFile, "\n" );
420 }
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static char * Abc_NtkName(Abc_Ntk_t *pNtk)
Definition: abc.h:270
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
void * pData
Definition: abc.h:145
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
static Abc_Obj_t * Abc_ObjFanout(Abc_Obj_t *pObj, int i)
Definition: abc.h:370
static Abc_Obj_t * Abc_ObjFanin(Abc_Obj_t *pObj, int i)
Definition: abc.h:372
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
void Io_NtkWriteSubcktFanins ( FILE *  pFile,
Abc_Obj_t pNode 
)

Function*************************************************************

Synopsis [Writes the primary input list.]

Description []

SideEffects []

SeeAlso []

Definition at line 513 of file ioWriteBlif.c.

514 {
515  Abc_Obj_t * pNet;
516  int LineLength;
517  int AddedLength;
518  int NameCounter;
519  char * pName;
520  int i;
521 
522  LineLength = 6;
523  NameCounter = 0;
524 
525  // get the output name
526  pName = Abc_ObjName(Abc_ObjFanout0(pNode));
527  // get the line length after the output name is written
528  AddedLength = strlen(pName) + 1;
529  fprintf( pFile, " m%d", Abc_ObjId(pNode) );
530 
531  // get the input names
532  Abc_ObjForEachFanin( pNode, pNet, i )
533  {
534  // get the fanin name
535  pName = Abc_ObjName(pNet);
536  // get the line length after the fanin name is written
537  AddedLength = strlen(pName) + 3;
538  if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
539  { // write the line extender
540  fprintf( pFile, " \\\n" );
541  // reset the line length
542  LineLength = 0;
543  NameCounter = 0;
544  }
545  fprintf( pFile, " %c=%s", 'a'+i, pName );
546  LineLength += AddedLength;
547  NameCounter++;
548  }
549 
550  // get the output name
551  pName = Abc_ObjName(Abc_ObjFanout0(pNode));
552  // get the line length after the output name is written
553  AddedLength = strlen(pName) + 3;
554  if ( NameCounter && LineLength + AddedLength > 75 )
555  { // write the line extender
556  fprintf( pFile, " \\\n" );
557  // reset the line length
558  LineLength = 0;
559  NameCounter = 0;
560  }
561  fprintf( pFile, " %c=%s", 'o', pName );
562 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
#define IO_WRITE_LINE_LENGTH
MACRO DEFINITIONS ///.
Definition: ioAbc.h:71
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
int strlen()
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
void Io_WriteBlif ( Abc_Ntk_t pNtk,
char *  FileName,
int  fWriteLatches,
int  fBb2Wb,
int  fSeq 
)

Function*************************************************************

Synopsis [Write the network into a BLIF file with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 84 of file ioWriteBlif.c.

85 {
86  FILE * pFile;
87  Abc_Ntk_t * pNtkTemp;
88  int i;
89  assert( Abc_NtkIsNetlist(pNtk) );
90  // start writing the file
91  pFile = fopen( FileName, "w" );
92  if ( pFile == NULL )
93  {
94  fprintf( stdout, "Io_WriteBlif(): Cannot open the output file.\n" );
95  return;
96  }
97  fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
98  // write the master network
99  Io_NtkWrite( pFile, pNtk, fWriteLatches, fBb2Wb, fSeq );
100  // make sure there is no logic hierarchy
101 // assert( Abc_NtkWhiteboxNum(pNtk) == 0 );
102  // write the hierarchy if present
103  if ( Abc_NtkBlackboxNum(pNtk) > 0 || Abc_NtkWhiteboxNum(pNtk) > 0 )
104  {
105  Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pNtkTemp, i )
106  {
107  if ( pNtkTemp == pNtk )
108  continue;
109  fprintf( pFile, "\n\n" );
110  Io_NtkWrite( pFile, pNtkTemp, fWriteLatches, fBb2Wb, fSeq );
111  }
112  }
113  fclose( pFile );
114 }
static ABC_NAMESPACE_IMPL_START void Io_NtkWrite(FILE *pFile, Abc_Ntk_t *pNtk, int fWriteLatches, int fBb2Wb, int fSeq)
DECLARATIONS ///.
Definition: ioWriteBlif.c:127
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
static int Abc_NtkWhiteboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:295
char * Extra_TimeStamp()
Vec_Ptr_t * vModules
Definition: abc.h:223
#define assert(ex)
Definition: util_old.h:213
static int Abc_NtkBlackboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:296
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Abc_Des_t * pDesign
Definition: abc.h:180
char * pName
Definition: abc.h:158
void Io_WriteBlifInt ( Abc_Ntk_t pNtk,
char *  FileName,
char *  pLutStruct,
int  fUseHie 
)

Function*************************************************************

Synopsis [Write the network into a BLIF file with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 1305 of file ioWriteBlif.c.

1306 {
1307  FILE * pFile;
1308  Vec_Int_t * vCover;
1309  Abc_Obj_t * pNode, * pLatch;
1310  int i;
1311  assert( Abc_NtkIsNetlist(pNtk) );
1312  // start writing the file
1313  pFile = fopen( FileName, "w" );
1314  if ( pFile == NULL )
1315  {
1316  fprintf( stdout, "Io_WriteBlifInt(): Cannot open the output file.\n" );
1317  return;
1318  }
1319  fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
1320  // write the model name
1321  fprintf( pFile, ".model %s\n", Abc_NtkName(pNtk) );
1322  // write the PIs
1323  fprintf( pFile, ".inputs" );
1324  Io_NtkWritePis( pFile, pNtk, 1 );
1325  fprintf( pFile, "\n" );
1326  // write the POs
1327  fprintf( pFile, ".outputs" );
1328  Io_NtkWritePos( pFile, pNtk, 1 );
1329  fprintf( pFile, "\n" );
1330  // write the latches
1331  if ( Abc_NtkLatchNum(pNtk) )
1332  fprintf( pFile, "\n" );
1333  Abc_NtkForEachLatch( pNtk, pLatch, i )
1334  Io_NtkWriteLatch( pFile, pLatch );
1335  if ( Abc_NtkLatchNum(pNtk) )
1336  fprintf( pFile, "\n" );
1337  // write the hierarchy
1338  vCover = Vec_IntAlloc( (1<<16) );
1339  if ( fUseHie )
1340  {
1341  // write each internal node
1342  fprintf( pFile, "\n" );
1343  Abc_NtkForEachNode( pNtk, pNode, i )
1344  Io_NtkWriteNodeSubckt( pFile, pNode, 0 );
1345  fprintf( pFile, ".end\n\n" );
1346  // write models
1347  Abc_NtkForEachNode( pNtk, pNode, i )
1348  Io_NtkWriteModelIntStruct( pFile, pNode, vCover, pLutStruct );
1349  fprintf( pFile, "\n" );
1350  }
1351  else
1352  {
1353  // write each internal node
1354  Abc_NtkForEachNode( pNtk, pNode, i )
1355  {
1356  if ( pLutStruct )
1357  Io_NtkWriteNodeIntStruct( pFile, pNode, vCover, pLutStruct );
1358  else
1359  Io_NtkWriteNodeInt( pFile, pNode, vCover );
1360  }
1361  fprintf( pFile, ".end\n\n" );
1362  }
1363  Vec_IntFree( vCover );
1364  fclose( pFile );
1365 }
void Io_NtkWriteNodeIntStruct(FILE *pFile, Abc_Obj_t *pNode, Vec_Int_t *vCover, char *pStr)
Definition: ioWriteBlif.c:965
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
void Io_NtkWriteNodeInt(FILE *pFile, Abc_Obj_t *pNode, Vec_Int_t *vCover)
Definition: ioWriteBlif.c:819
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
static void Io_NtkWritePis(FILE *pFile, Abc_Ntk_t *pNtk, int fWriteLatches)
Definition: ioWriteBlif.c:274
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
if(last==0)
Definition: sparse_int.h:34
static void Io_NtkWritePos(FILE *pFile, Abc_Ntk_t *pNtk, int fWriteLatches)
Definition: ioWriteBlif.c:336
else
Definition: sparse_int.h:55
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
void Io_NtkWriteModelIntStruct(FILE *pFile, Abc_Obj_t *pNode, Vec_Int_t *vCover, char *pStr)
Definition: ioWriteBlif.c:1129
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
int Io_NtkWriteNodeSubckt(FILE *pFile, Abc_Obj_t *pNode, int Length)
Definition: ioWriteBlif.c:645
static char * Abc_NtkName(Abc_Ntk_t *pNtk)
Definition: abc.h:270
static void Io_NtkWriteLatch(FILE *pFile, Abc_Obj_t *pLatch)
Definition: ioWriteBlif.c:433
char * Extra_TimeStamp()
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
char * pName
Definition: abc.h:158
void Io_WriteBlifLogic ( Abc_Ntk_t pNtk,
char *  FileName,
int  fWriteLatches 
)

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Write the network into a BLIF file with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 59 of file ioWriteBlif.c.

60 {
61  Abc_Ntk_t * pNtkTemp;
62  // derive the netlist
63  pNtkTemp = Abc_NtkToNetlist(pNtk);
64  if ( pNtkTemp == NULL )
65  {
66  fprintf( stdout, "Writing BLIF has failed.\n" );
67  return;
68  }
69  Io_WriteBlif( pNtkTemp, FileName, fWriteLatches, 0, 0 );
70  Abc_NtkDelete( pNtkTemp );
71 }
void Io_WriteBlif(Abc_Ntk_t *pNtk, char *FileName, int fWriteLatches, int fBb2Wb, int fSeq)
Definition: ioWriteBlif.c:84
ABC_DLL Abc_Ntk_t * Abc_NtkToNetlist(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:97
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
void Io_WriteBlifSpecial ( Abc_Ntk_t pNtk,
char *  FileName,
char *  pLutStruct,
int  fUseHie 
)

Function*************************************************************

Synopsis [Write the network into a BLIF file with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 1378 of file ioWriteBlif.c.

1379 {
1380  Abc_Ntk_t * pNtkTemp;
1381  assert( Abc_NtkIsLogic(pNtk) );
1382  Abc_NtkToSop( pNtk, 0 );
1383  // derive the netlist
1384  pNtkTemp = Abc_NtkToNetlist(pNtk);
1385  if ( pNtkTemp == NULL )
1386  {
1387  fprintf( stdout, "Writing BLIF has failed.\n" );
1388  return;
1389  }
1390  if ( pLutStruct && fUseHie )
1391  Io_WriteBlifInt( pNtkTemp, FileName, pLutStruct, 1 );
1392  else
1393  Io_WriteBlifInt( pNtkTemp, FileName, pLutStruct, 0 );
1394  Abc_NtkDelete( pNtkTemp );
1395 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
ABC_DLL Abc_Ntk_t * Abc_NtkToNetlist(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:97
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fDirect)
Definition: abcFunc.c:1124
void Io_WriteBlifInt(Abc_Ntk_t *pNtk, char *FileName, char *pLutStruct, int fUseHie)
Definition: ioWriteBlif.c:1305
#define assert(ex)
Definition: util_old.h:213
void Io_WriteTimingInfo ( FILE *  pFile,
Abc_Ntk_t pNtk 
)

Function*************************************************************

Synopsis [Writes the timing info.]

Description []

SideEffects []

SeeAlso []

Definition at line 665 of file ioWriteBlif.c.

666 {
667  Abc_Obj_t * pNode;
668  Abc_Time_t * pTime, * pTimeDef;
669  int i;
670 
671  if ( pNtk->pManTime == NULL )
672  return;
673 
674  fprintf( pFile, "\n" );
675 
676  if ( pNtk->AndGateDelay != 0.0 )
677  fprintf( pFile, ".and_gate_delay %g\n", pNtk->AndGateDelay );
678 
679  pTimeDef = Abc_NtkReadDefaultArrival( pNtk );
680  if ( pTimeDef->Rise != 0.0 || pTimeDef->Fall != 0.0 )
681  fprintf( pFile, ".default_input_arrival %g %g\n", pTimeDef->Rise, pTimeDef->Fall );
682  Abc_NtkForEachPi( pNtk, pNode, i )
683  {
684  pTime = Abc_NodeReadArrival(pNode);
685  if ( pTime->Rise == pTimeDef->Rise && pTime->Fall == pTimeDef->Fall )
686  continue;
687  fprintf( pFile, ".input_arrival %s %g %g\n", Abc_ObjName(Abc_ObjFanout0(pNode)), pTime->Rise, pTime->Fall );
688  }
689 
690  pTimeDef = Abc_NtkReadDefaultRequired( pNtk );
691  if ( pTimeDef->Rise != ABC_INFINITY || pTimeDef->Fall != ABC_INFINITY )
692  fprintf( pFile, ".default_output_required %g %g\n", pTimeDef->Rise, pTimeDef->Fall );
693  Abc_NtkForEachPo( pNtk, pNode, i )
694  {
695  pTime = Abc_NodeReadRequired(pNode);
696  if ( pTime->Rise == pTimeDef->Rise && pTime->Fall == pTimeDef->Fall )
697  continue;
698  fprintf( pFile, ".output_required %s %g %g\n", Abc_ObjName(Abc_ObjFanin0(pNode)), pTime->Rise, pTime->Fall );
699  }
700 
701  fprintf( pFile, "\n" );
702 
703  pTimeDef = Abc_NtkReadDefaultInputDrive( pNtk );
704  if ( pTimeDef->Rise != 0.0 || pTimeDef->Fall != 0.0 )
705  fprintf( pFile, ".default_input_drive %g %g\n", pTimeDef->Rise, pTimeDef->Fall );
706  if ( Abc_NodeReadInputDrive( pNtk, 0 ) )
707  Abc_NtkForEachPi( pNtk, pNode, i )
708  {
709  pTime = Abc_NodeReadInputDrive( pNtk, i );
710  if ( pTime->Rise == pTimeDef->Rise && pTime->Fall == pTimeDef->Fall )
711  continue;
712  fprintf( pFile, ".input_drive %s %g %g\n", Abc_ObjName(Abc_ObjFanout0(pNode)), pTime->Rise, pTime->Fall );
713  }
714 
715  pTimeDef = Abc_NtkReadDefaultOutputLoad( pNtk );
716  if ( pTimeDef->Rise != 0.0 || pTimeDef->Fall != 0.0 )
717  fprintf( pFile, ".default_output_load %g %g\n", pTimeDef->Rise, pTimeDef->Fall );
718  if ( Abc_NodeReadOutputLoad( pNtk, 0 ) )
719  Abc_NtkForEachPo( pNtk, pNode, i )
720  {
721  pTime = Abc_NodeReadOutputLoad( pNtk, i );
722  if ( pTime->Rise == pTimeDef->Rise && pTime->Fall == pTimeDef->Fall )
723  continue;
724  fprintf( pFile, ".output_load %s %g %g\n", Abc_ObjName(Abc_ObjFanin0(pNode)), pTime->Rise, pTime->Fall );
725  }
726 
727  fprintf( pFile, "\n" );
728 }
ABC_DLL Abc_Time_t * Abc_NtkReadDefaultArrival(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcTiming.c:67
float AndGateDelay
Definition: abc.h:194
ABC_DLL Abc_Time_t * Abc_NtkReadDefaultRequired(Abc_Ntk_t *pNtk)
Definition: abcTiming.c:72
ABC_DLL Abc_Time_t * Abc_NodeReadRequired(Abc_Obj_t *pNode)
Definition: abcTiming.c:82
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL Abc_Time_t * Abc_NodeReadArrival(Abc_Obj_t *pNode)
Definition: abcTiming.c:77
ABC_DLL Abc_Time_t * Abc_NtkReadDefaultInputDrive(Abc_Ntk_t *pNtk)
Definition: abcTiming.c:115
float Fall
Definition: abc.h:125
Abc_ManTime_t * pManTime
Definition: abc.h:192
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
ABC_DLL Abc_Time_t * Abc_NtkReadDefaultOutputLoad(Abc_Ntk_t *pNtk)
Definition: abcTiming.c:120
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
ABC_DLL Abc_Time_t * Abc_NodeReadInputDrive(Abc_Ntk_t *pNtk, int iPi)
Definition: abcTiming.c:125
float Rise
Definition: abc.h:124
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
ABC_DLL Abc_Time_t * Abc_NodeReadOutputLoad(Abc_Ntk_t *pNtk, int iPo)
Definition: abcTiming.c:130