abc/src/acd/ac_wrapper.cpp

70 lines
1.6 KiB
C++
Raw Normal View History

2023-11-15 18:38:00 +01:00
// #include "base/main/main.h"
#include "ac_wrapper.h"
#include "ac_decomposition.hpp"
// ABC_NAMESPACE_IMPL_START
2023-11-16 18:53:02 +01:00
int acd_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost, int try_no_late_arrival )
2023-11-15 18:38:00 +01:00
{
using namespace mockturtle;
int num_blocks = ( nVars <= 6 ) ? 1 : ( 1 << ( nVars - 6 ) );
/* translate truth table into static table */
kitty::dynamic_truth_table tt( nVars );
for ( int i = 0; i < num_blocks; ++i )
tt._bits[i] = pTruth[i];
ac_decomposition_params ps;
ps.lut_size = lutSize;
2023-11-16 18:53:02 +01:00
ps.try_no_late_arrival = static_cast<bool>( try_no_late_arrival );
2023-11-15 18:38:00 +01:00
ac_decomposition_stats st;
ac_decomposition_impl acd( tt, nVars, ps, &st );
2023-11-15 19:03:29 +01:00
int val = acd.run( *pdelay );
// int val = acd.compute_decomposition();
2023-11-15 18:38:00 +01:00
if ( val < 0 )
{
*pdelay = 0;
return -1;
}
*pdelay = acd.get_profile();
*cost = st.num_luts;
return 0;
}
int acd_decompose( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned char *decomposition )
{
using namespace mockturtle;
int num_blocks = ( nVars <= 6 ) ? 1 : ( 1 << ( nVars - 6 ) );
/* translate truth table into static table */
kitty::dynamic_truth_table tt( nVars );
for ( int i = 0; i < num_blocks; ++i )
tt._bits[i] = pTruth[i];
ac_decomposition_params ps;
ps.lut_size = lutSize;
ac_decomposition_stats st;
ac_decomposition_impl acd( tt, nVars, ps, &st );
acd.run( *pdelay );
int val = acd.compute_decomposition();
if ( val < 0 )
{
*pdelay = 0;
return -1;
}
*pdelay = acd.get_profile();
acd.get_decomposition( decomposition );
return 0;
}
// ABC_NAMESPACE_IMPL_END