openfpga/src/annotation/annotate_simulation_setting.cpp
/********************************************************************
 * Find the average signal density for all the nets of user's benchmark
 * by applying a weight to each net density
 *******************************************************************/
Find the average signal density for all the nets of user's benchmark
by applying a weight to each net density
Find the average signal density for all the nets of user ' s benchmark by applying a weight to each net density
static 
float average_weighted_atom_net_signal_density(const AtomContext& atom_ctx,
                                               const std::unordered_map<AtomNetId, t_net_power>& net_activity) {
  float weighted_avg_density = 0.;
  size_t weighted_net_cnt = 0;
  for (const AtomNetId& atom_net : atom_ctx.nlist.nets()) {
    if (0 == net_activity.count(atom_net)) {
      continue;
    }
    if (0. == net_activity.at(atom_net).density) {
      continue;
    }
    size_t net_weight; 
    if (0 == std::distance(atom_ctx.nlist.net_sinks(atom_net).begin(), atom_ctx.nlist.net_sinks(atom_net).end())) {
      net_weight = 1;
    } else {
      VTR_ASSERT(0 < std::distance(atom_ctx.nlist.net_sinks(atom_net).begin(), atom_ctx.nlist.net_sinks(atom_net).end()));
      net_weight = std::distance(atom_ctx.nlist.net_sinks(atom_net).begin(), atom_ctx.nlist.net_sinks(atom_net).end());
    }
    weighted_avg_density += net_activity.at(atom_net).density* net_weight;
    weighted_net_cnt += net_weight;
  }
  return weighted_avg_density / weighted_net_cnt; 
}
static float average_weighted_atom_net_signal_density ( const AtomContext & atom_ctx , const std :: unordered_map < AtomNetId , t_net_power > & net_activity ) { float weighted_avg_density = 0. ; size_t weighted_net_cnt = 0 ; for ( const AtomNetId & atom_net : atom_ctx . nlist . nets ( ) ) { if ( 0 == net_activity . count ( atom_net ) ) { continue ; } if ( 0. == net_activity . at ( atom_net ) . density ) { continue ; } size_t net_weight ; if ( 0 == std :: distance ( atom_ctx . nlist . net_sinks ( atom_net ) . begin ( ) , atom_ctx . nlist . net_sinks ( atom_net ) . end ( ) ) ) { net_weight = 1 ; } else { VTR_ASSERT ( 0 < std :: distance ( atom_ctx . nlist . net_sinks ( atom_net ) . begin ( ) , atom_ctx . nlist . net_sinks ( atom_net ) . end ( ) ) ) ; net_weight = std :: distance ( atom_ctx . nlist . net_sinks ( atom_net ) . begin ( ) , atom_ctx . nlist . net_sinks ( atom_net ) . end ( ) ) ; } weighted_avg_density += net_activity . at ( atom_net ) . density * net_weight ; weighted_net_cnt += net_weight ; } return weighted_avg_density / weighted_net_cnt ; }
Find the average signal density for all the nets of user's benchmark
 by applying a weight to each net density
Find the average signal density for all the nets of user ' s benchmark by applying a weight to each net density
/* get the average density of all the nets */ /* Skip the nets without any activity annotation */ /* Only care non-zero density nets */ /* Consider the weight of fan-out */