#include #include // std::pair #include // std::vector #include // std::find_if static const int num_processes = 20; static const int num_calls = 100; struct process_stats { typedef sc_core::sc_process_handle proc_handle; typedef std::pair< proc_handle, int > stats_type; typedef std::vector< stats_type > stats_container; struct pred { proc_handle p_; pred( const proc_handle & p ) : p_(p) {} bool operator()( stats_type const & s ) { return s.first == p_; } }; stats_container stats; void update() { // get current process handle proc_handle p = sc_core::sc_get_current_process_handle(); // lookup entry in table stats_container::iterator found = find_if( stats.begin(), stats.end(), pred(p) ); // not found, add to table if( found == stats.end() ) { stats.push_back( std::make_pair( p,0) ); found = stats.end()-1; } // increase stats found->second++; } void dump() const { for( stats_container::const_iterator it = stats.begin(); it!=stats.end(); ++it ) std::cout << (*it).first.name() << ": " << (*it).second << std::endl; } }; SC_MODULE(module) { process_stats flips; SC_CTOR(module) { // just ignore the warning... :) sc_core::sc_report_handler::set_actions( "object already exists" , sc_core::SC_DO_NOTHING ); for( int i=0; i