ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
simSeq.c File Reference
#include "base/abc/abc.h"
#include "sim.h"
Include dependency graph for simSeq.c:

Go to the source code of this file.

Functions

Vec_Ptr_tSim_SimulateSeqRandom (Abc_Ntk_t *pNtk, int nFrames, int nWords)
 FUNCTION DEFINITIONS ///.
 
Vec_Ptr_tSim_SimulateSeqModel (Abc_Ntk_t *pNtk, int nFrames, int *pModel)
 

Function Documentation

◆ Sim_SimulateSeqModel()

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}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition abc.h:500
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition abcAig.c:683
Vec_Ptr_t * Sim_UtilInfoAlloc(int nSize, int nWords, int fClean)
FUNCTION DEFINITIONS ///.
Definition simUtils.c:57
#define SIM_RANDOM_UNSIGNED
Definition sim.h:158
void Sim_UtilSetConst(unsigned *pPatRand, int nSimWords, int fConst1)
Definition simUtils.c:484
#define Sim_SimInfoGet(vInfo, pNode)
Definition sim.h:172
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sim_SimulateSeqRandom()

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
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}
int nWords
Definition abcNpn.c:127
void Sim_UtilSetRandom(unsigned *pPatRand, int nSimWords)
Definition simUtils.c:448
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function: