Skip to content

Commit 1681fa1

Browse files
made a few function operating on t_pb_type its member functions
1 parent 2c47c52 commit 1681fa1

File tree

4 files changed

+69
-64
lines changed

4 files changed

+69
-64
lines changed

libs/libarchfpga/src/physical_types.cpp

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,71 @@ const t_port* t_logical_block_type::get_port_by_pin(int pin) const {
252252
return nullptr;
253253
}
254254

255-
/**
255+
/*
256+
* t_pb_type
257+
*/
258+
259+
int t_pb_type::get_max_primitives() const {
260+
int max_size;
261+
262+
if (modes == nullptr) {
263+
max_size = 1;
264+
} else {
265+
max_size = 0;
266+
int temp_size = 0;
267+
for (int i = 0; i < num_modes; i++) {
268+
for (int j = 0; j < modes[i].num_pb_type_children; j++) {
269+
temp_size += modes[i].pb_type_children[j].num_pb * modes[i].pb_type_children[j].get_max_primitives();
270+
}
271+
if (temp_size > max_size) {
272+
max_size = temp_size;
273+
}
274+
}
275+
}
276+
277+
return max_size;
278+
}
279+
280+
/* finds maximum number of nets that can be contained in pb_type, this is bounded by the number of driving pins */
281+
int t_pb_type::get_max_nets() const {
282+
int max_nets;
283+
if (modes == nullptr) {
284+
max_nets = num_output_pins;
285+
} else {
286+
max_nets = 0;
287+
288+
for (int i = 0; i < num_modes; i++) {
289+
int temp_nets = 0;
290+
for (int j = 0; j < modes[i].num_pb_type_children; j++) {
291+
temp_nets += modes[i].pb_type_children[j].num_pb * modes[i].pb_type_children[j].get_max_nets();
292+
}
293+
294+
if (temp_nets > max_nets) {
295+
max_nets = temp_nets;
296+
}
297+
}
298+
}
299+
300+
if (is_root()) {
301+
max_nets += num_input_pins + num_output_pins + num_clock_pins;
302+
}
303+
304+
return max_nets;
305+
}
306+
307+
int t_pb_type::get_max_depth() const {
308+
int max_depth = depth;
309+
310+
for (int i = 0; i < num_modes; i++) {
311+
for (int j = 0; j < modes[i].num_pb_type_children; j++) {
312+
int temp_depth = modes[i].pb_type_children[j].get_max_depth();
313+
max_depth = std::max(max_depth, temp_depth);
314+
}
315+
}
316+
return max_depth;
317+
}
318+
319+
/*
256320
* t_pb_graph_node
257321
*/
258322

libs/libarchfpga/src/physical_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,10 @@ struct t_pb_type {
10921092
inline bool is_primitive() const {
10931093
return num_modes == 0;
10941094
}
1095+
1096+
int get_max_primitives() const;
1097+
int get_max_depth() const;
1098+
int get_max_nets() const;
10951099
};
10961100

10971101
/** Describes an operational mode of a clustered logic block

vpr/src/util/vpr_utils.cpp

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -729,66 +729,6 @@ static bool pb_type_contains_blif_model(const t_pb_type* pb_type, const std::reg
729729
return false;
730730
}
731731

732-
int get_max_primitives_in_pb_type(t_pb_type* pb_type) {
733-
int max_size;
734-
if (pb_type->modes == nullptr) {
735-
max_size = 1;
736-
} else {
737-
max_size = 0;
738-
int temp_size = 0;
739-
for (int i = 0; i < pb_type->num_modes; i++) {
740-
for (int j = 0; j < pb_type->modes[i].num_pb_type_children; j++) {
741-
temp_size += pb_type->modes[i].pb_type_children[j].num_pb
742-
* get_max_primitives_in_pb_type(
743-
&pb_type->modes[i].pb_type_children[j]);
744-
}
745-
if (temp_size > max_size) {
746-
max_size = temp_size;
747-
}
748-
}
749-
}
750-
return max_size;
751-
}
752-
753-
/* finds maximum number of nets that can be contained in pb_type, this is bounded by the number of driving pins */
754-
int get_max_nets_in_pb_type(const t_pb_type* pb_type) {
755-
int max_nets;
756-
if (pb_type->modes == nullptr) {
757-
max_nets = pb_type->num_output_pins;
758-
} else {
759-
max_nets = 0;
760-
for (int i = 0; i < pb_type->num_modes; i++) {
761-
int temp_nets = 0;
762-
for (int j = 0; j < pb_type->modes[i].num_pb_type_children; j++) {
763-
temp_nets += pb_type->modes[i].pb_type_children[j].num_pb
764-
* get_max_nets_in_pb_type(
765-
&pb_type->modes[i].pb_type_children[j]);
766-
}
767-
if (temp_nets > max_nets) {
768-
max_nets = temp_nets;
769-
}
770-
}
771-
}
772-
if (pb_type->is_root()) {
773-
max_nets += pb_type->num_input_pins + pb_type->num_output_pins
774-
+ pb_type->num_clock_pins;
775-
}
776-
return max_nets;
777-
}
778-
779-
int get_max_depth_of_pb_type(t_pb_type* pb_type) {
780-
int max_depth = pb_type->depth;
781-
for (int i = 0; i < pb_type->num_modes; i++) {
782-
for (int j = 0; j < pb_type->modes[i].num_pb_type_children; j++) {
783-
int temp_depth = get_max_depth_of_pb_type(&pb_type->modes[i].pb_type_children[j]);
784-
if (temp_depth > max_depth) {
785-
max_depth = temp_depth;
786-
}
787-
}
788-
}
789-
return max_depth;
790-
}
791-
792732
/**
793733
* given an atom block and physical primitive type, is the mapping legal
794734
*/

vpr/src/util/vpr_utils.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@ InstPort parse_inst_port(const std::string& str);
180180
//Returns the block type which is most likely the logic block
181181
t_logical_block_type_ptr infer_logic_block_type(const DeviceGrid& grid);
182182

183-
int get_max_primitives_in_pb_type(t_pb_type* pb_type);
184-
int get_max_depth_of_pb_type(t_pb_type* pb_type);
185-
int get_max_nets_in_pb_type(const t_pb_type* pb_type);
186183
bool primitive_type_feasible(AtomBlockId blk_id, const t_pb_type* cur_pb_type);
187184
t_pb_graph_pin* get_pb_graph_node_pin_from_model_port_pin(const t_model_ports* model_port, const int model_pin, const t_pb_graph_node* pb_graph_node);
188185
/// @brief Gets the pb_graph_node pin at the given pin index for the given

0 commit comments

Comments
 (0)