openfpga/src/annotation/annotate_simulation_setting.cpp
/********************************************************************
 * Find median of signal density of all the nets 
 *******************************************************************/
Find median of signal density of all the nets
Find median of signal density of all the nets
static 
size_t median_atom_net_signal_density(const AtomContext& atom_ctx,
                                      const std::unordered_map<AtomNetId, t_net_power>& net_activity) {
  std::vector<float> net_densities;
  net_densities.reserve(net_activity.size());
  for (const AtomNetId& atom_net : atom_ctx.nlist.nets()) {
    if (0 == net_activity.count(atom_net)) {
      continue;
    }
    net_densities.push_back(net_activity.at(atom_net).density);
  }
  std::sort(net_densities.begin(), net_densities.end());
  if (net_densities.size() % 2 != 0) { 
    return net_densities[size_t(net_densities.size() / 2)];
  }            
  return 0.5 * (net_densities[size_t((net_densities.size() - 1) / 2)] + net_densities[size_t((net_densities.size() - 1) / 2)]);
}
static size_t median_atom_net_signal_density ( const AtomContext & atom_ctx , const std :: unordered_map < AtomNetId , t_net_power > & net_activity ) { std :: vector < float > net_densities ; net_densities . reserve ( net_activity . size ( ) ) ; for ( const AtomNetId & atom_net : atom_ctx . nlist . nets ( ) ) { if ( 0 == net_activity . count ( atom_net ) ) { continue ; } net_densities . push_back ( net_activity . at ( atom_net ) . density ) ; } std :: sort ( net_densities . begin ( ) , net_densities . end ( ) ) ; if ( net_densities . size ( ) % 2 != 0 ) { return net_densities [ size_t ( net_densities . size ( ) / 2 ) ] ; } return 0.5 * ( net_densities [ size_t ( ( net_densities . size ( ) - 1 ) / 2 ) ] + net_densities [ size_t ( ( net_densities . size ( ) - 1 ) / 2 ) ] ) ; }
Find median of signal density of all the nets
Find median of signal density of all the nets
/* Sort the net density */ /* Skip the nets without any activity annotation */ /* Get the median */ /* check for even case */