vpr/src/pack/cluster.cpp
//Calculates molecule statistics for a single molecule
Calculates molecule statistics for a single molecule
Calculates molecule statistics for a single molecule
static t_molecule_stats calc_molecule_stats(const t_pack_molecule* molecule) {
    t_molecule_stats molecule_stats;
    auto& atom_ctx = g_vpr_ctx.atom();
    for (auto blk : molecule->atom_block_ids) {
        if (!blk) continue;
        ++molecule_stats.num_blocks; 
        const t_model* model = atom_ctx.nlist.block_model(blk);
        for (const t_model_ports* input_port = model->inputs; input_port != nullptr; input_port = input_port->next) {
            molecule_stats.num_input_pins += input_port->size;
        }
        for (const t_model_ports* output_port = model->outputs; output_port != nullptr; output_port = output_port->next) {
            molecule_stats.num_output_pins += output_port->size;
        }
    }
    molecule_stats.num_pins = molecule_stats.num_input_pins + molecule_stats.num_output_pins;
    std::set<AtomBlockId> molecule_atoms(molecule->atom_block_ids.begin(), molecule->atom_block_ids.end());
    for (auto blk : molecule->atom_block_ids) {
        if (!blk) continue;
        for (auto pin : atom_ctx.nlist.block_pins(blk)) {
            auto net = atom_ctx.nlist.pin_net(pin);
            auto pin_type = atom_ctx.nlist.pin_type(pin);
            if (pin_type == PinType::SINK) {
                auto driver_blk = atom_ctx.nlist.net_driver_block(net);
                if (molecule_atoms.count(driver_blk)) {
                } else {
                    ++molecule_stats.num_used_ext_inputs;
                }
            } else {
                VTR_ASSERT(pin_type == PinType::DRIVER);
                bool net_leaves_molecule = false;
                for (auto sink_pin : atom_ctx.nlist.net_sinks(net)) {
                    auto sink_blk = atom_ctx.nlist.pin_block(sink_pin);
                    if (!molecule_atoms.count(sink_blk)) {
                        net_leaves_molecule = true;
                        break;
                    }
                }
                if (net_leaves_molecule) {
                    ++molecule_stats.num_used_ext_outputs;
                }
            }
        }
    }
    molecule_stats.num_used_ext_pins = molecule_stats.num_used_ext_inputs + molecule_stats.num_used_ext_outputs;
    return molecule_stats;
}
static t_molecule_stats calc_molecule_stats ( const t_pack_molecule * molecule ) { t_molecule_stats molecule_stats ; auto & atom_ctx = g_vpr_ctx . atom ( ) ; for ( auto blk : molecule -> atom_block_ids ) { if ( ! blk ) continue ; ++ molecule_stats . num_blocks ; const t_model * model = atom_ctx . nlist . block_model ( blk ) ; for ( const t_model_ports * input_port = model -> inputs ; input_port != nullptr ; input_port = input_port -> next ) { molecule_stats . num_input_pins += input_port -> size ; } for ( const t_model_ports * output_port = model -> outputs ; output_port != nullptr ; output_port = output_port -> next ) { molecule_stats . num_output_pins += output_port -> size ; } } molecule_stats . num_pins = molecule_stats . num_input_pins + molecule_stats . num_output_pins ; std :: set < AtomBlockId > molecule_atoms ( molecule -> atom_block_ids . begin ( ) , molecule -> atom_block_ids . end ( ) ) ; for ( auto blk : molecule -> atom_block_ids ) { if ( ! blk ) continue ; for ( auto pin : atom_ctx . nlist . block_pins ( blk ) ) { auto net = atom_ctx . nlist . pin_net ( pin ) ; auto pin_type = atom_ctx . nlist . pin_type ( pin ) ; if ( pin_type == PinType :: SINK ) { auto driver_blk = atom_ctx . nlist . net_driver_block ( net ) ; if ( molecule_atoms . count ( driver_blk ) ) { } else { ++ molecule_stats . num_used_ext_inputs ; } } else { VTR_ASSERT ( pin_type == PinType :: DRIVER ) ; bool net_leaves_molecule = false ; for ( auto sink_pin : atom_ctx . nlist . net_sinks ( net ) ) { auto sink_blk = atom_ctx . nlist . pin_block ( sink_pin ) ; if ( ! molecule_atoms . count ( sink_blk ) ) { net_leaves_molecule = true ; break ; } } if ( net_leaves_molecule ) { ++ molecule_stats . num_used_ext_outputs ; } } } } molecule_stats . num_used_ext_pins = molecule_stats . num_used_ext_inputs + molecule_stats . num_used_ext_outputs ; return molecule_stats ; }
Calculates molecule statistics for a single molecule
Calculates molecule statistics for a single molecule
//Calculate the number of available pins on primitives within the molecule //Record number of valid blocks in molecule //Calculate the number of externally used pins //Pin driven by a block within the molecule //Does not count as an external connection //Pin driven by a block outside the molecule //There is at least one sink outside of the current molecule //We assume that any fanout occurs outside of the molecule, hence we only //count one used output (even if there are multiple sinks outside the molecule)