cbaCom.c 22.2 KB
Newer Older
1 2 3 4 5 6
/**CFile****************************************************************

  FileName    [cbaCom.c]

  SystemName  [ABC: Logic synthesis and verification system.]

7
  PackageName [Hierarchical word-level netlist.]
8

9
  Synopsis    [Command handlers.]
10 11 12 13 14 15 16 17 18 19 20 21

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 1.0. Started - November 29, 2014.]

  Revision    [$Id: cbaCom.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]

***********************************************************************/

#include "cba.h"
22
#include "proof/cec/cec.h"
23 24 25 26 27 28 29 30 31 32 33
#include "base/main/mainInt.h"

ABC_NAMESPACE_IMPL_START

////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

static int  Cba_CommandRead     ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int  Cba_CommandWrite    ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int  Cba_CommandPs       ( Abc_Frame_t * pAbc, int argc, char ** argv );
34 35
static int  Cba_CommandPut      ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int  Cba_CommandGet      ( Abc_Frame_t * pAbc, int argc, char ** argv );
36
static int  Cba_CommandClp      ( Abc_Frame_t * pAbc, int argc, char ** argv );
37
static int  Cba_CommandBlast    ( Abc_Frame_t * pAbc, int argc, char ** argv );
38
static int  Cba_CommandCec      ( Abc_Frame_t * pAbc, int argc, char ** argv );
39 40
static int  Cba_CommandTest     ( Abc_Frame_t * pAbc, int argc, char ** argv );

41 42 43
static inline Cba_Man_t * Cba_AbcGetMan( Abc_Frame_t * pAbc )                   { return (Cba_Man_t *)pAbc->pAbcCba;                        }
static inline void        Cba_AbcFreeMan( Abc_Frame_t * pAbc )                  { if ( pAbc->pAbcCba ) Cba_ManFree(Cba_AbcGetMan(pAbc));    }
static inline void        Cba_AbcUpdateMan( Abc_Frame_t * pAbc, Cba_Man_t * p ) { Cba_AbcFreeMan(pAbc); pAbc->pAbcCba = p;                  }
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

////////////////////////////////////////////////////////////////////////
///                     FUNCTION DEFINITIONS                         ///
////////////////////////////////////////////////////////////////////////

/**Function********************************************************************

  Synopsis    []

  Description []

  SideEffects []

  SeeAlso     []

******************************************************************************/
void Cba_Init( Abc_Frame_t * pAbc )
{
Alan Mishchenko committed
62 63 64 65 66 67 68 69 70
    Cmd_CommandAdd( pAbc, "New word level", ":read",       Cba_CommandRead,      0 );
    Cmd_CommandAdd( pAbc, "New word level", ":write",      Cba_CommandWrite,     0 );
    Cmd_CommandAdd( pAbc, "New word level", ":ps",         Cba_CommandPs,        0 );
    Cmd_CommandAdd( pAbc, "New word level", ":put",        Cba_CommandPut,       0 );
    Cmd_CommandAdd( pAbc, "New word level", ":get",        Cba_CommandGet,       0 );
    Cmd_CommandAdd( pAbc, "New word level", ":clp",        Cba_CommandClp,       0 );
    Cmd_CommandAdd( pAbc, "New word level", ":blast",      Cba_CommandBlast,     0 );
    Cmd_CommandAdd( pAbc, "New word level", ":cec",        Cba_CommandCec,       0 );
    Cmd_CommandAdd( pAbc, "New word level", ":test",       Cba_CommandTest,      0 );
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
}

/**Function********************************************************************

  Synopsis    []

  Description []

  SideEffects []

  SeeAlso     []

******************************************************************************/
void Cba_End( Abc_Frame_t * pAbc )
{
86
    Cba_AbcFreeMan( pAbc );
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
}


