Skip to content

Commit dd0606b

Browse files
vpr: Use Logic Elements instead of ALMs to be more general
1 parent 8cc6faf commit dd0606b

File tree

1 file changed

+51
-52
lines changed

1 file changed

+51
-52
lines changed

vpr/src/pack/cluster.cpp

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -347,17 +347,17 @@ static t_pb_graph_pin* get_driver_pb_graph_pin(const t_pb* driver_pb, const Atom
347347

348348
static void update_pb_type_count(const t_pb* pb, std::unordered_map<std::string, int>& pb_type_count);
349349

350-
static void update_alm_count(const t_pb* pb, const t_type_ptr logic_block_type, const t_pb_type* alm_pb_type, std::vector<int>& alm_count);
350+
static void update_le_count(const t_pb* pb, const t_type_ptr logic_block_type, const t_pb_type* le_pb_type, std::vector<int>& le_count);
351351

352352
static void print_pb_type_count(std::unordered_map<std::string, int>& pb_type_count);
353353

354354
static t_type_ptr identify_logic_block_type(std::map<const t_model*, std::vector<t_type_ptr>>& primitive_candidate_block_types);
355355

356-
static t_pb_type* identify_alm_block_type(t_type_ptr logic_block_type);
356+
static t_pb_type* identify_le_block_type(t_type_ptr logic_block_type);
357357

358358
static bool pb_used_for_blif_model(const t_pb* pb, std::string blif_model_name);
359359

360-
static void print_alm_count(std::vector<int>& alm_count);
360+
static void print_le_count(std::vector<int>& le_count, const t_pb_type* le_pb_type);
361361

362362
/*****************************************/
363363
/*globally accessible function*/
@@ -420,16 +420,15 @@ std::map<t_type_ptr, size_t> do_clustering(const t_packer_opts& packer_opts,
420420
// used for each physical block type defined in the architecture file.
421421
std::unordered_map<std::string, int> pb_type_count;
422422

423-
// this data structure tracks the number of ALMs used. It is populated only
424-
// for architectures which has an ALM-like logic blocks. The architecture is
425-
// assumed to have an ALM-like logic block only if it has a logic block that
426-
// contains LUT primitives and is the first pb_block to have more than one
427-
// instance from the top of the hierarchy (All parent pb_block have one
428-
// instance only and one mode only). Index 0 holds the number of ALMs that are
429-
// used for both logic (LUTs/adders) and registers. Index 1 holds the number
430-
// of ALMs that are used for logic (LUTs/adders) only. Index 2 holds the
431-
// number of ALMs that are used for registers only.
432-
std::vector<int> alm_count(3, 0);
423+
// this data structure tracks the number of Logic Elements (LEs) used. It is
424+
// populated only for architectures which has LEs. The architecture is assumed
425+
// to have LEs only iff it has a logic block that contains LUT primitives and is
426+
// the first pb_block to have more than one instance from the top of the hierarchy
427+
// (All parent pb_block have one instance only and one mode only). Index 0 holds
428+
// the number of LEs that are used for both logic (LUTs/adders) and registers.
429+
// Index 1 holds the number of LEs that are used for logic (LUTs/adders) only.
430+
// Index 2 holds the number of LEs that are used for registers only.
431+
std::vector<int> le_count(3, 0);
433432

434433
num_clb = 0;
435434

@@ -482,8 +481,8 @@ std::map<t_type_ptr, size_t> do_clustering(const t_packer_opts& packer_opts,
482481
auto primitive_candidate_block_types = identify_primitive_candidate_block_types();
483482
// find the cluster type that has lut primitives
484483
auto logic_block_type = identify_logic_block_type(primitive_candidate_block_types);
485-
// find an ALM-like pb_type within the found logic_block_type
486-
auto alm_pb_type = identify_alm_block_type(logic_block_type);
484+
// find a LE pb_type within the found logic_block_type
485+
auto le_pb_type = identify_le_block_type(logic_block_type);
487486

488487
blocks_since_last_analysis = 0;
489488
num_blocks_hill_added = 0;
@@ -737,8 +736,8 @@ std::map<t_type_ptr, size_t> do_clustering(const t_packer_opts& packer_opts,
737736
auto cur_pb = cluster_ctx.clb_nlist.block_pb(clb_index);
738737
// update the pb type count by counting the used pb types in this packed cluster
739738
update_pb_type_count(cur_pb, pb_type_count);
740-
// update the data structure holding the alm counts
741-
update_alm_count(cur_pb, logic_block_type, alm_pb_type, alm_count);
739+
// update the data structure holding the LE counts
740+
update_le_count(cur_pb, logic_block_type, le_pb_type, le_count);
742741
free_pb_stats_recursive(cur_pb);
743742
} else {
744743
/* Free up data structures and requeue used molecules */
@@ -758,9 +757,9 @@ std::map<t_type_ptr, size_t> do_clustering(const t_packer_opts& packer_opts,
758757
// physical block type after finishing the packing stage
759758
print_pb_type_count(pb_type_count);
760759

761-
// if this architecture has an ALM-like physical block, report its usage
762-
if (alm_pb_type) {
763-
print_alm_count(alm_count);
760+
// if this architecture has LE physical block, report its usage
761+
if (le_pb_type) {
762+
print_le_count(le_count, le_pb_type);
764763
}
765764

766765
/****************************************************************
@@ -3402,13 +3401,13 @@ static t_type_ptr identify_logic_block_type(std::map<const t_model*, std::vector
34023401
}
34033402

34043403
/**
3405-
* This function returns the pb_type that is similar to an ALM in an Intel
3406-
* FPGA. The ALM is defined as a physical block that contains a LUT primitive and
3404+
* This function returns the pb_type that is similar to Logic Element (LE) in an FPGA
3405+
* The LE is defined as a physical block that contains a LUT primitive and
34073406
* is found by searching a cluster type to find the first pb_type (from the top
3408-
* of the hierarchy clb->alm) that has more than one instance within the cluster.
3407+
* of the hierarchy clb->LE) that has more than one instance within the cluster.
34093408
*/
3410-
static t_pb_type* identify_alm_block_type(t_type_ptr logic_block_type) {
3411-
// if there is no CLB-like cluster, then there is no ALM-like pb_block
3409+
static t_pb_type* identify_le_block_type(t_type_ptr logic_block_type) {
3410+
// if there is no CLB-like cluster, then there is no LE pb_block
34123411
if (!logic_block_type)
34133412
return nullptr;
34143413

@@ -3423,7 +3422,7 @@ static t_pb_type* identify_alm_block_type(t_type_ptr logic_block_type) {
34233422
// explore the only child of this pb_graph_node
34243423
pb_graph_node = &pb_graph_node->child_pb_graph_nodes[0][0][0];
34253424
// if the child node has more than one instance in the
3426-
// cluster then this is the pb_type similar to an ALM
3425+
// cluster then this is the pb_type similar to a LE
34273426
if (pb_graph_node->pb_type->num_pb > 1)
34283427
return pb_graph_node->pb_type;
34293428
}
@@ -3432,12 +3431,12 @@ static t_pb_type* identify_alm_block_type(t_type_ptr logic_block_type) {
34323431
}
34333432

34343433
/**
3435-
* This function updates the alm_count data structure from the given packed cluster
3434+
* This function updates the le_count data structure from the given packed cluster
34363435
*/
3437-
static void update_alm_count(const t_pb* pb, const t_type_ptr logic_block_type, const t_pb_type* alm_pb_type, std::vector<int>& alm_count) {
3438-
// if this cluster doesn't contain ALMs or there
3439-
// are no alms in this architecture, ignore it
3440-
if (!logic_block_type || pb->pb_graph_node != logic_block_type->pb_graph_head || !alm_pb_type)
3436+
static void update_le_count(const t_pb* pb, const t_type_ptr logic_block_type, const t_pb_type* le_pb_type, std::vector<int>& le_count) {
3437+
// if this cluster doesn't contain LEs or there
3438+
// are no les in this architecture, ignore it
3439+
if (!logic_block_type || pb->pb_graph_node != logic_block_type->pb_graph_head || !le_pb_type)
34413440
return;
34423441

34433442
const std::string lut(".names");
@@ -3446,29 +3445,29 @@ static void update_alm_count(const t_pb* pb, const t_type_ptr logic_block_type,
34463445

34473446
auto parent_pb = pb;
34483447

3449-
// go down the hierarchy till the parent physical block of the ALM is found
3450-
while (parent_pb->child_pbs[0][0].pb_graph_node->pb_type != alm_pb_type) {
3448+
// go down the hierarchy till the parent physical block of the LE is found
3449+
while (parent_pb->child_pbs[0][0].pb_graph_node->pb_type != le_pb_type) {
34513450
parent_pb = &parent_pb->child_pbs[0][0];
34523451
}
34533452

3454-
// iterate over all the ALMs and update the ALM count accordingly
3455-
for (int ialm = 0; ialm < parent_pb->get_num_children_of_type(0); ialm++) {
3456-
if (!parent_pb->child_pbs[0][ialm].name)
3453+
// iterate over all the LEs and update the LE count accordingly
3454+
for (int ile = 0; ile < parent_pb->get_num_children_of_type(0); ile++) {
3455+
if (!parent_pb->child_pbs[0][ile].name)
34573456
continue;
34583457

3459-
auto has_used_lut = pb_used_for_blif_model(&parent_pb->child_pbs[0][ialm], lut);
3460-
auto has_used_adder = pb_used_for_blif_model(&parent_pb->child_pbs[0][ialm], adder);
3461-
auto has_used_ff = pb_used_for_blif_model(&parent_pb->child_pbs[0][ialm], ff);
3458+
auto has_used_lut = pb_used_for_blif_model(&parent_pb->child_pbs[0][ile], lut);
3459+
auto has_used_adder = pb_used_for_blif_model(&parent_pb->child_pbs[0][ile], adder);
3460+
auto has_used_ff = pb_used_for_blif_model(&parent_pb->child_pbs[0][ile], ff);
34623461

3463-
// First type of ALMs: used for logic and registers
3462+
// First type of LEs: used for logic and registers
34643463
if ((has_used_lut || has_used_adder) && has_used_ff) {
3465-
alm_count[0]++;
3466-
// Second type of ALMs: used for logic only
3464+
le_count[0]++;
3465+
// Second type of LEs: used for logic only
34673466
} else if (has_used_lut || has_used_adder) {
3468-
alm_count[1]++;
3469-
// Third type of ALMs: used for registers only
3467+
le_count[1]++;
3468+
// Third type of LEs: used for registers only
34703469
} else if (has_used_ff) {
3471-
alm_count[2]++;
3470+
le_count[2]++;
34723471
}
34733472
}
34743473
}
@@ -3505,12 +3504,12 @@ static bool pb_used_for_blif_model(const t_pb* pb, std::string blif_model_name)
35053504
}
35063505

35073506
/**
3508-
* Print the alm count data strurture
3507+
* Print the LE count data strurture
35093508
*/
3510-
static void print_alm_count(std::vector<int>& alm_count) {
3511-
VTR_LOG("\nALM count...\n");
3512-
VTR_LOG(" Total number of ALMs used : %d\n", alm_count[0] + alm_count[1] + alm_count[2]);
3513-
VTR_LOG(" ALMs used for logic and registers : %d\n", alm_count[0]);
3514-
VTR_LOG(" ALMs used for logic only : %d\n", alm_count[1]);
3515-
VTR_LOG(" ALMs used for registers only : %d\n\n", alm_count[2]);
3509+
static void print_le_count(std::vector<int>& le_count, const t_pb_type* le_pb_type) {
3510+
VTR_LOG("\nLogic Element (%s) detailed count:\n", le_pb_type->name);
3511+
VTR_LOG(" Total number of Logic Elements used : %d\n", le_count[0] + le_count[1] + le_count[2]);
3512+
VTR_LOG(" LEs used for logic and registers : %d\n", le_count[0]);
3513+
VTR_LOG(" LEs used for logic only : %d\n", le_count[1]);
3514+
VTR_LOG(" LEs used for registers only : %d\n\n", le_count[2]);
35163515
}

0 commit comments

Comments
 (0)