ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
extraLutCas.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "aig/miniaig/miniaig.h"
#include "bdd/cudd/cuddInt.h"
#include "bdd/dsd/dsd.h"
Include dependency graph for extraLutCas.h:

Go to the source code of this file.

Macros

#define Mini_AigForEachNonPo(p, i)
 

Functions

void Abc_LutCasCollapseDeref (DdManager *dd, Vec_Ptr_t *vFuncs)
 
Vec_Ptr_tAbc_LutCasCollapse (Mini_Aig_t *p, DdManager *dd, int nBddLimit, int fVerbose)
 
Vec_Ptr_tAbc_LutBddScan (DdManager *dd, DdNode *bFunc, int nVars)
 
char * Abc_LutBddToTruth (Vec_Ptr_t *vFuncs)
 
char * Abc_NtkPrecomputeData ()
 
int Abc_NtkDecPatCount (int iFirst, int nStep, int MyuMax, char *pDecPat, char *pPermInfo)
 
int Abc_NtkDecPatDecompose_rec (int Mask, int nMaskVars, int iStart, int nVars, int nDiffs, int nRails, char *pDecPat, char *pPermInfo)
 
int Abc_NtkDecPatDecompose (int nVars, int nRails, char *pDecPat, char *pPermInfo)
 
int Abc_NtkCascadeDecompose (int nVars, int nRails, char *pDecPat, char *pPermInfo)
 
Vec_Ptr_tAbc_LutCasFakeNames (int nNames)
 
void Abc_LutCasPrintDsd (DdManager *dd, DdNode *bFunc, int fVerbose)
 
DdNode * Abc_LutCasBuildBdds (Mini_Aig_t *p, DdManager **pdd, int fReorder)
 

Macro Definition Documentation

◆ Mini_AigForEachNonPo

#define Mini_AigForEachNonPo ( p,
i )
Value:
for (i = 1; i < Mini_AigNodeNum(p); i++) if ( Mini_AigNodeIsPo(p, i) ) {} else
Cube * p
Definition exorList.c:222

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