/**Function********************************************************************

  Synopsis    []

  Description []

  SideEffects []

  SeeAlso     []

******************************************************************************/
int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
{
    FILE * pFile;
104
    Cba_Man_t * p = NULL;
105
    char * pFileName = NULL;
106
    int c, fTest = 0, fDfs = 0, fVerbose = 0;
107
    Extra_UtilGetoptReset();
108
    while ( ( c = Extra_UtilGetopt( argc, argv, "tdvh" ) ) != EOF )
109 110 111
    {
        switch ( c )
        {
112 113
        case 't':
            fTest ^= 1;
114
            break;
115 116 117
        case 'd':
            fDfs ^= 1;
            break;
118 119 120 121 122 123 124 125 126 127 128 129 130 131
        case 'v':
            fVerbose ^= 1;
            break;
        case 'h':
            goto usage;
        default:
            goto usage;
        }
    }
    if ( argc != globalUtilOptind + 1 )
    {
        printf( "Cba_CommandRead(): Input file name should be given on the command line.\n" );
        return 0;
    }
132
        // get the file name
133 134 135 136
    pFileName = argv[globalUtilOptind];
    if ( (pFile = fopen( pFileName, "r" )) == NULL )
    {
        Abc_Print( 1, "Cannot open input file \"%s\". ", pFileName );
137
        if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".v", ".blif", ".smt", ".cba", NULL )) )
138 139 140 141 142
            Abc_Print( 1, "Did you mean \"%s\"?", pFileName );
        Abc_Print( 1, "\n" );
        return 0;
    }
    fclose( pFile );
143
    if ( fTest )
144
    {
145 146 147 148 149
        if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" )  )
            Prs_ManReadBlifTest( pFileName );
        else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" )  )
            Prs_ManReadVerilogTest( pFileName );
        else 
150
        {
151 152
            printf( "Unrecognized input file extension.\n" );
            return 0;
153
        }
154
        return 0;
155
    }
156 157
    if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" )  )
        p = Cba_ManReadBlif( pFileName );
158
    else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" )  )
159
        p = Cba_ManReadVerilog( pFileName );
160 161
    else if ( !strcmp( Extra_FileNameExtension(pFileName), "cba" )  )
        p = Cba_ManReadCba( pFileName );
162 163 164 165 166
    else 
    {
        printf( "Unrecognized input file extension.\n" );
        return 0;
    }
167 168 169 170 171 172
    if ( fDfs )
    {
        Cba_Man_t * pTemp;
        p = Cba_ManDup( pTemp = p, Cba_NtkCollectDfs );
        Cba_ManFree( pTemp );
    }
173
    Cba_AbcUpdateMan( pAbc, p );
174 175
    return 0;
usage:
Alan Mishchenko committed
176
    Abc_Print( -2, "usage: :read [-tdvh] <file_name>\n" );
177
    Abc_Print( -2, "\t         reads hierarchical design\n" );
178
    Abc_Print( -2, "\t-t     : toggle testing the parser [default = %s]\n", fTest? "yes": "no" );
179
    Abc_Print( -2, "\t-d     : toggle computing DFS ordering [default = %s]\n", fDfs? "yes": "no" );
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
    Abc_Print( -2, "\t-h     : print the command usage\n");
    return 1;
}

