abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cbaWriteBlif.c File Reference
#include "cba.h"
#include "cbaPrs.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Cba_PrsWriteBlifArray (FILE *pFile, Cba_Ntk_t *p, Vec_Int_t *vFanins, int fFirst)
 DECLARATIONS ///. More...
 
void Cba_PrsWriteBlifArray2 (FILE *pFile, Cba_Ntk_t *p, Vec_Int_t *vFanins)
 
void Cba_PrsWriteBlifLines (FILE *pFile, Cba_Ntk_t *p)
 
void Cba_PrsWriteBlifNtk (FILE *pFile, Cba_Ntk_t *p)
 
void Cba_PrsWriteBlif (char *pFileName, Cba_Man_t *pDes)
 

Function Documentation

void Cba_PrsWriteBlif ( char *  pFileName,
Cba_Man_t pDes 
)

Definition at line 105 of file cbaWriteBlif.c.

106 {
107  FILE * pFile;
108  Cba_Ntk_t * pNtk;
109  int i;
110  pFile = fopen( pFileName, "wb" );
111  if ( pFile == NULL )
112  {
113  printf( "Cannot open output file \"%s\".\n", pFileName );
114  return;
115  }
116  fprintf( pFile, "// Design \"%s\" written by ABC on %s\n\n", Cba_ManName(pDes), Extra_TimeStamp() );
117  Cba_ManForEachNtk( pDes, pNtk, i )
118  Cba_PrsWriteBlifNtk( pFile, pNtk );
119  fclose( pFile );
120 }
Definition: cba.h:99
static char * Cba_ManName(Cba_Man_t *p)
Definition: cba.h:120
void Cba_PrsWriteBlifNtk(FILE *pFile, Cba_Ntk_t *p)
Definition: cbaWriteBlif.c:87
char * Extra_TimeStamp()
#define Cba_ManForEachNtk(p, pNtk, i)
MACRO DEFINITIONS ///.
Definition: cba.h:155
ABC_NAMESPACE_IMPL_START void Cba_PrsWriteBlifArray ( FILE *  pFile,
Cba_Ntk_t p,
Vec_Int_t vFanins,
int  fFirst 
)

DECLARATIONS ///.

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

FileName [cbaWriteBlif.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Verilog parser.]

