abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcXsim.c File Reference
#include "base/abc/abc.h"
#include "aig/gia/gia.h"

Go to the source code of this file.

Macros

#define XVS0   ABC_INIT_ZERO
 DECLARATIONS ///. More...
 
#define XVS1   ABC_INIT_ONE
 
#define XVSX   ABC_INIT_DC
 

Functions

static void Abc_ObjSetXsim (Abc_Obj_t *pObj, int Value)
 
static int Abc_ObjGetXsim (Abc_Obj_t *pObj)
 
static int Abc_XsimInv (int Value)
 
static int Abc_XsimAnd (int Value0, int Value1)
 
static int Abc_XsimRand2 ()
 
static int Abc_XsimRand3 ()
 
static int Abc_ObjGetXsimFanin0 (Abc_Obj_t *pObj)
 
static int Abc_ObjGetXsimFanin1 (Abc_Obj_t *pObj)
 
static void Abc_XsimPrint (FILE *pFile, int Value)
 
void Abc_NtkXValueSimulate (Abc_Ntk_t *pNtk, int nFrames, int fXInputs, int fXState, int fVerbose)
 FUNCTION DEFINITIONS ///. More...
 
void Abc_NtkCycleInitState (Abc_Ntk_t *pNtk, int nFrames, int fUseXval, int fVerbose)
 

Macro Definition Documentation

#define XVS0   ABC_INIT_ZERO

DECLARATIONS ///.

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