/**Function********************************************************************

  Synopsis    []

  Description []

  SideEffects []

  SeeAlso     []

******************************************************************************/
int Cba_CommandWrite( Abc_Frame_t * pAbc, int argc, char ** argv )
{
198
    Cba_Man_t * p = Cba_AbcGetMan(pAbc);
199
    char * pFileName = NULL;
200
    int fInclineCats =    0;
201 202
    int c, fVerbose  =    0;
    Extra_UtilGetoptReset();
203
    while ( ( c = Extra_UtilGetopt( argc, argv, "cvh" ) ) != EOF )
204 205 206
    {
        switch ( c )
        {
207 208
        case 'c':
            fInclineCats ^= 1;
209
            break;
210 211 212 213 214 215 216 217 218
        case 'v':
            fVerbose ^= 1;
            break;
        case 'h':
            goto usage;
        default:
            goto usage;
        }
    }
219
    if ( p == NULL )
220 221 222 223
    {
        Abc_Print( 1, "Cba_CommandWrite(): There is no current design.\n" );
        return 0;
    }
224

225
    if ( argc == globalUtilOptind + 1 )
226
        pFileName = argv[globalUtilOptind];
227
    else if ( argc == globalUtilOptind && p )
228 229 230 231
    {
        pFileName = Extra_FileNameGenericAppend( Cba_ManSpec(p) ? Cba_ManSpec(p) : Cba_ManName(p), "_out.v" );
        printf( "Generated output file name \"%s\".\n", pFileName );
    }
232
    else 
233 234 235 236
    {
        printf( "Output file name should be given on the command line.\n" );
        return 0;
    }
237 238 239 240
    // perform writing
    if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" )  )
        Cba_ManWriteBlif( pFileName, p );
    else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" )  )
241
        Cba_ManWriteVerilog( pFileName, p, fInclineCats );
242 243
    else if ( !strcmp( Extra_FileNameExtension(pFileName), "cba" )  )
        Cba_ManWriteCba( pFileName, p );
244 245 246 247 248
    else 
    {
        printf( "Unrecognized output file extension.\n" );
        return 0;
    }
249 250
    return 0;
usage:
Alan Mishchenko committed
251
    Abc_Print( -2, "usage: :write [-cvh]\n" );
252
    Abc_Print( -2, "\t         writes the design into a file in BLIF or Verilog\n" );
253
    Abc_Print( -2, "\t-c     : toggle inlining input concatenations [default = %s]\n",  fInclineCats? "yes": "no" );
254
    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",  fVerbose? "yes": "no" );
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
    Abc_Print( -2, "\t-h     : print the command usage\n");
    return 1;
}


/**Function********************************************************************

  Synopsis    []

  Description []

  SideEffects []

  SeeAlso     []

******************************************************************************/
int Cba_CommandPs( Abc_Frame_t * pAbc, int argc, char ** argv )
{
273
    Cba_Man_t * p = Cba_AbcGetMan(pAbc);
274 275 276 277 278
    int nModules     = 0;
    int fShowMulti   = 0;
    int fShowAdder   = 0;
    int fDistrib     = 0;
    int c, fVerbose  = 0;
279
    Extra_UtilGetoptReset();
280
    while ( ( c = Extra_UtilGetopt( argc, argv, "Mmadvh" ) ) != EOF )
281 282 283
    {
        switch ( c )
        {
284 285 286 287 288 289 290 291 292 293 294
        case 'M':
            if ( globalUtilOptind >= argc )
            {
                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
                goto usage;
            }
            nModules = atoi(argv[globalUtilOptind]);
            globalUtilOptind++;
            if ( nModules < 0 )
                goto usage;
            break;
295 296 297 298 299 300 301 302 303
        case 'm':
            fShowMulti ^= 1;
            break;
        case 'a':
            fShowAdder ^= 1;
            break;
        case 'd':
            fDistrib ^= 1;
            break;
304 305 306 307 308 309 310 311 312
        case 'v':
            fVerbose ^= 1;
            break;
        case 'h':
            goto usage;
        default:
            goto usage;
        }
    }
313
    if ( p == NULL )
314 315 316 317
    {
        Abc_Print( 1, "Cba_CommandPs(): There is no current design.\n" );
        return 0;
    }
318 319 320 321 322 323 324 325 326 327
    if ( nModules )
    {
        Cba_ManPrintStats( p, nModules, fVerbose );
        return 0;
    }
    Cba_NtkPrintStatsFull( Cba_ManRoot(p), fDistrib, fVerbose );
    if ( fShowMulti )
        Cba_NtkPrintNodes( Cba_ManRoot(p), CBA_BOX_MUL );
    if ( fShowAdder )
        Cba_NtkPrintNodes( Cba_ManRoot(p), CBA_BOX_ADD );
328 329
    return 0;
usage:
Alan Mishchenko committed
330
    Abc_Print( -2, "usage: :ps [-M num] [-madvh]\n" );
331
    Abc_Print( -2, "\t         prints statistics\n" );
332
    Abc_Print( -2, "\t-M num : the number of first modules to report [default = %d]\n", nModules );
333 334 335
    Abc_Print( -2, "\t-m     : toggle printing multipliers [default = %s]\n",         fShowMulti? "yes": "no" );
    Abc_Print( -2, "\t-a     : toggle printing adders [default = %s]\n",              fShowAdder? "yes": "no" );
    Abc_Print( -2, "\t-d     : toggle printing distrubition [default = %s]\n",        fDistrib? "yes": "no" );
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
    Abc_Print( -2, "\t-h     : print the command usage\n");
    return 1;
}

