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

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START void 
Sim_SimulateSeqFrame (Vec_Ptr_t *vInfo, Abc_Ntk_t *pNtk, int iFrames, int nWords, int fTransfer)
 DECLARATIONS ///. More...
 
Vec_Ptr_tSim_SimulateSeqRandom (Abc_Ntk_t *pNtk, int nFrames, int nWords)
 FUNCTION DEFINITIONS ///. More...
 
Vec_Ptr_tSim_SimulateSeqModel (Abc_Ntk_t *pNtk, int nFrames, int *pModel)
 

Function Documentation

void Sim_SimulateSeqFrame ( Vec_Ptr_t vInfo,
Abc_Ntk_t pNtk,
int  iFrames,
int  nWords,
int  fTransfer 
)
static

DECLARATIONS ///.

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

FileName [simSeq.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Simulation for sequential circuits.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

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

Synopsis [Simulates one frame of sequential circuit.]

Description [Assumes that the latches and POs are already initialized. In the end transfers the data to the latches of the next frame.]

SideEffects []

SeeAlso []

Definition at line 155 of file simSeq.c.

156 {
157  Abc_Obj_t * pNode;
158  int i;
159  Abc_NtkForEachNode( pNtk, pNode, i )
160  Sim_UtilSimulateNodeOne( pNode, vInfo, nWords, iFrames * nWords );
161  Abc_NtkForEachPo( pNtk, pNode, i )
162  Sim_UtilTransferNodeOne( pNode, vInfo, nWords, iFrames * nWords, 0 );
163  if ( !fTransfer )
164  return;
165  Abc_NtkForEachLatch( pNtk, pNode, i )
166  Sim_UtilTransferNodeOne( pNode, vInfo, nWords, iFrames * nWords, 1 );
167 }
int nWords
Definition: abcNpn.c:127
void Sim_UtilSimulateNodeOne(Abc_Obj_t *pNode, Vec_Ptr_t *vSimInfo, int nSimWords, int nOffset)
Definition: simUtils.c:302
if(last==0)
Definition: sparse_int.h:34
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
void Sim_UtilTransferNodeOne(Abc_Obj_t *pNode, Vec_Ptr_t *vSimInfo, int nSimWords, int nOffset, int fShift)
Definition: simUtils.c:341
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
Vec_Ptr_t* Sim_SimulateSeqModel ( Abc_Ntk_t pNtk,
int  nFrames,
int *  pModel 
)

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

Synopsis [Simulates sequential circuit.]

Description [Takes sequential circuit (pNtk). Simulates the given number (nFrames) of the circuit with the given model. The model is assumed to contain values of PIs for each frame. The latches are initialized to the initial state. One word of data is simulated.]

SideEffects []

SeeAlso []

Definition at line 92 of file simSeq.c.

93 {
94  Vec_Ptr_t * vInfo;
95  Abc_Obj_t * pNode;
96  unsigned * pUnsigned;
97  int i, k;
98  vInfo = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), nFrames, 0 );
99  // set the constant data
100  pNode = Abc_AigConst1(pNtk);
101  Sim_UtilSetConst( Sim_SimInfoGet(vInfo,pNode), nFrames, 1 );
102  // set the random PI data
103  Abc_NtkForEachPi( pNtk, pNode, i )
104  {
105  pUnsigned = Sim_SimInfoGet(vInfo,pNode);
106  for ( k = 0; k < nFrames; k++ )
107  pUnsigned[k] = pModel[k * Abc_NtkPiNum(pNtk) + i] ? ~((unsigned)0) : 0;
108  }
109  // set the initial state data
110  Abc_NtkForEachLatch( pNtk, pNode, i )
111  {
112  pUnsigned = Sim_SimInfoGet(vInfo,pNode);
113  if ( Abc_LatchIsInit0(pNode) )
114  pUnsigned[0] = 0;
115  else if ( Abc_LatchIsInit1(pNode) )
116  pUnsigned[0] = ~((unsigned)0);
117  else
118  pUnsigned[0] = SIM_RANDOM_UNSIGNED;
119  }
120  // simulate the nodes for the given number of timeframes
121  for ( i = 0; i < nFrames; i++ )
122  Sim_SimulateSeqFrame( vInfo, pNtk, i, 1, (int)(i < nFrames-1) );
123 /*
124  // print the simulated values
125  for ( i = 0; i < nFrames; i++ )
126  {
127  printf( "Frame %d : ", i+1 );
128  Abc_NtkForEachPi( pNtk, pNode, k )
129  printf( "%d", Sim_SimInfoGet(vInfo,pNode)[i] > 0 );
130  printf( " " );
131  Abc_NtkForEachLatch( pNtk, pNode, k )
132  printf( "%d", Sim_SimInfoGet(vInfo,pNode)[i] > 0 );
133  printf( " " );
134  Abc_NtkForEachPo( pNtk, pNode, k )
135  printf( "%d", Sim_SimInfoGet(vInfo,pNode)[i] > 0 );
136  printf( "\n" );
137  }
138  printf( "\n" );
139 */
140  return vInfo;
141 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
#define Sim_SimInfoGet(vInfo, pNode)
Definition: sim.h:172
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
#define SIM_RANDOM_UNSIGNED
Definition: sim.h:158
static int Abc_LatchIsInit0(Abc_Obj_t *pLatch)
Definition: abc.h:422
Vec_Ptr_t * Sim_UtilInfoAlloc(int nSize, int nWords, int fClean)
FUNCTION DEFINITIONS ///.
Definition: simUtils.c:57
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static int Abc_LatchIsInit1(Abc_Obj_t *pLatch)
Definition: abc.h:423
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
void Sim_UtilSetConst(unsigned *pPatRand, int nSimWords, int fConst1)
Definition: simUtils.c:483
static ABC_NAMESPACE_IMPL_START void Sim_SimulateSeqFrame(Vec_Ptr_t *vInfo, Abc_Ntk_t *pNtk, int iFrames, int nWords, int fTransfer)
DECLARATIONS ///.
Definition: simSeq.c:155
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
Vec_Ptr_t* Sim_SimulateSeqRandom ( Abc_Ntk_t pNtk,
int  nFrames,
int  nWords 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Simulates sequential circuit.]

