36 INP float incremental_cost,
INP boolean valid);
69 &cluster_placement_stats_list[i],
73 return cluster_placement_stats_list;
93 float cost, lowest_cost;
97 if (cluster_placement_stats->curr_molecule != molecule) {
101 cluster_placement_stats->curr_molecule = molecule;
104 if (cluster_placement_stats->in_flight != NULL) {
108 cur = cluster_placement_stats->in_flight;
111 cluster_placement_stats->tried = cur;
113 assert(next == NULL);
114 cluster_placement_stats->in_flight = NULL;
125 for (i = 0; i < cluster_placement_stats->num_pb_types; i++) {
126 if (cluster_placement_stats->valid_primitives[i]->next_primitive == NULL) {
130 molecule->logical_block_ptrs[molecule->root]->index,
131 cluster_placement_stats->valid_primitives[i]->next_primitive->pb_graph_node->pb_type)) {
132 prev = cluster_placement_stats->valid_primitives[i];
133 cur = cluster_placement_stats->valid_primitives[i]->
next_primitive;
139 cluster_placement_stats->invalid = cur;
147 primitives_list, clb_index);
148 if (cost < lowest_cost) {
160 for (i = 0; i < molecule->num_blocks; i++) {
161 primitives_list[i] = NULL;
166 assert(cost == lowest_cost);
169 cluster_placement_stats->in_flight = best;
190 cur = cluster_placement_stats->invalid;
191 while (cur != NULL) {
196 cur = cluster_placement_stats->invalid = NULL;
198 for (i = 0; i < cluster_placement_stats->num_pb_types; i++) {
200 cluster_placement_stats->valid_primitives[i] != NULL && cluster_placement_stats->valid_primitives[i]->next_primitive != NULL);
201 cur = cluster_placement_stats->valid_primitives[i]->
next_primitive;
202 while (cur != NULL) {
208 cluster_placement_stats->curr_molecule = NULL;
219 cur = cluster_placement_stats_list[i].tried;
220 while (cur != NULL) {
225 cur = cluster_placement_stats_list[i].in_flight;
226 while (cur != NULL) {
231 cur = cluster_placement_stats_list[i].invalid;
232 while (cur != NULL) {
237 for (j = 0; j < cluster_placement_stats_list[i].num_pb_types; j++) {
239 cluster_placement_stats_list[i].valid_primitives[j]->
next_primitive;
240 while (cur != NULL) {
245 free(cluster_placement_stats_list[i].valid_primitives[j]);
247 free(cluster_placement_stats_list[i].valid_primitives);
249 free(cluster_placement_stats_list);
265 for (i = 0; i < cluster_placement_stats->num_pb_types; i++) {
266 if (cluster_placement_stats->valid_primitives[i]->next_primitive == NULL) {
271 == cluster_placement_stats->valid_primitives[i]->next_primitive->pb_graph_node->pb_type) {
276 cluster_placement_primitive;
279 if (success ==
FALSE) {
280 assert(null_index !=
OPEN);
282 cluster_placement_stats->valid_primitives[null_index]->
next_primitive;
283 cluster_placement_stats->valid_primitives[null_index]->
next_primitive =
284 cluster_placement_primitive;
297 const t_pb_type *pb_type = pb_graph_node->pb_type;
299 if (pb_type->
modes == 0) {
304 pb_graph_node->cluster_placement_primitive = placement_primitive;
309 while (success ==
FALSE) {
310 if (cluster_placement_stats->valid_primitives[i] == NULL
311 || cluster_placement_stats->valid_primitives[i]->next_primitive->pb_graph_node->pb_type
312 == pb_graph_node->pb_type) {
313 if (cluster_placement_stats->valid_primitives[i] == NULL) {
316 cluster_placement_stats->num_pb_types++;
327 for (i = 0; i < pb_type->
num_modes; i++) {
332 cluster_placement_stats,
333 &pb_graph_node->child_pb_graph_nodes[i][j][k]);
359 cur = primitive->cluster_placement_primitive;
368 skip = pb_graph_node;
382 incr_cost, (
boolean)(i == valid_mode));
397 for (i = 0; i < pb_graph_node->pb_type->num_modes; i++) {
400 j < pb_graph_node->pb_type->modes[i].num_pb_type_children;
404 < pb_graph_node->pb_type->modes[i].pb_type_children[j].num_pb;
407 &pb_graph_node->child_pb_graph_nodes[i][j][k], 0,
421 INP float incremental_cost,
INP boolean valid) {
424 if (pb_graph_node->pb_type->num_modes == 0) {
426 placement_primitive =
434 for (i = 0; i < pb_graph_node->pb_type->num_modes; i++) {
436 j < pb_graph_node->pb_type->modes[i].num_pb_type_children;
440 < pb_graph_node->pb_type->modes[i].pb_type_children[j].num_pb;
443 &pb_graph_node->child_pb_graph_nodes[i][j][k],
444 incremental_cost, valid);
461 molecule->logical_block_ptrs[molecule->root]->index,
463 if (root->cluster_placement_primitive->valid ==
TRUE) {
465 for (i = 0; i < list_size; i++) {
466 primitives_list[i] = NULL;
468 cost = root->cluster_placement_primitive->base_cost
469 + root->cluster_placement_primitive->incremental_cost;
470 primitives_list[molecule->root] = root;
473 molecule->pack_pattern->root_block, primitives_list,
478 for (i = 0; i < list_size; i++) {
480 (primitives_list[i] == NULL) == (molecule->logical_block_ptrs[i] == NULL));
497 primitives_list[pack_pattern_block->block_id];
500 int from_pin, from_port;
504 cur = pack_pattern_block->connections;
511 if (primitives_list[next_block->
block_id] == NULL && molecule->logical_block_ptrs[next_block->
block_id] != NULL) {
519 cur_pin = &pb_graph_node->
output_pins[from_port][from_pin];
521 pack_pattern_block->pattern_index, cur_pin,
TRUE);
524 assert(cur->
to_block == pack_pattern_block);
526 cur_pin = &pb_graph_node->
clock_pins[from_port][from_pin];
528 cur_pin = &pb_graph_node->
input_pins[from_port][from_pin];
531 pack_pattern_block->pattern_index, cur_pin,
FALSE);
534 if (next_pin != NULL) {
537 if (molecule->logical_block_ptrs[next_block->
block_id] != NULL
538 && primitives_list[next_block->
block_id] == NULL) {
542 molecule->logical_block_ptrs[next_block->
block_id]->index,
544 primitives_list[next_block->
block_id] = next_primitive;
549 next_block, primitives_list, cost)) {
576 for (i = 0; i < cur_pin->num_output_edges; i++) {
578 if (cur_pin->output_edges[i]->infer_pattern) {
579 for (k = 0; k < cur_pin->output_edges[i]->num_output_pins;
581 if (cur_pin->output_edges[i]->output_pins[k]->parent_node->pb_type->num_modes
586 cur_pin->output_edges[i]->output_pins[k],
590 if (temp_pin != NULL) {
591 assert(dest_pin == NULL || dest_pin == temp_pin);
595 for (j = 0; j < cur_pin->output_edges[i]->num_pack_patterns;
597 if (cur_pin->output_edges[i]->pack_pattern_indices[j]
600 k < cur_pin->output_edges[i]->num_output_pins;
602 if (cur_pin->output_edges[i]->output_pins[k]->parent_node->pb_type->num_modes
610 cur_pin->output_edges[i]->output_pins[k],
614 if (temp_pin != NULL) {
615 assert(dest_pin == NULL || dest_pin == temp_pin);
623 for (i = 0; i < cur_pin->num_input_edges; i++) {
625 if (cur_pin->input_edges[i]->infer_pattern) {
626 for (k = 0; k < cur_pin->input_edges[i]->num_input_pins; k++) {
627 if (cur_pin->input_edges[i]->input_pins[k]->parent_node->pb_type->num_modes
632 cur_pin->input_edges[i]->input_pins[k],
636 if (temp_pin != NULL) {
637 assert(dest_pin == NULL || dest_pin == temp_pin);
641 for (j = 0; j < cur_pin->input_edges[i]->num_pack_patterns;
643 if (cur_pin->input_edges[i]->pack_pattern_indices[j]
645 for (k = 0; k < cur_pin->input_edges[i]->num_input_pins;
647 if (cur_pin->input_edges[i]->input_pins[k]->parent_node->pb_type->num_modes
654 cur_pin->input_edges[i]->input_pins[k],
658 if (temp_pin != NULL) {
659 assert(dest_pin == NULL || dest_pin == temp_pin);
673 cur = cluster_placement_stats->tried;
674 while (cur != NULL) {
679 cluster_placement_stats->tried = NULL;
681 cur = cluster_placement_stats->in_flight;
686 assert(next == NULL);
688 cluster_placement_stats->in_flight = NULL;
703 INP int ilogical_block) {
708 if (cluster_placement_stats->in_flight) {
710 cluster_placement_stats->in_flight->pb_graph_node->pb_type)) {
716 for (i = 0; i < cluster_placement_stats->num_pb_types; i++) {
717 if (cluster_placement_stats->valid_primitives[i]->next_primitive == NULL) {
721 cluster_placement_stats->valid_primitives[i]->next_primitive->pb_graph_node->pb_type)) {
722 prev = cluster_placement_stats->valid_primitives[i];
723 cur = cluster_placement_stats->valid_primitives[i]->
next_primitive;
729 cluster_placement_stats->invalid = cur;
770 root_block = molecule->logical_block_ptrs[molecule->root];
771 for(i = 0; feasible && i < root->num_output_ports; i++) {
772 for(j = 0; feasible && j < root->num_output_pins[i]; j++) {
773 if(root->output_pins[i][j].is_forced_connection) {
774 model_port = root->output_pins[i][j].port->model_port;
783 sink_pb_graph_pin = &root->output_pins[i][j];
static boolean expand_forced_pack_molecule_placement(INP t_pack_molecule *molecule, INP t_pack_pattern_block *pack_pattern_block, INOUTP t_pb_graph_node **primitives_list, INOUTP float *cost)
void set_mode_cluster_placement_stats(INP t_pb_graph_node *pb_graph_node, int mode)
boolean primitive_type_feasible(int iblk, const t_pb_type *cur_pb_type)
t_pb_graph_pin ** clock_pins
struct s_pb_type * pb_type_children
struct s_pb_graph_node * parent_pb_graph_node
t_pb_graph_pin ** output_pins
t_pack_pattern_block * from_block
struct s_pb_graph_edge ** output_edges
int get_max_primitives_in_pb_type(t_pb_type *pb_type)
void free_cluster_placement_stats(INOUTP t_cluster_placement_stats *cluster_placement_stats_list)
void * my_calloc(size_t nelem, size_t size)
static void update_primitive_cost_or_status(INP t_pb_graph_node *pb_graph_node, INP float incremental_cost, INP boolean valid)
void commit_primitive(INOUTP t_cluster_placement_stats *cluster_placement_stats, INP t_pb_graph_node *primitive)
t_pb_graph_pin ** output_pins
t_pack_pattern_block * to_block
t_cluster_placement_stats * alloc_and_load_cluster_placement_stats(void)
static t_pb_graph_pin * expand_pack_molecule_pin_edge(INP int pattern_id, INP t_pb_graph_pin *cur_pin, INP boolean forward)
t_pack_molecule * curr_molecule
static float try_place_molecule(INP t_pack_molecule *molecule, INP t_pb_graph_node *root, INOUTP t_pb_graph_node **primitives_list, INP int clb_index)
struct s_cluster_placement_primitive * cluster_placement_primitive
t_pack_patterns * pack_pattern
struct s_cluster_placement_primitive * next_primitive
static void flush_intermediate_queues(INOUTP t_cluster_placement_stats *cluster_placement_stats)
struct s_pb_graph_edge ** input_edges
float compute_primitive_base_cost(INP t_pb_graph_node *primitive)
static boolean root_passes_early_filter(INP t_pb_graph_node *root, INP t_pack_molecule *molecule, INP int clb_index)
#define HUGE_POSITIVE_FLOAT
int get_array_size_of_molecule(t_pack_molecule *molecule)
t_pb_graph_pin * from_pin
void reset_cluster_placement_stats(INOUTP t_cluster_placement_stats *cluster_placement_stats)
struct s_pb_graph_node * parent_node
void reset_tried_but_unused_cluster_placements(INOUTP t_cluster_placement_stats *cluster_placement_stats)
struct s_pack_pattern_connections * next
boolean exists_free_primitive_for_logical_block(INOUTP t_cluster_placement_stats *cluster_placement_stats, INP int ilogical_block)
struct s_pb_graph_node *** child_pb_graph_nodes
struct s_pb_type * pb_type
t_pb_graph_pin ** input_pins
t_cluster_placement_primitive ** valid_primitives
t_pb_graph_node * pb_graph_node
enum e_pack_pattern_molecule_type type
struct s_type_descriptor * type_descriptors
t_pb_graph_node * pb_graph_node
static void requeue_primitive(INOUTP t_cluster_placement_stats *cluster_placement_stats, t_cluster_placement_primitive *cluster_placement_primitive)
boolean get_next_primitive_list(INOUTP t_cluster_placement_stats *cluster_placement_stats, INP t_pack_molecule *molecule, INOUTP t_pb_graph_node **primitives_list, INP int clb_index)
static void load_cluster_placement_stats_for_pb_graph_node(INOUTP t_cluster_placement_stats *cluster_placement_stats, INOUTP t_pb_graph_node *pb_graph_node)
t_pb_graph_pin ** input_pins
struct s_logical_block * logical_block