/**Function********************************************************************

  Synopsis    []

  Description []

  SideEffects []

  SeeAlso     []

******************************************************************************/
352 353 354 355
int Cba_CommandPut( Abc_Frame_t * pAbc, int argc, char ** argv )
{
    Cba_Man_t * p = Cba_AbcGetMan(pAbc);
    Gia_Man_t * pGia = NULL;
356
    int c, fBarBufs = 1, fSeq = 0, fVerbose  = 0;
357
    Extra_UtilGetoptReset();
358
    while ( ( c = Extra_UtilGetopt( argc, argv, "bsvh" ) ) != EOF )
359 360 361
    {
        switch ( c )
        {
362 363 364
        case 'b':
            fBarBufs ^= 1;
            break;
365 366 367
        case 's':
            fSeq ^= 1;
            break;
368 369 370 371 372 373 374 375 376 377 378 379 380 381
        case 'v':
            fVerbose ^= 1;
            break;
        case 'h':
            goto usage;
        default:
            goto usage;
        }
    }
    if ( p == NULL )
    {
        Abc_Print( 1, "Cba_CommandPut(): There is no current design.\n" );
        return 0;
    }
382
    pGia = Cba_ManBlast( p, fBarBufs, fSeq, fVerbose );
383 384 385 386 387 388 389 390
    if ( pGia == NULL )
    {
        Abc_Print( 1, "Cba_CommandPut(): Conversion to AIG has failed.\n" );
        return 0;
    }
    Abc_FrameUpdateGia( pAbc, pGia );
    return 0;
usage:
Alan Mishchenko committed
391
    Abc_Print( -2, "usage: :put [-bsvh]\n" );
392 393
    Abc_Print( -2, "\t         extracts AIG from the hierarchical design\n" );
    Abc_Print( -2, "\t-b     : toggle using barrier buffers [default = %s]\n", fBarBufs? "yes": "no" );
394
    Abc_Print( -2, "\t-s     : toggle blasting sequential elements [default = %s]\n", fSeq? "yes": "no" );
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411
    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
    Abc_Print( -2, "\t-h     : print the command usage\n");
    return 1;
}

/**Function********************************************************************

  Synopsis    []

  Description []

  SideEffects []

  SeeAlso     []

******************************************************************************/
int Cba_CommandGet( Abc_Frame_t * pAbc, int argc, char ** argv )
412
{
413
    Cba_Man_t * pNew = NULL, * p = Cba_AbcGetMan(pAbc);
414
    int c, fMapped = 0, fVerbose  = 0;
415 416 417 418 419 420
    Extra_UtilGetoptReset();
    while ( ( c = Extra_UtilGetopt( argc, argv, "mvh" ) ) != EOF )
    {
        switch ( c )
        {
        case 'm':
421
            fMapped ^= 1;
422 423 424 425 426 427 428 429 430 431
            break;
        case 'v':
            fVerbose ^= 1;
            break;
        case 'h':
            goto usage;
        default:
            goto usage;
        }
    }
432 433 434 435 436
    if ( p == NULL )
    {
        Abc_Print( 1, "Cba_CommandGet(): There is no current design.\n" );
        return 0;
    }
437

438 439 440 441 442 443 444
    if ( fMapped )
    {
        if ( pAbc->pNtkCur == NULL )
        {
            Abc_Print( 1, "Cba_CommandGet(): There is no current mapped design.\n" );
            return 0;
        }
445
        pNew = Cba_ManInsertAbc( p, pAbc->pNtkCur );
446 447 448 449 450 451 452 453 454 455 456 457 458
    }
    else
    {
        if ( pAbc->pGia == NULL )
        {
            Abc_Print( 1, "Cba_CommandGet(): There is no current AIG.\n" );
            return 0;
        }
        pNew = Cba_ManInsertGia( p, pAbc->pGia );
    }
    Cba_AbcUpdateMan( pAbc, pNew );
    return 0;
usage:
Alan Mishchenko committed
459
    Abc_Print( -2, "usage: :get [-mvh]\n" );
460
    Abc_Print( -2, "\t         extracts AIG or mapped network into the hierarchical design\n" );
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477
    Abc_Print( -2, "\t-m     : toggle using mapped network from main-space [default = %s]\n", fMapped? "yes": "no" );
    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
    Abc_Print( -2, "\t-h     : print the command usage\n");
    return 1;
}

