abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cmdPlugin.c File Reference
#include <unistd.h>
#include "base/abc/abc.h"
#include "base/main/mainInt.h"
#include "cmd.h"
#include "cmdInt.h"
#include "misc/util/utilSignal.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START char * Abc_GetBinaryName (Abc_Frame_t *pAbc, int argc, char **argv)
 DECLARATIONS ///. More...
 
Vec_Str_tAbc_ManReadFile (char *pFileName)
 
Vec_Int_tAbc_ManReadBinary (char *pFileName, char *pToken)
 
int Abc_ManReadInteger (char *pFileName, char *pToken)
 
int Abc_ManReadStatus (char *pFileName, char *pToken)
 
Vec_Int_tAbc_ManExpandCex (Gia_Man_t *pGia, Vec_Int_t *vCex)
 
static unsigned textToBin (char *text, unsigned long text_sz)
 
Gia_Man_tAbc_ManReadAig (char *pFileName, char *pToken)
 
int Cmd_CommandAbcPlugIn (Abc_Frame_t *pAbc, int argc, char **argv)
 
int Cmd_CommandAbcLoadPlugIn (Abc_Frame_t *pAbc, int argc, char **argv)
 

Function Documentation

ABC_NAMESPACE_IMPL_START char* Abc_GetBinaryName ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)

DECLARATIONS ///.

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

FileName [cmdPlugin.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Integrating external binary.]

Author [Alan Mishchenko, Niklas Een]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - September 29, 2010.]

