Removing unnecessary structs

This commit is contained in:
aletempiac 2024-02-21 09:47:16 +01:00
parent 0cd548f1cb
commit 13fd0d55c7
2 changed files with 16 additions and 33 deletions

View File

@ -74,9 +74,7 @@ int acd66_evaluate( word * pTruth, unsigned nVars, int compute_decomposition )
{ {
using namespace acd; using namespace acd;
acd66_params ps; acd66_impl acd( nVars, false );
ps.verify = false;
acd66_impl acd( nVars, ps );
if ( acd.run( pTruth ) == 0 ) if ( acd.run( pTruth ) == 0 )
return 0; return 0;
@ -97,8 +95,7 @@ int acd66_decompose( word * pTruth, unsigned nVars, unsigned char *decomposition
{ {
using namespace acd; using namespace acd;
acd66_params ps; acd66_impl acd( nVars, false );
acd66_impl acd( nVars, ps );
acd.run( pTruth ); acd.run( pTruth );
int val = acd.compute_decomposition(); int val = acd.compute_decomposition();

View File

@ -44,25 +44,6 @@ ABC_NAMESPACE_CXX_HEADER_START
namespace acd namespace acd
{ {
/*! \brief Parameters for acd66 */
struct acd66_params
{
/*! \brief Maximum size of the free set (1 < num < 6). */
uint32_t max_free_set_vars{ 5 };
/*! \brief Number of configurations to test for decomposition. */
uint32_t max_evaluations{ 3 };
/*! \brief Run verification before returning. */
bool verify{ false };
};
/*! \brief Statistics for acd66 */
struct acd66_stats
{
uint32_t num_edges{ 0 };
};
class acd66_impl class acd66_impl
{ {
private: private:
@ -71,8 +52,8 @@ private:
using LTT = kitty::static_truth_table<6>; using LTT = kitty::static_truth_table<6>;
public: public:
explicit acd66_impl( uint32_t num_vars, acd66_params const& ps, acd66_stats* pst = nullptr ) explicit acd66_impl( uint32_t num_vars, bool verify = false )
: num_vars( num_vars ), ps( ps ), pst( pst ) : num_vars( num_vars ), verify( verify )
{ {
std::iota( permutations.begin(), permutations.end(), 0 ); std::iota( permutations.begin(), permutations.end(), 0 );
} }
@ -102,17 +83,23 @@ public:
compute_decomposition_impl(); compute_decomposition_impl();
if ( ps.verify && !verify_impl() ) if ( verify && !verify_impl() )
{ {
return 1; return 1;
} }
if ( pst ) return 0;
}
uint32_t get_num_edges()
{
if ( bs_support_size == UINT32_MAX )
{ {
pst->num_edges = bs_support_size + best_free_set + 1 + ( best_multiplicity > 2 ? 1 : 0 ); return num_vars + 1 + ( best_multiplicity > 2 ? 1 : 0 );
} }
return 0; /* real value after support minimization */
return bs_support_size + best_free_set + 1 + ( best_multiplicity > 2 ? 1 : 0 );
} }
/* contains a 1 for BS variables */ /* contains a 1 for BS variables */
@ -146,7 +133,7 @@ private:
best_free_set = UINT32_MAX; best_free_set = UINT32_MAX;
/* find AC decompositions with minimal multiplicity */ /* find AC decompositions with minimal multiplicity */
for ( uint32_t i = num_vars - 6; i <= 5 && i <= ps.max_free_set_vars; ++i ) for ( uint32_t i = num_vars - 6; i <= 5; ++i )
{ {
if ( find_decomposition_bs( i ) ) if ( find_decomposition_bs( i ) )
return true; return true;
@ -940,8 +927,7 @@ private:
uint32_t bs_support[6]; uint32_t bs_support[6];
uint32_t num_vars; uint32_t num_vars;
acd66_params const& ps; bool verify;
acd66_stats* pst;
std::array<uint32_t, max_num_vars> permutations; std::array<uint32_t, max_num_vars> permutations;
}; };