abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
bblif.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "misc/util/abc_global.h"
#include "bblif.h"

Go to the source code of this file.

Data Structures

struct  Vec_Int_t_
 
struct  Vec_Str_t_
 
struct  Bbl_Obj_t_
 
struct  Bbl_Fnc_t_
 
struct  Bbl_Ent_t_
 
struct  Bbl_Man_t_
 

Macros

#define Bbl_ManForEachObj_int(p, pObj, h)   for ( h = 0; (h < p->nSize) && (pObj = Bbl_VecObj(p,h)); h += Bbl_ObjSize(pObj) )
 
#define Bbl_ManForEachFnc_int(p, pObj, h)   for ( h = 0; (h < p->nSize) && (pObj = Bbl_VecFnc(p,h)); h += Bbl_FncSize(pObj) )
 
#define Bbl_ObjForEachFanin_int(pObj, pFanin, i)   for ( i = 0; (i < (int)pObj->nFanins) && (pFanin = Bbl_ObjFanin(pObj,i)); i++ )
 
#define BBLIF_ALLOC(type, num)   ((type *) malloc(sizeof(type) * (num)))
 
#define BBLIF_CALLOC(type, num)   ((type *) calloc((num), sizeof(type)))
 
#define BBLIF_FALLOC(type, num)   ((type *) memset(malloc(sizeof(type) * (num)), 0xff, sizeof(type) * (num)))
 
#define BBLIF_FREE(obj)   ((obj) ? (free((char *) (obj)), (obj) = 0) : 0)
 
#define BBLIF_REALLOC(type, obj, num)
 

Typedefs

typedef
typedefABC_NAMESPACE_IMPL_START
struct Vec_Int_t_ 
Vec_Int_t
 DECLARATIONS ///. More...
 
typedef struct Vec_Str_t_ Vec_Str_t
 
typedef struct Bbl_Fnc_t_ Bbl_Fnc_t
 
typedef struct Bbl_Ent_t_ Bbl_Ent_t
 

Functions

static int Bbl_ObjIsCi (Bbl_Obj_t *pObj)
 
static int Bbl_ObjIsCo (Bbl_Obj_t *pObj)
 
static int Bbl_ObjIsNode (Bbl_Obj_t *pObj)
 
static int Bbl_ObjFaninNum (Bbl_Obj_t *pObj)
 
static Bbl_Obj_tBbl_ObjFanin (Bbl_Obj_t *pObj, int i)
 
static int Bbl_ObjSize (Bbl_Obj_t *pObj)
 
static int Bbl_FncSize (Bbl_Fnc_t *pFnc)
 
static Bbl_Obj_tBbl_VecObj (Vec_Str_t *p, int h)
 
static Bbl_Fnc_tBbl_VecFnc (Vec_Str_t *p, int h)
 
static Bbl_Ent_tBbl_VecEnt (Vec_Str_t *p, int h)
 
static char * Bbl_ManSop (Bbl_Man_t *p, int h)
 
static Bbl_Obj_tBbl_ManObj (Bbl_Man_t *p, int Id)
 
static Vec_Int_tVec_IntAlloc (int nCap)
 FUNCTION DEFINITIONS ///. More...
 
static Vec_Int_tVec_IntStart (int nSize)
 
static Vec_Int_tVec_IntStartNatural (int nSize)
 
static Vec_Int_tVec_IntAllocArray (int *pArray, int nSize)
 
static void Vec_IntFree (Vec_Int_t *p)
 
static int Vec_IntSize (Vec_Int_t *p)
 
static int Vec_IntEntry (Vec_Int_t *p, int i)
 
static void Vec_IntWriteEntry (Vec_Int_t *p, int i, int Entry)
 
static void Vec_IntAddToEntry (Vec_Int_t *p, int i, int Addition)
 
static int Vec_IntEntryLast (Vec_Int_t *p)
 
static void Vec_IntGrow (Vec_Int_t *p, int nCapMin)
 
static void Vec_IntFill (Vec_Int_t *p, int nSize, int Fill)
 
static void Vec_IntFillExtra (Vec_Int_t *p, int nSize, int Fill)
 
static int Vec_IntGetEntry (Vec_Int_t *p, int i)
 
static void Vec_IntSetEntry (Vec_Int_t *p, int i, int Entry)
 
static void Vec_IntShrink (Vec_Int_t *p, int nSizeNew)
 
static void Vec_IntClear (Vec_Int_t *p)
 
static void Vec_IntPush (Vec_Int_t *p, int Entry)
 
static Vec_Str_tVec_StrAlloc (int nCap)
 
static Vec_Str_tVec_StrAllocArray (char *pArray, int nSize)
 
char * Vec_StrFetch (Vec_Str_t *p, int nBytes)
 
void Vec_StrWrite (FILE *pFile, Vec_Str_t *p)
 
Vec_Str_tVec_StrRead (char **ppStr)
 
static int Vec_StrSize (Vec_Str_t *p)
 
static void Vec_StrFree (Vec_Str_t *p)
 
int Bbl_ManFileSize (char *pFileName)
 
char * Bbl_ManFileRead (char *pFileName)
 
void Bbl_ManDumpBinaryBlif (Bbl_Man_t *p, char *pFileName)
 
Bbl_Man_tBbl_ManReadBinaryBlif (char *pFileName)
 
void Bbl_ManPrintStats (Bbl_Man_t *p)
 
void Bbl_ManStop (Bbl_Man_t *p)
 
Bbl_Man_tBbl_ManStart (char *pName)
 MACRO DEFINITIONS ///. More...
 
void Bbl_ManSortCubes (char **pCubes, int nCubes, int nVars)
 
char * Bbl_ManSortSop (char *pSop, int nVars)
 
int Bbl_ManCreateEntry (Bbl_Man_t *p, int iFunc, int iNext)
 
int Bbl_ManSopCheckUnique (Bbl_Man_t *p, char *pSop, int nVars, int nCubes, int iFunc)
 
int Bbl_ManSaveSop (Bbl_Man_t *p, char *pSop, int nVars)
 
void Bbl_ManCreateObject (Bbl_Man_t *p, Bbl_Type_t Type, int ObjId, int nFanins, char *pSop)
 
void Bbl_ManAddFanin (Bbl_Man_t *p, int ObjId, int FaninId)
 
int Bbl_ManCheck (Bbl_Man_t *p)
 
int Bbl_ObjIsInput (Bbl_Obj_t *p)
 
int Bbl_ObjIsOutput (Bbl_Obj_t *p)
 
int Bbl_ObjIsLut (Bbl_Obj_t *p)
 
int Bbl_ObjId (Bbl_Obj_t *p)
 
int Bbl_ObjIdOriginal (Bbl_Man_t *pMan, Bbl_Obj_t *p)
 
int Bbl_ObjFaninNumber (Bbl_Obj_t *p)
 
char * Bbl_ObjSop (Bbl_Man_t *pMan, Bbl_Obj_t *p)
 
int Bbl_ObjIsMarked (Bbl_Obj_t *p)
 
void Bbl_ObjMark (Bbl_Obj_t *p)
 
int Bbl_ObjFncHandle (Bbl_Obj_t *p)
 
char * Bbl_ManName (Bbl_Man_t *p)
 
int Bbl_ManFncSize (Bbl_Man_t *p)
 
Bbl_Obj_tBbl_ManObjFirst (Bbl_Man_t *p)
 
Bbl_Obj_tBbl_ManObjNext (Bbl_Man_t *p, Bbl_Obj_t *pObj)
 
Bbl_Obj_tBbl_ObjFaninFirst (Bbl_Obj_t *p)
 
Bbl_Obj_tBbl_ObjFaninNext (Bbl_Obj_t *p, Bbl_Obj_t *pPrev)
 
void Bbl_ManDumpBlif (Bbl_Man_t *p, char *pFileName)
 
char * Bbl_ManTruthToSop (unsigned *pTruth, int nVars)
 
static void Bbl_ManSopToTruthElem (int nVars, unsigned **pVars)
 
unsigned * Bbl_ManSopToTruth (char *pSop, int nVars)
 
void Bbl_ManTestTruth (char *pSop, int nVars)
 
void Bbl_ManSimpleDemo ()
 

Macro Definition Documentation

#define Bbl_ManForEachFnc_int (   p,
  pObj,
 
)    for ( h = 0; (h < p->nSize) && (pObj = Bbl_VecFnc(p,h)); h += Bbl_FncSize(pObj) )

Definition at line 121 of file bblif.c.

#define Bbl_ManForEachObj_int (   p,
  pObj,
 
)    for ( h = 0; (h < p->nSize) && (pObj = Bbl_VecObj(p,h)); h += Bbl_ObjSize(pObj) )

Definition at line 119 of file bblif.c.