FileName [extraLutCas.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [extra]

Synopsis [LUT cascade decomposition.]

Description [LUT cascade decomposition.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - August 6, 2024.]

Revision [

Id
extraLutCas.h,v 1.00 2024/08/06 00:00:00 alanmi Exp

]

Definition at line 60 of file extraLutCas.h.

Function Documentation

◆ Abc_LutBddScan()

Vec_Ptr_t * Abc_LutBddScan ( DdManager * dd,
DdNode * bFunc,
int nVars )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 126 of file extraLutCas.h.

127{
128 Vec_Ptr_t * vRes = Vec_PtrAlloc( 1 << nVars );
129 Vec_Ptr_t * vRes2 = Vec_PtrAlloc( 1 << nVars );
130 Vec_PtrPush( vRes, bFunc );
131 int v, Level = Cudd_ReadPerm( dd, Cudd_NodeReadIndex(bFunc) );
132 for ( v = 0; v < dd->size; v++ )
133 printf( "%2d : perm = %d invperm = %d\n", v, dd->perm[v], dd->invperm[v] );
134 for ( v = 0; v < nVars; v++ )
135 {
136 int i, LevelCur = Level + v;
137 Vec_PtrClear( vRes2 );
138 DdNode * bTemp;
139 Vec_PtrForEachEntry( DdNode *, vRes, bTemp, i ) {
140 int LevelTemp = Cudd_ReadPerm( dd, Cudd_NodeReadIndex(bTemp) );
141 if ( LevelTemp == LevelCur ) {
142 Vec_PtrPush( vRes2, Cudd_NotCond(Cudd_E(bTemp), Cudd_IsComplement(bTemp)) );
143 Vec_PtrPush( vRes2, Cudd_NotCond(Cudd_T(bTemp), Cudd_IsComplement(bTemp)) );
144 }
145 else if ( LevelTemp > LevelCur ) {
146 Vec_PtrPush( vRes2, bTemp );
147 Vec_PtrPush( vRes2, bTemp );
148 }
149 else assert( 0 );
150 }
151 ABC_SWAP( Vec_Ptr_t *, vRes, vRes2 );
152 //Vec_PtrForEachEntry( DdNode *, vRes, bTemp, i )
153 // printf( "%p ", bTemp );
154 //printf( "\n" );
155 }
156 Vec_PtrFree( vRes2 );
157 assert( Vec_PtrSize(vRes) == (1 << nVars) );
158 return vRes;
159}
#define ABC_SWAP(Type, a, b)
Definition abc_global.h:253
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55

◆ Abc_LutBddToTruth()

char * Abc_LutBddToTruth ( Vec_Ptr_t * vFuncs)

Definition at line 160 of file extraLutCas.h.

161{
162 assert( Vec_PtrSize(vFuncs) <= 256 );
163 char * pRes = ABC_CALLOC( char, Vec_PtrSize(vFuncs)+1 );
164 void * pTemp, * pStore[256] = {Vec_PtrEntry(vFuncs, 0)};
165 int i, k, nStore = 1; pRes[0] = 'a';
166 Vec_PtrForEachEntryStart( void *, vFuncs, pTemp, i, 1 ) {
167 for ( k = 0; k < nStore; k++ )
168 if ( pStore[k] == pTemp )
169 break;
170 if ( k == nStore )
171 pStore[nStore++] = pTemp;
172 pRes[i] = 'a' + (char)k;
173 }
174 return pRes;
175}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition vecPtr.h:57

◆ Abc_LutCasBuildBdds()

DdNode * Abc_LutCasBuildBdds ( Mini_Aig_t * p,
DdManager ** pdd,
int fReorder )

Definition at line 320 of file extraLutCas.h.

321{
322 DdManager * dd = Cudd_Init( Mini_AigPiNum(p), 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
323 if ( fReorder ) Cudd_AutodynEnable( dd, CUDD_REORDER_SYMM_SIFT );
324 Vec_Ptr_t * vFuncs = Abc_LutCasCollapse( p, dd, 10000, 0 );
325 if ( fReorder ) Cudd_AutodynDisable( dd );
326 if ( vFuncs == NULL ) {
327 Extra_StopManager( dd );
328 return NULL;
329 }
330 DdNode * bNode = (DdNode *)Vec_PtrEntry(vFuncs, 0);
331 Vec_PtrFree(vFuncs);
332 *pdd = dd;
333 return bNode;
334}
void Extra_StopManager(DdManager *dd)
Vec_Ptr_t * Abc_LutCasCollapse(Mini_Aig_t *p, DdManager *dd, int nBddLimit, int fVerbose)
Definition extraLutCas.h:81
Here is the call graph for this function:

◆ Abc_LutCasCollapse()

Vec_Ptr_t * Abc_LutCasCollapse ( Mini_Aig_t * p,
DdManager * dd,
int nBddLimit,
int fVerbose )

Definition at line 81 of file extraLutCas.h.

82{
83 DdNode * bFunc0, * bFunc1, * bFunc; int Id, nOuts = 0;
84 Vec_Ptr_t * vFuncs = Vec_PtrStart( Mini_AigNodeNum(p) );
85 Vec_PtrWriteEntry( vFuncs, 0, Cudd_ReadLogicZero(dd) ), Cudd_Ref(Cudd_ReadLogicZero(dd));
86 Mini_AigForEachPi( p, Id )
87 Vec_PtrWriteEntry( vFuncs, Id, Cudd_bddIthVar(dd,Id-1) ), Cudd_Ref(Cudd_bddIthVar(dd,Id-1));
88 Mini_AigForEachAnd( p, Id ) {
89 bFunc0 = Cudd_NotCond( (DdNode *)Vec_PtrEntry(vFuncs, Mini_AigLit2Var(Mini_AigNodeFanin0(p, Id))), Mini_AigLitIsCompl(Mini_AigNodeFanin0(p, Id)) );
90 bFunc1 = Cudd_NotCond( (DdNode *)Vec_PtrEntry(vFuncs, Mini_AigLit2Var(Mini_AigNodeFanin1(p, Id))), Mini_AigLitIsCompl(Mini_AigNodeFanin1(p, Id)) );
91 bFunc = Cudd_bddAndLimit( dd, bFunc0, bFunc1, nBddLimit );
92 if ( bFunc == NULL )
93 {
94 Abc_LutCasCollapseDeref( dd, vFuncs );
95 return NULL;
96 }
97 Cudd_Ref( bFunc );
98 Vec_PtrWriteEntry( vFuncs, Id, bFunc );
99 }
100 Mini_AigForEachPo( p, Id ) {
101 bFunc0 = Cudd_NotCond( (DdNode *)Vec_PtrEntry(vFuncs, Mini_AigLit2Var(Mini_AigNodeFanin0(p, Id))), Mini_AigLitIsCompl(Mini_AigNodeFanin0(p, Id)) );
102 Vec_PtrWriteEntry( vFuncs, Id, bFunc0 ); Cudd_Ref( bFunc0 );
103 }
104 Mini_AigForEachNonPo( p, Id ) {
105 bFunc = (DdNode *)Vec_PtrEntry(vFuncs, Id);
106 Cudd_RecursiveDeref( dd, bFunc );
107 Vec_PtrWriteEntry( vFuncs, Id, NULL );
108 }
109 Mini_AigForEachPo( p, Id )
110 Vec_PtrWriteEntry( vFuncs, nOuts++, Vec_PtrEntry(vFuncs, Id) );
111 Vec_PtrShrink( vFuncs, nOuts );
112 return vFuncs;
113}
void Abc_LutCasCollapseDeref(DdManager *dd, Vec_Ptr_t *vFuncs)
Definition extraLutCas.h:73
#define Mini_AigForEachNonPo(p, i)
Definition extraLutCas.h:60
#define Mini_AigForEachPi(p, i)
Definition miniaig.h:138
#define Mini_AigForEachPo(p, i)
Definition miniaig.h:139
#define Mini_AigForEachAnd(p, i)
Definition miniaig.h:140
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_LutCasCollapseDeref()

void Abc_LutCasCollapseDeref ( DdManager * dd,
Vec_Ptr_t * vFuncs )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 73 of file extraLutCas.h.

74{
75 DdNode * bFunc; int i;
76 Vec_PtrForEachEntry( DdNode *, vFuncs, bFunc, i )
77 if ( bFunc )
78 Cudd_RecursiveDeref( dd, bFunc );
79 Vec_PtrFree( vFuncs );
80}
Here is the caller graph for this function:

◆ Abc_LutCasFakeNames()

Vec_Ptr_t * Abc_LutCasFakeNames ( int nNames)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 280 of file extraLutCas.h.

281{
282 Vec_Ptr_t * vNames;
283 char Buffer[5];
284 int i;
285
286 vNames = Vec_PtrAlloc( nNames );
287 for ( i = 0; i < nNames; i++ )
288 {
289 if ( nNames < 26 )
290 {
291 Buffer[0] = 'a' + i;
292 Buffer[1] = 0;
293 }
294 else
295 {
296 Buffer[0] = 'a' + i%26;
297 Buffer[1] = '0' + i/26;
298 Buffer[2] = 0;
299 }
300 Vec_PtrPush( vNames, Extra_UtilStrsav(Buffer) );
301 }
302 return vNames;
303}
char * Extra_UtilStrsav(const char *s)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_LutCasPrintDsd()

void Abc_LutCasPrintDsd ( DdManager * dd,
DdNode * bFunc,
int fVerbose )

Definition at line 304 of file extraLutCas.h.

305{
306 Dsd_Manager_t * pManDsd = Dsd_ManagerStart( dd, dd->size, 0 );
307 Dsd_Decompose( pManDsd, &bFunc, 1 );
308 if ( fVerbose )
309 {
310 Vec_Ptr_t * vNamesCi = Abc_LutCasFakeNames( dd->size );
311 Vec_Ptr_t * vNamesCo = Abc_LutCasFakeNames( 1 );
312 char ** ppNamesCi = (char **)Vec_PtrArray( vNamesCi );
313 char ** ppNamesCo = (char **)Vec_PtrArray( vNamesCo );
314 Dsd_TreePrint( stdout, pManDsd, ppNamesCi, ppNamesCo, 0, -1, 0 );
315 Vec_PtrFreeFree( vNamesCi );
316 Vec_PtrFreeFree( vNamesCo );
317 }
318 Dsd_ManagerStop( pManDsd );
319}
Dsd_Manager_t * Dsd_ManagerStart(DdManager *dd, int nSuppMax, int fVerbose)
FUNCTION DECLARATIONS ///.
Definition dsdMan.c:47
void Dsd_TreePrint(FILE *pFile, Dsd_Manager_t *dMan, char *pInputNames[], char *pOutputNames[], int fShortNames, int Output, int OffSet)
Definition dsdTree.c:830
struct Dsd_Manager_t_ Dsd_Manager_t
TYPEDEF DEFINITIONS ///.
Definition dsd.h:59
void Dsd_ManagerStop(Dsd_Manager_t *dMan)
Definition dsdMan.c:100
void Dsd_Decompose(Dsd_Manager_t *dMan, DdNode **pbFuncs, int nFuncs)
DECOMPOSITION FUNCTIONS ///.
Definition dsdProc.c:113
Vec_Ptr_t * Abc_LutCasFakeNames(int nNames)
Here is the call graph for this function:

◆ Abc_NtkCascadeDecompose()

int Abc_NtkCascadeDecompose ( int nVars,
int nRails,
char * pDecPat,
char * pPermInfo )

Definition at line 262 of file extraLutCas.h.

263{
264 return 0;
265}

◆ Abc_NtkDecPatCount()

int Abc_NtkDecPatCount ( int iFirst,
int nStep,
int MyuMax,
char * pDecPat,
char * pPermInfo )

Definition at line 210 of file extraLutCas.h.

211{
212 int s, k, nPats = 1;
213 char Pats[256] = { pDecPat[(int)pPermInfo[iFirst]] };
214 assert( MyuMax <= 256 );
215 for ( s = 1; s < nStep; s++ ) {
216 char Entry = pDecPat[(int)pPermInfo[iFirst+s]];
217 for ( k = 0; k < nPats; k++ )
218 if ( Pats[k] == Entry )
219 break;
220 if ( k < nPats )
221 continue;
222 if ( nPats == MyuMax )
223 return MyuMax + 1;
224 assert( nPats < 256 );
225 Pats[nPats++] = Entry;
226 }
227 return nPats;
228}
Here is the caller graph for this function:

◆ Abc_NtkDecPatDecompose()

int Abc_NtkDecPatDecompose ( int nVars,
int nRails,
char * pDecPat,
char * pPermInfo )

Definition at line 252 of file extraLutCas.h.

253{
254 int BoundSet = ~(~0 << nVars);
255 int Myu = Abc_NtkDecPatCount( 0, 1 << nVars, 256, pDecPat, pPermInfo + 256*BoundSet );
256 int Log2 = Abc_Base2Log( Myu );
257 if ( Log2 <= nRails )
258 return BoundSet;
259 return Abc_NtkDecPatDecompose_rec( BoundSet, nVars, 0, nVars, Log2 - nRails, nRails, pDecPat, pPermInfo );
260}
int Abc_NtkDecPatDecompose_rec(int Mask, int nMaskVars, int iStart, int nVars, int nDiffs, int nRails, char *pDecPat, char *pPermInfo)
int Abc_NtkDecPatCount(int iFirst, int nStep, int MyuMax, char *pDecPat, char *pPermInfo)
Here is the call graph for this function:

◆ Abc_NtkDecPatDecompose_rec()

int Abc_NtkDecPatDecompose_rec ( int Mask,
int nMaskVars,
int iStart,
int nVars,
int nDiffs,
int nRails,
char * pDecPat,
char * pPermInfo )

Definition at line 229 of file extraLutCas.h.

230{
231 if ( nDiffs == 0 || iStart == nVars )
232 return 0;
233 int v, m, nMints = 1 << nVars;
234 for ( v = iStart; v < nVars; v++ ) {
235 int MaskThis = Mask & ~(1 << v);
236 int nStep = 1 << (nMaskVars - 1);
237 int MyuMax = 0;
238 for ( m = 0; m < nMints; m += nStep ) {
239 int MyuCur = Abc_NtkDecPatCount( m, nStep, 1 << nDiffs, pDecPat, pPermInfo+256*MaskThis );
240 MyuMax = Abc_MaxInt( MyuMax, MyuCur );
241 }
242 if ( MyuMax > (1 << nDiffs) )
243 continue;
244 if ( MyuMax <= (1 << nRails) )
245 return MaskThis;
246 MaskThis = Abc_NtkDecPatDecompose_rec( MaskThis, nMaskVars-1, v+1, nVars, nDiffs-1, nRails, pDecPat, pPermInfo );
247 if ( MaskThis )
248 return MaskThis;
249 }
250 return 0;
251}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkPrecomputeData()

char * Abc_NtkPrecomputeData ( )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 188 of file extraLutCas.h.

189{
190 char * pRes = ABC_CALLOC( char, 1 << 16 );
191 int i, k, b;
192 for ( i = 0; i < 256; i++ ) {
193 int nOnes = __builtin_popcount(i);
194 char * pTemp = pRes + 256*i;
195 for ( k = 0; k < 256; k++ ) {
196 int iMask = 0, Counts[2] = {nOnes, 0};
197 for ( b = 0; b < 8; Counts[(i >> b++)&1]++ )
198 if ( (k >> b) & 1 )
199 iMask |= 1 << Counts[(i >> b)&1];
200 pTemp[iMask] = (char)k;
201 assert( Counts[1] == nOnes );
202 }
203 }
204 for ( i = 0; i < 16; i++, printf("\n") )
205 for ( printf("%x : ", i), k = 0; k < 16; k++ )
206 printf( "%x=%x ", k, (int)pRes[i*256+k] );
207 return pRes;
208}