ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
simSeq.c
Go to the documentation of this file.
1
20
21#include "base/abc/abc.h"
22#include "sim.h"
23
25
26
30
31static void Sim_SimulateSeqFrame( Vec_Ptr_t * vInfo, Abc_Ntk_t * pNtk, int iFrames, int nWords, int fTransfer );
32
36
51Vec_Ptr_t * Sim_SimulateSeqRandom( Abc_Ntk_t * pNtk, int nFrames, int nWords )
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}
77
92Vec_Ptr_t * Sim_SimulateSeqModel( Abc_Ntk_t * pNtk, int nFrames, int * pModel )
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}
142
155void Sim_SimulateSeqFrame( Vec_Ptr_t * vInfo, Abc_Ntk_t * pNtk, int iFrames, int nWords, int fTransfer )
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}
168
169
173
174
176
int nWords
Definition abcNpn.c:127
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition abc.h:520
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition abc.h:500
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
#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
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Vec_Ptr_t * Sim_SimulateSeqRandom(Abc_Ntk_t *pNtk, int nFrames, int nWords)
FUNCTION DEFINITIONS ///.
Definition simSeq.c:51
Vec_Ptr_t * Sim_SimulateSeqModel(Abc_Ntk_t *pNtk, int nFrames, int *pModel)
Definition simSeq.c:92
void Sim_UtilSetRandom(unsigned *pPatRand, int nSimWords)
Definition simUtils.c:448
Vec_Ptr_t * Sim_UtilInfoAlloc(int nSize, int nWords, int fClean)
FUNCTION DEFINITIONS ///.
Definition simUtils.c:57
void Sim_UtilSimulateNodeOne(Abc_Obj_t *pNode, Vec_Ptr_t *vSimInfo, int nSimWords, int nOffset)
Definition simUtils.c:303
void Sim_UtilTransferNodeOne(Abc_Obj_t *pNode, Vec_Ptr_t *vSimInfo, int nSimWords, int nOffset, int fShift)
Definition simUtils.c:342
#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
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42