Revision [

Id:
cmdPlugin.c,v 1.00 2010/09/29 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 130 of file cmdPlugin.c.

131 {
132  char * pTemp;
133  int i;
134  Vec_PtrForEachEntry( char *, pAbc->vPlugInComBinPairs, pTemp, i )
135  {
136  i++;
137  if ( strcmp( pTemp, argv[0] ) == 0 )
138  return (char *)Vec_PtrEntry( pAbc->vPlugInComBinPairs, i );
139  }
140  assert( 0 );
141  return NULL;
142 }
int strcmp()
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Vec_Int_t* Abc_ManExpandCex ( Gia_Man_t pGia,
Vec_Int_t vCex 
)

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

Synopsis [Work-around to insert 0s for PIs without fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 286 of file cmdPlugin.c.

287 {
288  Vec_Int_t * vCexNew;
289  Gia_Obj_t * pObj;
290  int i, k;
291 
292  // start with register outputs
293  vCexNew = Vec_IntAlloc( Vec_IntSize(vCex) );
294  Gia_ManForEachRo( pGia, pObj, i )
295  Vec_IntPush( vCexNew, 0 );
296 
297  ABC_FREE( pGia->pRefs );
298  Gia_ManCreateRefs( pGia );
299  k = Gia_ManRegNum( pGia );
300  while ( 1 )
301  {
302  Gia_ManForEachPi( pGia, pObj, i )
303  {
304  if ( Gia_ObjRefNum(pGia, pObj) == 0 )
305  Vec_IntPush( vCexNew, 0 );
306  else
307  {
308  if ( k == Vec_IntSize(vCex) )
309  break;
310  Vec_IntPush( vCexNew, Vec_IntEntry(vCex, k++) );
311  }
312  }
313  if ( k == Vec_IntSize(vCex) )
314  break;
315  }
316  return vCexNew;
317 }
void Gia_ManCreateRefs(Gia_Man_t *p)
Definition: giaUtil.c:715
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Gia_ObjRefNum(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:521
Definition: gia.h:75
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Gia_ManForEachPi(p, pObj, i)
Definition: gia.h:1034
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define Gia_ManForEachRo(p, pObj, i)
Definition: gia.h:1038
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
Gia_Man_t* Abc_ManReadAig ( char *  pFileName,
char *  pToken 
)

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

Synopsis [Derives AIG from the text string in the file.]

Description []

SideEffects []

SeeAlso []

Definition at line 359 of file cmdPlugin.c.

360 {
361  Gia_Man_t * pGia = NULL;
362  unsigned nBinaryPart;
363  Vec_Str_t * vStr;
364  char * pStr, * pEnd;
365  vStr = Abc_ManReadFile( pFileName );
366  if ( vStr == NULL )
367  return NULL;
368  pStr = Vec_StrArray( vStr );
369  pStr = strstr( pStr, pToken );
370  if ( pStr != NULL )
371  {
372  // skip token
373  pStr += strlen(pToken);
374  // skip spaces
375  while ( *pStr == ' ' )
376  pStr++;
377  // set the end at newline
378  for ( pEnd = pStr; *pEnd; pEnd++ )
379  if ( *pEnd == '\r' || *pEnd == '\n' )
380  {
381  *pEnd = 0;
382  break;
383  }
384  // convert into binary AIGER
385  nBinaryPart = textToBin( pStr, strlen(pStr) );
386  // dump it into file
387  if ( 0 )
388  {
389  FILE * pFile = fopen( "test.aig", "wb" );
390  fwrite( pStr, 1, nBinaryPart, pFile );
391  fclose( pFile );
392  }
393  // derive AIG
394  pGia = Gia_AigerReadFromMemory( pStr, nBinaryPart, 0, 0 );
395  }
396  Vec_StrFree( vStr );
397  return pGia;
398 
399 }
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
Gia_Man_t * Gia_AigerReadFromMemory(char *pContents, int nFileSize, int fSkipStrash, int fCheck)
Definition: giaAiger.c:176
Vec_Str_t * Abc_ManReadFile(char *pFileName)
Definition: cmdPlugin.c:155
static unsigned textToBin(char *text, unsigned long text_sz)
Definition: cmdPlugin.c:330
char * strstr()
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
Definition: gia.h:95
int strlen()
Vec_Int_t* Abc_ManReadBinary ( char *  pFileName,
char *  pToken 
)

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

Synopsis [Read flop map.]

Description []

SideEffects []

SeeAlso []

Definition at line 185 of file cmdPlugin.c.

186 {
187  Vec_Int_t * vMap = NULL;
188  Vec_Str_t * vStr;
189  char * pStr;
190  int i, Length;
191  vStr = Abc_ManReadFile( pFileName );
192  if ( vStr == NULL )
193  return NULL;
194  pStr = Vec_StrArray( vStr );
195  pStr = strstr( pStr, pToken );
196  if ( pStr != NULL )
197  {
198  pStr += strlen( pToken );
199  vMap = Vec_IntAlloc( 100 );
200  Length = strlen( pStr );
201  for ( i = 0; i < Length; i++ )
202  {
203  if ( pStr[i] == '0' || pStr[i] == '?' )
204  Vec_IntPush( vMap, 0 );
205  else if ( pStr[i] == '1' )
206  Vec_IntPush( vMap, 1 );
207  if ( ('a' <= pStr[i] && pStr[i] <= 'z') ||
208  ('A' <= pStr[i] && pStr[i] <= 'Z') )
209  break;
210  }
211  }
212  Vec_StrFree( vStr );
213  return vMap;
214 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
Vec_Str_t * Abc_ManReadFile(char *pFileName)
Definition: cmdPlugin.c:155
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
char * strstr()
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
int strlen()
Vec_Str_t* Abc_ManReadFile ( char *  pFileName)

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

Synopsis [Read flop map.]

Description []

SideEffects []

SeeAlso []

Definition at line 155 of file cmdPlugin.c.

156 {
157  FILE * pFile;
158  Vec_Str_t * vStr;
159  int c;
160  pFile = fopen( pFileName, "r" );
161  if ( pFile == NULL )
162  {
163  printf( "Cannot open file \"%s\".\n", pFileName );
164  return NULL;
165  }
166  vStr = Vec_StrAlloc( 100 );
167  while ( (c = fgetc(pFile)) != EOF )
168  Vec_StrPush( vStr, (char)c );
169  Vec_StrPush( vStr, '\0' );
170  fclose( pFile );
171  return vStr;
172 }
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
int Abc_ManReadInteger ( char *  pFileName,
char *  pToken 
)

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

Synopsis [Read flop map.]

Description []

SideEffects []

SeeAlso []

Definition at line 227 of file cmdPlugin.c.

228 {
229  int Result = -1;
230  Vec_Str_t * vStr;
231  char * pStr;
232  vStr = Abc_ManReadFile( pFileName );
233  if ( vStr == NULL )
234  return -1;
235  pStr = Vec_StrArray( vStr );
236  pStr = strstr( pStr, pToken );
237  if ( pStr != NULL )
238  Result = atoi( pStr + strlen(pToken) );
239  Vec_StrFree( vStr );
240  return Result;
241 }
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
Vec_Str_t * Abc_ManReadFile(char *pFileName)
Definition: cmdPlugin.c:155
char * strstr()
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
int strlen()
int Abc_ManReadStatus ( char *  pFileName,
char *  pToken 
)

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

Synopsis [Read flop map.]

Description []

SideEffects []

SeeAlso []

Definition at line 254 of file cmdPlugin.c.

255 {
256  int Result = -1;
257  Vec_Str_t * vStr;
258  char * pStr;
259  vStr = Abc_ManReadFile( pFileName );
260  if ( vStr == NULL )
261  return -1;
262  pStr = Vec_StrArray( vStr );
263  pStr = strstr( pStr, pToken );
264  if ( pStr != NULL )
265  {
266  if ( strncmp(pStr+8, "proved", 6) == 0 )
267  Result = 1;
268  else if ( strncmp(pStr+8, "failed", 6) == 0 )
269  Result = 0;
270  }
271  Vec_StrFree( vStr );
272  return Result;
273 }
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
Vec_Str_t * Abc_ManReadFile(char *pFileName)
Definition: cmdPlugin.c:155
char * strstr()
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
int strncmp()
int Cmd_CommandAbcLoadPlugIn ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 642 of file cmdPlugin.c.

643 {
644  FILE * pFile;
645  char pBuffer[1000];
646  char * pCommandLine;
647  char * pTempFile;
648  char * pStrDirBin, * pStrSection;
649  int fd, RetValue;
650 
651  if ( argc != 3 )
652  {
653  Abc_Print( -1, "Wrong number of arguments.\n" );
654  goto usage;
655  }
656  // collect arguments
657  pStrDirBin = argv[argc-2];
658  pStrSection = argv[argc-1];
659 
660  // check if the file exists
661  if ( (pFile = fopen( pStrDirBin, "r" )) == NULL )
662  {
663 // Abc_Print( -1, "Cannot run the binary \"%s\".\n", pStrDirBin );
664 // goto usage;
665  return 0;
666  }
667  fclose( pFile );
668 
669  // create temp file
670  fd = Util_SignalTmpFile( "__abctmp_", ".txt", &pTempFile );
671  if ( fd == -1 )
672  {
673  Abc_Print( -1, "Cannot create a temporary file.\n" );
674  goto usage;
675  }
676 #ifdef WIN32
677  _close( fd );
678 #else
679  close( fd );
680 #endif
681 
682  // get command list
683  pCommandLine = ABC_ALLOC( char, 100 + strlen(pStrDirBin) + strlen(pTempFile) );
684 // sprintf( pCommandLine, "%s -abc -list-commands > %s", pStrDirBin, pTempFile );
685  sprintf( pCommandLine, "%s -abc -list-commands > %s", pStrDirBin, pTempFile );
686  RetValue = Util_SignalSystem( pCommandLine );
687  if ( RetValue == -1 )
688  {
689  Abc_Print( -1, "Command \"%s\" did not succeed.\n", pCommandLine );
690  ABC_FREE( pCommandLine );
691  ABC_FREE( pTempFile );
692  goto usage;
693  }
694  ABC_FREE( pCommandLine );
695 
696  // create commands
697  pFile = fopen( pTempFile, "r" );
698  if ( pFile == NULL )
699  {
700  Abc_Print( -1, "Cannot open file with the list of commands.\n" );
701  ABC_FREE( pTempFile );
702  goto usage;
703  }
704  while ( fgets( pBuffer, 1000, pFile ) != NULL )
705  {
706  if ( pBuffer[strlen(pBuffer)-1] == '\n' )
707  pBuffer[strlen(pBuffer)-1] = 0;
708  Cmd_CommandAdd( pAbc, pStrSection, pBuffer, Cmd_CommandAbcPlugIn, 1 );
709 // plugin_commands.push(Pair(cmd_name, binary_name));
710  Vec_PtrPush( pAbc->vPlugInComBinPairs, Extra_UtilStrsav(pBuffer) );
711  Vec_PtrPush( pAbc->vPlugInComBinPairs, Extra_UtilStrsav(pStrDirBin) );
712 // printf( "Creating command %s with binary %s\n", pBuffer, pStrDirBin );
713  }
714  fclose( pFile );
715  Util_SignalTmpFileRemove( pTempFile, 0 );
716  ABC_FREE( pTempFile );
717  return 0;
718 usage:
719  Abc_Print( -2, "usage: load_plugin <plugin_dir\\binary_name> <section_name>\n" );
720  Abc_Print( -2, "\t loads external binary as a plugin\n" );
721  Abc_Print( -2, "\t-h : print the command usage\n");
722  return 1;
723 }
int Util_SignalTmpFile(const char *prefix, const char *suffix, char **out_name)
INCLUDES ///.
Definition: utilSignal.c:53
int Cmd_CommandAbcPlugIn(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmdPlugin.c:412
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
void Cmd_CommandAdd(Abc_Frame_t *pAbc, const char *sGroup, const char *sName, Cmd_CommandFuncType pFunc, int fChanges)
Definition: cmdApi.c:63
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
char * Extra_UtilStrsav(const char *s)
void Util_SignalTmpFileRemove(const char *fname, int fLeave)
Definition: utilSignal.c:58
char * sprintf()
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
#define ABC_FREE(obj)
Definition: abc_global.h:232
int strlen()
ABC_NAMESPACE_IMPL_START int Util_SignalSystem(const char *cmd)
DECLARATIONS ///.
Definition: utilSignal.c:46
int Cmd_CommandAbcPlugIn ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 412 of file cmdPlugin.c.

413 {
414  char * pFileIn, * pFileOut;
415  char * pFileNameBinary;
416  Vec_Str_t * vCommand;
417  Vec_Int_t * vCex;
418  FILE * pFile;
419  Gia_Man_t * pGia;
420  int i, fd;
421  abctime clk;
422  int fLeaveFiles;
423 /*
424  Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
425  if ( pNtk == NULL )
426  {
427  Abc_Print( -1, "Current network does not exist\n" );
428  return 1;
429  }
430  if ( !Abc_NtkIsStrash( pNtk) )
431  {
432  Abc_Print( -1, "The current network is not an AIG. Cannot continue.\n" );
433  return 1;
434  }
435 */
436 
437  if ( pAbc->pGia == NULL )
438  {
439  if (argc == 2 && strcmp(argv[1], "-h") == 0)
440  {
441  // Run command to produce help string:
442  vCommand = Vec_StrAlloc( 100 );
443  pFileNameBinary = Abc_GetBinaryName( pAbc, argc, argv );
444  Vec_StrAppend( vCommand, pFileNameBinary );
445  Vec_StrAppend( vCommand, " -abc " );
446  Vec_StrAppend( vCommand, argv[0] );
447  Vec_StrAppend( vCommand, " -h" );
448  Vec_StrPush( vCommand, 0 );
449  Util_SignalSystem( Vec_StrArray(vCommand) );
450  Vec_StrFree( vCommand );
451  }
452  else
453  {
454  Abc_Print( -1, "Current AIG does not exist (try command &ps).\n" );
455  }
456  return 1;
457  }
458 
459  // check if there is the binary
460  pFileNameBinary = Abc_GetBinaryName( pAbc, argc, argv );
461  if ( (pFile = fopen( pFileNameBinary, "r" )) == NULL )
462  {
463  Abc_Print( -1, "Cannot run the binary \"%s\".\n\n", pFileNameBinary );
464  return 1;
465  }
466  fclose( pFile );
467 
468  // create temp file
469  fd = Util_SignalTmpFile( "__abctmp_", ".aig", &pFileIn );
470  if ( fd == -1 )
471  {
472  Abc_Print( -1, "Cannot create a temporary file.\n" );
473  return 1;
474  }
475 #ifdef WIN32
476  _close( fd );
477 #else
478  close( fd );
479 #endif
480 
481  // create temp file
482  fd = Util_SignalTmpFile( "__abctmp_", ".out", &pFileOut );
483  if ( fd == -1 )
484  {
485  ABC_FREE( pFileIn );
486  Abc_Print( -1, "Cannot create a temporary file.\n" );
487  return 1;
488  }
489 #ifdef WIN32
490  _close( fd );
491 #else
492  close( fd );
493 #endif
494 
495 
496  // write current network into a file
497 /*
498  {
499  extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
500  Aig_Man_t * pAig;
501  pAig = Abc_NtkToDar( pNtk, 0, 1 );
502  Ioa_WriteAiger( pAig, pFileIn, 0, 0 );
503  Aig_ManStop( pAig );
504  }
505 */
506  // check what to do with the files
507  fLeaveFiles = 0;
508  if ( strcmp( argv[argc-1], "!" ) == 0 )
509  {
510  Abc_Print( 0, "Input file \"%s\" and output file \"%s\" are not deleted.\n", pFileIn, pFileOut );
511  fLeaveFiles = 1;
512  argc--;
513  }
514 
515  // create input file
516  Gia_AigerWrite( pAbc->pGia, pFileIn, 0, 0 );
517 
518  // create command line
519  vCommand = Vec_StrAlloc( 100 );
520  Vec_StrAppend( vCommand, pFileNameBinary );
521  // add input/output file
522  Vec_StrAppend( vCommand, " -abc" );
523 // Vec_StrAppend( vCommand, " -input=C:/_projects/abc/_TEST/hwmcc/139442p0.aig" );
524  Vec_StrAppend( vCommand, " -input=" );
525  Vec_StrAppend( vCommand, pFileIn );
526  Vec_StrAppend( vCommand, " -output=" );
527  Vec_StrAppend( vCommand, pFileOut );
528  // add other arguments
529  for ( i = 0; i < argc; i++ )
530  {
531  Vec_StrAppend( vCommand, " " );
532  Vec_StrAppend( vCommand, argv[i] );
533  }
534  Vec_StrPush( vCommand, 0 );
535 
536  // run the command line
537 //printf( "Running command line: %s\n", Vec_StrArray(vCommand) );
538 
539  clk = Abc_Clock();
540  if ( Util_SignalSystem( Vec_StrArray(vCommand) ) )
541  {
542  Abc_Print( -1, "The following command has returned non-zero exit status:\n" );
543  Abc_Print( -1, "\"%s\"\n", Vec_StrArray(vCommand) );
544  return 1;
545  }
546  clk = Abc_Clock() - clk;
547  Vec_StrFree( vCommand );
548 
549  // check if the output file exists
550  if ( (pFile = fopen( pFileOut, "r" )) == NULL )
551  {
552  Abc_Print( -1, "There is no output file \"%s\".\n", pFileOut );
553  return 1;
554  }
555  fclose( pFile );
556 
557  // process the output
558  if ( Extra_FileSize(pFileOut) > 0 )
559  {
560  // get status
561  pAbc->Status = Abc_ManReadStatus( pFileOut, "result:" );
562  // get bug-free depth
563  pAbc->nFrames = Abc_ManReadInteger( pFileOut, "bug-free-depth:" );
564  // get abstraction
565  pAbc->pGia->vFlopClasses = Abc_ManReadBinary( pFileOut, "abstraction:" );
566  // get counter-example
567  vCex = Abc_ManReadBinary( pFileOut, "counter-example:" );
568  if ( vCex )
569  {
570  int nFrames, nRemain;
571 
572  nFrames = (Vec_IntSize(vCex) - Gia_ManRegNum(pAbc->pGia)) / Gia_ManPiNum(pAbc->pGia);
573  nRemain = (Vec_IntSize(vCex) - Gia_ManRegNum(pAbc->pGia)) % Gia_ManPiNum(pAbc->pGia);
574  if ( nRemain != 0 )
575  {
576  Vec_Int_t * vTemp;
577  Abc_Print( 1, "Adjusting counter-example by adding zeros for PIs without fanout.\n" );
578  // expand the counter-example to include PIs without fanout
579  vCex = Abc_ManExpandCex( pAbc->pGia, vTemp = vCex );
580  Vec_IntFree( vTemp );
581  }
582 
583  nFrames = (Vec_IntSize(vCex) - Gia_ManRegNum(pAbc->pGia)) / Gia_ManPiNum(pAbc->pGia);
584  nRemain = (Vec_IntSize(vCex) - Gia_ManRegNum(pAbc->pGia)) % Gia_ManPiNum(pAbc->pGia);
585  if ( nRemain != 0 )
586  Abc_Print( 1, "Counter example has a wrong length.\n" );
587  else
588  {
589  Abc_Print( 1, "Problem is satisfiable. Found counter-example in frame %d. ", nFrames-1 );
590  Abc_PrintTime( 1, "Time", clk );
591  ABC_FREE( pAbc->pCex );
592  pAbc->pCex = Abc_CexCreate( Gia_ManRegNum(pAbc->pGia), Gia_ManPiNum(pAbc->pGia), Vec_IntArray(vCex), nFrames-1, 0, 0 );
593 
594 // Abc_CexPrint( pAbc->pCex );
595 
596 // if ( !Gia_ManVerifyCex( pAbc->pGia, pAbc->pCex, 0 ) )
597 // Abc_Print( 1, "Generated counter-example is INVALID.\n" );
598 
599  // remporary work-around to detect the output number - October 18, 2010
600  pAbc->pCex->iPo = Gia_ManFindFailedPoCex( pAbc->pGia, pAbc->pCex, 0 );
601  if ( pAbc->pCex->iPo == -1 )
602  {
603  Abc_Print( 1, "Generated counter-example is INVALID.\n" );
604  ABC_FREE( pAbc->pCex );
605  }
606  else
607  {
608  Abc_Print( 1, "Returned counter-example successfully verified in ABC.\n" );
609  }
610  }
611  Vec_IntFreeP( &vCex );
612  }
613  // get AIG if present
614  pGia = Abc_ManReadAig( pFileOut, "aig:" );
615  if ( pGia != NULL )
616  {
617  Gia_ManStopP( &pAbc->pGia );
618  pAbc->pGia = pGia;
619  }
620  }
621 
622  // clean up
623  Util_SignalTmpFileRemove( pFileIn, fLeaveFiles );
624  Util_SignalTmpFileRemove( pFileOut, fLeaveFiles );
625 
626  ABC_FREE( pFileIn );
627  ABC_FREE( pFileOut );
628  return 0;
629 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
int Util_SignalTmpFile(const char *prefix, const char *suffix, char **out_name)
INCLUDES ///.
Definition: utilSignal.c:53
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
Gia_Man_t * Abc_ManReadAig(char *pFileName, char *pToken)
Definition: cmdPlugin.c:359
int Abc_ManReadStatus(char *pFileName, char *pToken)
Definition: cmdPlugin.c:254
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
int Gia_ManFindFailedPoCex(Gia_Man_t *pAig, Abc_Cex_t *p, int nOutputs)
Definition: giaCex.c:87
void Gia_ManStopP(Gia_Man_t **p)
Definition: giaMan.c:177
int strcmp()
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
Vec_Int_t * Abc_ManReadBinary(char *pFileName, char *pToken)
Definition: cmdPlugin.c:185
static void Vec_StrAppend(Vec_Str_t *p, const char *pString)
Definition: vecStr.h:645
Vec_Int_t * Abc_ManExpandCex(Gia_Man_t *pGia, Vec_Int_t *vCex)
Definition: cmdPlugin.c:286
void Util_SignalTmpFileRemove(const char *fname, int fLeave)
Definition: utilSignal.c:58
int Extra_FileSize(char *pFileName)
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
int Abc_ManReadInteger(char *pFileName, char *pToken)
Definition: cmdPlugin.c:227
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
void Gia_AigerWrite(Gia_Man_t *p, char *pFileName, int fWriteSymbols, int fCompact)
Definition: giaAiger.c:1024
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define ABC_FREE(obj)
Definition: abc_global.h:232
Definition: gia.h:95
ABC_NAMESPACE_IMPL_START int Util_SignalSystem(const char *cmd)
DECLARATIONS ///.
Definition: utilSignal.c:46
ABC_NAMESPACE_IMPL_START char * Abc_GetBinaryName(Abc_Frame_t *pAbc, int argc, char **argv)
DECLARATIONS ///.
Definition: cmdPlugin.c:130
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
ABC_INT64_T abctime
Definition: abc_global.h:278
Abc_Cex_t * Abc_CexCreate(int nRegs, int nPis, int *pArray, int iFrame, int iPo, int fSkipRegs)
Definition: utilCex.c:110
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
static unsigned textToBin ( char *  text,
unsigned long  text_sz 
)
static

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

Synopsis [Procedure to convert the AIG from text into binary form.]

Description []

SideEffects []

SeeAlso []

Definition at line 330 of file cmdPlugin.c.

331 {
332  char* dst = text;
333  const char* src = text;
334  unsigned sz, i;
335  sscanf(src, "%u ", &sz);
336  while(*src++ != ' ');
337  for ( i = 0; i < sz; i += 3 )
338  {
339  dst[0] = (char)( (unsigned)src[0] - '0') | (((unsigned)src[1] - '0') << 6);
340  dst[1] = (char)(((unsigned)src[1] - '0') >> 2) | (((unsigned)src[2] - '0') << 4);
341  dst[2] = (char)(((unsigned)src[2] - '0') >> 4) | (((unsigned)src[3] - '0') << 2);
342  src += 4;
343  dst += 3;
344  }
345  return sz;
346 }