cbaPrs.h 20.9 KB
Newer Older
1 2 3 4 5 6
/**CFile****************************************************************

  FileName    [cbaPrs.h]

  SystemName  [ABC: Logic synthesis and verification system.]

7
  PackageName [Hierarchical word-level netlist.]
8

9
  Synopsis    [Parser declarations.]
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

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

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

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

#ifndef ABC__base__prs__prs_h
#define ABC__base__prs__prs_h


////////////////////////////////////////////////////////////////////////
///                          INCLUDES                                ///
////////////////////////////////////////////////////////////////////////

29 30 31
#include "aig/gia/gia.h"
#include "misc/util/utilNam.h"

32 33 34 35 36 37
////////////////////////////////////////////////////////////////////////
///                         PARAMETERS                               ///
////////////////////////////////////////////////////////////////////////

ABC_NAMESPACE_HEADER_START 

38 39 40 41 42 43 44
// Verilog keywords
typedef enum { 
    PRS_VER_NONE = 0,  // 0:  unused
    PRS_VER_INPUT,     // 1:  input
    PRS_VER_OUTPUT,    // 2:  output
    PRS_VER_INOUT,     // 3:  inout
    PRS_VER_WIRE,      // 4:  wire
45 46 47
    PRS_VER_REG,       // 5:  reg
    PRS_VER_MODULE,    // 6:  module
    PRS_VER_ASSIGN,    // 7:  assign
48
    PRS_VER_ALWAYS,    // 8:  always
49 50 51 52 53 54 55 56 57
    PRS_VER_FUNCTION,  // 9:  function
    PRS_VER_DEFPARAM,  // 10: defparam
    PRS_VER_BEGIN,     // 11: begin
    PRS_VER_END,       // 12: end
    PRS_VER_CASE,      // 13: case
    PRS_VER_ENDCASE,   // 14: endcase
    PRS_VER_SIGNED,    // 15: signed
    PRS_VER_ENDMODULE, // 16: endmodule
    PRS_VER_UNKNOWN    // 17: unknown
58 59
} Cba_VerType_t;

60
// parser name types
61
typedef enum { 
62 63 64 65
    CBA_PRS_NAME = 0,  // 0:  name/variable
    CBA_PRS_SLICE,     // 1:  slice
    CBA_PRS_CONST,     // 2:  constant
    CBA_PRS_CONCAT,    // 3:  concatentation
66
} Prs_ManType_t; 
67 68 69 70 71

////////////////////////////////////////////////////////////////////////
///                         BASIC TYPES                              ///
////////////////////////////////////////////////////////////////////////

72
// network
73 74
typedef struct Prs_Ntk_t_ Prs_Ntk_t;
struct Prs_Ntk_t_
75
{
76
    // general info
77 78 79 80 81 82 83 84 85 86
    int             iModuleName;
    unsigned        fMapped : 1;
    unsigned        fSlices : 1;
    unsigned        fHasC0s : 1;
    unsigned        fHasC1s : 1;
    unsigned        fHasCXs : 1;
    unsigned        fHasCZs : 1;
    Abc_Nam_t *     pStrs;
    Abc_Nam_t *     pFuns;
    Hash_IntMan_t * vHash;
87
    // interface
88
    Vec_Int_t       vOrder;     // order of signals
89
    // signal names
90 91 92 93
    Vec_Int_t       vInouts;    // inouts 
    Vec_Int_t       vInputs;    // inputs 
    Vec_Int_t       vOutputs;   // outputs
    Vec_Int_t       vWires;     // wires  
94
    // signal ranges
95 96 97 98
    Vec_Int_t       vInoutsR;   // inouts 
    Vec_Int_t       vInputsR;   // inputs 
    Vec_Int_t       vOutputsR;  // outputs
    Vec_Int_t       vWiresR;    // wires  
99
    // slices/concatenations/objects
100 101 102 103
    Vec_Int_t       vSlices;    // NameId + RangeId
    Vec_Int_t       vConcats;   // array of NameId/SliceId/ConstId
    Vec_Int_t       vBoxes;     // ModuleId + InstId + array of pairs {FormNameId, ActSignalId(NameId/SliceId/ConstId/ConcatId)}
    Vec_Int_t       vObjs;      // box handles
104 105
};

106
// parser
107 108
typedef struct Prs_Man_t_ Prs_Man_t;
struct Prs_Man_t_
109 110
{
    // input data
111 112 113 114 115 116 117 118 119
    char *          pName;       // file name
    char *          pBuffer;     // file contents
    char *          pLimit;      // end of file
    char *          pCur;        // current position
    Abc_Nam_t *     pStrs;       // string manager
    Abc_Nam_t *     pFuns;       // cover manager
    Hash_IntMan_t * vHash;       // variable ranges
    Prs_Ntk_t *     pNtk;        // current network
    Vec_Ptr_t *     vNtks;       // input networks
120
    // temporary data
121 122 123
    Vec_Str_t       vCover;      // one SOP cover
    Vec_Int_t       vTemp;       // array of tokens
    Vec_Int_t       vTemp2;      // array of tokens
124 125
    Vec_Int_t       vTemp3;      // array of tokens
    Vec_Int_t       vTemp4;      // array of tokens
Alan Mishchenko committed
126
    // statistics
127 128 129
    Vec_Int_t       vKnown;
    Vec_Int_t       vFailed;
    Vec_Int_t       vSucceeded;
130
    // error handling
131
    int             nOpens;      // open port counter
132
    int             fUsingTemp2; // vTemp2 is in use
133 134 135
    int             FuncNameId;  // temp value
    int             FuncRangeId; // temp value
    char ErrorStr[1000];         // error
136 137
};

138
static inline Prs_Ntk_t * Prs_ManNtk( Vec_Ptr_t * vPrs, int i )        { return i >= 0 && i < Vec_PtrSize(vPrs) ? (Prs_Ntk_t *)Vec_PtrEntry(vPrs, i) : NULL; }
139
static inline Prs_Ntk_t * Prs_ManRoot( Vec_Ptr_t * vPrs )              { return Prs_ManNtk(vPrs, 0);                             }
Alan Mishchenko committed
140
static inline Abc_Nam_t * Prs_ManNameMan( Vec_Ptr_t * vPrs )           { return Prs_ManRoot(vPrs)->pStrs;                        }
141
static inline Abc_Nam_t * Prs_ManFuncMan( Vec_Ptr_t * vPrs )           { return Prs_ManRoot(vPrs)->pFuns;                        }
142 143 144 145 146 147 148 149

static inline int         Prs_NtkId( Prs_Ntk_t * p )                   { return p->iModuleName;                                  }
static inline int         Prs_NtkPioNum( Prs_Ntk_t * p )               { return Vec_IntSize(&p->vInouts);                        }
static inline int         Prs_NtkPiNum( Prs_Ntk_t * p )                { return Vec_IntSize(&p->vInputs);                        }
static inline int         Prs_NtkPoNum( Prs_Ntk_t * p )                { return Vec_IntSize(&p->vOutputs);                       }
static inline int         Prs_NtkBoxNum( Prs_Ntk_t * p )               { return Vec_IntSize(&p->vObjs);                          }
static inline int         Prs_NtkObjNum( Prs_Ntk_t * p )               { return Prs_NtkPioNum(p) + Prs_NtkPiNum(p) + Prs_NtkPoNum(p) + Prs_NtkBoxNum(p); }
static inline char *      Prs_NtkStr( Prs_Ntk_t * p, int h )           { return Abc_NamStr(p->pStrs, h);                         }
150 151
static inline char *      Prs_NtkSop( Prs_Ntk_t * p, int h )           { return Abc_NamStr(p->pFuns, h);                         }
static inline char *      Prs_NtkConst( Prs_Ntk_t * p, int h )         { return Abc_NamStr(p->pFuns, h);                         }
152 153
static inline char *      Prs_NtkName( Prs_Ntk_t * p )                 { return Prs_NtkStr(p, Prs_NtkId(p));                     }
static inline int         Prs_NtkSigName( Prs_Ntk_t * p, int i )       { if (!p->fSlices) return i; assert(Abc_Lit2Att2(i) == CBA_PRS_NAME); return Abc_Lit2Var2(i); }
154
static inline int         Ptr_NtkRangeSize( Prs_Ntk_t * p, int h )     { int l = Hash_IntObjData0(p->vHash, h), r = Hash_IntObjData1(p->vHash, h); return 1 + (l > r ? l-r : r-l); }
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183

static inline int         Prs_SliceName( Prs_Ntk_t * p, int h )        { return Vec_IntEntry(&p->vSlices, h);                    }
static inline int         Prs_SliceRange( Prs_Ntk_t * p, int h )       { return Vec_IntEntry(&p->vSlices, h+1);                  }

static inline int         Prs_CatSize( Prs_Ntk_t * p, int h )          { return Vec_IntEntry(&p->vConcats, h);                   }
static inline int *       Prs_CatArray( Prs_Ntk_t * p, int h )         { return Vec_IntEntryP(&p->vConcats, h+1);                }
static inline Vec_Int_t * Prs_CatSignals( Prs_Ntk_t * p, int h )       { static Vec_Int_t V; V.nSize = V.nCap = Prs_CatSize(p, h); V.pArray = Prs_CatArray(p, h); return &V; }

static inline int         Prs_BoxHand( Prs_Ntk_t * p, int i )          { return Vec_IntEntry(&p->vObjs, i);                      }
static inline int         Prs_BoxSize( Prs_Ntk_t * p, int i )          { return Vec_IntEntry(&p->vBoxes, Prs_BoxHand(p, i))-2;   }
static inline int         Prs_BoxIONum( Prs_Ntk_t * p, int i )         { return Prs_BoxSize(p, i) / 2;                           }
static inline int         Prs_BoxNtk( Prs_Ntk_t * p, int i )           { return Vec_IntEntry(&p->vBoxes, Prs_BoxHand(p, i)+1);   }
static inline void        Prs_BoxSetNtk( Prs_Ntk_t * p, int i, int m ) { Vec_IntWriteEntry(&p->vBoxes, Prs_BoxHand(p, i)+1, m);  }
static inline int         Prs_BoxName( Prs_Ntk_t * p, int i )          { return Vec_IntEntry(&p->vBoxes, Prs_BoxHand(p, i)+2);   }
static inline int         Prs_BoxIsNode( Prs_Ntk_t * p, int i )        { return!Vec_IntEntry(&p->vBoxes, Prs_BoxHand(p, i)+3);   } // no formal names
static inline int *       Prs_BoxArray( Prs_Ntk_t * p, int i )         { return Vec_IntEntryP(&p->vBoxes, Prs_BoxHand(p, i)+3);  }
static inline Vec_Int_t * Prs_BoxSignals( Prs_Ntk_t * p, int i )       { static Vec_Int_t V; V.nSize = V.nCap = Prs_BoxSize(p, i); V.pArray = Prs_BoxArray(p, i); return &V; }

#define Prs_ManForEachNameVec( vVec, p, pName, i )   \
    for ( i = 0; (i < Vec_IntSize(vVec)) && ((pName) = Abc_NamStr(p->pStrs, Vec_IntEntry(vVec,i))); i++ )

#define Prs_NtkForEachPio( p, NameId, i )            \
    for ( i = 0; i < Prs_NtkPioNum(p) && ((NameId) = Vec_IntEntry(&p->vInouts, i)); i++ )
#define Prs_NtkForEachPi( p, NameId, i )             \
    for ( i = 0; i < Prs_NtkPiNum(p) && ((NameId) = Vec_IntEntry(&p->vInputs, i)); i++ )
#define Prs_NtkForEachPo( p, NameId, i )             \
    for ( i = 0; i < Prs_NtkPoNum(p) && ((NameId) = Vec_IntEntry(&p->vOutputs, i)); i++ )
#define Prs_NtkForEachBox( p, vVec, i )              \
    for ( i = 0; i < Prs_NtkBoxNum(p) && ((vVec) = Prs_BoxSignals(p, i)); i++ )
184 185 186 187 188 189

////////////////////////////////////////////////////////////////////////
///                      MACRO DEFINITIONS                           ///
////////////////////////////////////////////////////////////////////////

// create error message
190
static inline int Prs_ManErrorSet( Prs_Man_t * p, char * pError, int Value )
191 192
{
    assert( !p->ErrorStr[0] );
Alan Mishchenko committed
193
    sprintf( p->ErrorStr, "%s", pError );
194 195
    return Value;
}
Alan Mishchenko committed
196
// clear error message
197
static inline void Prs_ManErrorClear( Prs_Man_t * p )
Alan Mishchenko committed
198 199 200
{
    p->ErrorStr[0] = '\0';
}
201
// print error message
202
static inline int Prs_ManErrorPrint( Prs_Man_t * p )
203 204 205 206 207 208 209 210 211
{
    char * pThis; int iLine = 0;
    if ( !p->ErrorStr[0] ) return 1;
    for ( pThis = p->pBuffer; pThis < p->pCur; pThis++ )
        iLine += (int)(*pThis == '\n');
    printf( "Line %d: %s\n", iLine, p->ErrorStr );
    return 0;
}

212 213 214 215 216 217 218 219
// parsing network
static inline void Prs_ManInitializeNtk( Prs_Man_t * p, int iName, int fSlices )
{
    assert( p->pNtk == NULL );
    p->pNtk = ABC_CALLOC( Prs_Ntk_t, 1 );
    p->pNtk->iModuleName = iName;
    p->pNtk->fSlices = fSlices;
    p->pNtk->pStrs = Abc_NamRef( p->pStrs );
220
    p->pNtk->pFuns = Abc_NamRef( p->pFuns );
221
    p->pNtk->vHash = Hash_IntManRef( p->vHash );
222 223 224
    Vec_PtrPush( p->vNtks, p->pNtk );
}
static inline void Prs_ManFinalizeNtk( Prs_Man_t * p )
225
{
226 227
    assert( p->pNtk != NULL );
    p->pNtk = NULL;
228 229
}

230
static inline int Prs_ManNewStrId( Prs_Man_t * p, const char * format, ...  )
231
{
232 233
    Abc_Nam_t * pStrs = p->pStrs;
    Vec_Str_t * vBuf = Abc_NamBuffer( pStrs );
234 235 236 237 238 239 240 241 242 243 244
    int nAdded, nSize = 1000; 
    va_list args;   va_start( args, format );
    Vec_StrGrow( vBuf, Vec_StrSize(vBuf) + nSize );
    nAdded = vsnprintf( Vec_StrLimit(vBuf), nSize, format, args );
    if ( nAdded > nSize )
    {
        Vec_StrGrow( vBuf, Vec_StrSize(vBuf) + nAdded + nSize );
        nSize = vsnprintf( Vec_StrLimit(vBuf), nAdded, format, args );
        assert( nSize == nAdded );
    }
    va_end( args );
245
    return Abc_NamStrFindOrAddLim( pStrs, Vec_StrLimit(vBuf), Vec_StrLimit(vBuf) + nAdded, NULL );
246 247
}

248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
// parsing slice/concatentation/box
static inline int Prs_NtkAddSlice( Prs_Ntk_t * p, int Name, int Range )
{
    int Value = Vec_IntSize(&p->vSlices);
    Vec_IntPushTwo( &p->vSlices, Name, Range );
    return Value;
}
static inline int Prs_NtkAddConcat( Prs_Ntk_t * p, Vec_Int_t * vTemp )
{
    int Value;
    if ( !(Vec_IntSize(&p->vConcats) & 1) )
        Vec_IntPush(&p->vConcats, -1);
    Value = Vec_IntSize(&p->vConcats);
    assert( Value & 1 );
    Vec_IntPush( &p->vConcats, Vec_IntSize(vTemp) );
    Vec_IntAppend( &p->vConcats, vTemp );
    return Value;
}
static inline void Prs_NtkAddBox( Prs_Ntk_t * p, int ModName, int InstName, Vec_Int_t * vTemp )
{
    int Value;
    assert( Vec_IntSize(vTemp) % 2 == 0 );
    if ( !(Vec_IntSize(&p->vBoxes) & 1) )
        Vec_IntPush(&p->vBoxes, -1);
    Value = Vec_IntSize(&p->vBoxes);
    assert( Value & 1 );
    Vec_IntPush( &p->vObjs, Value );
    // create entry
    Vec_IntPush( &p->vBoxes, Vec_IntSize(vTemp)+2 );
    Vec_IntPush( &p->vBoxes, ModName );
    Vec_IntPush( &p->vBoxes, InstName );
    Vec_IntAppend( &p->vBoxes, vTemp );
}
static inline char * Prs_ManLoadFile( char * pFileName, char ** ppLimit )
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
{
    char * pBuffer;
    int nFileSize, RetValue;
    FILE * pFile = fopen( pFileName, "rb" );
    if ( pFile == NULL )
    {
        printf( "Cannot open input file.\n" );
        return NULL;
    }
    // get the file size, in bytes
    fseek( pFile, 0, SEEK_END );  
    nFileSize = ftell( pFile );  
    // move the file current reading position to the beginning
    rewind( pFile ); 
    // load the contents of the file into memory
297
    pBuffer = ABC_ALLOC( char, nFileSize + 16 );
298 299
    pBuffer[0] = '\n';
    RetValue = fread( pBuffer+1, nFileSize, 1, pFile );
300
    fclose( pFile );
301
    // terminate the string with '\0'
302 303 304
    pBuffer[nFileSize + 1] = '\n';
    pBuffer[nFileSize + 2] = '\0';
    *ppLimit = pBuffer + nFileSize + 3;
305 306
    return pBuffer;
}
307
static inline Prs_Man_t * Prs_ManAlloc( char * pFileName )
308
{
309 310
    Prs_Man_t * p;
    p = ABC_CALLOC( Prs_Man_t, 1 );
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
    if ( pFileName )
    {
        char * pBuffer, * pLimit;
        pBuffer = Prs_ManLoadFile( pFileName, &pLimit );
        if ( pBuffer == NULL )
            return NULL;
        p->pName   = pFileName;
        p->pBuffer = pBuffer;
        p->pLimit  = pLimit;
        p->pCur    = pBuffer;
    }
    p->pStrs = Abc_NamStart( 1000, 24 );
    p->pFuns = Abc_NamStart( 100, 24 );
    p->vHash = Hash_IntManStart( 1000 );
    p->vNtks = Vec_PtrAlloc( 100 );
326 327
    return p;
}
328 329

static inline void Prs_NtkFree( Prs_Ntk_t * p )
330
{
331
    if ( p->pStrs ) Abc_NamDeref( p->pStrs );
332
    if ( p->pFuns ) Abc_NamDeref( p->pFuns );
333
    if ( p->vHash ) Hash_IntManDeref( p->vHash );
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
    Vec_IntErase( &p->vOrder );
    Vec_IntErase( &p->vInouts );
    Vec_IntErase( &p->vInputs );
    Vec_IntErase( &p->vOutputs );
    Vec_IntErase( &p->vWires );
    Vec_IntErase( &p->vInoutsR );
    Vec_IntErase( &p->vInputsR );
    Vec_IntErase( &p->vOutputsR );
    Vec_IntErase( &p->vWiresR );
    Vec_IntErase( &p->vSlices );
    Vec_IntErase( &p->vConcats );
    Vec_IntErase( &p->vBoxes );
    Vec_IntErase( &p->vObjs );
    ABC_FREE( p );
}
Alan Mishchenko committed
349

350 351 352 353 354 355 356 357
static inline void Prs_ManVecFree( Vec_Ptr_t * vPrs )
{
    Prs_Ntk_t * pNtk; int i;
    Vec_PtrForEachEntry( Prs_Ntk_t *, vPrs, pNtk, i )
        Prs_NtkFree( pNtk );
    Vec_PtrFree( vPrs );
}

358 359
static inline void Prs_ManFree( Prs_Man_t * p )
{
360
    if ( p->pStrs ) Abc_NamDeref( p->pStrs );
361
    if ( p->pFuns ) Abc_NamDeref( p->pFuns );
362
    if ( p->vHash ) Hash_IntManDeref( p->vHash );
363
    if ( p->vNtks ) Prs_ManVecFree( p->vNtks );
364
    // temporary
Alan Mishchenko committed
365 366 367
    Vec_StrErase( &p->vCover );
    Vec_IntErase( &p->vTemp );
    Vec_IntErase( &p->vTemp2 );
368 369
    Vec_IntErase( &p->vTemp3 );
    Vec_IntErase( &p->vTemp4 );
Alan Mishchenko committed
370 371 372
    Vec_IntErase( &p->vKnown );
    Vec_IntErase( &p->vFailed );
    Vec_IntErase( &p->vSucceeded );
373 374 375
    ABC_FREE( p->pBuffer );
    ABC_FREE( p );
}
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394

static inline int Prs_NtkMemory( Prs_Ntk_t * p )
{
    int nMem = sizeof(Prs_Ntk_t);
    nMem += Vec_IntMemory( &p->vOrder );
    nMem += Vec_IntMemory( &p->vInouts );
    nMem += Vec_IntMemory( &p->vInputs );
    nMem += Vec_IntMemory( &p->vOutputs );
    nMem += Vec_IntMemory( &p->vWires );
    nMem += Vec_IntMemory( &p->vInoutsR );
    nMem += Vec_IntMemory( &p->vInputsR );
    nMem += Vec_IntMemory( &p->vOutputsR );
    nMem += Vec_IntMemory( &p->vWiresR );
    nMem += Vec_IntMemory( &p->vSlices );
    nMem += Vec_IntMemory( &p->vBoxes );
    nMem += Vec_IntMemory( &p->vConcats );
    return nMem;
}
static inline int Prs_ManMemory( Vec_Ptr_t * vPrs )
395
{
396 397 398 399
    Prs_Ntk_t * pNtk; int i;
    int nMem = Vec_PtrMemory(vPrs);
    Vec_PtrForEachEntry( Prs_Ntk_t *, vPrs, pNtk, i )
        nMem += Prs_NtkMemory( pNtk );
Alan Mishchenko committed
400
    nMem += Abc_NamMemUsed(Prs_ManNameMan(vPrs));
401
    return nMem;
402
}
403

404

405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
/**Function*************************************************************

  Synopsis    [Other APIs.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
static inline Cba_ObjType_t Ptr_SopToType( char * pSop )
{
    if ( !strcmp(pSop, " 0\n") )         return CBA_BOX_CF;
    if ( !strcmp(pSop, " 1\n") )         return CBA_BOX_CT;
    if ( !strcmp(pSop, "1 1\n") )        return CBA_BOX_BUF;
    if ( !strcmp(pSop, "0 1\n") )        return CBA_BOX_INV;
    if ( !strcmp(pSop, "11 1\n") )       return CBA_BOX_AND;
    if ( !strcmp(pSop, "00 1\n") )       return CBA_BOX_NOR;
    if ( !strcmp(pSop, "00 0\n") )       return CBA_BOX_OR;
    if ( !strcmp(pSop, "-1 1\n1- 1\n") ) return CBA_BOX_OR;
    if ( !strcmp(pSop, "1- 1\n-1 1\n") ) return CBA_BOX_OR;
    if ( !strcmp(pSop, "01 1\n10 1\n") ) return CBA_BOX_XOR;
    if ( !strcmp(pSop, "10 1\n01 1\n") ) return CBA_BOX_XOR;
    if ( !strcmp(pSop, "11 1\n00 1\n") ) return CBA_BOX_XNOR;
    if ( !strcmp(pSop, "00 1\n11 1\n") ) return CBA_BOX_XNOR;
    if ( !strcmp(pSop, "10 1\n") )       return CBA_BOX_SHARP;
    if ( !strcmp(pSop, "01 1\n") )       return CBA_BOX_SHARPL;
    assert( 0 );
    return CBA_OBJ_NONE;
}
static inline char * Ptr_SopToTypeName( char * pSop )
{
    if ( !strcmp(pSop, " 0\n") )         return "CBA_BOX_C0";
    if ( !strcmp(pSop, " 1\n") )         return "CBA_BOX_C1";
    if ( !strcmp(pSop, "1 1\n") )        return "CBA_BOX_BUF";
    if ( !strcmp(pSop, "0 1\n") )        return "CBA_BOX_INV";
    if ( !strcmp(pSop, "11 1\n") )       return "CBA_BOX_AND";
    if ( !strcmp(pSop, "00 1\n") )       return "CBA_BOX_NOR";
    if ( !strcmp(pSop, "00 0\n") )       return "CBA_BOX_OR";
    if ( !strcmp(pSop, "-1 1\n1- 1\n") ) return "CBA_BOX_OR";
    if ( !strcmp(pSop, "1- 1\n-1 1\n") ) return "CBA_BOX_OR";
    if ( !strcmp(pSop, "01 1\n10 1\n") ) return "CBA_BOX_XOR";
    if ( !strcmp(pSop, "10 1\n01 1\n") ) return "CBA_BOX_XOR";
    if ( !strcmp(pSop, "11 1\n00 1\n") ) return "CBA_BOX_XNOR";
    if ( !strcmp(pSop, "00 1\n11 1\n") ) return "CBA_BOX_XNOR";
    if ( !strcmp(pSop, "10 1\n") )       return "CBA_BOX_SHARP";
    if ( !strcmp(pSop, "01 1\n") )       return "CBA_BOX_SHARPL";
    assert( 0 );
    return NULL;
}
static inline char * Ptr_TypeToName( Cba_ObjType_t Type )
{
    if ( Type == CBA_BOX_CF )    return "const0";
    if ( Type == CBA_BOX_CT )    return "const1";
    if ( Type == CBA_BOX_CX )    return "constX";
    if ( Type == CBA_BOX_CZ )    return "constZ";
    if ( Type == CBA_BOX_BUF )   return "buf";
    if ( Type == CBA_BOX_INV )   return "not";
    if ( Type == CBA_BOX_AND )   return "and";
    if ( Type == CBA_BOX_NAND )  return "nand";
    if ( Type == CBA_BOX_OR )    return "or";
    if ( Type == CBA_BOX_NOR )   return "nor";
    if ( Type == CBA_BOX_XOR )   return "xor";
    if ( Type == CBA_BOX_XNOR )  return "xnor";
    if ( Type == CBA_BOX_MUX )   return "mux";
    if ( Type == CBA_BOX_MAJ )   return "maj";
    if ( Type == CBA_BOX_SHARP ) return "sharp";
    if ( Type == CBA_BOX_SHARPL) return "sharpl";
474
    if ( Type == CBA_BOX_TRI)    return "bufifl";
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
    assert( 0 );
    return "???";
}
static inline char * Ptr_TypeToSop( Cba_ObjType_t Type )
{
    if ( Type == CBA_BOX_CF )    return " 0\n";
    if ( Type == CBA_BOX_CT )    return " 1\n";
    if ( Type == CBA_BOX_CX )    return " 0\n";
    if ( Type == CBA_BOX_CZ )    return " 0\n";
    if ( Type == CBA_BOX_BUF )   return "1 1\n";
    if ( Type == CBA_BOX_INV )   return "0 1\n";
    if ( Type == CBA_BOX_AND )   return "11 1\n";
    if ( Type == CBA_BOX_NAND )  return "11 0\n";
    if ( Type == CBA_BOX_OR )    return "00 0\n";
    if ( Type == CBA_BOX_NOR )   return "00 1\n";
    if ( Type == CBA_BOX_XOR )   return "01 1\n10 1\n";
    if ( Type == CBA_BOX_XNOR )  return "00 1\n11 1\n";
    if ( Type == CBA_BOX_SHARP ) return "10 1\n";
    if ( Type == CBA_BOX_SHARPL) return "01 1\n";
    if ( Type == CBA_BOX_MUX )   return "11- 1\n0-1 1\n";
    if ( Type == CBA_BOX_MAJ )   return "11- 1\n1-1 1\n-11 1\n";
    assert( 0 );
    return "???";
}

500

501 502 503 504 505 506 507 508
////////////////////////////////////////////////////////////////////////
///                             ITERATORS                            ///
////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
///                    FUNCTION DECLARATIONS                         ///
////////////////////////////////////////////////////////////////////////

509 510
/*=== cbaReadVer.c ========================================================*/
extern void Prs_NtkAddVerilogDirectives( Prs_Man_t * p );
511 512 513 514 515 516 517 518 519 520


ABC_NAMESPACE_HEADER_END

#endif

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