ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
giaSwitch.c
Go to the documentation of this file.
1
20
21#include "giaAig.h"
22#include "base/main/main.h"
23
25
26
30
31// switching estimation parameters
34{
35 // user-controlled parameters
36 int nWords; // the number of machine words
37 int nIters; // the number of timeframes
38 int nPref; // the number of first timeframes to skip
39 int nRandPiFactor; // PI trans prob (-1=3/8; 0=1/2; 1=1/4; 2=1/8, etc)
40 int fProbOne; // collect probability of one
41 int fProbTrans; // collect probatility of Swiing
42 int fVerbose; // enables verbose output
43};
44
47{
50 int nWords;
51 // simulation information
52 unsigned * pDataSim; // simulation data
53 unsigned * pDataSimCis; // simulation data for CIs
54 unsigned * pDataSimCos; // simulation data for COs
55 int * pData1; // switching data
56};
57
58static inline unsigned * Gia_SwiData( Gia_ManSwi_t * p, int i ) { return p->pDataSim + i * p->nWords; }
59static inline unsigned * Gia_SwiDataCi( Gia_ManSwi_t * p, int i ) { return p->pDataSimCis + i * p->nWords; }
60static inline unsigned * Gia_SwiDataCo( Gia_ManSwi_t * p, int i ) { return p->pDataSimCos + i * p->nWords; }
61
65
78{
79 memset( p, 0, sizeof(Gia_ParSwi_t) );
80 p->nWords = 10; // the number of machine words of simulatation data
81 p->nIters = 48; // the number of all timeframes to simulate
82 p->nPref = 16; // the number of first timeframes to skip when computing switching
83 p->nRandPiFactor = 0; // primary input transition probability (-1=3/8; 0=1/2; 1=1/4; 2=1/8, etc)
84 p->fProbOne = 0; // compute probability of signal being one (if 0, compute probability of switching)
85 p->fProbTrans = 1; // compute signal transition probability (if 0, compute transition probability using probability of being one)
86 p->fVerbose = 0; // enables verbose output
87}
88
101{
102 Gia_ManSwi_t * p;
103 p = ABC_ALLOC( Gia_ManSwi_t, 1 );
104 memset( p, 0, sizeof(Gia_ManSwi_t) );
105 p->pAig = Gia_ManFront( pAig );
106 p->pPars = pPars;
107 p->nWords = pPars->nWords;
108 p->pDataSim = ABC_ALLOC( unsigned, p->nWords * p->pAig->nFront );
109 p->pDataSimCis = ABC_ALLOC( unsigned, p->nWords * Gia_ManCiNum(p->pAig) );
110 p->pDataSimCos = ABC_ALLOC( unsigned, p->nWords * Gia_ManCoNum(p->pAig) );
111 p->pData1 = ABC_CALLOC( int, Gia_ManObjNum(pAig) );
112 return p;
113}
114
127{
128 Gia_ManStop( p->pAig );
129 ABC_FREE( p->pData1 );
130 ABC_FREE( p->pDataSim );
131 ABC_FREE( p->pDataSimCis );
132 ABC_FREE( p->pDataSimCos );
133 ABC_FREE( p );
134}
135
147static inline void Gia_ManSwiSimInfoRandom( Gia_ManSwi_t * p, unsigned * pInfo, int nProbNum )
148{
149 unsigned Mask = 0;
150 int w, i;
151 if ( nProbNum == -1 )
152 { // 3/8 = 1/4 + 1/8
153 Mask = (Gia_ManRandom( 0 ) & Gia_ManRandom( 0 )) |
154 (Gia_ManRandom( 0 ) & Gia_ManRandom( 0 ) & Gia_ManRandom( 0 ));
155 for ( w = p->nWords-1; w >= 0; w-- )
156 pInfo[w] ^= Mask;
157 }
158 else if ( nProbNum > 0 )
159 {
160 Mask = Gia_ManRandom( 0 );
161 for ( i = 0; i < nProbNum; i++ )
162 Mask &= Gia_ManRandom( 0 );
163 for ( w = p->nWords-1; w >= 0; w-- )
164 pInfo[w] ^= Mask;
165 }
166 else if ( nProbNum == 0 )
167 {
168 for ( w = p->nWords-1; w >= 0; w-- )
169 pInfo[w] = Gia_ManRandom( 0 );
170 }
171 else
172 assert( 0 );
173}
174
186static inline void Gia_ManSwiSimInfoRandomShift( Gia_ManSwi_t * p, unsigned * pInfo, int nProbNum )
187{
188 unsigned Mask = 0;
189 int w, i;
190 if ( nProbNum == -1 )
191 { // 3/8 = 1/4 + 1/8
192 Mask = (Gia_ManRandom( 0 ) & Gia_ManRandom( 0 )) |
193 (Gia_ManRandom( 0 ) & Gia_ManRandom( 0 ) & Gia_ManRandom( 0 ));
194 }
195 else if ( nProbNum >= 0 )
196 {
197 Mask = Gia_ManRandom( 0 );
198 for ( i = 0; i < nProbNum; i++ )
199 Mask &= Gia_ManRandom( 0 );
200 }
201 else
202 assert( 0 );
203 for ( w = p->nWords-1; w >= 0; w-- )
204 pInfo[w] = (pInfo[w] << 16) | ((pInfo[w] ^ Mask) & 0xffff);
205}
206
218static inline void Gia_ManSwiSimInfoZero( Gia_ManSwi_t * p, unsigned * pInfo )
219{
220 int w;
221 for ( w = p->nWords-1; w >= 0; w-- )
222 pInfo[w] = 0;
223}
224
236static inline void Gia_ManSwiSimInfoOne( Gia_ManSwi_t * p, unsigned * pInfo )
237{
238 int w;
239 for ( w = p->nWords-1; w >= 0; w-- )
240 pInfo[w] = ~0;
241}
242
254static inline void Gia_ManSwiSimInfoCopy( Gia_ManSwi_t * p, unsigned * pInfo, unsigned * pInfo0 )
255{
256 int w;
257 for ( w = p->nWords-1; w >= 0; w-- )
258 pInfo[w] = pInfo0[w];
259}
260
272static inline void Gia_ManSwiSimInfoCopyShift( Gia_ManSwi_t * p, unsigned * pInfo, unsigned * pInfo0 )
273{
274 int w;
275 for ( w = p->nWords-1; w >= 0; w-- )
276 pInfo[w] = (pInfo[w] << 16) | (pInfo0[w] & 0xffff);
277}
278
290static inline void Gia_ManSwiSimulateCi( Gia_ManSwi_t * p, Gia_Obj_t * pObj, int iCi )
291{
292 unsigned * pInfo = Gia_SwiData( p, Gia_ObjValue(pObj) );
293 unsigned * pInfo0 = Gia_SwiDataCi( p, iCi );
294 int w;
295 for ( w = p->nWords-1; w >= 0; w-- )
296 pInfo[w] = pInfo0[w];
297}
298
310static inline void Gia_ManSwiSimulateCo( Gia_ManSwi_t * p, int iCo, Gia_Obj_t * pObj )
311{
312 unsigned * pInfo = Gia_SwiDataCo( p, iCo );
313 unsigned * pInfo0 = Gia_SwiData( p, Gia_ObjDiff0(pObj) );
314 int w;
315 if ( Gia_ObjFaninC0(pObj) )
316 for ( w = p->nWords-1; w >= 0; w-- )
317 pInfo[w] = ~pInfo0[w];
318 else
319 for ( w = p->nWords-1; w >= 0; w-- )
320 pInfo[w] = pInfo0[w];
321}
322
334static inline void Gia_ManSwiSimulateNode( Gia_ManSwi_t * p, Gia_Obj_t * pObj )
335{
336 unsigned * pInfo = Gia_SwiData( p, Gia_ObjValue(pObj) );
337 unsigned * pInfo0 = Gia_SwiData( p, Gia_ObjDiff0(pObj) );
338 unsigned * pInfo1 = Gia_SwiData( p, Gia_ObjDiff1(pObj) );
339 int w;
340 if ( Gia_ObjFaninC0(pObj) )
341 {
342 if ( Gia_ObjFaninC1(pObj) )
343 for ( w = p->nWords-1; w >= 0; w-- )
344 pInfo[w] = ~(pInfo0[w] | pInfo1[w]);
345 else
346 for ( w = p->nWords-1; w >= 0; w-- )
347 pInfo[w] = ~pInfo0[w] & pInfo1[w];
348 }
349 else
350 {
351 if ( Gia_ObjFaninC1(pObj) )
352 for ( w = p->nWords-1; w >= 0; w-- )
353 pInfo[w] = pInfo0[w] & ~pInfo1[w];
354 else
355 for ( w = p->nWords-1; w >= 0; w-- )
356 pInfo[w] = pInfo0[w] & pInfo1[w];
357 }
358}
359
371static inline void Gia_ManSwiSimInfoInit( Gia_ManSwi_t * p )
372{
373 int i = 0;
374 for ( ; i < Gia_ManPiNum(p->pAig); i++ )
375 Gia_ManSwiSimInfoRandom( p, Gia_SwiDataCi(p, i), 0 );
376 for ( ; i < Gia_ManCiNum(p->pAig); i++ )
377 Gia_ManSwiSimInfoZero( p, Gia_SwiDataCi(p, i) );
378}
379
391static inline void Gia_ManSwiSimInfoTransfer( Gia_ManSwi_t * p, int nProbNum )
392{
393 int i = 0, nShift = Gia_ManPoNum(p->pAig)-Gia_ManPiNum(p->pAig);
394 for ( ; i < Gia_ManPiNum(p->pAig); i++ )
395 Gia_ManSwiSimInfoRandom( p, Gia_SwiDataCi(p, i), nProbNum );
396 for ( ; i < Gia_ManCiNum(p->pAig); i++ )
397 Gia_ManSwiSimInfoCopy( p, Gia_SwiDataCi(p, i), Gia_SwiDataCo(p, nShift+i) );
398}
399
411static inline void Gia_ManSwiSimInfoTransferShift( Gia_ManSwi_t * p, int nProbNum )
412{
413 int i = 0, nShift = Gia_ManPoNum(p->pAig)-Gia_ManPiNum(p->pAig);
414 for ( ; i < Gia_ManPiNum(p->pAig); i++ )
415 Gia_ManSwiSimInfoRandomShift( p, Gia_SwiDataCi(p, i), nProbNum );
416 for ( ; i < Gia_ManCiNum(p->pAig); i++ )
417 Gia_ManSwiSimInfoCopyShift( p, Gia_SwiDataCi(p, i), Gia_SwiDataCo(p, nShift+i) );
418}
419
431static inline int Gia_ManSwiSimInfoCountOnes( Gia_ManSwi_t * p, int iPlace )
432{
433 unsigned * pInfo;
434 int w, Counter = 0;
435 pInfo = Gia_SwiData( p, iPlace );
436 for ( w = p->nWords-1; w >= 0; w-- )
437 Counter += Gia_WordCountOnes( pInfo[w] );
438 return Counter;
439}
440
452static inline int Gia_ManSwiSimInfoCountTrans( Gia_ManSwi_t * p, int iPlace )
453{
454 unsigned * pInfo;
455 int w, Counter = 0;
456 pInfo = Gia_SwiData( p, iPlace );
457 for ( w = p->nWords-1; w >= 0; w-- )
458 Counter += 2*Gia_WordCountOnes( (pInfo[w] ^ (pInfo[w] >> 16)) & 0xffff );
459 return Counter;
460}
461
473static inline void Gia_ManSwiSimulateRound( Gia_ManSwi_t * p, int fCount )
474{
475 Gia_Obj_t * pObj;
476 int i;//, iCis = 0, iCos = 0;
477 assert( p->pAig->nFront > 0 );
478 assert( Gia_ManConst0(p->pAig)->Value == 0 );
479 Gia_ManSwiSimInfoZero( p, Gia_SwiData(p, 0) );
480 Gia_ManForEachObj1( p->pAig, pObj, i )
481 {
482 if ( Gia_ObjIsAndOrConst0(pObj) )
483 {
484 assert( Gia_ObjValue(pObj) < p->pAig->nFront );
485 Gia_ManSwiSimulateNode( p, pObj );
486 }
487 else if ( Gia_ObjIsCo(pObj) )
488 {
489 assert( Gia_ObjValue(pObj) == GIA_NONE );
490// Gia_ManSwiSimulateCo( p, iCos++, pObj );
491 Gia_ManSwiSimulateCo( p, Gia_ObjCioId(pObj), pObj );
492 }
493 else // if ( Gia_ObjIsCi(pObj) )
494 {
495 assert( Gia_ObjValue(pObj) < p->pAig->nFront );
496// Gia_ManSwiSimulateCi( p, pObj, iCis++ );
497 Gia_ManSwiSimulateCi( p, pObj, Gia_ObjCioId(pObj) );
498 }
499 if ( fCount && !Gia_ObjIsCo(pObj) )
500 {
501 if ( p->pPars->fProbTrans )
502 p->pData1[i] += Gia_ManSwiSimInfoCountTrans( p, Gia_ObjValue(pObj) );
503 else
504 p->pData1[i] += Gia_ManSwiSimInfoCountOnes( p, Gia_ObjValue(pObj) );
505 }
506 }
507// assert( Gia_ManCiNum(p->pAig) == iCis );
508// assert( Gia_ManCoNum(p->pAig) == iCos );
509}
510
522float Gia_ManSwiComputeSwitching( int nOnes, int nSimWords )
523{
524 int nTotal = 32 * nSimWords;
525 return (float)2.0 * nOnes / nTotal * (nTotal - nOnes) / nTotal;
526}
527
539float Gia_ManSwiComputeProbOne( int nOnes, int nSimWords )
540{
541 int nTotal = 32 * nSimWords;
542 return (float)nOnes / nTotal;
543}
544
557{
558 Gia_ManSwi_t * p;
559 Gia_Obj_t * pObj;
560 Vec_Int_t * vSwitching;
561 float * pSwitching;
562 int i;
563 abctime clk, clkTotal = Abc_Clock();
564 if ( pPars->fProbOne && pPars->fProbTrans )
565 printf( "Conflict of options: Can either compute probability of 1, or probability of switching by observing transitions.\n" );
566 // create manager
567 clk = Abc_Clock();
568 p = Gia_ManSwiCreate( pAig, pPars );
569 if ( pPars->fVerbose )
570 {
571 printf( "Obj = %8d (%8d). F = %6d. ",
572 pAig->nObjs, Gia_ManCiNum(pAig) + Gia_ManAndNum(pAig), p->pAig->nFront );
573 printf( "AIG = %7.2f MB. F-mem = %7.2f MB. Other = %7.2f MB. ",
574 12.0*Gia_ManObjNum(p->pAig)/(1<<20),
575 4.0*p->nWords*p->pAig->nFront/(1<<20),
576 4.0*p->nWords*(Gia_ManCiNum(p->pAig) + Gia_ManCoNum(p->pAig))/(1<<20) );
577 ABC_PRT( "Time", Abc_Clock() - clk );
578 }
579 // perform simulation
580 Gia_ManRandom( 1 );
581 Gia_ManSwiSimInfoInit( p );
582 for ( i = 0; i < pPars->nIters; i++ )
583 {
584 Gia_ManSwiSimulateRound( p, i >= pPars->nPref );
585 if ( i == pPars->nIters - 1 )
586 break;
587 if ( pPars->fProbTrans )
588 Gia_ManSwiSimInfoTransferShift( p, pPars->nRandPiFactor );
589 else
590 Gia_ManSwiSimInfoTransfer( p, pPars->nRandPiFactor );
591 }
592 if ( pPars->fVerbose )
593 {
594 printf( "Simulated %d frames with %d words. ", pPars->nIters, pPars->nWords );
595 ABC_PRT( "Simulation time", Abc_Clock() - clkTotal );
596 }
597 // derive the result
598 vSwitching = Vec_IntStart( Gia_ManObjNum(pAig) );
599 pSwitching = (float *)vSwitching->pArray;
600 if ( pPars->fProbOne )
601 {
602 Gia_ManForEachObj( pAig, pObj, i )
603 pSwitching[i] = Gia_ManSwiComputeProbOne( p->pData1[i], pPars->nWords*(pPars->nIters-pPars->nPref) );
604 Gia_ManForEachCo( pAig, pObj, i )
605 {
606 if ( Gia_ObjFaninC0(pObj) )
607 pSwitching[Gia_ObjId(pAig,pObj)] = (float)1.0-pSwitching[Gia_ObjId(pAig,Gia_ObjFanin0(pObj))];
608 else
609 pSwitching[Gia_ObjId(pAig,pObj)] = pSwitching[Gia_ObjId(pAig,Gia_ObjFanin0(pObj))];
610 }
611 }
612 else if ( pPars->fProbTrans )
613 {
614 Gia_ManForEachObj( pAig, pObj, i )
615 pSwitching[i] = Gia_ManSwiComputeSwitching( p->pData1[i], pPars->nWords*(pPars->nIters-pPars->nPref) );
616 }
617 else
618 {
619 Gia_ManForEachObj( pAig, pObj, i )
620 pSwitching[i] = Gia_ManSwiComputeSwitching( p->pData1[i], pPars->nWords*(pPars->nIters-pPars->nPref) );
621 }
622/*
623 printf( "PI: " );
624 Gia_ManForEachPi( pAig, pObj, i )
625 printf( "%d=%d (%f) ", i, p->pData1[Gia_ObjId(pAig,pObj)], pSwitching[Gia_ObjId(pAig,pObj)] );
626 printf( "\n" );
627
628 printf( "LO: " );
629 Gia_ManForEachRo( pAig, pObj, i )
630 printf( "%d=%d (%f) ", i, p->pData1[Gia_ObjId(pAig,pObj)], pSwitching[Gia_ObjId(pAig,pObj)] );
631 printf( "\n" );
632
633 printf( "PO: " );
634 Gia_ManForEachPo( pAig, pObj, i )
635 printf( "%d=%d (%f) ", i, p->pData1[Gia_ObjId(pAig,pObj)], pSwitching[Gia_ObjId(pAig,pObj)] );
636 printf( "\n" );
637
638 printf( "LI: " );
639 Gia_ManForEachRi( pAig, pObj, i )
640 printf( "%d=%d (%f) ", i, p->pData1[Gia_ObjId(pAig,pObj)], pSwitching[Gia_ObjId(pAig,pObj)] );
641 printf( "\n" );
642*/
644 return vSwitching;
645
646}
647
658Vec_Int_t * Gia_ManComputeSwitchProbs( Gia_Man_t * pGia, int nFrames, int nPref, int fProbOne )
659{
660 Gia_ParSwi_t Pars, * pPars = &Pars;
661 // set the default parameters
663 // override some of the defaults
664 pPars->nIters = nFrames; // set number of total timeframes
665 if ( Abc_FrameReadFlag("seqsimframes") )
666 pPars->nIters = atoi( Abc_FrameReadFlag("seqsimframes") );
667 pPars->nPref = nPref; // set number of first timeframes to skip
668 // decide what should be computed
669 if ( fProbOne )
670 {
671 // if the user asked to compute propability of 1, we do not need transition information
672 pPars->fProbOne = 1; // enable computing probabiblity of being one
673 pPars->fProbTrans = 0; // disable computing transition probability
674 }
675 else
676 {
677 // if the user asked for transition propabability, we do not need to compute probability of 1
678 pPars->fProbOne = 0; // disable computing probabiblity of being one
679 pPars->fProbTrans = 1; // enable computing transition probability
680 }
681 // perform the computation of switching activity
682 return Gia_ManSwiSimulate( pGia, pPars );
683}
684Vec_Int_t * Gia_ManComputeSwitchProbs2( Gia_Man_t * pGia, int nFrames, int nPref, int fProbOne, int nRandPiFactor )
685{
686 Gia_ParSwi_t Pars, * pPars = &Pars;
687 // set the default parameters
689 pPars->nRandPiFactor = nRandPiFactor;
690 // override some of the defaults
691 pPars->nIters = nFrames; // set number of total timeframes
692 if ( Abc_FrameReadFlag("seqsimframes") )
693 pPars->nIters = atoi( Abc_FrameReadFlag("seqsimframes") );
694 pPars->nPref = nPref; // set number of first timeframes to skip
695 // decide what should be computed
696 if ( fProbOne )
697 {
698 // if the user asked to compute propability of 1, we do not need transition information
699 pPars->fProbOne = 1; // enable computing probabiblity of being one
700 pPars->fProbTrans = 0; // disable computing transition probability
701 }
702 else
703 {
704 // if the user asked for transition propabability, we do not need to compute probability of 1
705 pPars->fProbOne = 0; // disable computing probabiblity of being one
706 pPars->fProbTrans = 1; // enable computing transition probability
707 }
708 // perform the computation of switching activity
709 return Gia_ManSwiSimulate( pGia, pPars );
710}
711Vec_Int_t * Saig_ManComputeSwitchProbs( Aig_Man_t * pAig, int nFrames, int nPref, int fProbOne )
712{
713 Vec_Int_t * vSwitching, * vResult;
714 Gia_Man_t * p;
715 Aig_Obj_t * pObj;
716 int i;
717 // translate AIG into the intermediate form (takes care of choices if present!)
718 p = Gia_ManFromAigSwitch( pAig );
719 // perform the computation of switching activity
720 vSwitching = Gia_ManComputeSwitchProbs( p, nFrames, nPref, fProbOne );
721 // transfer the computed result to the original AIG
722 vResult = Vec_IntStart( Aig_ManObjNumMax(pAig) );
723 Aig_ManForEachObj( pAig, pObj, i )
724 {
725// if ( Aig_ObjIsCo(pObj) )
726// printf( "%d=%f\n", i, Abc_Int2Float( Vec_IntEntry(vSwitching, Abc_Lit2Var(pObj->iData)) ) );
727 Vec_IntWriteEntry( vResult, i, Vec_IntEntry(vSwitching, Abc_Lit2Var(pObj->iData)) );
728 }
729 // delete intermediate results
730 Vec_IntFree( vSwitching );
731 Gia_ManStop( p );
732 return vResult;
733}
734
747{
748 Gia_Obj_t * pObj;
749 float SwitchTotal = 0.0;
750 int i;
751 assert( p->pSwitching );
752 ABC_FREE( p->pRefs );
754 Gia_ManForEachObj( p, pObj, i )
755 SwitchTotal += (float)Gia_ObjRefNum(p, pObj) * p->pSwitching[i] / 255;
756 return SwitchTotal;
757}
758
770/*
771float Gia_ManComputeSwitching( Gia_Man_t * p, int nFrames, int nPref, int fProbOne )
772{
773 Gia_Man_t * pDfs;
774 Gia_Obj_t * pObj, * pObjDfs;
775 Vec_Int_t * vSwitching;
776 float * pSwitching, Switch, SwitchTotal = 0.0;
777 int i;
778 // derives the DFS ordered AIG
779 if ( Gia_ManHasMapping(p) )
780 Gia_ManSetRefsMapped(p);
781 else
782 Gia_ManCreateRefs( p );
783// pDfs = Gia_ManDupOrderDfs( p );
784 pDfs = Gia_ManDup( p );
785 assert( Gia_ManObjNum(pDfs) == Gia_ManObjNum(p) );
786 // perform the computation of switching activity
787 vSwitching = Gia_ManComputeSwitchProbs( pDfs, nFrames, nPref, fProbOne );
788 // transfer the computed result to the original AIG
789 ABC_FREE( p->pSwitching );
790 p->pSwitching = ABC_CALLOC( unsigned char, Gia_ManObjNum(p) );
791 pSwitching = (float *)vSwitching->pArray;
792 Gia_ManForEachObj( p, pObj, i )
793 {
794 pObjDfs = Gia_ObjFromLit( pDfs, pObj->Value );
795 Switch = pSwitching[ Gia_ObjId(pDfs, pObjDfs) ];
796 p->pSwitching[i] = (char)((Switch >= 1.0) ? 255 : (int)((0.002 + Switch) * 255)); // 0.00196 = (1/255)/2
797 if ( Gia_ObjIsCi(pObj) || (Gia_ObjIsAnd(pObj) && (!Gia_ManHasMapping(p) || Gia_ObjIsLut(p, i))) )
798 {
799 SwitchTotal += (float)Gia_ObjRefNum(p, pObj) * p->pSwitching[i] / 255;
800// printf( "%d = %.2f\n", i, (float)Gia_ObjRefNum(p, pObj) * p->pSwitching[i] / 255 );
801 }
802 }
803 Vec_IntFree( vSwitching );
804 Gia_ManStop( pDfs );
805 return SwitchTotal;
806}
807*/
808float Gia_ManComputeSwitching( Gia_Man_t * p, int nFrames, int nPref, int fProbOne )
809{
810 Vec_Int_t * vSwitching = Gia_ManComputeSwitchProbs( p, nFrames, nPref, fProbOne );
811 float * pSwi = (float *)Vec_IntArray(vSwitching), SwiTotal = 0;
812 Gia_Obj_t * pObj;
813 int i, k, iFan;
814 if ( Gia_ManHasMapping(p) )
815 {
816 Gia_ManForEachLut( p, i )
817 Gia_LutForEachFanin( p, i, iFan, k )
818 SwiTotal += pSwi[iFan];
819 }
820 else
821 {
822 Gia_ManForEachAnd( p, pObj, i )
823 SwiTotal += pSwi[Gia_ObjFaninId0(pObj, i)] + pSwi[Gia_ObjFaninId1(pObj, i)];
824 }
825 if ( 0 )
826 {
827 Gia_ManForEachObj( p, pObj, i )
828 {
829 printf( "Switch %6.2f ", pSwi[i] );
830 Gia_ObjPrint( p, pObj );
831 }
832 }
833 Vec_IntFree( vSwitching );
834 return SwiTotal;
835}
836
849{
850 Vec_Flt_t * vSimData;
851 Gia_Man_t * pDfs = Gia_ManDup( p );
852 assert( Gia_ManObjNum(pDfs) == Gia_ManObjNum(p) );
853 vSimData = (Vec_Flt_t *)Gia_ManComputeSwitchProbs( pDfs, (Gia_ManRegNum(p) ? 16 : 1), 0, 1 );
854 Gia_ManStop( pDfs );
855 return vSimData;
856}
857
861
862
864
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
#define Aig_ManForEachObj(p, pObj, i)
Definition aig.h:403
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
int nTotal
DECLARATIONS ///.
Definition cutTruth.c:37
ABC_DLL char * Abc_FrameReadFlag(char *pFlag)
Definition mainFrame.c:69
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
Gia_Man_t * Gia_ManFromAigSwitch(Aig_Man_t *p)
Definition giaAig.c:252
float Gia_ManSwiComputeProbOne(int nOnes, int nSimWords)
Definition giaSwitch.c:539
void Gia_ManSetDefaultParamsSwi(Gia_ParSwi_t *p)
FUNCTION DEFINITIONS ///.
Definition giaSwitch.c:77
float Gia_ManSwiComputeSwitching(int nOnes, int nSimWords)
Definition giaSwitch.c:522
float Gia_ManComputeSwitching(Gia_Man_t *p, int nFrames, int nPref, int fProbOne)
Definition giaSwitch.c:808
Vec_Int_t * Saig_ManComputeSwitchProbs(Aig_Man_t *pAig, int nFrames, int nPref, int fProbOne)
Definition giaSwitch.c:711
void Gia_ManSwiDelete(Gia_ManSwi_t *p)
Definition giaSwitch.c:126
Vec_Int_t * Gia_ManSwiSimulate(Gia_Man_t *pAig, Gia_ParSwi_t *pPars)
Definition giaSwitch.c:556
typedefABC_NAMESPACE_IMPL_START struct Gia_ParSwi_t_ Gia_ParSwi_t
DECLARATIONS ///.
Definition giaSwitch.c:32
struct Gia_ManSwi_t_ Gia_ManSwi_t
Definition giaSwitch.c:45
Vec_Flt_t * Gia_ManPrintOutputProb(Gia_Man_t *p)
Definition giaSwitch.c:848
Gia_ManSwi_t * Gia_ManSwiCreate(Gia_Man_t *pAig, Gia_ParSwi_t *pPars)
Definition giaSwitch.c:100
float Gia_ManEvaluateSwitching(Gia_Man_t *p)
Definition giaSwitch.c:746
Vec_Int_t * Gia_ManComputeSwitchProbs(Gia_Man_t *pGia, int nFrames, int nPref, int fProbOne)
Definition giaSwitch.c:658
Vec_Int_t * Gia_ManComputeSwitchProbs2(Gia_Man_t *pGia, int nFrames, int nPref, int fProbOne, int nRandPiFactor)
Definition giaSwitch.c:684
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
Definition giaDup.c:720
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
#define Gia_ManForEachLut(p, i)
Definition gia.h:1157
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition gia.h:1161
void Gia_ObjPrint(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition giaUtil.c:1456
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
#define Gia_ManForEachObj1(p, pObj, i)
Definition gia.h:1192
#define GIA_NONE
INCLUDES ///.
Definition gia.h:45
Gia_Man_t * Gia_ManFront(Gia_Man_t *p)
Definition giaFront.c:147
void Gia_ManCreateRefs(Gia_Man_t *p)
Definition giaUtil.c:779
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition gia.h:1190
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
unsigned Gia_ManRandom(int fReset)
FUNCTION DEFINITIONS ///.
Definition giaUtil.c:49
int iData
Definition aig.h:88
Gia_Man_t * pAig
Definition giaSwitch.c:48
unsigned * pDataSim
Definition giaSwitch.c:52
unsigned * pDataSimCis
Definition giaSwitch.c:53
Gia_ParSwi_t * pPars
Definition giaSwitch.c:49
unsigned * pDataSimCos
Definition giaSwitch.c:54
int nObjs
Definition gia.h:103
int nRandPiFactor
Definition giaSwitch.c:39
#define assert(ex)
Definition util_old.h:213
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Vec_Flt_t_ Vec_Flt_t
INCLUDES ///.
Definition vecFlt.h:42