/**Function********************************************************************

  Synopsis    []

  Description []

  SideEffects []

  SeeAlso     []

******************************************************************************/
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
int Cba_CommandClp( Abc_Frame_t * pAbc, int argc, char ** argv )
{
    Cba_Man_t * pNew = NULL, * p = Cba_AbcGetMan(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;
        default:
            goto usage;
        }
    }
    if ( p == NULL )
    {
        Abc_Print( 1, "Cba_CommandGet(): There is no current design.\n" );
        return 0;
    }
501
    pNew = Cba_ManCollapse( p );
502 503 504
    Cba_AbcUpdateMan( pAbc, pNew );
    return 0;
usage:
Alan Mishchenko committed
505
    Abc_Print( -2, "usage: :clp [-vh]\n" );
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522
    Abc_Print( -2, "\t         collapses the current hierarchical design\n" );
    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
    Abc_Print( -2, "\t-h     : print the command usage\n");
    return 1;
}

/**Function********************************************************************

  Synopsis    []

  Description []

  SideEffects []

  SeeAlso     []

******************************************************************************/
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
int Cba_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv )
{
    Gia_Man_t * pNew = NULL;
    Cba_Man_t * p = Cba_AbcGetMan(pAbc);
    int c, fSeq = 0, fVerbose  = 0;
    Extra_UtilGetoptReset();
    while ( ( c = Extra_UtilGetopt( argc, argv, "svh" ) ) != EOF )
    {
        switch ( c )
        {
        case 's':
            fSeq ^= 1;
            break;
        case 'v':
            fVerbose ^= 1;
            break;
        case 'h':
            goto usage;
        default:
            goto usage;
        }
    }
    if ( p == NULL )
    {
        Abc_Print( 1, "Cba_CommandBlast(): There is no current design.\n" );
        return 0;
    }
    pNew = Cba_ManBlast( p, 0, fSeq, fVerbose );
    if ( pNew == NULL )
    {
        Abc_Print( 1, "Cba_CommandBlast(): Bit-blasting has failed.\n" );
        return 0;
    }
    Abc_FrameUpdateGia( pAbc, pNew );
    return 0;
usage:
Alan Mishchenko committed
559
    Abc_Print( -2, "usage: :blast [-svh]\n" );
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
    Abc_Print( -2, "\t         performs bit-blasting of the word-level design\n" );
    Abc_Print( -2, "\t-s     : toggle blasting sequential elements [default = %s]\n", fSeq? "yes": "no" );
    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
    Abc_Print( -2, "\t-h     : print the command usage\n");
    return 1;
}

/**Function********************************************************************

  Synopsis    []

  Description []

  SideEffects []

  SeeAlso     []

******************************************************************************/
578 579
int Cba_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
{
580
    Cba_Man_t * p = Cba_AbcGetMan(pAbc), * pTemp;
581
    Gia_Man_t * pFirst, * pSecond, * pMiter;
582
    Cec_ParCec_t ParsCec, * pPars = &ParsCec;
583
    char * pFileName, * pStr, ** pArgvNew;
584
    int c, nArgcNew, fDumpMiter = 0;
585 586 587 588 589 590 591 592
    FILE * pFile;
    Cec_ManCecSetDefaultParams( pPars );
    Extra_UtilGetoptReset();
    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
    {
        switch ( c )
        {
        case 'v':
593
            pPars->fVerbose ^= 1;
594 595 596 597 598 599 600 601
            break;
        case 'h':
            goto usage;
        default:
            goto usage;
        }
    }
    if ( p == NULL )
602
    {
603
        Abc_Print( 1, "Cba_CommandCec(): There is no current design.\n" );
604 605
        return 0;
    }
606

607 608 609
    pArgvNew = argv + globalUtilOptind;
    nArgcNew = argc - globalUtilOptind;
    if ( nArgcNew != 1 )
610
    {
611 612 613 614 615
        if ( p->pSpec == NULL )
        {
            Abc_Print( -1, "File name is not given on the command line.\n" );
            return 1;
        }
616
        pFileName = p->pSpec;
617 618
    }
    else
619
        pFileName = pArgvNew[0];
620
    // fix the wrong symbol
621
    for ( pStr = pFileName; *pStr; pStr++ )
622 623
        if ( *pStr == '>' )
            *pStr = '\\';
624
    if ( (pFile = fopen( pFileName, "r" )) == NULL )
625
    {
626 627 628
        Abc_Print( -1, "Cannot open input file \"%s\". ", pFileName );
        if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".v", ".blif", NULL, NULL, NULL )) )
            Abc_Print( 1, "Did you mean \"%s\"?", pFileName );
