src/base/abci/abcXsim.c File Reference

#include "abc.h"
Include dependency graph for abcXsim.c:

Go to the source code of this file.

Defines

#define XVS0   ABC_INIT_ZERO
#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)
void Abc_NtkCycleInitState (Abc_Ntk_t *pNtk, int nFrames, int fVerbose)

Define Documentation

#define XVS0   ABC_INIT_ZERO

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

] DECLARATIONS ///

Definition at line 27 of file abcXsim.c.

#define XVS1   ABC_INIT_ONE

Definition at line 28 of file abcXsim.c.

#define XVSX   ABC_INIT_DC

Definition at line 29 of file abcXsim.c.


Function Documentation

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

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

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

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

SideEffects []

SeeAlso []

Definition at line 192 of file abcXsim.c.

00193 {
00194     Abc_Obj_t * pObj;
00195     int i, f;
00196     assert( Abc_NtkIsStrash(pNtk) );
00197     srand( 0x12341234 );
00198     // initialize the values
00199     Abc_ObjSetXsim( Abc_AigConst1(pNtk), XVS1 );
00200     Abc_NtkForEachPi( pNtk, pObj, i )
00201         Abc_ObjSetXsim( pObj, Abc_XsimRand2() );
00202     Abc_NtkForEachLatch( pNtk, pObj, i )
00203         Abc_ObjSetXsim( Abc_ObjFanout0(pObj), Abc_LatchIsInit1(pObj)? XVS1 : XVS0 );
00204     // simulate for the given number of timeframes
00205     for ( f = 0; f < nFrames; f++ )
00206     {
00207         Abc_AigForEachAnd( pNtk, pObj, i )
00208             Abc_ObjSetXsim( pObj, Abc_XsimAnd(Abc_ObjGetXsimFanin0(pObj), Abc_ObjGetXsimFanin1(pObj)) );
00209         Abc_NtkForEachCo( pNtk, pObj, i )
00210             Abc_ObjSetXsim( pObj, Abc_ObjGetXsimFanin0(pObj) );
00211         // assign input values
00212         Abc_NtkForEachPi( pNtk, pObj, i )
00213             Abc_ObjSetXsim( pObj, Abc_XsimRand2() );
00214         // transfer the latch values
00215         Abc_NtkForEachLatch( pNtk, pObj, i )
00216             Abc_ObjSetXsim( Abc_ObjFanout0(pObj), Abc_ObjGetXsim(Abc_ObjFanin0(pObj)) );
00217     }
00218     // set the final values
00219     Abc_NtkForEachLatch( pNtk, pObj, i )
00220         pObj->pData = (void *)Abc_ObjGetXsim(Abc_ObjFanout0(pObj));
00221 }

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 106 of file abcXsim.c.

00107 {
00108     Abc_Obj_t * pObj;
00109     int i, f;
00110     assert( Abc_NtkIsStrash(pNtk) );
00111     srand( 0x12341234 );
00112     // start simulation
00113     Abc_ObjSetXsim( Abc_AigConst1(pNtk), XVS1 );
00114     if ( fXInputs )
00115     {
00116         Abc_NtkForEachPi( pNtk, pObj, i )
00117             Abc_ObjSetXsim( pObj, XVSX );
00118     }
00119     else
00120     {
00121         Abc_NtkForEachPi( pNtk, pObj, i )
00122             Abc_ObjSetXsim( pObj, Abc_XsimRand2() );
00123     }
00124     if ( fXState )
00125     {
00126         Abc_NtkForEachLatch( pNtk, pObj, i )
00127             Abc_ObjSetXsim( Abc_ObjFanout0(pObj), XVSX );
00128     }
00129     else
00130     {
00131         Abc_NtkForEachLatch( pNtk, pObj, i )
00132             Abc_ObjSetXsim( Abc_ObjFanout0(pObj), Abc_LatchInit(pObj) );
00133     }
00134     // simulate and print the result
00135     fprintf( stdout, "Frame : Inputs : Latches : Outputs\n" );
00136     for ( f = 0; f < nFrames; f++ )
00137     {
00138         Abc_AigForEachAnd( pNtk, pObj, i )
00139             Abc_ObjSetXsim( pObj, Abc_XsimAnd(Abc_ObjGetXsimFanin0(pObj), Abc_ObjGetXsimFanin1(pObj)) );
00140         Abc_NtkForEachCo( pNtk, pObj, i )
00141             Abc_ObjSetXsim( pObj, Abc_ObjGetXsimFanin0(pObj) );
00142         // print out
00143         fprintf( stdout, "%2d : ", f );
00144         Abc_NtkForEachPi( pNtk, pObj, i )
00145             Abc_XsimPrint( stdout, Abc_ObjGetXsim(pObj) );
00146         fprintf( stdout, " : " );
00147         Abc_NtkForEachLatch( pNtk, pObj, i )
00148         {
00149 //            if ( Abc_ObjGetXsim(Abc_ObjFanout0(pObj)) != XVSX )
00150 //                printf( " %s=", Abc_ObjName(pObj) );
00151             Abc_XsimPrint( stdout, Abc_ObjGetXsim(Abc_ObjFanout0(pObj)) );
00152         }
00153         fprintf( stdout, " : " );
00154         Abc_NtkForEachPo( pNtk, pObj, i )
00155             Abc_XsimPrint( stdout, Abc_ObjGetXsim(pObj) );
00156         if ( Abc_NtkAssertNum(pNtk) )
00157         {
00158         fprintf( stdout, " : " );
00159         Abc_NtkForEachAssert( pNtk, pObj, i )
00160             Abc_XsimPrint( stdout, Abc_ObjGetXsim(pObj) );
00161         }
00162         fprintf( stdout, "\n" );
00163         // assign input values
00164         if ( fXInputs )
00165         {
00166             Abc_NtkForEachPi( pNtk, pObj, i )
00167                 Abc_ObjSetXsim( pObj, XVSX );
00168         }
00169         else
00170         {
00171             Abc_NtkForEachPi( pNtk, pObj, i )
00172                 Abc_ObjSetXsim( pObj, Abc_XsimRand2() );
00173         }
00174         // transfer the latch values
00175         Abc_NtkForEachLatch( pNtk, pObj, i )
00176             Abc_ObjSetXsim( Abc_ObjFanout0(pObj), Abc_ObjGetXsim(Abc_ObjFanin0(pObj)) );
00177     }
00178 }

