diff --git a/.vs/CMake Overview b/.vs/CMake Overview new file mode 100644 index 000000000..e69de29bb diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json new file mode 100644 index 000000000..8f0d73346 --- /dev/null +++ b/.vs/ProjectSettings.json @@ -0,0 +1,3 @@ +{ + "CurrentProjectSetting": "x64-Debug" +} \ No newline at end of file diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 000000000..ba489ecf6 --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,11 @@ +{ + "ExpandedNodes": [ + "", + "\\include", + "\\include\\mockturtle", + "\\include\\mockturtle\\algorithms", + "\\test", + "\\test\\algorithms" + ], + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vs/mockturtle/v16/.suo b/.vs/mockturtle/v16/.suo new file mode 100644 index 000000000..a6d211394 Binary files /dev/null and b/.vs/mockturtle/v16/.suo differ diff --git a/.vs/mockturtle/v16/Browse.VC.db b/.vs/mockturtle/v16/Browse.VC.db new file mode 100644 index 000000000..73f5b56c1 Binary files /dev/null and b/.vs/mockturtle/v16/Browse.VC.db differ diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 000000000..0c66c992b Binary files /dev/null and b/.vs/slnx.sqlite differ diff --git a/include/mockturtle/algorithms/simulation.hpp b/include/mockturtle/algorithms/simulation.hpp index 2c43d88b3..30a23a347 100644 --- a/include/mockturtle/algorithms/simulation.hpp +++ b/include/mockturtle/algorithms/simulation.hpp @@ -1,27 +1,3 @@ -/* mockturtle: C++ logic network library - * Copyright (C) 2018-2021 EPFL - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ /*! \file simulation.hpp diff --git a/include/mockturtle/algorithms/simulation_cec.hpp b/include/mockturtle/algorithms/simulation_cec.hpp index 2b8cce16c..ee2b183bb 100644 --- a/include/mockturtle/algorithms/simulation_cec.hpp +++ b/include/mockturtle/algorithms/simulation_cec.hpp @@ -1,70 +1,97 @@ -/* mockturtle: C++ logic network library - * Copyright (C) 2018-2021 EPFL - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -/*! - \file simulation_cec.hpp - \brief Simulation-based CEC - - EPFL CS-472 2021 Final Project Option 2 -*/ + #pragma once #include #include #include - #include "../utils/node_map.hpp" #include "miter.hpp" #include "simulation.hpp" +#include namespace mockturtle { /* Statistics to be reported */ -struct simulation_cec_stats -{ - /*! \brief Split variable (simulation size). */ +struct simulation_cec_stats{ + //Here we write Split Variable, that is related to the simulation size + + + uint32_t split_var{ 0 }; - /*! \brief Number of simulation rounds. */ + + //Number of simulation rounds + uint32_t rounds{ 0 }; }; -namespace detail -{ +namespace detail{ + + //start here--------------------------------------------------------------------- + +class split_var_renato{ +public: + + unsigned num_variables; + + unsigned split_variable; + + uint64_t others_round; + //Destructor of the class + split_var_renato() = delete; + + //This is the contructor of the class + split_var_renato( unsigned num_variables, unsigned split_variable, uint64_t others_round ) : num_variables( num_variables ), split_variable{ split_variable }, others_round{ others_round } {} + + kitty::dynamic_truth_table compute_constant( bool value ) const + { + kitty::dynamic_truth_table tt( split_variable ); + return value ? ~tt : tt; + } + + kitty::dynamic_truth_table compute_pi( uint32_t index ) const + { + kitty::dynamic_truth_table tt( split_variable ); + if ( index < split_variable ) { + kitty::create_nth_var( tt, index ); + } + else { + + bool value = ( others_round >> ( index - split_variable ) ) & 1; + if ( !value ){ + tt = ~tt; + + + } + } + + return tt; + } + + kitty::dynamic_truth_table compute_not( kitty::dynamic_truth_table const& value ) const + { + return ~value; + } +private: + + + //uint64_t others_round; +}; +//finish here -------------------------------------------------- template class simulation_cec_impl { public: using pattern_t = unordered_node_map; + using node = typename Ntk::node; using signal = typename Ntk::signal; public: + explicit simulation_cec_impl( Ntk& ntk, simulation_cec_stats& st ) : _ntk( ntk ), _st( st ) @@ -73,31 +100,69 @@ class simulation_cec_impl bool run() { - /* TODO: write your implementation here */ - return false; + + // START HERE ---------------------- + unsigned n = _ntk.num_pis(); + unsigned split_variable; + unsigned V = _ntk.size(); + + + if ( n <= 6 ) + { + split_variable = n; + //or also _st.split_variable + } + else { + + + int m = 7; + while ( m < n && ( 32 + ( 1 << ( ( m + 1 ) - 3 ) ) ) * V <= 1 << 29 ) + { + m++; + } + split_variable = m; + //or _st.split_variable + } + + int rounds = 1 << ( n - split_variable ); + + // I store them in the statistics struct + _st.split_var = split_variable; + _st.rounds = rounds; + + // This is the actual simulation... + + for ( uint64_t others_round = 0; others_round < rounds; others_round++ ) + { // We iterate over all the possible assignations of the remaining variables + split_var_renato simul( _ntk.num_pis(), split_variable, others_round ); + const auto tts = simulate( _ntk, simul ); + + // const std::vector tts + for ( auto& po : tts ) + { + if ( !kitty::is_const0( po ) ) + { + return false; + } + } + } + + return true; } + + + //FINISH HERE --------------------------- -private: - /* you can add additional methods here */ private: Ntk& _ntk; simulation_cec_stats& _st; - /* you can add other attributes here */ + }; -} // namespace detail +} -/* Entry point for users to call */ -/*! \brief Simulation-based CEC. - * - * This function implements a simulation-based combinational equivalence checker. - * The implementation creates a miter network and run several rounds of simulation - * to verify the functional equivalence. For memory and speed reasons this approach - * is limited up to 40 input networks. It returns an optional which is `nullopt`, - * if the network has more than 40 inputs. - */ template std::optional simulation_cec( Ntk const& ntk1, Ntk const& ntk2, simulation_cec_stats* pst = nullptr ) { @@ -131,4 +196,6 @@ std::optional simulation_cec( Ntk const& ntk1, Ntk const& ntk2, simulation return result; } -} // namespace mockturtle + + +}