629 630 631 632
        Abc_Print( 1, "\n" );
        return 1;
    }
    fclose( pFile );
633

634
    // extract AIG from the current design
635
    pFirst = Cba_ManBlast( p, 0, 0, 0 );
636 637 638 639
    if ( pFirst == NULL )
    {
        Abc_Print( -1, "Extracting AIG from the current design has failed.\n" );
        return 0;
640
    }
641
    // extract AIG from the second design
642 643 644 645 646 647 648

    if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" )  )
        pTemp = Cba_ManReadBlif( pFileName );
    else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" )  )
        pTemp = Cba_ManReadVerilog( pFileName );
    else if ( !strcmp( Extra_FileNameExtension(pFileName), "cba" )  )
        pTemp = Cba_ManReadCba( pFileName );
649
    else assert( 0 );
650
    pSecond = Cba_ManBlast( pTemp, 0, 0, 0 );
651
    Cba_ManFree( pTemp );
652
    if ( pSecond == NULL )
653
    {
654 655
        Gia_ManStop( pFirst );
        Abc_Print( -1, "Extracting AIG from the original design has failed.\n" );
656 657
        return 0;
    }
658 659 660 661 662 663 664
    // compute the miter
    pMiter = Gia_ManMiter( pFirst, pSecond, 0, 1, 0, 0, pPars->fVerbose );
    if ( pMiter )
    {
        if ( fDumpMiter )
        {
            Abc_Print( 0, "The verification miter is written into file \"%s\".\n", "cec_miter.aig" );
665
            Gia_AigerWrite( pMiter, "cec_miter.aig", 0, 0, 0 );
666 667 668 669 670 671 672
        }
        pAbc->Status = Cec_ManVerify( pMiter, pPars );
        //Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexComb );
        Gia_ManStop( pMiter );
    }
    Gia_ManStop( pFirst );
    Gia_ManStop( pSecond );
673 674
    return 0;
usage:
Alan Mishchenko committed
675
    Abc_Print( -2, "usage: :cec [-vh]\n" );
676
    Abc_Print( -2, "\t         combinational equivalence checking\n" );
677
    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694
    Abc_Print( -2, "\t-h     : print the command usage\n");
    return 1;
}

/**Function********************************************************************

  Synopsis    []

  Description []

  SideEffects []

  SeeAlso     []

******************************************************************************/
int Cba_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
{
695
    Cba_Man_t * p = Cba_AbcGetMan(pAbc);
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710
    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;
        default:
            goto usage;
        }
    }
711
    if ( p == NULL )
712 713 714 715 716 717
    {
        Abc_Print( 1, "Cba_CommandTest(): There is no current design.\n" );
        return 0;
    }
    return 0;
usage:
Alan Mishchenko committed
718
    Abc_Print( -2, "usage: :test [-vh]\n" );
719 720 721 722 723 724 725 726 727 728 729 730 731
    Abc_Print( -2, "\t         experiments with word-level networks\n" );
    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
    Abc_Print( -2, "\t-h     : print the command usage\n");
    return 1;
}

////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////


ABC_NAMESPACE_IMPL_END