Synopsis [Parses several flavors of word-level Verilog.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id:
cbaWriteVer.c,v 1.00 2014/11/29 00:00:00 alanmi Exp

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

Synopsis [Writing parser state into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file cbaWriteBlif.c.

46 {
47  int NameId, i;
48  Vec_IntForEachEntryStart( vFanins, NameId, i, fFirst )
49  fprintf( pFile, " %s", Cba_NtkStr(p, NameId) );
50  if ( fFirst )
51  fprintf( pFile, " %s", Cba_NtkStr(p, Vec_IntEntry(vFanins,0)) );
52  fprintf( pFile, "\n" );
53 }
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static char * Cba_NtkStr(Cba_Ntk_t *p, int i)
Definition: cba.h:127
if(last==0)
Definition: sparse_int.h:34
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
void Cba_PrsWriteBlifArray2 ( FILE *  pFile,
Cba_Ntk_t p,
Vec_Int_t vFanins 
)

Definition at line 54 of file cbaWriteBlif.c.

55 {
56  int FormId, NameId, i;
57  assert( Vec_IntSize(vFanins) % 2 == 0 );
58  Vec_IntForEachEntryDouble( vFanins, FormId, NameId, i )
59  fprintf( pFile, " %s=%s", Cba_NtkStr(p, FormId), Cba_NtkStr(p, NameId) );
60  fprintf( pFile, "\n" );
61 }
static char * Cba_NtkStr(Cba_Ntk_t *p, int i)
Definition: cba.h:127
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition: vecInt.h:66
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
void Cba_PrsWriteBlifLines ( FILE *  pFile,
Cba_Ntk_t p 
)

Definition at line 62 of file cbaWriteBlif.c.

63 {
64  Vec_Int_t * vFanins;
65  int Type, Func, i;
66  Cba_NtkForEachObjTypeFuncFanins( p, Type, Func, vFanins, i )
67  if ( Type == CBA_PRS_NODE ) // .names/assign/box2 (no formal/actual binding)
68  {
69  fprintf( pFile, ".names" );
70  Cba_PrsWriteBlifArray( pFile, p, vFanins, 1 );
71  fprintf( pFile, "%s", Cba_NtkFuncStr(p, Func) );
72  }
73  else if ( Type == CBA_PRS_BOX ) // .names/assign/box2 (no formal/actual binding)
74  {
75  fprintf( pFile, ".subckt" );
76  fprintf( pFile, " %s", Cba_NtkStr(p, Func) );
77  Cba_PrsWriteBlifArray2( pFile, p, vFanins );
78  }
79  else if ( Type == CBA_PRS_LATCH ) // .names/assign/box2 (no formal/actual binding)
80  {
81  fprintf( pFile, ".latch" );
82  fprintf( pFile, " %s", Cba_NtkStr(p, Vec_IntEntry(vFanins, 1)) );
83  fprintf( pFile, " %s", Cba_NtkStr(p, Vec_IntEntry(vFanins, 0)) );
84  fprintf( pFile, " %c\n", '0' + Func );
85  }
86 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define Cba_NtkForEachObjTypeFuncFanins(p, Type, Func, vFanins, i)
Definition: cba.h:160
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static char * Cba_NtkStr(Cba_Ntk_t *p, int i)
Definition: cba.h:127
if(last==0)
Definition: sparse_int.h:34
ABC_NAMESPACE_IMPL_START void Cba_PrsWriteBlifArray(FILE *pFile, Cba_Ntk_t *p, Vec_Int_t *vFanins, int fFirst)
DECLARATIONS ///.
Definition: cbaWriteBlif.c:45
void Cba_PrsWriteBlifArray2(FILE *pFile, Cba_Ntk_t *p, Vec_Int_t *vFanins)
Definition: cbaWriteBlif.c:54
static char * Cba_NtkFuncStr(Cba_Ntk_t *p, int i)
Definition: cba.h:129
void Cba_PrsWriteBlifNtk ( FILE *  pFile,
Cba_Ntk_t p 
)

Definition at line 87 of file cbaWriteBlif.c.

88 {
89  assert( Vec_IntSize(&p->vTypes) == Cba_NtkObjNum(p) );
90  assert( Vec_IntSize(&p->vFuncs) == Cba_NtkObjNum(p) );
91  // write header
92  fprintf( pFile, ".model %s\n", Cba_NtkName(p) );
93  if ( Vec_IntSize(&p->vInouts) )
94  fprintf( pFile, ".inouts" );
95  if ( Vec_IntSize(&p->vInouts) )
96  Cba_PrsWriteBlifArray( pFile, p, &p->vInouts, 0 );
97  fprintf( pFile, ".inputs" );
98  Cba_PrsWriteBlifArray( pFile, p, &p->vInputs, 0 );
99  fprintf( pFile, ".outputs" );
100  Cba_PrsWriteBlifArray( pFile, p, &p->vOutputs, 0 );
101  // write objects
102  Cba_PrsWriteBlifLines( pFile, p );
103  fprintf( pFile, ".end\n\n" );
104 }
static char * Cba_NtkName(Cba_Ntk_t *p)
Definition: cba.h:125
Vec_Int_t vInputs
Definition: cba.h:105
Vec_Int_t vOutputs
Definition: cba.h:106
Vec_Int_t vFuncs
Definition: cba.h:110
static int Cba_NtkObjNum(Cba_Ntk_t *p)
Definition: cba.h:126
ABC_NAMESPACE_IMPL_START void Cba_PrsWriteBlifArray(FILE *pFile, Cba_Ntk_t *p, Vec_Int_t *vFanins, int fFirst)
DECLARATIONS ///.
Definition: cbaWriteBlif.c:45
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
Vec_Int_t vInouts
Definition: cba.h:104
void Cba_PrsWriteBlifLines(FILE *pFile, Cba_Ntk_t *p)
Definition: cbaWriteBlif.c:62
Vec_Int_t vTypes
Definition: cba.h:109