static int Abc_ObjGetXsim ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 32 of file abcXsim.c.

00032 { return (int)pObj->pCopy;      }

static int Abc_ObjGetXsimFanin0 ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 63 of file abcXsim.c.

00064 { 
00065     int RetValue;
00066     RetValue = Abc_ObjGetXsim(Abc_ObjFanin0(pObj));
00067     return Abc_ObjFaninC0(pObj)? Abc_XsimInv(RetValue) : RetValue;
00068 }

static int Abc_ObjGetXsimFanin1 ( Abc_Obj_t pObj  )  [inline, static]

Definition at line 69 of file abcXsim.c.

00070 { 
00071     int RetValue;
00072     RetValue = Abc_ObjGetXsim(Abc_ObjFanin1(pObj));
00073     return Abc_ObjFaninC1(pObj)? Abc_XsimInv(RetValue) : RetValue;
00074 }

static void Abc_ObjSetXsim ( Abc_Obj_t pObj,
int  Value 
) [inline, static]

Definition at line 31 of file abcXsim.c.

00031 { pObj->pCopy = (void *)Value;  }

static int Abc_XsimAnd ( int  Value0,
int  Value1 
) [inline, static]

Definition at line 42 of file abcXsim.c.

00043 { 
00044     if ( Value0 == XVS0 || Value1 == XVS0 )
00045         return XVS0;
00046     if ( Value0 == XVSX || Value1 == XVSX )
00047         return XVSX;
00048     assert( Value0 == XVS1 && Value1 == XVS1 );
00049     return XVS1;
00050 }

static int Abc_XsimInv ( int  Value  )  [inline, static]

Definition at line 33 of file abcXsim.c.

00034 { 
00035     if ( Value == XVS0 )
00036         return XVS1;
00037     if ( Value == XVS1 )
00038         return XVS0;
00039     assert( Value == XVSX );       
00040     return XVSX;
00041 }

static void Abc_XsimPrint ( FILE *  pFile,
int  Value 
) [inline, static]

Definition at line 75 of file abcXsim.c.

00076 { 
00077     if ( Value == XVS0 )
00078     {
00079         fprintf( pFile, "0" );
00080         return;
00081     }
00082     if ( Value == XVS1 )
00083     {
00084         fprintf( pFile, "1" );
00085         return;
00086     }
00087     assert( Value == XVSX );       
00088     fprintf( pFile, "x" );
00089 }

static int Abc_XsimRand2 (  )  [inline, static]

Definition at line 51 of file abcXsim.c.

00052 {
00053     return (rand() & 1) ? XVS1 : XVS0;
00054 }

static int Abc_XsimRand3 (  )  [inline, static]

Definition at line 55 of file abcXsim.c.

00056 {
00057     int RetValue;
00058     do { 
00059         RetValue = rand() & 3; 
00060     } while ( RetValue == 0 );
00061     return RetValue;
00062 }


Generated on Tue Jan 5 12:18:43 2010 for abc70930 by  doxygen 1.6.1