mirror of https://github.com/YosysHQ/abc.git
Fixes and improvements
This commit is contained in:
parent
5b49724fcc
commit
e8924e5534
|
|
@ -23,94 +23,99 @@
|
|||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static constexpr bool use_generic_acd = true;
|
||||
|
||||
int acd_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost, int try_no_late_arrival )
|
||||
{
|
||||
using namespace acd;
|
||||
|
||||
if ( use_generic_acd )
|
||||
ac_decomposition_params ps;
|
||||
ps.lut_size = lutSize;
|
||||
ps.use_first = false;
|
||||
ps.try_no_late_arrival = static_cast<bool>( try_no_late_arrival );
|
||||
ac_decomposition_stats st;
|
||||
|
||||
ac_decomposition_impl acd( nVars, ps, &st );
|
||||
int val = acd.run( pTruth, *pdelay );
|
||||
|
||||
if ( val < 0 )
|
||||
{
|
||||
ac_decomposition_params ps;
|
||||
ps.lut_size = lutSize;
|
||||
ps.use_first = false;
|
||||
ps.try_no_late_arrival = static_cast<bool>( try_no_late_arrival );
|
||||
ac_decomposition_stats st;
|
||||
|
||||
ac_decomposition_impl acd( nVars, ps, &st );
|
||||
int val = acd.run( pTruth, *pdelay );
|
||||
|
||||
if ( val < 0 )
|
||||
{
|
||||
*pdelay = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
*pdelay = acd.get_profile();
|
||||
*cost = st.num_luts;
|
||||
|
||||
return val;
|
||||
*pdelay = 0;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
acd66_impl acd( nVars );
|
||||
int val = acd.run( pTruth, *pdelay );
|
||||
|
||||
if ( val == 0 )
|
||||
{
|
||||
*pdelay = 0;
|
||||
return -1;
|
||||
}
|
||||
*pdelay = acd.get_profile();
|
||||
*cost = st.num_luts;
|
||||
|
||||
*pdelay = acd.get_profile();
|
||||
*cost = 2;
|
||||
|
||||
return val;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
int acd_decompose( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned char *decomposition )
|
||||
{
|
||||
using namespace acd;
|
||||
|
||||
if ( use_generic_acd )
|
||||
ac_decomposition_params ps;
|
||||
ps.lut_size = lutSize;
|
||||
ps.use_first = true;
|
||||
ac_decomposition_stats st;
|
||||
|
||||
ac_decomposition_impl acd( nVars, ps, &st );
|
||||
acd.run( pTruth, *pdelay );
|
||||
int val = acd.compute_decomposition();
|
||||
|
||||
if ( val < 0 )
|
||||
{
|
||||
ac_decomposition_params ps;
|
||||
ps.lut_size = lutSize;
|
||||
ps.use_first = true;
|
||||
ac_decomposition_stats st;
|
||||
|
||||
ac_decomposition_impl acd( nVars, ps, &st );
|
||||
acd.run( pTruth, *pdelay );
|
||||
int val = acd.compute_decomposition();
|
||||
|
||||
if ( val < 0 )
|
||||
{
|
||||
*pdelay = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
*pdelay = acd.get_profile();
|
||||
acd.get_decomposition( decomposition );
|
||||
return 0;
|
||||
*pdelay = 0;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
|
||||
*pdelay = acd.get_profile();
|
||||
acd.get_decomposition( decomposition );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int acd2_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost, int try_no_late_arrival )
|
||||
{
|
||||
using namespace acd;
|
||||
|
||||
acdXX_params ps;
|
||||
ps.lut_size = lutSize;
|
||||
ps.max_shared_vars = lutSize - 2;
|
||||
acdXX_impl acd( nVars, ps );
|
||||
int val = acd.run( pTruth, *pdelay );
|
||||
|
||||
if ( val == 0 )
|
||||
{
|
||||
acd66_impl acd( nVars );
|
||||
acd.run( pTruth, *pdelay );
|
||||
int val = acd.compute_decomposition();
|
||||
|
||||
if ( val != 0 )
|
||||
{
|
||||
*pdelay = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
*pdelay = acd.get_profile();
|
||||
|
||||
acd.get_decomposition( decomposition );
|
||||
return 0;
|
||||
*pdelay = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
acd.compute_decomposition();
|
||||
*pdelay = acd.get_profile();
|
||||
*cost = 2;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
int acd2_decompose( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned char *decomposition )
|
||||
{
|
||||
using namespace acd;
|
||||
|
||||
acdXX_params ps;
|
||||
ps.lut_size = lutSize;
|
||||
ps.max_shared_vars = lutSize - 2;
|
||||
acdXX_impl acd( nVars, ps );
|
||||
acd.run( pTruth, *pdelay );
|
||||
int val = acd.compute_decomposition();
|
||||
|
||||
if ( val != 0 )
|
||||
{
|
||||
*pdelay = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
*pdelay = acd.get_profile();
|
||||
|
||||
acd.get_decomposition( decomposition );
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline int acd66_decompose( word * pTruth, unsigned nVars, unsigned char *decomposition )
|
||||
|
|
|
|||
|
|
@ -34,8 +34,9 @@ ABC_NAMESPACE_HEADER_START
|
|||
|
||||
int acd_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost, int try_no_late_arrival );
|
||||
int acd_decompose( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned char *decomposition );
|
||||
int acd2_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost, int try_no_late_arrival );
|
||||
int acd2_decompose( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned char *decomposition );
|
||||
|
||||
int acd66_decompose( word * pTruth, unsigned nVars, unsigned char *decomposition );
|
||||
int acdXX_decompose( word * pTruth, unsigned lutSize, unsigned nVars, unsigned char *decomposition );
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
|
|
|||
|
|
@ -138,9 +138,20 @@ public:
|
|||
if ( best_multiplicity == UINT32_MAX )
|
||||
return -1;
|
||||
|
||||
for ( uint32_t i = 0; i < best_free_set; ++i )
|
||||
if ( bs_support_size == UINT32_MAX )
|
||||
{
|
||||
profile |= 1 << permutations[i];
|
||||
for ( uint32_t i = 0; i < best_free_set; ++i )
|
||||
{
|
||||
profile |= 1 << permutations[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( uint32_t i = 0; i < bs_support_size; ++i )
|
||||
{
|
||||
profile |= 1 << permutations[bs_support[i] + best_free_set];
|
||||
}
|
||||
profile = ~profile & ( ( 1u << num_vars ) - 1 );
|
||||
}
|
||||
|
||||
return profile;
|
||||
|
|
@ -1074,7 +1085,7 @@ private:
|
|||
++bytes;
|
||||
|
||||
/* write support */
|
||||
for ( uint32_t i = best_free_set; i < best_free_set; ++i )
|
||||
for ( uint32_t i = 0; i < best_free_set; ++i )
|
||||
{
|
||||
*pArray = (unsigned char)permutations[i];
|
||||
pArray++;
|
||||
|
|
|
|||
|
|
@ -155,10 +155,21 @@ public:
|
|||
|
||||
if ( best_multiplicity == UINT32_MAX )
|
||||
return -1;
|
||||
|
||||
for ( uint32_t i = 0; i < best_free_set; ++i )
|
||||
|
||||
if ( bs_support_size == UINT32_MAX )
|
||||
{
|
||||
profile |= 1 << permutations[i];
|
||||
for ( uint32_t i = 0; i < best_free_set; ++i )
|
||||
{
|
||||
profile |= 1 << permutations[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( uint32_t i = 0; i < bs_support_size; ++i )
|
||||
{
|
||||
profile |= 1 << permutations[bs_support[i] + best_free_set];
|
||||
}
|
||||
profile = ~profile & ( ( 1u << num_vars ) - 1 );
|
||||
}
|
||||
|
||||
return profile;
|
||||
|
|
@ -1101,7 +1112,7 @@ private:
|
|||
++bytes;
|
||||
|
||||
/* write support */
|
||||
for ( uint32_t i = best_free_set; i < best_free_set; ++i )
|
||||
for ( uint32_t i = 0; i < best_free_set; ++i )
|
||||
{
|
||||
*pArray = (unsigned char)permutations[i];
|
||||
pArray++;
|
||||
|
|
|
|||
Loading…
Reference in New Issue