Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2021 cec chen #57

Open
wants to merge 2 commits into
base: v2021-cec
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Linux CI

on:
push:
branches:
Expand Down Expand Up @@ -98,4 +98,4 @@ jobs:
- name: Run tests
run: |
cd build
./test/run_tests "~[quality]"
./test/run_tests "~[quality]"
79 changes: 78 additions & 1 deletion include/mockturtle/algorithms/simulation_cec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,47 @@ struct simulation_cec_stats

namespace detail
{
class tt_simulator
{
public:
tt_simulator() = delete;
tt_simulator( uint32_t split_var, uint32_t round ) : _split_var( split_var ), _round( round ) {}

kitty::dynamic_truth_table compute_constant( bool value ) const
{
kitty::dynamic_truth_table tt( _split_var );
return value ? ~tt : tt;
}

kitty::dynamic_truth_table compute_pi( uint32_t index ) const
{
kitty::dynamic_truth_table tt( _split_var );
if( index < _split_var )
{
kitty::create_nth_var( tt, index );
}
else
{
bool val = ((_round >> (index - _split_var)) & 1);
if( val == 0 )
{
tt = ~tt;
}
}

return tt;
}

kitty::dynamic_truth_table compute_not( kitty::dynamic_truth_table const& value ) const
{
return ~value;
}

private:
uint32_t _split_var;
uint32_t _round;
};


template<class Ntk>
class simulation_cec_impl
Expand All @@ -74,18 +115,54 @@ class simulation_cec_impl
bool run()
{
/* TODO: write your implementation here */
return false;
uint32_t num_pis = _ntk.num_pis();
uint32_t num_nodes = _ntk.size();

_st.split_var = calculate_split_var(num_pis, num_nodes);
_st.rounds = 1 << (num_pis - _st.split_var);

for(uint32_t rounds = 0; rounds < _st.rounds; rounds++)
{
tt_simulator t_sim(_st.split_var, rounds);
const auto tt_po = simulate<kitty::dynamic_truth_table>(_ntk, t_sim);

for(auto& it : tt_po)
{
if(kitty::is_const0(it) == 0)
{
return false;
}
}
}
return true;
}

private:
/* you can add additional methods here */
uint32_t calculate_split_var(uint32_t num_pis, uint32_t num_nodes)
{
if(num_pis <= 6u)
{
return num_pis;
}
else
{
uint32_t m = 7;
while(m <= num_pis && ( 32 + ( 1 << (m - 3)) * num_nodes ) <= ( 1 << 29 ) )
{
m++;
}
return m-1;
}
}

private:
Ntk& _ntk;
simulation_cec_stats& _st;
/* you can add other attributes here */
};


} // namespace detail

/* Entry point for users to call */
Expand Down