#define Bbl_ObjForEachFanin_int (   pObj,
  pFanin,
 
)    for ( i = 0; (i < (int)pObj->nFanins) && (pFanin = Bbl_ObjFanin(pObj,i)); i++ )

Definition at line 123 of file bblif.c.

#define BBLIF_ALLOC (   type,
  num 
)    ((type *) malloc(sizeof(type) * (num)))

Definition at line 126 of file bblif.c.

#define BBLIF_CALLOC (   type,
  num 
)    ((type *) calloc((num), sizeof(type)))

Definition at line 127 of file bblif.c.

#define BBLIF_FALLOC (   type,
  num 
)    ((type *) memset(malloc(sizeof(type) * (num)), 0xff, sizeof(type) * (num)))

Definition at line 128 of file bblif.c.

#define BBLIF_FREE (   obj)    ((obj) ? (free((char *) (obj)), (obj) = 0) : 0)

Definition at line 129 of file bblif.c.

#define BBLIF_REALLOC (   type,
  obj,
  num 
)
Value:
((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \
((type *) malloc(sizeof(type) * (num))))
char * malloc()
char * realloc()

Definition at line 130 of file bblif.c.

Typedef Documentation

typedef struct Bbl_Ent_t_ Bbl_Ent_t

Definition at line 76 of file bblif.c.

typedef struct Bbl_Fnc_t_ Bbl_Fnc_t

Definition at line 68 of file bblif.c.

typedef typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t

DECLARATIONS ///.

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

FileName [bblif.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Binary BLIF representation for logic networks.]

Synopsis [Main implementation module.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - February 28, 2009.]

Revision [

Id:
bblif.c,v 1.00 2009/02/28 00:00:00 alanmi Exp

]

Definition at line 37 of file bblif.c.

typedef struct Vec_Str_t_ Vec_Str_t

Definition at line 46 of file bblif.c.

Function Documentation

static int Bbl_FncSize ( Bbl_Fnc_t pFnc)
inlinestatic

Definition at line 110 of file bblif.c.

110 { return sizeof(Bbl_Fnc_t) + sizeof(int) * pFnc->nWords; }
int nWords
Definition: bblif.c:71
struct Bbl_Fnc_t_ Bbl_Fnc_t
Definition: bblif.c:68
void Bbl_ManAddFanin ( Bbl_Man_t p,
int  ObjId,
int  FaninId 
)

Fnction*************************************************************

Synopsis [Creates fanin/fanout relationship between two objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 1023 of file bblif.c.

1024 {
1025  Bbl_Obj_t * pObj, * pFanin;
1026  int iFanin;
1027  pObj = Bbl_ManObj( p, ObjId );
1028  if ( Bbl_ObjIsCi(pObj) )
1029  {
1030  printf( "Bbl_ManAddFanin(): Cannot add fanin of the combinational input (Id = %d).\n", ObjId );
1031  return;
1032  }
1033  pFanin = Bbl_ManObj( p, FaninId );
1034  if ( Bbl_ObjIsCo(pFanin) )
1035  {
1036  printf( "Bbl_ManAddFanin(): Cannot add fanout of the combinational output (Id = %d).\n", FaninId );
1037  return;
1038  }
1039  iFanin = Vec_IntEntry( p->vFaninNums, ObjId );
1040  if ( iFanin >= (int)pObj->nFanins )
1041  {
1042  printf( "Bbl_ManAddFanin(): Trying to add more fanins to object (Id = %d) than declared (%d).\n", ObjId, pObj->nFanins );
1043  return;
1044  }
1045  assert( iFanin < (int)pObj->nFanins );
1046  Vec_IntWriteEntry( p->vFaninNums, ObjId, iFanin+1 );
1047  pObj->pFanins[iFanin] = (char *)pObj - (char *)pFanin;
1048 }
static Bbl_Obj_t * Bbl_ManObj(Bbl_Man_t *p, int Id)
Definition: bblif.c:117
int pFanins[0]
Definition: bblif.c:64
unsigned nFanins
Definition: bblif.c:63
Vec_Int_t * vFaninNums
Definition: bblif.c:93
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Bbl_ObjIsCo(Bbl_Obj_t *pObj)
Definition: bblif.c:103
#define assert(ex)
Definition: util_old.h:213
static int Bbl_ObjIsCi(Bbl_Obj_t *pObj)
Definition: bblif.c:102
int Bbl_ManCheck ( Bbl_Man_t p)

Fnction*************************************************************

Synopsis [Returns 1 if the manager was created correctly.]

Description []

SideEffects []

SeeAlso []

Definition at line 1062 of file bblif.c.

1063 {
1064  Bbl_Obj_t * pObj;
1065  int h, RetValue = 1;
1066  Bbl_ManForEachObj_int( p->pObjs, pObj, h )
1067  {
1068  if ( Bbl_ObjIsNode(pObj) && pObj->Fnc == -1 )
1069  RetValue = 0, printf( "Bbl_ManCheck(): Node %d does not have function specified.\n", pObj->Id );
1070  if ( Bbl_ObjIsCi(pObj) && pObj->Fnc != -1 )
1071  RetValue = 0, printf( "Bbl_ManCheck(): CI with %d has function specified.\n", pObj->Id );
1072  if ( Bbl_ObjIsCo(pObj) && pObj->Fnc != -1 )
1073  RetValue = 0, printf( "Bbl_ManCheck(): CO with %d has function specified.\n", pObj->Id );
1074  if ( Vec_IntEntry(p->vFaninNums, pObj->Id) != (int)pObj->nFanins )
1075  RetValue = 0, printf( "Bbl_ManCheck(): Object %d has less fanins (%d) than declared (%d).\n",
1076  pObj->Id, Vec_IntEntry(p->vFaninNums, pObj->Id), pObj->nFanins );
1077  }
1078  return RetValue;
1079 }
unsigned nFanins
Definition: bblif.c:63
Vec_Int_t * vFaninNums
Definition: bblif.c:93
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define Bbl_ManForEachObj_int(p, pObj, h)
Definition: bblif.c:119
static int Bbl_ObjIsNode(Bbl_Obj_t *pObj)
Definition: bblif.c:104
static int Bbl_ObjIsCo(Bbl_Obj_t *pObj)
Definition: bblif.c:103
Vec_Str_t * pObjs
Definition: bblif.c:88
int Fnc
Definition: bblif.c:58
static int Bbl_ObjIsCi(Bbl_Obj_t *pObj)
Definition: bblif.c:102
int Id
Definition: bblif.c:57
int Bbl_ManCreateEntry ( Bbl_Man_t p,
int  iFunc,
int  iNext 
)

Fnction*************************************************************

Synopsis [Saves one entry.]

Description []

SideEffects []

SeeAlso []

Definition at line 901 of file bblif.c.

902 {
903  Bbl_Ent_t * pEnt;
904  pEnt = (Bbl_Ent_t *)Vec_StrFetch( p->pEnts, 2 * sizeof(int) );
905  pEnt->iFunc = iFunc;
906  pEnt->iNext = iNext;
907  return (char *)pEnt - p->pEnts->pArray;
908 }
int iFunc
Definition: bblif.c:79
Vec_Str_t * pEnts
Definition: bblif.c:98
char * pArray
Definition: bblif.c:51
int iNext
Definition: bblif.c:80
char * Vec_StrFetch(Vec_Str_t *p, int nBytes)
Definition: bblif.c:539
void Bbl_ManCreateObject ( Bbl_Man_t p,
Bbl_Type_t  Type,
int  ObjId,
int  nFanins,
char *  pSop 
)

Fnction*************************************************************

Synopsis [Adds one object.]

Description []

SideEffects []

SeeAlso []

Definition at line 988 of file bblif.c.

989 {
990  Bbl_Obj_t * pObj;
991  if ( Type == BBL_OBJ_CI && nFanins != 0 )
992  {
993  printf( "Attempting to create a combinational input with %d fanins (should be 0).\n", nFanins );
994  return;
995  }
996  if ( Type == BBL_OBJ_CO && nFanins != 1 )
997  {
998  printf( "Attempting to create a combinational output with %d fanins (should be 1).\n", nFanins );
999  return;
1000  }
1001  pObj = (Bbl_Obj_t *)Vec_StrFetch( p->pObjs, sizeof(Bbl_Obj_t) + nFanins * sizeof(int) );
1002  memset( pObj, 0, sizeof(Bbl_Obj_t) );
1003  Vec_IntSetEntry( p->vId2Obj, ObjId, (char *)pObj - p->pObjs->pArray );
1004  Vec_IntSetEntry( p->vFaninNums, ObjId, 0 );
1005  pObj->fCi = (Type == BBL_OBJ_CI);
1006  pObj->fCo = (Type == BBL_OBJ_CO);
1007  pObj->Id = ObjId;
1008  pObj->Fnc = pSop? Bbl_ManSaveSop(p, pSop, nFanins) : -1;
1009  pObj->nFanins = nFanins;
1010 }
char * memset()
static void Vec_IntSetEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:418
Vec_Int_t * vId2Obj
Definition: bblif.c:91
unsigned nFanins
Definition: bblif.c:63
Vec_Int_t * vFaninNums
Definition: bblif.c:93
char * pArray
Definition: bblif.c:51
int Bbl_ManSaveSop(Bbl_Man_t *p, char *pSop, int nVars)
Definition: bblif.c:954
unsigned fCi
Definition: bblif.c:59
unsigned fCo
Definition: bblif.c:60
Vec_Str_t * pObjs
Definition: bblif.c:88
int Fnc
Definition: bblif.c:58
char * Vec_StrFetch(Vec_Str_t *p, int nBytes)
Definition: bblif.c:539
int Id
Definition: bblif.c:57
void Bbl_ManDumpBinaryBlif ( Bbl_Man_t p,
char *  pFileName 
)

Fnction*************************************************************

Synopsis [Writes data into file.]

Description []

SideEffects []

SeeAlso []

Definition at line 691 of file bblif.c.

692 {
693  FILE * pFile;
694  pFile = fopen( pFileName, "wb" );
695  Vec_StrWrite( pFile, p->pName );
696  Vec_StrWrite( pFile, p->pObjs );
697  Vec_StrWrite( pFile, p->pFncs );
698  fclose( pFile );
699 }
Vec_Str_t * pName
Definition: bblif.c:87
void Vec_StrWrite(FILE *pFile, Vec_Str_t *p)
Definition: bblif.c:561
Vec_Str_t * pFncs
Definition: bblif.c:89
Vec_Str_t * pObjs
Definition: bblif.c:88
void Bbl_ManDumpBlif ( Bbl_Man_t p,
char *  pFileName 
)

Fnction*************************************************************

Synopsis [Drives text BLIF file for debugging.]

Description []

SideEffects []

SeeAlso []

Definition at line 1218 of file bblif.c.

1219 {
1220  FILE * pFile;
1221  Bbl_Obj_t * pObj, * pFanin;
1222  pFile = fopen( pFileName, "w" );
1223  fprintf( pFile, "# Test file written by Bbl_ManDumpBlif() in ABC.\n" );
1224  fprintf( pFile, ".model %s\n", Bbl_ManName(p) );
1225  // write objects
1226  Bbl_ManForEachObj( p, pObj )
1227  {
1228  if ( Bbl_ObjIsInput(pObj) )
1229  fprintf( pFile, ".inputs %d\n", Bbl_ObjId(pObj) );
1230  else if ( Bbl_ObjIsOutput(pObj) )
1231  fprintf( pFile, ".outputs %d\n", Bbl_ObjId(pObj) );
1232  else if ( Bbl_ObjIsLut(pObj) )
1233  {
1234  fprintf( pFile, ".names" );
1235  Bbl_ObjForEachFanin( pObj, pFanin )
1236  fprintf( pFile, " %d", Bbl_ObjId(pFanin) );
1237  fprintf( pFile, " %d\n", Bbl_ObjId(pObj) );
1238  fprintf( pFile, "%s", Bbl_ObjSop(p, pObj) );
1239  }
1240  else assert( 0 );
1241  }
1242  // write output drivers
1243  Bbl_ManForEachObj( p, pObj )
1244  {
1245  if ( !Bbl_ObjIsOutput(pObj) )
1246  continue;
1247  fprintf( pFile, ".names" );
1248  Bbl_ObjForEachFanin( pObj, pFanin )
1249  fprintf( pFile, " %d", Bbl_ObjId(pFanin) );
1250  fprintf( pFile, " %d\n", Bbl_ObjId(pObj) );
1251  fprintf( pFile, "1 1\n" );
1252  }
1253  fprintf( pFile, ".end\n" );
1254  fclose( pFile );
1255 }
int Bbl_ObjIsInput(Bbl_Obj_t *p)
Definition: bblif.c:1093
char * Bbl_ManName(Bbl_Man_t *p)
Definition: bblif.c:1115
int Bbl_ObjId(Bbl_Obj_t *p)
Definition: bblif.c:1096
int Bbl_ObjIsLut(Bbl_Obj_t *p)
Definition: bblif.c:1095
#define Bbl_ManForEachObj(p, pObj)
Definition: bblif.h:257
else
Definition: sparse_int.h:55
#define assert(ex)
Definition: util_old.h:213
#define Bbl_ObjForEachFanin(pObj, pFanin)
Definition: bblif.h:260
int Bbl_ObjIsOutput(Bbl_Obj_t *p)
Definition: bblif.c:1094
char * Bbl_ObjSop(Bbl_Man_t *pMan, Bbl_Obj_t *p)
Definition: bblif.c:1099
char* Bbl_ManFileRead ( char *  pFileName)

Fnction*************************************************************

Synopsis [Read data from file.]

Description []

SideEffects []

SeeAlso []

Definition at line 664 of file bblif.c.

665 {
666  FILE * pFile;
667  char * pContents;
668  int nFileSize;
669  int RetValue;
670  nFileSize = Bbl_ManFileSize( pFileName );
671  pFile = fopen( pFileName, "rb" );
672  pContents = BBLIF_ALLOC( char, nFileSize );
673  RetValue = fread( pContents, nFileSize, 1, pFile );
674  fclose( pFile );
675  return pContents;
676 }
#define BBLIF_ALLOC(type, num)
Definition: bblif.c:126
int Bbl_ManFileSize(char *pFileName)
Definition: bblif.c:637
int Bbl_ManFileSize ( char *  pFileName)

Fnction*************************************************************

Synopsis [Returns the file size.]

Description [The file should be closed.]

SideEffects []

SeeAlso []

Definition at line 637 of file bblif.c.

638 {
639  FILE * pFile;
640  int nFileSize;
641  pFile = fopen( pFileName, "r" );
642  if ( pFile == NULL )
643  {
644  printf( "Bbl_ManFileSize(): The file is unavailable (absent or open).\n" );
645  return 0;
646  }
647  fseek( pFile, 0, SEEK_END );
648  nFileSize = ftell( pFile );
649  fclose( pFile );
650  return nFileSize;
651 }
#define SEEK_END
Definition: zconf.h:392
int Bbl_ManFncSize ( Bbl_Man_t p)

Fnction*************************************************************

Synopsis [Returns the maximum handle of the SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 1131 of file bblif.c.

1132 {
1133  return p->pFncs->nSize;
1134 }
int nSize
Definition: bblif.c:50
Vec_Str_t * pFncs
Definition: bblif.c:89
char* Bbl_ManName ( Bbl_Man_t p)

Fnction*************************************************************

Synopsis [Returns the name of the design.]

Description []

SideEffects []

SeeAlso []

Definition at line 1115 of file bblif.c.

1116 {
1117  return p->pName->pArray;
1118 }
Vec_Str_t * pName
Definition: bblif.c:87
char * pArray
Definition: bblif.c:51
static Bbl_Obj_t* Bbl_ManObj ( Bbl_Man_t p,
int  Id 
)
inlinestatic

Definition at line 117 of file bblif.c.

117 { return Bbl_VecObj(p->pObjs, p->vId2Obj->pArray[Id]); }
static Bbl_Obj_t * Bbl_VecObj(Vec_Str_t *p, int h)
Definition: bblif.c:112
Vec_Int_t * vId2Obj
Definition: bblif.c:91
Vec_Str_t * pObjs
Definition: bblif.c:88
Bbl_Obj_t* Bbl_ManObjFirst ( Bbl_Man_t p)

Fnction*************************************************************

Synopsis [Returns the first object.]

Description []

SideEffects []

SeeAlso []

Definition at line 1147 of file bblif.c.

1148 {
1149  return Bbl_VecObj( p->pObjs, 0 );
1150 }
static Bbl_Obj_t * Bbl_VecObj(Vec_Str_t *p, int h)
Definition: bblif.c:112
Vec_Str_t * pObjs
Definition: bblif.c:88
Bbl_Obj_t* Bbl_ManObjNext ( Bbl_Man_t p,
Bbl_Obj_t pObj 
)

Fnction*************************************************************

Synopsis [Returns the next object.]

Description []

SideEffects []

SeeAlso []

Definition at line 1163 of file bblif.c.

1164 {
1165  char * pNext = (char *)pObj + Bbl_ObjSize(pObj);
1166  char * pEdge = p->pObjs->pArray + p->pObjs->nSize;
1167  return (Bbl_Obj_t *)(pNext < pEdge ? pNext : NULL);
1168 }
char * pArray
Definition: bblif.c:51
static int Bbl_ObjSize(Bbl_Obj_t *pObj)
Definition: bblif.c:109
int nSize
Definition: bblif.c:50
Vec_Str_t * pObjs
Definition: bblif.c:88
void Bbl_ManPrintStats ( Bbl_Man_t p)

Fnction*************************************************************

Synopsis [Prints stats of the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 749 of file bblif.c.

750 {
751  Bbl_Obj_t * pObj;
752  Bbl_Fnc_t * pFnc;
753  int h, nFuncs = 0, nNodes = 0, nObjs = 0;
754  Bbl_ManForEachObj_int( p->pObjs, pObj, h )
755  nObjs++, nNodes += Bbl_ObjIsNode(pObj);
756  Bbl_ManForEachFnc_int( p->pFncs, pFnc, h )
757  nFuncs++;
758  printf( "Total objects = %7d. Total nodes = %7d. Unique functions = %7d.\n", nObjs, nNodes, nFuncs );
759  printf( "Name manager = %5.2f MB\n", 1.0*Vec_StrSize(p->pName)/(1 << 20) );
760  printf( "Objs manager = %5.2f MB\n", 1.0*Vec_StrSize(p->pObjs)/(1 << 20) );
761  printf( "Fncs manager = %5.2f MB\n", 1.0*Vec_StrSize(p->pFncs)/(1 << 20) );
762 }
#define Bbl_ManForEachFnc_int(p, pObj, h)
Definition: bblif.c:121
int nodes
Definition: abcSaucy.c:61
#define Bbl_ManForEachObj_int(p, pObj, h)
Definition: bblif.c:119
static int Bbl_ObjIsNode(Bbl_Obj_t *pObj)
Definition: bblif.c:104
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
Vec_Str_t * pObjs
Definition: bblif.c:88
Bbl_Man_t* Bbl_ManReadBinaryBlif ( char *  pFileName)

Fnction*************************************************************

Synopsis [Creates manager after reading.]

Description []

SideEffects []

SeeAlso []

Definition at line 712 of file bblif.c.

713 {
714  Bbl_Man_t * p;
715  Bbl_Obj_t * pObj;
716  char * pBuffer;
717  int h;
718  p = BBLIF_ALLOC( Bbl_Man_t, 1 );
719  memset( p, 0, sizeof(Bbl_Man_t) );
720  p->nFileSize = Bbl_ManFileSize( pFileName );
721  p->pFileData = Bbl_ManFileRead( pFileName );
722  // extract three managers
723  pBuffer = p->pFileData;
724  p->pName = Vec_StrRead( &pBuffer );
725  p->pObjs = Vec_StrRead( &pBuffer );
726  p->pFncs = Vec_StrRead( &pBuffer );
727  assert( pBuffer - p->pFileData == p->nFileSize );
728  // remember original IDs in the objects
729  p->vObj2Id = Vec_IntAlloc( 1000 );
730  Bbl_ManForEachObj_int( p->pObjs, pObj, h )
731  {
732  Vec_IntPush( p->vObj2Id, pObj->Id );
733  pObj->Id = Vec_IntSize(p->vObj2Id) - 1;
734  }
735  return p;
736 }
char * memset()
Vec_Str_t * pName
Definition: bblif.c:87
int nFileSize
Definition: bblif.c:95
#define BBLIF_ALLOC(type, num)
Definition: bblif.c:126
static Llb_Mgr_t * p
Definition: llb3Image.c:950
char * pFileData
Definition: bblif.c:96
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int Bbl_ManFileSize(char *pFileName)
Definition: bblif.c:637
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Bbl_ManForEachObj_int(p, pObj, h)
Definition: bblif.c:119
Vec_Str_t * Vec_StrRead(char **ppStr)
Definition: bblif.c:578
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Vec_Int_t * vObj2Id
Definition: bblif.c:92
#define assert(ex)
Definition: util_old.h:213
char * Bbl_ManFileRead(char *pFileName)
Definition: bblif.c:664
Vec_Str_t * pFncs
Definition: bblif.c:89
Vec_Str_t * pObjs
Definition: bblif.c:88
int Id
Definition: bblif.c:57
int Bbl_ManSaveSop ( Bbl_Man_t p,
char *  pSop,
int  nVars 
)

Fnction*************************************************************

Synopsis [Saves one SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 954 of file bblif.c.

955 {
956  Bbl_Fnc_t * pFnc;
957  char * pSopNew;
958  int iFunc, Length = strlen(pSop) + 1;
959  int nWords = Length / 4 + (Length % 4 > 0);
960  // reorder cubes to semi-canicize SOPs
961  pSopNew = Bbl_ManSortSop( pSop, nVars );
962  // get the candidate location
963  iFunc = Bbl_ManSopCheckUnique( p, pSopNew, nVars, Length / (nVars + 3), Vec_StrSize(p->pFncs) );
964 // iFunc = Vec_StrSize(p->pFncs);
965  if ( iFunc == Vec_StrSize(p->pFncs) )
966  { // store this SOP
967  pFnc = (Bbl_Fnc_t *)Vec_StrFetch( p->pFncs, sizeof(Bbl_Fnc_t) + nWords * sizeof(int) );
968  pFnc->pWords[nWords-1] = 0;
969  pFnc->nWords = nWords;
970  strcpy( (char *)pFnc->pWords, pSopNew );
971  assert( iFunc == (char *)pFnc - p->pFncs->pArray );
972  }
973  BBLIF_FREE( pSopNew );
974  return iFunc;
975 }
int nWords
Definition: bblif.c:71
int nWords
Definition: abcNpn.c:127
int Bbl_ManSopCheckUnique(Bbl_Man_t *p, char *pSop, int nVars, int nCubes, int iFunc)
Definition: bblif.c:921
char * pArray
Definition: bblif.c:51
char * Bbl_ManSortSop(char *pSop, int nVars)
Definition: bblif.c:864
char * strcpy()
#define BBLIF_FREE(obj)
Definition: bblif.c:129
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
int pWords[0]
Definition: bblif.c:72
#define assert(ex)
Definition: util_old.h:213
int strlen()
Vec_Str_t * pFncs
Definition: bblif.c:89
char * Vec_StrFetch(Vec_Str_t *p, int nBytes)
Definition: bblif.c:539
void Bbl_ManSimpleDemo ( )

Fnction*************************************************************

Synopsis [This demo shows using the internal to construct a half-adder.]

Description [We construct the logic network for the half-adder represnted using the BLIF file below]

SideEffects []

SeeAlso []

Definition at line 1446 of file bblif.c.

1447 {
1448 /*
1449  # There are contents of a BLIF file representing a half-adder:
1450  .model hadder
1451  .inputs a // ID = 1
1452  .inputs b // ID = 2
1453  .inputs cin // ID = 3
1454  .outputs s // ID = 4
1455  .outputs cout // ID = 5
1456  .names a b cin s_driver // ID = 6
1457  100 1
1458  010 1
1459  001 1
1460  111 1
1461  .names a b cin cout_driver // ID = 7
1462  -11 1
1463  1-1 1
1464  11- 1
1465  .names s_driver s
1466  1 1
1467  .names cout_driver cout
1468  1 1
1469  .end
1470 */
1471  Bbl_Man_t * p;
1472  // start the data manager
1473  p = Bbl_ManStart( "hadder" );
1474  // create CIs
1475  Bbl_ManCreateObject( p, BBL_OBJ_CI, 1, 0, NULL ); // a
1476  Bbl_ManCreateObject( p, BBL_OBJ_CI, 2, 0, NULL ); // b
1477  Bbl_ManCreateObject( p, BBL_OBJ_CI, 3, 0, NULL ); // cin
1478  // create COs
1479  Bbl_ManCreateObject( p, BBL_OBJ_CO, 4, 1, NULL ); // s
1480  Bbl_ManCreateObject( p, BBL_OBJ_CO, 5, 1, NULL ); // cout
1481  // create internal nodes
1482  Bbl_ManCreateObject( p, BBL_OBJ_NODE, 6, 3, "100 1\n010 1\n001 1\n111 1\n" ); // s_driver
1483  Bbl_ManCreateObject( p, BBL_OBJ_NODE, 7, 3, "-11 1\n1-1 1\n11- 1\n" ); // cout_driver
1484  // add fanins of node 6
1485  Bbl_ManAddFanin( p, 6, 1 ); // s_driver <- a
1486  Bbl_ManAddFanin( p, 6, 2 ); // s_driver <- b
1487  Bbl_ManAddFanin( p, 6, 3 ); // s_driver <- cin
1488  // add fanins of node 7
1489  Bbl_ManAddFanin( p, 7, 1 ); // cout_driver <- a
1490  Bbl_ManAddFanin( p, 7, 2 ); // cout_driver <- b
1491  Bbl_ManAddFanin( p, 7, 3 ); // cout_driver <- cin
1492  // add fanins of COs
1493  Bbl_ManAddFanin( p, 4, 6 ); // s <- s_driver
1494  Bbl_ManAddFanin( p, 5, 7 ); // cout <- cout_driver
1495  // sanity check
1496  Bbl_ManCheck( p );
1497  // write BLIF file as a sanity check
1498  Bbl_ManDumpBlif( p, "hadder.blif" );
1499  // write binary BLIF file
1500  Bbl_ManDumpBinaryBlif( p, "hadder.bblif" );
1501  // remove the manager
1502  Bbl_ManStop( p );
1503 
1504 
1505 // Bbl_ManTestTruth( "100 1\n010 1\n001 1\n111 1\n", 3 );
1506 // Bbl_ManTestTruth( "-11 0\n1-1 0\n11- 0\n", 3 );
1507 // Bbl_ManTestTruth( "--- 1\n", 3 );
1508 }
void Bbl_ManAddFanin(Bbl_Man_t *p, int ObjId, int FaninId)
Definition: bblif.c:1023
Bbl_Man_t * Bbl_ManStart(char *pName)
MACRO DEFINITIONS ///.
Definition: bblif.c:806
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Bbl_ManCheck(Bbl_Man_t *p)
Definition: bblif.c:1062
void Bbl_ManDumpBlif(Bbl_Man_t *p, char *pFileName)
Definition: bblif.c:1218
void Bbl_ManDumpBinaryBlif(Bbl_Man_t *p, char *pFileName)
Definition: bblif.c:691
void Bbl_ManStop(Bbl_Man_t *p)
Definition: bblif.c:775
void Bbl_ManCreateObject(Bbl_Man_t *p, Bbl_Type_t Type, int ObjId, int nFanins, char *pSop)
Definition: bblif.c:988
static char* Bbl_ManSop ( Bbl_Man_t p,
int  h 
)
inlinestatic

Definition at line 116 of file bblif.c.

116 { return (char *)Bbl_VecFnc(p->pFncs, h)->pWords; }
static Bbl_Fnc_t * Bbl_VecFnc(Vec_Str_t *p, int h)
Definition: bblif.c:113
int pWords[0]
Definition: bblif.c:72
Vec_Str_t * pFncs
Definition: bblif.c:89
int Bbl_ManSopCheckUnique ( Bbl_Man_t p,
char *  pSop,
int  nVars,
int  nCubes,
int  iFunc 
)

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

Synopsis [Sorts the cubes in the SOP to uniqify them to some extent.]

Description []

SideEffects []

SeeAlso []

Definition at line 921 of file bblif.c.

922 {
923  Bbl_Fnc_t * pFnc;
924  Bbl_Ent_t * pEnt;
925  int h, Length = strlen(pSop) + 1;
926  int nWords = (Length / 4 + (Length % 4 > 0));
927  if ( nVars > 16 ) nVars = 16;
928  if ( nCubes > 16 ) nCubes = 16;
929 // if ( nVars == 16 && nCubes == 16 )
930 // return iFunc;
931  for ( h = p->SopMap[nVars][nCubes]; h; h = pEnt->iNext )
932  {
933  pEnt = Bbl_VecEnt( p->pEnts, h );
934  pFnc = Bbl_VecFnc( p->pFncs, pEnt->iFunc );
935  assert( nVars == 16 || nCubes == 16 || pFnc->nWords == nWords );
936  if ( pFnc->nWords == nWords && memcmp( pFnc->pWords, pSop, Length ) == 0 )
937  return pEnt->iFunc;
938  }
939  p->SopMap[nVars][nCubes] = Bbl_ManCreateEntry( p, iFunc, p->SopMap[nVars][nCubes] );
940  return iFunc;
941 }
int nWords
Definition: bblif.c:71
static Bbl_Fnc_t * Bbl_VecFnc(Vec_Str_t *p, int h)
Definition: bblif.c:113
int nWords
Definition: abcNpn.c:127
int iFunc
Definition: bblif.c:79
Vec_Str_t * pEnts
Definition: bblif.c:98
int iNext
Definition: bblif.c:80
int SopMap[17][17]
Definition: bblif.c:99
int memcmp()
int pWords[0]
Definition: bblif.c:72
#define assert(ex)
Definition: util_old.h:213
int strlen()
Vec_Str_t * pFncs
Definition: bblif.c:89
int Bbl_ManCreateEntry(Bbl_Man_t *p, int iFunc, int iNext)
Definition: bblif.c:901
static Bbl_Ent_t * Bbl_VecEnt(Vec_Str_t *p, int h)
Definition: bblif.c:114
unsigned* Bbl_ManSopToTruth ( char *  pSop,
int  nVars 
)

Fnction*************************************************************

Synopsis [Converting SOP into a truth table.]

Description [The SOP is represented as a C-string, as documented in file "bblif.h". The truth table is returned as a bit-string composed of 2^nVars bits. For functions of less than 6 variables, the full machine word is returned. (The truth table looks as if the function had 5 variables.) The use of this procedure should be limited to Boolean functions with no more than 16 inputs.]

SideEffects []

SeeAlso []

Definition at line 1362 of file bblif.c.

1363 {
1364  unsigned * pTruth, * pCube, * pVars[16];
1365  int nWords = nVars <= 5 ? 1 : (1 << (nVars - 5));
1366  int v, c, w, nCubes, fCompl = 0;
1367  if ( pSop == NULL )
1368  return NULL;
1369  if ( strlen(pSop) % (nVars + 3) != 0 )
1370  {
1371  printf( "Bbl_ManSopToTruth(): SOP is represented incorrectly.\n" );
1372  return NULL;
1373  }
1374  // create storage for TTs of the result, elementary variables and the temp cube
1375  pTruth = BBLIF_ALLOC( unsigned, nWords );
1376  pVars[0] = BBLIF_ALLOC( unsigned, nWords * (nVars+1) );
1377  for ( v = 1; v < nVars; v++ )
1378  pVars[v] = pVars[v-1] + nWords;
1379  pCube = pVars[v-1] + nWords;
1380  Bbl_ManSopToTruthElem( nVars, pVars );
1381  // iterate through the cubes
1382  memset( pTruth, 0, sizeof(unsigned) * nWords );
1383  nCubes = strlen(pSop) / (nVars + 3);
1384  for ( c = 0; c < nCubes; c++ )
1385  {
1386  fCompl = (pSop[nVars+1] == '0');
1387  memset( pCube, 0xff, sizeof(unsigned) * nWords );
1388  // iterate through the literals of the cube
1389  for ( v = 0; v < nVars; v++ )
1390  if ( pSop[v] == '1' )
1391  for ( w = 0; w < nWords; w++ )
1392  pCube[w] &= pVars[v][w];
1393  else if ( pSop[v] == '0' )
1394  for ( w = 0; w < nWords; w++ )
1395  pCube[w] &= ~pVars[v][w];
1396  // add cube to storage
1397  for ( w = 0; w < nWords; w++ )
1398  pTruth[w] |= pCube[w];
1399  // go to the next cube
1400  pSop += (nVars + 3);
1401  }
1402  BBLIF_FREE( pVars[0] );
1403  if ( fCompl )
1404  for ( w = 0; w < nWords; w++ )
1405  pTruth[w] = ~pTruth[w];
1406  return pTruth;
1407 }
char * memset()
#define BBLIF_ALLOC(type, num)
Definition: bblif.c:126
int nWords
Definition: abcNpn.c:127
static void Bbl_ManSopToTruthElem(int nVars, unsigned **pVars)
Definition: bblif.c:1323
#define BBLIF_FREE(obj)
Definition: bblif.c:129
int strlen()
static void Bbl_ManSopToTruthElem ( int  nVars,
unsigned **  pVars 
)
inlinestatic

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

Synopsis [Allocates the array of truth tables for the given number of vars.]

Description []

SideEffects []

SeeAlso []

Definition at line 1323 of file bblif.c.

1324 {
1325  unsigned Masks[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
1326  int i, k, nWords;
1327  nWords = (nVars <= 5 ? 1 : (1 << (nVars - 5)));
1328  for ( i = 0; i < nVars; i++ )
1329  {
1330  if ( i < 5 )
1331  {
1332  for ( k = 0; k < nWords; k++ )
1333  pVars[i][k] = Masks[i];
1334  }
1335  else
1336  {
1337  for ( k = 0; k < nWords; k++ )
1338  if ( k & (1 << (i-5)) )
1339  pVars[i][k] = ~(unsigned)0;
1340  else
1341  pVars[i][k] = 0;
1342  }
1343  }
1344 }
int nWords
Definition: abcNpn.c:127
void Bbl_ManSortCubes ( char **  pCubes,
int  nCubes,
int  nVars 
)

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

Synopsis [Performs selection sort on the array of cubes.]

Description []

SideEffects []

SeeAlso []

Definition at line 839 of file bblif.c.

840 {
841  char * pTemp;
842  int i, j, best_i;
843  for ( i = 0; i < nCubes-1; i++ )
844  {
845  best_i = i;
846  for (j = i+1; j < nCubes; j++)
847  if ( memcmp( pCubes[j], pCubes[best_i], nVars ) < 0 )
848  best_i = j;
849  pTemp = pCubes[i]; pCubes[i] = pCubes[best_i]; pCubes[best_i] = pTemp;
850  }
851 }
int memcmp()
char* Bbl_ManSortSop ( char *  pSop,
int  nVars 
)

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

Synopsis [Sorts the cubes in the SOP to uniqify them to some extent.]

Description []

SideEffects []

SeeAlso []

Definition at line 864 of file bblif.c.

865 {
866  char ** pCubes, * pSopNew;
867  int c, Length, nCubes;
868  Length = strlen(pSop);
869  assert( Length % (nVars + 3) == 0 );
870  nCubes = Length / (nVars + 3);
871  if ( nCubes < 2 )
872  {
873  pSopNew = BBLIF_ALLOC( char, Length + 1 );
874  memcpy( pSopNew, pSop, Length + 1 );
875  return pSopNew;
876  }
877  pCubes = BBLIF_ALLOC( char *, nCubes );
878  for ( c = 0; c < nCubes; c++ )
879  pCubes[c] = pSop + c * (nVars + 3);
880  if ( nCubes < 300 )
881  Bbl_ManSortCubes( pCubes, nCubes, nVars );
882  pSopNew = BBLIF_ALLOC( char, Length + 1 );
883  for ( c = 0; c < nCubes; c++ )
884  memcpy( pSopNew + c * (nVars + 3), pCubes[c], nVars + 3 );
885  BBLIF_FREE( pCubes );
886  pSopNew[nCubes * (nVars + 3)] = 0;
887  return pSopNew;
888 }
#define BBLIF_ALLOC(type, num)
Definition: bblif.c:126
char * memcpy()
#define BBLIF_FREE(obj)
Definition: bblif.c:129
#define assert(ex)
Definition: util_old.h:213
int strlen()
void Bbl_ManSortCubes(char **pCubes, int nCubes, int nVars)
Definition: bblif.c:839
Bbl_Man_t* Bbl_ManStart ( char *  pName)

MACRO DEFINITIONS ///.

Fnction*************************************************************

Synopsis [Creates manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 806 of file bblif.c.

807 {
808  Bbl_Man_t * p;
809  int nLength;
810  p = BBLIF_ALLOC( Bbl_Man_t, 1 );
811  memset( p, 0, sizeof(Bbl_Man_t) );
812  nLength = pName? 4 * ((strlen(pName) + 1) / 4 + 1) : 0;
813  p->pName = Vec_StrAlloc( nLength );
814  p->pName->nSize = p->pName->nCap;
815  if ( pName )
816  strcpy( p->pName->pArray, pName );
817  p->pObjs = Vec_StrAlloc( 1 << 16 );
818  p->pFncs = Vec_StrAlloc( 1 << 16 );
819  p->pEnts = Vec_StrAlloc( 1 << 16 ); p->pEnts->nSize = 1;
820  p->vId2Obj = Vec_IntStart( 1 << 10 );
821  p->vFaninNums = Vec_IntStart( 1 << 10 );
822  return p;
823 }
char * memset()
Vec_Str_t * pName
Definition: bblif.c:87
#define BBLIF_ALLOC(type, num)
Definition: bblif.c:126
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Int_t * vId2Obj
Definition: bblif.c:91
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
Vec_Int_t * vFaninNums
Definition: bblif.c:93
Vec_Str_t * pEnts
Definition: bblif.c:98
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
char * pArray
Definition: bblif.c:51
char * strcpy()
int nSize
Definition: bblif.c:50
int strlen()
Vec_Str_t * pFncs
Definition: bblif.c:89
int nCap
Definition: bblif.c:49
Vec_Str_t * pObjs
Definition: bblif.c:88
void Bbl_ManStop ( Bbl_Man_t p)

Fnction*************************************************************

Synopsis [Deletes the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 775 of file bblif.c.

776 {
777  if ( p->vId2Obj ) Vec_IntFree( p->vId2Obj );
778  if ( p->vObj2Id ) Vec_IntFree( p->vObj2Id );
779  if ( p->vFaninNums ) Vec_IntFree( p->vFaninNums );
780  if ( p->pFileData )
781  {
782  BBLIF_FREE( p->pFileData );
783  p->pName->pArray = NULL;
784  p->pObjs->pArray = NULL;
785  p->pFncs->pArray = NULL;
786  }
787  if ( p->pEnts )
788  Vec_StrFree( p->pEnts );
789  Vec_StrFree( p->pName );
790  Vec_StrFree( p->pObjs );
791  Vec_StrFree( p->pFncs );
792  BBLIF_FREE( p );
793 }
Vec_Str_t * pName
Definition: bblif.c:87
char * pFileData
Definition: bblif.c:96
Vec_Int_t * vId2Obj
Definition: bblif.c:91
Vec_Int_t * vFaninNums
Definition: bblif.c:93
Vec_Str_t * pEnts
Definition: bblif.c:98
char * pArray
Definition: bblif.c:51
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
#define BBLIF_FREE(obj)
Definition: bblif.c:129
Vec_Int_t * vObj2Id
Definition: bblif.c:92
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Vec_Str_t * pFncs
Definition: bblif.c:89
Vec_Str_t * pObjs
Definition: bblif.c:88
void Bbl_ManTestTruth ( char *  pSop,
int  nVars 
)

Fnction*************************************************************

Synopsis [Checks the truth table computation.]

Description [We construct the logic network for the half-adder represnted using the BLIF file below]

SideEffects []

SeeAlso []

Definition at line 1422 of file bblif.c.

1423 {
1424  unsigned * pTruth;
1425  char * pSopNew;
1426  pTruth = Bbl_ManSopToTruth( pSop, nVars );
1427  pSopNew = Bbl_ManTruthToSop( pTruth, nVars );
1428  printf( "Old SOP:\n%s\n", pSop );
1429  printf( "New SOP:\n%s\n", pSopNew );
1430  BBLIF_FREE( pSopNew );
1431  BBLIF_FREE( pTruth );
1432 }
char * Bbl_ManTruthToSop(unsigned *pTruth, int nVars)
Definition: bblif.c:1273
unsigned * Bbl_ManSopToTruth(char *pSop, int nVars)
Definition: bblif.c:1362
#define BBLIF_FREE(obj)
Definition: bblif.c:129
char* Bbl_ManTruthToSop ( unsigned *  pTruth,
int  nVars 
)

Fnction*************************************************************

Synopsis [Converting truth table into an SOP.]

Description [The truth table is given as a bit-string pTruth composed of 2^nVars bits. The result is an SOP derived by collecting minterms appearing in the truth table. The SOP is represented as a C-string, as documented in file "bblif.h". It is recommended to limit the use of this procedure to Boolean functions up to 6 inputs.]

SideEffects []

SeeAlso []

Definition at line 1273 of file bblif.c.

1274 {
1275  char * pResult, * pTemp;
1276  int nMints, nOnes, b, v;
1277  assert( nVars >= 0 && nVars <= 16 );
1278  nMints = (1 << nVars);
1279  // count the number of ones
1280  nOnes = 0;
1281  for ( b = 0; b < nMints; b++ )
1282  nOnes += ((pTruth[b>>5] >> (b&31)) & 1);
1283  // handle constants
1284  if ( nOnes == 0 || nOnes == nMints )
1285  {
1286  pResult = pTemp = BBLIF_ALLOC( char, nVars + 4 );
1287  for ( v = 0; v < nVars; v++ )
1288  *pTemp++ = '-';
1289  *pTemp++ = ' ';
1290  *pTemp++ = nOnes? '1' : '0';
1291  *pTemp++ = '\n';
1292  *pTemp++ = 0;
1293  assert( pTemp - pResult == nVars + 4 );
1294  return pResult;
1295  }
1296  pResult = pTemp = BBLIF_ALLOC( char, nOnes * (nVars + 3) + 1 );
1297  for ( b = 0; b < nMints; b++ )
1298  {
1299  if ( ((pTruth[b>>5] >> (b&31)) & 1) == 0 )
1300  continue;
1301  for ( v = 0; v < nVars; v++ )
1302  *pTemp++ = ((b >> v) & 1)? '1' : '0';
1303  *pTemp++ = ' ';
1304  *pTemp++ = '1';
1305  *pTemp++ = '\n';
1306  }
1307  *pTemp++ = 0;
1308  assert( pTemp - pResult == nOnes * (nVars + 3) + 1 );
1309  return pResult;
1310 }
#define BBLIF_ALLOC(type, num)
Definition: bblif.c:126
#define assert(ex)
Definition: util_old.h:213
static Bbl_Obj_t* Bbl_ObjFanin ( Bbl_Obj_t pObj,
int  i 
)
inlinestatic

Definition at line 107 of file bblif.c.

107 { return (Bbl_Obj_t *)(((char *)pObj) - pObj->pFanins[i]); }
int pFanins[0]
Definition: bblif.c:64
Bbl_Obj_t* Bbl_ObjFaninFirst ( Bbl_Obj_t p)

Fnction*************************************************************

Synopsis [Returns the first fanin.]

Description []

SideEffects []

SeeAlso []

Definition at line 1181 of file bblif.c.

1182 {
1183  return Bbl_ObjFaninNum(p) ? Bbl_ObjFanin( p, 0 ) : NULL;
1184 }
static Bbl_Obj_t * Bbl_ObjFanin(Bbl_Obj_t *pObj, int i)
Definition: bblif.c:107
static int Bbl_ObjFaninNum(Bbl_Obj_t *pObj)
Definition: bblif.c:106
Bbl_Obj_t* Bbl_ObjFaninNext ( Bbl_Obj_t p,
Bbl_Obj_t pPrev 
)

Fnction*************************************************************

Synopsis [Returns the next fanin.]

Description []

SideEffects []

SeeAlso []

Definition at line 1197 of file bblif.c.

1198 {
1199  Bbl_Obj_t * pFanin;
1200  int i;
1201  Bbl_ObjForEachFanin_int( p, pFanin, i )
1202  if ( pFanin == pPrev )
1203  break;
1204  return i < Bbl_ObjFaninNum(p) - 1 ? Bbl_ObjFanin( p, i+1 ) : NULL;
1205 }
static Bbl_Obj_t * Bbl_ObjFanin(Bbl_Obj_t *pObj, int i)
Definition: bblif.c:107
#define Bbl_ObjForEachFanin_int(pObj, pFanin, i)
Definition: bblif.c:123
static int Bbl_ObjFaninNum(Bbl_Obj_t *pObj)
Definition: bblif.c:106
if(last==0)
Definition: sparse_int.h:34
static int Bbl_ObjFaninNum ( Bbl_Obj_t pObj)
inlinestatic

Definition at line 106 of file bblif.c.

106 { return pObj->nFanins; }
unsigned nFanins
Definition: bblif.c:63
int Bbl_ObjFaninNumber ( Bbl_Obj_t p)

Definition at line 1098 of file bblif.c.

1098 { return Bbl_ObjFaninNum(p); }
static int Bbl_ObjFaninNum(Bbl_Obj_t *pObj)
Definition: bblif.c:106
int Bbl_ObjFncHandle ( Bbl_Obj_t p)

Definition at line 1102 of file bblif.c.

1102 { return p->Fnc; }
int Fnc
Definition: bblif.c:58
int Bbl_ObjId ( Bbl_Obj_t p)

Definition at line 1096 of file bblif.c.

1096 { return p->Id; }
int Id
Definition: bblif.c:57
int Bbl_ObjIdOriginal ( Bbl_Man_t pMan,
Bbl_Obj_t p 
)

Definition at line 1097 of file bblif.c.

1097 { assert(0); return Vec_IntEntry(pMan->vObj2Id, p->Id); }
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
Vec_Int_t * vObj2Id
Definition: bblif.c:92
#define assert(ex)
Definition: util_old.h:213
int Id
Definition: bblif.c:57
static int Bbl_ObjIsCi ( Bbl_Obj_t pObj)
inlinestatic

Definition at line 102 of file bblif.c.

102 { return pObj->fCi; }
unsigned fCi
Definition: bblif.c:59
static int Bbl_ObjIsCo ( Bbl_Obj_t pObj)
inlinestatic

Definition at line 103 of file bblif.c.

103 { return pObj->fCo; }
unsigned fCo
Definition: bblif.c:60
int Bbl_ObjIsInput ( Bbl_Obj_t p)

Fnction*************************************************************

Synopsis [Misc APIs.]

Description []

SideEffects []

SeeAlso []

Definition at line 1093 of file bblif.c.

1093 { return Bbl_ObjIsCi(p); }
static int Bbl_ObjIsCi(Bbl_Obj_t *pObj)
Definition: bblif.c:102
int Bbl_ObjIsLut ( Bbl_Obj_t p)

Definition at line 1095 of file bblif.c.

1095 { return Bbl_ObjIsNode(p); }
static int Bbl_ObjIsNode(Bbl_Obj_t *pObj)
Definition: bblif.c:104
int Bbl_ObjIsMarked ( Bbl_Obj_t p)

Definition at line 1100 of file bblif.c.

1100 { return p->fMark; }
unsigned fMark
Definition: bblif.c:62
static int Bbl_ObjIsNode ( Bbl_Obj_t pObj)
inlinestatic

Definition at line 104 of file bblif.c.

104 { return!pObj->fCi && !pObj->fCo; }
unsigned fCi
Definition: bblif.c:59
unsigned fCo
Definition: bblif.c:60
int Bbl_ObjIsOutput ( Bbl_Obj_t p)

Definition at line 1094 of file bblif.c.

1094 { return Bbl_ObjIsCo(p); }
static int Bbl_ObjIsCo(Bbl_Obj_t *pObj)
Definition: bblif.c:103
void Bbl_ObjMark ( Bbl_Obj_t p)

Definition at line 1101 of file bblif.c.

1101 { p->fMark = 1; }
unsigned fMark
Definition: bblif.c:62
static int Bbl_ObjSize ( Bbl_Obj_t pObj)
inlinestatic

Definition at line 109 of file bblif.c.

109 { return sizeof(Bbl_Obj_t) + sizeof(int) * pObj->nFanins; }
struct Bbl_Obj_t_ Bbl_Obj_t
Definition: bblif.h:216
unsigned nFanins
Definition: bblif.c:63
char* Bbl_ObjSop ( Bbl_Man_t pMan,
Bbl_Obj_t p 
)

Definition at line 1099 of file bblif.c.

1099 { return Bbl_ManSop(pMan, p->Fnc); }
static char * Bbl_ManSop(Bbl_Man_t *p, int h)
Definition: bblif.c:116
int Fnc
Definition: bblif.c:58
static Bbl_Ent_t* Bbl_VecEnt ( Vec_Str_t p,
int  h 
)
inlinestatic

Definition at line 114 of file bblif.c.

114 { return (Bbl_Ent_t *)(p->pArray + h); }
char * pArray
Definition: bblif.c:51
static Bbl_Fnc_t* Bbl_VecFnc ( Vec_Str_t p,
int  h 
)
inlinestatic

Definition at line 113 of file bblif.c.

113 { return (Bbl_Fnc_t *)(p->pArray + h); }
char * pArray
Definition: bblif.c:51
static Bbl_Obj_t* Bbl_VecObj ( Vec_Str_t p,
int  h 
)
inlinestatic

Definition at line 112 of file bblif.c.

112 { return (Bbl_Obj_t *)(p->pArray + h); }
char * pArray
Definition: bblif.c:51
static void Vec_IntAddToEntry ( Vec_Int_t p,
int  i,
int  Addition 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 302 of file bblif.c.

303 {
304  assert( i >= 0 && i < p->nSize );
305  p->pArray[i] += Addition;
306 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define assert(ex)
Definition: util_old.h:213
static Vec_Int_t* Vec_IntAlloc ( int  nCap)
inlinestatic

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocates a vector with the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 149 of file bblif.c.

150 {
151  Vec_Int_t * p;
152  p = BBLIF_ALLOC( Vec_Int_t, 1 );
153  if ( nCap > 0 && nCap < 16 )
154  nCap = 16;
155  p->nSize = 0;
156  p->nCap = nCap;
157  p->pArray = p->nCap? BBLIF_ALLOC( int, p->nCap ) : NULL;
158  return p;
159 }
#define BBLIF_ALLOC(type, num)
Definition: bblif.c:126
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Vec_Int_t* Vec_IntAllocArray ( int *  pArray,
int  nSize 
)
inlinestatic

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

Synopsis [Creates the vector from an integer array of the given size.]

Description []

SideEffects []

SeeAlso []

Definition at line 214 of file bblif.c.

215 {
216  Vec_Int_t * p;
217  p = BBLIF_ALLOC( Vec_Int_t, 1 );
218  p->nSize = nSize;
219  p->nCap = nSize;
220  p->pArray = pArray;
221  return p;
222 }
#define BBLIF_ALLOC(type, num)
Definition: bblif.c:126
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static void Vec_IntClear ( Vec_Int_t p)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 452 of file bblif.c.

453 {
454  p->nSize = 0;
455 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntEntry ( Vec_Int_t p,
int  i 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 268 of file bblif.c.

269 {
270  assert( i >= 0 && i < p->nSize );
271  return p->pArray[i];
272 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define assert(ex)
Definition: util_old.h:213
static int Vec_IntEntryLast ( Vec_Int_t p)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 319 of file bblif.c.

320 {
321  assert( p->nSize > 0 );
322  return p->pArray[p->nSize-1];
323 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFill ( Vec_Int_t p,
int  nSize,
int  Fill 
)
inlinestatic

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

Synopsis [Fills the vector with given number of entries.]

Description []

SideEffects []

SeeAlso []

Definition at line 356 of file bblif.c.

357 {
358  int i;
359  Vec_IntGrow( p, nSize );
360  for ( i = 0; i < nSize; i++ )
361  p->pArray[i] = Fill;
362  p->nSize = nSize;
363 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
static void Vec_IntFillExtra ( Vec_Int_t p,
int  nSize,
int  Fill 
)
inlinestatic

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

Synopsis [Fills the vector with given number of entries.]

Description []

SideEffects []

SeeAlso []

Definition at line 376 of file bblif.c.

377 {
378  int i;
379  if ( p->nSize >= nSize )
380  return;
381  if ( nSize > 2 * p->nCap )
382  Vec_IntGrow( p, nSize );
383  else if ( nSize > p->nCap )
384  Vec_IntGrow( p, 2 * p->nCap );
385  for ( i = p->nSize; i < nSize; i++ )
386  p->pArray[i] = Fill;
387  p->nSize = nSize;
388 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
static void Vec_IntFree ( Vec_Int_t p)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 235 of file bblif.c.

236 {
237  BBLIF_FREE( p->pArray );
238  BBLIF_FREE( p );
239 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define BBLIF_FREE(obj)
Definition: bblif.c:129
static int Vec_IntGetEntry ( Vec_Int_t p,
int  i 
)
inlinestatic

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

Synopsis [Returns the entry even if the place not exist.]

Description []

SideEffects []

SeeAlso []

Definition at line 401 of file bblif.c.

402 {
403  Vec_IntFillExtra( p, i + 1, 0 );
404  return Vec_IntEntry( p, i );
405 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntFillExtra(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:376
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void Vec_IntGrow ( Vec_Int_t p,
int  nCapMin 
)
inlinestatic

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

Synopsis [Resizes the vector to the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 336 of file bblif.c.

337 {
338  if ( p->nCap >= nCapMin )
339  return;
340  p->pArray = BBLIF_REALLOC( int, p->pArray, nCapMin );
341  assert( p->pArray );
342  p->nCap = nCapMin;
343 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define BBLIF_REALLOC(type, obj, num)
Definition: bblif.c:130
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntPush ( Vec_Int_t p,
int  Entry 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 468 of file bblif.c.

469 {
470  if ( p->nSize == p->nCap )
471  {
472  if ( p->nCap < 16 )
473  Vec_IntGrow( p, 16 );
474  else
475  Vec_IntGrow( p, 2 * p->nCap );
476  }
477  p->pArray[p->nSize++] = Entry;
478 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
static void Vec_IntSetEntry ( Vec_Int_t p,
int  i,
int  Entry 
)
inlinestatic

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

Synopsis [Inserts the entry even if the place does not exist.]

Description []

SideEffects []

SeeAlso []

Definition at line 418 of file bblif.c.

419 {
420  Vec_IntFillExtra( p, i + 1, 0 );
421  Vec_IntWriteEntry( p, i, Entry );
422 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntFillExtra(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:376
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static void Vec_IntShrink ( Vec_Int_t p,
int  nSizeNew 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 435 of file bblif.c.

436 {
437  assert( p->nSize >= nSizeNew );
438  p->nSize = nSizeNew;
439 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define assert(ex)
Definition: util_old.h:213
static int Vec_IntSize ( Vec_Int_t p)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 252 of file bblif.c.

253 {
254  return p->nSize;
255 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Vec_Int_t* Vec_IntStart ( int  nSize)
inlinestatic

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

Synopsis [Allocates a vector with the given size and cleans it.]

Description []

SideEffects []

SeeAlso []

Definition at line 172 of file bblif.c.

173 {
174  Vec_Int_t * p;
175  p = Vec_IntAlloc( nSize );
176  p->nSize = nSize;
177  memset( p->pArray, 0, sizeof(int) * nSize );
178  return p;
179 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static Vec_Int_t* Vec_IntStartNatural ( int  nSize)
inlinestatic

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

Synopsis [Allocates a vector with the given size and cleans it.]

Description []

SideEffects []

SeeAlso []

Definition at line 192 of file bblif.c.

193 {
194  Vec_Int_t * p;
195  int i;
196  p = Vec_IntAlloc( nSize );
197  p->nSize = nSize;
198  for ( i = 0; i < nSize; i++ )
199  p->pArray[i] = i;
200  return p;
201 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntWriteEntry ( Vec_Int_t p,
int  i,
int  Entry 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 285 of file bblif.c.

286 {
287  assert( i >= 0 && i < p->nSize );
288  p->pArray[i] = Entry;
289 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define assert(ex)
Definition: util_old.h:213
static Vec_Str_t* Vec_StrAlloc ( int  nCap)
inlinestatic

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

Synopsis [Allocates a vector with the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 495 of file bblif.c.

496 {
497  Vec_Str_t * p;
498  p = BBLIF_ALLOC( Vec_Str_t, 1 );
499  if ( nCap > 0 && nCap < 16 )
500  nCap = 16;
501  p->nSize = 0;
502  p->nCap = nCap;
503  p->pArray = p->nCap? BBLIF_ALLOC( char, p->nCap ) : NULL;
504  return p;
505 }
#define BBLIF_ALLOC(type, num)
Definition: bblif.c:126
static Llb_Mgr_t * p
Definition: llb3Image.c:950
char * pArray
Definition: bblif.c:51
int nSize
Definition: bblif.c:50
int nCap
Definition: bblif.c:49
static Vec_Str_t* Vec_StrAllocArray ( char *  pArray,
int  nSize 
)
inlinestatic

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

Synopsis [Creates the vector from an array of the given size.]

Description []

SideEffects []

SeeAlso []

Definition at line 518 of file bblif.c.

519 {
520  Vec_Str_t * p;
521  p = BBLIF_ALLOC( Vec_Str_t, 1 );
522  p->nSize = nSize;
523  p->nCap = nSize;
524  p->pArray = pArray;
525  return p;
526 }
#define BBLIF_ALLOC(type, num)
Definition: bblif.c:126
static Llb_Mgr_t * p
Definition: llb3Image.c:950
char * pArray
Definition: bblif.c:51
int nSize
Definition: bblif.c:50
int nCap
Definition: bblif.c:49
char* Vec_StrFetch ( Vec_Str_t p,
int  nBytes 
)

Fnction*************************************************************

Synopsis [Returns a piece of memory.]

Description []

SideEffects []

SeeAlso []

Definition at line 539 of file bblif.c.

540 {
541  while ( p->nSize + nBytes > p->nCap )
542  {
543  p->pArray = BBLIF_REALLOC( char, p->pArray, 3 * p->nCap );
544  p->nCap *= 3;
545  }
546  p->nSize += nBytes;
547  return p->pArray + p->nSize - nBytes;
548 }
#define BBLIF_REALLOC(type, obj, num)
Definition: bblif.c:130
char * pArray
Definition: bblif.c:51
int nSize
Definition: bblif.c:50
int nCap
Definition: bblif.c:49
static void Vec_StrFree ( Vec_Str_t p)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 616 of file bblif.c.

617 {
618  BBLIF_FREE( p->pArray );
619  BBLIF_FREE( p );
620 }
char * pArray
Definition: bblif.c:51
#define BBLIF_FREE(obj)
Definition: bblif.c:129
Vec_Str_t* Vec_StrRead ( char **  ppStr)

Fnction*************************************************************

Synopsis [Write vector into file.]

Description []

SideEffects []

SeeAlso []

Definition at line 578 of file bblif.c.

579 {
580  Vec_Str_t * p;
581  char * pStr = *ppStr;
582  p = Vec_StrAlloc( 0 );
583  p->nSize = *(int *)pStr;
584  p->pArray = pStr + sizeof(int);
585  *ppStr = pStr + sizeof(int) + p->nSize * sizeof(char);
586  return p;
587 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
char * pArray
Definition: bblif.c:51
int nSize
Definition: bblif.c:50
static int Vec_StrSize ( Vec_Str_t p)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 600 of file bblif.c.

601 {
602  return p->nSize;
603 }
int nSize
Definition: bblif.c:50
void Vec_StrWrite ( FILE *  pFile,
Vec_Str_t p 
)

Fnction*************************************************************

Synopsis [Write vector into file.]

Description []

SideEffects []

SeeAlso []

Definition at line 561 of file bblif.c.

562 {
563  fwrite( &p->nSize, sizeof(int), 1, pFile );
564  fwrite( p->pArray, sizeof(char), p->nSize, pFile );
565 }
char * pArray
Definition: bblif.c:51
int nSize
Definition: bblif.c:50