115 unsigned Mask = Abc_InfoMask( nBits );
116 Vec_Wec_t * vDivs = Vec_WecStart( 2*nBits );
118 unsigned * pPlace =
ABC_CALLOC(
unsigned, (1 << nBits) );
119 int n, a, b, One, Two, i, k, New, Bound = 1 << (nBits-1);
123 pPlace[Mask & (-1)] = ~0;
125 for ( i = 2; i < (1 << nBits); i++ )
129 printf(
"Generating numbers using %d adders:\n", 0 );
130 for ( i = 0; i < nBits; i++ )
132 Vec_WecPush( vDivs, 0, 1<<i );
133 printf(
"%d = %d << %d\n", 1<<i, 1, i );
136 for ( n = 1; n < nBits; n++ )
139 for ( a = 1; a < (1 << nBits); a++ )
140 if ( pPlace[a] == 0 )
142 if ( a == (1 << nBits) )
145 printf(
"Generating numbers using %d adders:\n", n );
146 vThree = Vec_WecEntry( vDivs, n );
147 for ( a = 0; a < nBits; a++ )
148 for ( b = 0; b < nBits; b++ )
152 vOne = Vec_WecEntry( vDivs, a );
153 vTwo = Vec_WecEntry( vDivs, b );
158 if ( New >= -Bound && New < Bound && pPlace[Mask & New] == 0 )
161 Vec_IntPush( vThree, New );
163 pPlace[Mask & New] = (One << 16) | Two;
164 printf(
"%d = %d + %d\n", New, One, Two );
167 if ( New >= -Bound && New < Bound && pPlace[Mask & New] == 0 )
170 Vec_IntPush( vThree, New );
172 pPlace[Mask & New] = (One << 16) | Two | (1 << 15);
173 printf(
"%d = %d - %d\n", New, One, Two );
176 if ( New >= -Bound && New < Bound && pPlace[Mask & New] == 0 )
179 Vec_IntPush( vThree, New );
181 pPlace[Mask & New] = (Two << 16) | One | (1 << 15);
182 printf(
"%d = %d - %d\n", New, Two, One );
185 printf(
"Adding one incrementor:\n" );
191 if ( pPlace[Mask & New] == 0 )
193 pPlace[Mask & New] = One << 16;
194 printf(
"-%d = ~%d + 1\n", One, One );
199 Vec_WecPrint( vDivs, 0 );
200 Vec_WecFree( vDivs );
213 unsigned Mask = Abc_InfoMask( nBits );
214 unsigned New = Mask & (unsigned)n;
215 int nTotal = nWidth+nBits;
216 int One =
p[New] >> 16;
217 int Two =
p[New] & 0x7FFF;
218 char Sign = n < 0 ?
'N' :
'n';
219 char Oper = ((
p[New] >> 15) & 1) ?
'-' :
'+';
224 for ( nZeros = 0; nZeros < nBits; nZeros++ )
225 if ( (n >> nZeros) & 1 )
229 fprintf( pFile,
" wire [%d:0] N1 = -n1;\n",
nTotal-1 );
230 if ( Abc_AbsInt(nn) != 1 )
233 fprintf( pFile,
" wire [%d:0] %c%d = %c%d << %d;\n",
nTotal-1, Sign, Abc_AbsInt(n), Sign, Abc_AbsInt(nn), nZeros );
235 else if ( One && Two )
239 fprintf( pFile,
" wire [%d:0] %c%d = n%d %c n%d;\n",
nTotal-1, Sign, Abc_AbsInt(n), One, Oper, Two );
244 fprintf( pFile,
" wire [%d:0] N%d = -n%d;\n",
nTotal-1, One, One );