Skip to content

Commit

Permalink
Mda aig opt (#12)
Browse files Browse the repository at this point in the history
Cleaning code + bug fixes.

* Removed unneeded files

* Fixed minor bug

* Fixed bug with feedthrough nets and improperly named IO

* Fixed bugs with optimizing and writing sequential networks
  • Loading branch information
maustin8 authored and srtemp committed Nov 20, 2019
1 parent d68a008 commit b2d59f7
Show file tree
Hide file tree
Showing 7 changed files with 219 additions and 362 deletions.
3 changes: 0 additions & 3 deletions core/algorithms/optimization/optimization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,14 @@ namespace oracle{
else if(high){
for(int i = 0; i < num_parts; i++){
oracle::partition_view<aig_names> part_aig = partitions_aig.create_part(ntk_aig, i);

auto opt_aig = mockturtle::node_resynthesis<mockturtle::aig_network>( part_aig, resyn_aig );

oracle::aig_script5 aigopt;
opt_aig = aigopt.run(opt_aig);
mockturtle::depth_view part_aig_opt_depth{opt_aig};
int aig_opt_size = opt_aig.num_gates();
int aig_opt_depth = part_aig_opt_depth.depth();

auto opt_mig = mockturtle::node_resynthesis<mockturtle::mig_network>( part_aig, resyn_mig );

oracle::mig_script migopt;
opt_mig = migopt.run(opt_mig);
mockturtle::depth_view part_mig_opt_depth{opt_mig};
Expand Down
2 changes: 2 additions & 0 deletions core/commands/optimization/oracle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ namespace alice
mockturtle::depth_view orig_depth{names_view};
oracle::partition_manager<aig_names> partitions(names_view, num_partitions);
store<part_man_aig_ntk>().extend() = std::make_shared<part_man_aig>( partitions );

std::cout << filename << " partitioned " << num_partitions << " times\n";

if(is_set("high"))
high = true;
Expand Down
6 changes: 5 additions & 1 deletion lib/mockturtle/include/mockturtle/algorithms/refactoring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,16 @@ class refactoring_impl
} );

ntk.foreach_gate( [&]( auto const& n, auto i ) {

if ( i >= size )
{
return false;
}
if ( ntk.fanout_size( n ) == 0u )
if ( ntk.fanout_size( n ) == 0u || ntk.is_ci( n ) )
{
return true;
}

const auto mffc = make_with_stopwatch<mffc_view<Ntk>>( st.time_mffc, ntk, n );

pbar( i, i, _candidates, _estimated_gain );
Expand All @@ -165,11 +167,13 @@ class refactoring_impl
return true;
}

// std::cout << "making leaves\n";
std::vector<signal<Ntk>> leaves( mffc.num_pis() );
mffc.foreach_pi( [&]( auto const& n, auto j ) {
leaves[j] = ntk.make_signal( n );
} );

// std::cout << "beginning simulation\n";
default_simulator<kitty::dynamic_truth_table> sim( mffc.num_pis() );
const auto tt = call_with_stopwatch( st.time_simulation,
[&]() { return simulate<kitty::dynamic_truth_table>( mffc, sim )[0]; } );
Expand Down
6 changes: 5 additions & 1 deletion lib/mockturtle/include/mockturtle/algorithms/simulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,19 @@ node_map<SimulationType, Ntk> simulate_nodes( Ntk const& ntk, Simulator const& s
static_assert( has_compute_v<Ntk, SimulationType>, "Ntk does not implement the compute method for SimulationType" );

node_map<SimulationType, Ntk> node_to_value( ntk );

// std::cout << "simulate nodes\n";
node_to_value[ntk.get_node( ntk.get_constant( false ) )] = sim.compute_constant( ntk.constant_value( ntk.get_node( ntk.get_constant( false ) ) ) );
if ( ntk.get_node( ntk.get_constant( false ) ) != ntk.get_node( ntk.get_constant( true ) ) )
{
node_to_value[ntk.get_node( ntk.get_constant( true ) )] = sim.compute_constant( ntk.constant_value( ntk.get_node( ntk.get_constant( true ) ) ) );
}
ntk.foreach_pi( [&]( auto const& n, auto i ) {
// std::cout << "PI: " << n << " is_ro = " << ntk.is_ro(n) << "\n";
node_to_value[n] = sim.compute_pi( i );
} );

ntk.foreach_gate( [&]( auto const& n ) {
// std::cout << "gate = " << n << " is ro = " << ntk.is_ro(n) << "\n";
std::vector<SimulationType> fanin_values( ntk.fanin_size( n ) );
ntk.foreach_fanin( n, [&]( auto const& f, auto i ) {
fanin_values[i] = node_to_value[f];
Expand Down Expand Up @@ -342,8 +344,10 @@ std::vector<SimulationType> simulate( Ntk const& ntk, Simulator const& sim = Sim

const auto node_to_value = simulate_nodes<SimulationType, Ntk, Simulator>( ntk, sim );

// std::cout << "computing POs\n";
std::vector<SimulationType> po_values( ntk.num_pos() );
ntk.foreach_po( [&]( auto const& f, auto i ) {
// std::cout << "PO: " << f.index << "\n";
if ( ntk.is_complemented( f ) )
{
po_values[i] = sim.compute_not( node_to_value[f] );
Expand Down
Loading

0 comments on commit b2d59f7

Please sign in to comment.