FileName [abcXsim.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Using X-valued simulation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
abcXsim.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 30 of file abcXsim.c.

#define XVS1   ABC_INIT_ONE

Definition at line 31 of file abcXsim.c.

#define XVSX   ABC_INIT_DC

Definition at line 32 of file abcXsim.c.

Function Documentation

void Abc_NtkCycleInitState ( Abc_Ntk_t pNtk,
int  nFrames,
int  fUseXval,
int  fVerbose 
)

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

Synopsis [Cycles the circuit to create a new initial state.]

Description [Simulates the circuit with random (or ternary) input for the given number of timeframes to get a better initial state.]

SideEffects []

SeeAlso []

Definition at line 192 of file abcXsim.c.

193 {
194  Abc_Obj_t * pObj;
195  int i, f;
196  assert( Abc_NtkIsStrash(pNtk) );
197 // srand( 0x12341234 );
198  Gia_ManRandom( 1 );
199  // initialize the values
201  Abc_NtkForEachLatch( pNtk, pObj, i )
203  // simulate for the given number of timeframes
204  for ( f = 0; f < nFrames; f++ )
205  {
206  Abc_NtkForEachPi( pNtk, pObj, i )
207  Abc_ObjSetXsim( pObj, fUseXval? ABC_INIT_DC : Abc_XsimRand2() );
208 // Abc_ObjSetXsim( pObj, ABC_INIT_ONE );
209  Abc_AigForEachAnd( pNtk, pObj, i )
211  Abc_NtkForEachCo( pNtk, pObj, i )
212  Abc_ObjSetXsim( pObj, Abc_ObjGetXsimFanin0(pObj) );
213  Abc_NtkForEachLatch( pNtk, pObj, i )
215  }
216  // set the final values
217  Abc_NtkForEachLatch( pNtk, pObj, i )
218  {
219  pObj->pData = (void *)(ABC_PTRINT_T)Abc_ObjGetXsim(Abc_ObjFanout0(pObj));
220 // printf( "%d", Abc_LatchIsInit1(pObj) );
221  }
222 // printf( "\n" );
223 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static int Abc_LatchInit(Abc_Obj_t *pLatch)
Definition: abc.h:425
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Abc_XsimRand2()
Definition: abcXsim.c:54
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
for(p=first;p->value< newval;p=p->next)
unsigned Gia_ManRandom(int fReset)
FUNCTION DEFINITIONS ///.
Definition: giaUtil.c:49
static int Abc_ObjGetXsimFanin1(Abc_Obj_t *pObj)
Definition: abcXsim.c:74
#define Abc_AigForEachAnd(pNtk, pNode, i)
Definition: abc.h:485
static int Abc_ObjGetXsim(Abc_Obj_t *pObj)
Definition: abcXsim.c:35
static void Abc_ObjSetXsim(Abc_Obj_t *pObj, int Value)
Definition: abcXsim.c:34
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static int Abc_XsimAnd(int Value0, int Value1)
Definition: abcXsim.c:45
#define XVS1
Definition: abcXsim.c:31
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjGetXsimFanin0(Abc_Obj_t *pObj)
Definition: abcXsim.c:68
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
void Abc_NtkXValueSimulate ( Abc_Ntk_t pNtk,
int  nFrames,
int  fXInputs,
int  fXState,
int  fVerbose 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Performs X-valued simulation of the sequential network.]

Description []

SideEffects []

SeeAlso []

Definition at line 111 of file abcXsim.c.

112 {
113  Abc_Obj_t * pObj;
114  int i, f;
115  assert( Abc_NtkIsStrash(pNtk) );
116 // srand( 0x12341234 );
117  Gia_ManRandom( 1 );
118  // start simulation
120  if ( fXInputs )
121  {
122  Abc_NtkForEachPi( pNtk, pObj, i )
123  Abc_ObjSetXsim( pObj, XVSX );
124  }
125  else
126  {
127  Abc_NtkForEachPi( pNtk, pObj, i )
128  Abc_ObjSetXsim( pObj, Abc_XsimRand2() );
129  }
130  if ( fXState )
131  {
132  Abc_NtkForEachLatch( pNtk, pObj, i )
133  Abc_ObjSetXsim( Abc_ObjFanout0(pObj), XVSX );
134  }
135  else
136  {
137  Abc_NtkForEachLatch( pNtk, pObj, i )
139  }
140  // simulate and print the result
141  fprintf( stdout, "Frame : Inputs : Latches : Outputs\n" );
142  for ( f = 0; f < nFrames; f++ )
143  {
144  Abc_AigForEachAnd( pNtk, pObj, i )
146  Abc_NtkForEachCo( pNtk, pObj, i )
147  Abc_ObjSetXsim( pObj, Abc_ObjGetXsimFanin0(pObj) );
148  // print out
149  fprintf( stdout, "%2d : ", f );
150  Abc_NtkForEachPi( pNtk, pObj, i )
151  Abc_XsimPrint( stdout, Abc_ObjGetXsim(pObj) );
152  fprintf( stdout, " : " );
153  Abc_NtkForEachLatch( pNtk, pObj, i )
154  {
155 // if ( Abc_ObjGetXsim(Abc_ObjFanout0(pObj)) != XVSX )
156 // printf( " %s=", Abc_ObjName(pObj) );
157  Abc_XsimPrint( stdout, Abc_ObjGetXsim(Abc_ObjFanout0(pObj)) );
158  }
159  fprintf( stdout, " : " );
160  Abc_NtkForEachPo( pNtk, pObj, i )
161  Abc_XsimPrint( stdout, Abc_ObjGetXsim(pObj) );
162  fprintf( stdout, "\n" );
163  // assign input values
164  if ( fXInputs )
165  {
166  Abc_NtkForEachPi( pNtk, pObj, i )
167  Abc_ObjSetXsim( pObj, XVSX );
168  }
169  else
170  {
171  Abc_NtkForEachPi( pNtk, pObj, i )
172  Abc_ObjSetXsim( pObj, Abc_XsimRand2() );
173  }
174  // transfer the latch values
175  Abc_NtkForEachLatch( pNtk, pObj, i )
177  }
178 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static int Abc_LatchInit(Abc_Obj_t *pLatch)
Definition: abc.h:425
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
#define XVSX
Definition: abcXsim.c:32
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Abc_XsimRand2()
Definition: abcXsim.c:54
static void Abc_XsimPrint(FILE *pFile, int Value)
Definition: abcXsim.c:80
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
for(p=first;p->value< newval;p=p->next)
unsigned Gia_ManRandom(int fReset)
FUNCTION DEFINITIONS ///.
Definition: giaUtil.c:49
static int Abc_ObjGetXsimFanin1(Abc_Obj_t *pObj)
Definition: abcXsim.c:74
#define Abc_AigForEachAnd(pNtk, pNode, i)
Definition: abc.h:485
static int Abc_ObjGetXsim(Abc_Obj_t *pObj)
Definition: abcXsim.c:35
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
static void Abc_ObjSetXsim(Abc_Obj_t *pObj, int Value)
Definition: abcXsim.c:34
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static int Abc_XsimAnd(int Value0, int Value1)
Definition: abcXsim.c:45
#define XVS1
Definition: abcXsim.c:31
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjGetXsimFanin0(Abc_Obj_t *pObj)
Definition: abcXsim.c:68
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
static int Abc_ObjGetXsim ( Abc_Obj_t pObj)
inlinestatic

Definition at line 35 of file abcXsim.c.

35 { return (int)(ABC_PTRINT_T)pObj->pCopy; }
Abc_Obj_t * pCopy
Definition: abc.h:148
static int Abc_ObjGetXsimFanin0 ( Abc_Obj_t pObj)
inlinestatic

Definition at line 68 of file abcXsim.c.

69 {
70  int RetValue;
71  RetValue = Abc_ObjGetXsim(Abc_ObjFanin0(pObj));
72  return Abc_ObjFaninC0(pObj)? Abc_XsimInv(RetValue) : RetValue;
73 }
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_ObjGetXsim(Abc_Obj_t *pObj)
Definition: abcXsim.c:35
static int Abc_XsimInv(int Value)
Definition: abcXsim.c:36
static int Abc_ObjGetXsimFanin1 ( Abc_Obj_t pObj)
inlinestatic

Definition at line 74 of file abcXsim.c.

75 {
76  int RetValue;
77  RetValue = Abc_ObjGetXsim(Abc_ObjFanin1(pObj));
78  return Abc_ObjFaninC1(pObj)? Abc_XsimInv(RetValue) : RetValue;
79 }
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
static int Abc_ObjGetXsim(Abc_Obj_t *pObj)
Definition: abcXsim.c:35
static int Abc_XsimInv(int Value)
Definition: abcXsim.c:36
static void Abc_ObjSetXsim ( Abc_Obj_t pObj,
int  Value 
)
inlinestatic

Definition at line 34 of file abcXsim.c.

34 { pObj->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)Value; }
Abc_Obj_t * pCopy
Definition: abc.h:148
static int Abc_XsimAnd ( int  Value0,
int  Value1 
)
inlinestatic

Definition at line 45 of file abcXsim.c.

46 {
47  if ( Value0 == XVS0 || Value1 == XVS0 )
48  return XVS0;
49  if ( Value0 == XVSX || Value1 == XVSX )
50  return XVSX;
51  assert( Value0 == XVS1 && Value1 == XVS1 );
52  return XVS1;
53 }
#define XVS0
DECLARATIONS ///.
Definition: abcXsim.c:30
#define XVSX
Definition: abcXsim.c:32
#define XVS1
Definition: abcXsim.c:31
#define assert(ex)
Definition: util_old.h:213
static int Abc_XsimInv ( int  Value)
inlinestatic

Definition at line 36 of file abcXsim.c.

37 {
38  if ( Value == XVS0 )
39  return XVS1;
40  if ( Value == XVS1 )
41  return XVS0;
42  assert( Value == XVSX );
43  return XVSX;
44 }
#define XVS0
DECLARATIONS ///.
Definition: abcXsim.c:30
#define XVSX
Definition: abcXsim.c:32
#define XVS1
Definition: abcXsim.c:31
#define assert(ex)
Definition: util_old.h:213
static void Abc_XsimPrint ( FILE *  pFile,
int  Value 
)
inlinestatic

Definition at line 80 of file abcXsim.c.

81 {
82  if ( Value == XVS0 )
83  {
84  fprintf( pFile, "0" );
85  return;
86  }
87  if ( Value == XVS1 )
88  {
89  fprintf( pFile, "1" );
90  return;
91  }
92  assert( Value == XVSX );
93  fprintf( pFile, "x" );
94 }
#define XVS0
DECLARATIONS ///.
Definition: abcXsim.c:30
#define XVSX
Definition: abcXsim.c:32
#define XVS1
Definition: abcXsim.c:31
#define assert(ex)
Definition: util_old.h:213
static int Abc_XsimRand2 ( )
inlinestatic

Definition at line 54 of file abcXsim.c.

55 {
56 // return (rand() & 1) ? XVS1 : XVS0;
57  return (Gia_ManRandom(0) & 1) ? XVS1 : XVS0;
58 }
#define XVS0
DECLARATIONS ///.
Definition: abcXsim.c:30
unsigned Gia_ManRandom(int fReset)
FUNCTION DEFINITIONS ///.
Definition: giaUtil.c:49
#define XVS1
Definition: abcXsim.c:31
static int Abc_XsimRand3 ( )
inlinestatic

Definition at line 59 of file abcXsim.c.

60 {
61  int RetValue;
62  do {
63 // RetValue = rand() & 3;
64  RetValue = Gia_ManRandom(0) & 3;
65  } while ( RetValue == 0 );
66  return RetValue;
67 }
unsigned Gia_ManRandom(int fReset)
FUNCTION DEFINITIONS ///.
Definition: giaUtil.c:49