1 /**CFile****************************************************************
2
3 FileName [simSymSim.c]
4
5 SystemName [ABC: Logic synthesis and verification system.]
6
7 PackageName [Network and node package.]
8
9 Synopsis [Simulation to determine two-variable symmetries.]
10
11 Author [Alan Mishchenko]
12
13 Affiliation [UC Berkeley]
14
15 Date [Ver. 1.0. Started - June 20, 2005.]
16
17 Revision [$Id: simSymSim.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18
19 ***********************************************************************/
20
21 #include "base/abc/abc.h"
22 #include "sim.h"
23
24 ABC_NAMESPACE_IMPL_START
25
26
27 ////////////////////////////////////////////////////////////////////////
28 /// DECLARATIONS ///
29 ////////////////////////////////////////////////////////////////////////
30
31 static void Sim_SymmsCreateSquare( Sym_Man_t * p, unsigned * pPat );
32 static void Sim_SymmsDeriveInfo( Sym_Man_t * p, unsigned * pPat, Abc_Obj_t * pNode, Vec_Ptr_t * vMatrsNonSym, int Output );
33
34 ////////////////////////////////////////////////////////////////////////
35 /// FUNCTION DEFINITIONS ///
36 ////////////////////////////////////////////////////////////////////////
37
38 /**Function*************************************************************
39
40 Synopsis [Detects non-symmetric pairs using one pattern.]
41
42 Description []
43
44 SideEffects []
45
46 SeeAlso []
47
48 ***********************************************************************/
Sim_SymmsSimulate(Sym_Man_t * p,unsigned * pPat,Vec_Ptr_t * vMatrsNonSym)49 void Sim_SymmsSimulate( Sym_Man_t * p, unsigned * pPat, Vec_Ptr_t * vMatrsNonSym )
50 {
51 Abc_Obj_t * pNode;
52 int i, nPairsTotal, nPairsSym, nPairsNonSym;
53 abctime clk;
54
55 // create the simulation matrix
56 Sim_SymmsCreateSquare( p, pPat );
57 // simulate each node in the DFS order
58 clk = Abc_Clock();
59 Vec_PtrForEachEntry( Abc_Obj_t *, p->vNodes, pNode, i )
60 {
61 // if ( Abc_NodeIsConst(pNode) )
62 // continue;
63 Sim_UtilSimulateNodeOne( pNode, p->vSim, p->nSimWords, 0 );
64 }
65 p->timeSim += Abc_Clock() - clk;
66 // collect info into the CO matrices
67 clk = Abc_Clock();
68 Abc_NtkForEachCo( p->pNtk, pNode, i )
69 {
70 pNode = Abc_ObjFanin0(pNode);
71 // if ( Abc_ObjIsCi(pNode) || Abc_AigNodeIsConst(pNode) )
72 // continue;
73 nPairsTotal = Vec_IntEntry(p->vPairsTotal, i);
74 nPairsSym = Vec_IntEntry(p->vPairsSym, i);
75 nPairsNonSym = Vec_IntEntry(p->vPairsNonSym,i);
76 assert( nPairsTotal >= nPairsSym + nPairsNonSym );
77 if ( nPairsTotal == nPairsSym + nPairsNonSym )
78 continue;
79 Sim_SymmsDeriveInfo( p, pPat, pNode, vMatrsNonSym, i );
80 }
81 p->timeMatr += Abc_Clock() - clk;
82 }
83
84 /**Function*************************************************************
85
86 Synopsis [Creates the square matrix of simulation info.]
87
88 Description []
89
90 SideEffects []
91
92 SeeAlso []
93
94 ***********************************************************************/
Sim_SymmsCreateSquare(Sym_Man_t * p,unsigned * pPat)95 void Sim_SymmsCreateSquare( Sym_Man_t * p, unsigned * pPat )
96 {
97 unsigned * pSimInfo;
98 Abc_Obj_t * pNode;
99 int i, w;
100 // for each PI var copy the pattern
101 Abc_NtkForEachCi( p->pNtk, pNode, i )
102 {
103 pSimInfo = (unsigned *)Vec_PtrEntry( p->vSim, pNode->Id );
104 if ( Sim_HasBit(pPat, i) )
105 {
106 for ( w = 0; w < p->nSimWords; w++ )
107 pSimInfo[w] = SIM_MASK_FULL;
108 }
109 else
110 {
111 for ( w = 0; w < p->nSimWords; w++ )
112 pSimInfo[w] = 0;
113 }
114 // flip one bit
115 Sim_XorBit( pSimInfo, i );
116 }
117 }
118
119 /**Function*************************************************************
120
121 Synopsis [Transfers the info to the POs.]
122
123 Description []
124
125 SideEffects []
126
127 SeeAlso []
128
129 ***********************************************************************/
Sim_SymmsDeriveInfo(Sym_Man_t * p,unsigned * pPat,Abc_Obj_t * pNode,Vec_Ptr_t * vMatrsNonSym,int Output)130 void Sim_SymmsDeriveInfo( Sym_Man_t * p, unsigned * pPat, Abc_Obj_t * pNode, Vec_Ptr_t * vMatrsNonSym, int Output )
131 {
132 Extra_BitMat_t * pMat;
133 Vec_Int_t * vSupport;
134 unsigned * pSupport;
135 unsigned * pSimInfo;
136 int i, w, Index;
137 // get the matrix, the support, and the simulation info
138 pMat = (Extra_BitMat_t *)Vec_PtrEntry( vMatrsNonSym, Output );
139 vSupport = Vec_VecEntryInt( p->vSupports, Output );
140 pSupport = (unsigned *)Vec_PtrEntry( p->vSuppFun, Output );
141 pSimInfo = (unsigned *)Vec_PtrEntry( p->vSim, pNode->Id );
142 // generate vectors A1 and A2
143 for ( w = 0; w < p->nSimWords; w++ )
144 {
145 p->uPatCol[w] = pSupport[w] & pPat[w] & pSimInfo[w];
146 p->uPatRow[w] = pSupport[w] & pPat[w] & ~pSimInfo[w];
147 }
148 // add two dimensions
149 Vec_IntForEachEntry( vSupport, i, Index )
150 if ( Sim_HasBit( p->uPatCol, i ) )
151 Extra_BitMatrixOr( pMat, i, p->uPatRow );
152 // add two dimensions
153 Vec_IntForEachEntry( vSupport, i, Index )
154 if ( Sim_HasBit( p->uPatRow, i ) )
155 Extra_BitMatrixOr( pMat, i, p->uPatCol );
156 // generate vectors B1 and B2
157 for ( w = 0; w < p->nSimWords; w++ )
158 {
159 p->uPatCol[w] = pSupport[w] & ~pPat[w] & pSimInfo[w];
160 p->uPatRow[w] = pSupport[w] & ~pPat[w] & ~pSimInfo[w];
161 }
162 // add two dimensions
163 Vec_IntForEachEntry( vSupport, i, Index )
164 if ( Sim_HasBit( p->uPatCol, i ) )
165 Extra_BitMatrixOr( pMat, i, p->uPatRow );
166 // add two dimensions
167 Vec_IntForEachEntry( vSupport, i, Index )
168 if ( Sim_HasBit( p->uPatRow, i ) )
169 Extra_BitMatrixOr( pMat, i, p->uPatCol );
170 }
171
172 ////////////////////////////////////////////////////////////////////////
173 /// END OF FILE ///
174 ////////////////////////////////////////////////////////////////////////
175
176
177 ABC_NAMESPACE_IMPL_END
178
179