Description [Takes sequential circuit (pNtk). Simulates the given number (nFrames) of the circuit with the given number of machine words (nWords) of random simulation data, starting from the initial state. If the initial state of some latches is a don't-care, uses random input for that latch.]

SideEffects []

SeeAlso []

Definition at line 51 of file simSeq.c.

52 {
53  Vec_Ptr_t * vInfo;
54  Abc_Obj_t * pNode;
55  int i;
56  assert( Abc_NtkIsStrash(pNtk) );
57  vInfo = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), nWords * nFrames, 0 );
58  // set the constant data
59  pNode = Abc_AigConst1(pNtk);
60  Sim_UtilSetConst( Sim_SimInfoGet(vInfo,pNode), nWords * nFrames, 1 );
61  // set the random PI data
62  Abc_NtkForEachPi( pNtk, pNode, i )
63  Sim_UtilSetRandom( Sim_SimInfoGet(vInfo,pNode), nWords * nFrames );
64  // set the initial state data
65  Abc_NtkForEachLatch( pNtk, pNode, i )
66  if ( Abc_LatchIsInit0(pNode) )
67  Sim_UtilSetConst( Sim_SimInfoGet(vInfo,pNode), nWords, 0 );
68  else if ( Abc_LatchIsInit1(pNode) )
69  Sim_UtilSetConst( Sim_SimInfoGet(vInfo,pNode), nWords, 1 );
70  else
71  Sim_UtilSetRandom( Sim_SimInfoGet(vInfo,pNode), nWords );
72  // simulate the nodes for the given number of timeframes
73  for ( i = 0; i < nFrames; i++ )
74  Sim_SimulateSeqFrame( vInfo, pNtk, i, nWords, (int)(i < nFrames-1) );
75  return vInfo;
76 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
#define Sim_SimInfoGet(vInfo, pNode)
Definition: sim.h:172
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
void Sim_UtilSetRandom(unsigned *pPatRand, int nSimWords)
Definition: simUtils.c:447
static int Abc_LatchIsInit0(Abc_Obj_t *pLatch)
Definition: abc.h:422
int nWords
Definition: abcNpn.c:127
for(p=first;p->value< newval;p=p->next)
Vec_Ptr_t * Sim_UtilInfoAlloc(int nSize, int nWords, int fClean)
FUNCTION DEFINITIONS ///.
Definition: simUtils.c:57
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static int Abc_LatchIsInit1(Abc_Obj_t *pLatch)
Definition: abc.h:423
void Sim_UtilSetConst(unsigned *pPatRand, int nSimWords, int fConst1)
Definition: simUtils.c:483
#define assert(ex)
Definition: util_old.h:213
static ABC_NAMESPACE_IMPL_START void Sim_SimulateSeqFrame(Vec_Ptr_t *vInfo, Abc_Ntk_t *pNtk, int iFrames, int nWords, int fTransfer)
DECLARATIONS ///.
Definition: simSeq.c:155
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513