abc-master
|
#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_t * | Bbl_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_t * | Bbl_VecObj (Vec_Str_t *p, int h) |
static Bbl_Fnc_t * | Bbl_VecFnc (Vec_Str_t *p, int h) |
static Bbl_Ent_t * | Bbl_VecEnt (Vec_Str_t *p, int h) |
static char * | Bbl_ManSop (Bbl_Man_t *p, int h) |
static Bbl_Obj_t * | Bbl_ManObj (Bbl_Man_t *p, int Id) |
static Vec_Int_t * | Vec_IntAlloc (int nCap) |
FUNCTION DEFINITIONS ///. More... | |
static Vec_Int_t * | Vec_IntStart (int nSize) |
static Vec_Int_t * | Vec_IntStartNatural (int nSize) |
static Vec_Int_t * | Vec_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_t * | Vec_StrAlloc (int nCap) |
static Vec_Str_t * | Vec_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_t * | Vec_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_t * | Bbl_ManReadBinaryBlif (char *pFileName) |
void | Bbl_ManPrintStats (Bbl_Man_t *p) |
void | Bbl_ManStop (Bbl_Man_t *p) |
Bbl_Man_t * | Bbl_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_t * | Bbl_ManObjFirst (Bbl_Man_t *p) |
Bbl_Obj_t * | Bbl_ManObjNext (Bbl_Man_t *p, Bbl_Obj_t *pObj) |
Bbl_Obj_t * | Bbl_ObjFaninFirst (Bbl_Obj_t *p) |
Bbl_Obj_t * | Bbl_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 () |
#define Bbl_ManForEachFnc_int | ( | p, | |
pObj, | |||
h | |||
) | for ( h = 0; (h < p->nSize) && (pObj = Bbl_VecFnc(p,h)); h += Bbl_FncSize(pObj) ) |
#define Bbl_ManForEachObj_int | ( | p, | |
pObj, | |||
h | |||
) | for ( h = 0; (h < p->nSize) && (pObj = Bbl_VecObj(p,h)); h += Bbl_ObjSize(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_FREE | ( | obj | ) | ((obj) ? (free((char *) (obj)), (obj) = 0) : 0) |
#define BBLIF_REALLOC | ( | type, | |
obj, | |||
num | |||
) |
typedef struct Bbl_Ent_t_ Bbl_Ent_t |
typedef struct Bbl_Fnc_t_ Bbl_Fnc_t |
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 [
]
typedef struct Vec_Str_t_ Vec_Str_t |
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.
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.
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.
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.
void Bbl_ManDumpBinaryBlif | ( | Bbl_Man_t * | p, |
char * | pFileName | ||
) |
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.
char* Bbl_ManFileRead | ( | char * | pFileName | ) |
int Bbl_ManFileSize | ( | char * | pFileName | ) |
int Bbl_ManFncSize | ( | Bbl_Man_t * | p | ) |
char* Bbl_ManName | ( | Bbl_Man_t * | p | ) |
Fnction*************************************************************
Synopsis [Returns the next object.]
Description []
SideEffects []
SeeAlso []
Definition at line 1163 of file bblif.c.
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.
Bbl_Man_t* Bbl_ManReadBinaryBlif | ( | char * | pFileName | ) |
Fnction*************************************************************
Synopsis [Creates manager after reading.]
Description []
SideEffects []
SeeAlso []
Definition at line 712 of file bblif.c.
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.
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.
|
inlinestatic |
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 []
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.
|
inlinestatic |
void Bbl_ManSortCubes | ( | char ** | pCubes, |
int | nCubes, | ||
int | nVars | ||
) |
char* Bbl_ManSortSop | ( | char * | pSop, |
int | nVars | ||
) |
Bbl_Man_t* Bbl_ManStart | ( | char * | pName | ) |
MACRO DEFINITIONS ///.
Fnction*************************************************************
Synopsis [Creates manager.]
Description []
SideEffects []
SeeAlso []
void Bbl_ManStop | ( | Bbl_Man_t * | p | ) |
void Bbl_ManTestTruth | ( | char * | pSop, |
int | nVars | ||
) |
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.
Definition at line 107 of file bblif.c.
Fnction*************************************************************
Synopsis [Returns the next fanin.]
Description []
SideEffects []
SeeAlso []
Definition at line 1197 of file bblif.c.
int Bbl_ObjIsInput | ( | Bbl_Obj_t * | p | ) |
Definition at line 114 of file bblif.c.
Definition at line 113 of file bblif.c.
Definition at line 112 of file bblif.c.
|
inlinestatic |
|
inlinestatic |
FUNCTION DEFINITIONS ///.
Function*************************************************************
Synopsis [Allocates a vector with the given capacity.]
Description []
SideEffects []
SeeAlso []
Definition at line 149 of file bblif.c.
|
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.
|
inlinestatic |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Function*************************************************************
Synopsis [Returns the entry even if the place not exist.]
Description []
SideEffects []
SeeAlso []
Definition at line 401 of file bblif.c.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Function*************************************************************
Synopsis [Inserts the entry even if the place does not exist.]
Description []
SideEffects []
SeeAlso []
Definition at line 418 of file bblif.c.
|
inlinestatic |
|
inlinestatic |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
|
inlinestatic |
Function*************************************************************
Synopsis [Allocates a vector with the given size and cleans it.]
Description []
SideEffects []
SeeAlso []
Definition at line 172 of file bblif.c.
|
inlinestatic |
Function*************************************************************
Synopsis [Allocates a vector with the given size and cleans it.]
Description []
SideEffects []
SeeAlso []
Definition at line 192 of file bblif.c.
|
inlinestatic |
|
inlinestatic |
Function*************************************************************
Synopsis [Allocates a vector with the given capacity.]
Description []
SideEffects []
SeeAlso []
Definition at line 495 of file bblif.c.
|
inlinestatic |
Function*************************************************************
Synopsis [Creates the vector from an array of the given size.]
Description []
SideEffects []
SeeAlso []
Definition at line 518 of file bblif.c.
char* Vec_StrFetch | ( | Vec_Str_t * | p, |
int | nBytes | ||
) |
|
inlinestatic |
Vec_Str_t* Vec_StrRead | ( | char ** | ppStr | ) |
Fnction*************************************************************
Synopsis [Write vector into file.]
Description []
SideEffects []
SeeAlso []
Definition at line 578 of file bblif.c.
|
inlinestatic |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []