41 #define NET_USED_SOURCE_BLOCK 0
42 #define NET_USED_SINK_BLOCK 1
43 #define SOURCE_BLOCK 0
53 #define NUM_TYPES_USED 3
55 #define DEBUG_TIMING_PLACE_LOOKUP
57 #define DUMPFILE "lookup_dump.echo"
91 static FILE *lookup_dump;
105 struct s_block **original_block,
int *original_num_nets,
106 int *original_num_blocks);
109 struct s_block *original_block,
int original_num_nets,
110 int original_num_blocks);
118 INP int num_directs);
125 int source_y_loc,
int source_z_loc,
t_type_ptr sink_type,
126 int sink_x_loc,
int sink_y_loc,
int sink_z_loc);
129 int source_x_loc,
int source_y_loc,
t_type_ptr sink_type,
130 int sink_x_loc,
int sink_y_loc,
struct s_router_opts router_opts,
139 t_type_ptr sink_type,
int source_x,
int source_y,
int start_x,
140 int end_x,
int start_y,
int end_y,
struct s_router_opts router_opts,
171 static void print_array(
float **array_to_print,
203 for (i = 0; i < det_routing_arch.
num_segment; i++) {
204 if (segment_inf[i].length > length)
205 length = segment_inf[i].
length;
218 len = strlen(
"TEMP_NET");
242 int ix_b, ix_p, len, i;
253 len = strlen(
"TEMP_BLOCK");
259 for (ix_p = 1; ix_p < max_pins; ix_p++)
278 dummy_type_descriptors[0].
index = 0;
279 dummy_type_descriptors[1] = *
IO_TYPE;
280 dummy_type_descriptors[1].
index = 1;
282 dummy_type_descriptors[2].
index = 2;
285 IO_TYPE = &dummy_type_descriptors[1];
292 for (i = 0; i <
nx + 2; i++) {
293 for (j = 0; j <
ny + 2; j++) {
294 if ((i == 0 && j == 0) || (i == nx + 1 && j == 0)
295 || (i == 0 && j == ny + 1)
296 || (i == nx + 1 && j == ny + 1)) {
298 }
else if (i == 0 || i == nx + 1 || j == 0 || j == ny + 1) {
320 for (i = 0; i <
nx + 2; i++) {
321 for (j = 0; j <
ny + 2; j++) {
333 for (i = 0; i <=
nx + 1; i++) {
334 for (j = 0; j <=
ny + 1; j++) {
345 struct s_block **original_block,
int *original_num_nets,
346 int *original_num_blocks) {
354 *original_block =
block;
368 struct s_block *original_block,
int original_num_nets,
369 int original_num_blocks) {
379 free(
clb_net[i].node_block_pin);
389 block = original_block;
404 int width_fac, i, max_pins_per_clb;
406 max_pins_per_clb = 0;
412 width_fac = 4 * max_pins_per_clb;
425 INP int num_directs) {
482 if (clb_opins_used_locally != NULL) {
487 free(clb_opins_used_locally);
488 clb_opins_used_locally = NULL;
494 int source_y_loc,
int source_z_loc,
t_type_ptr sink_type,
495 int sink_x_loc,
int sink_y_loc,
int sink_z_loc) {
515 grid[source_x_loc][source_y_loc].
usage += 1;
522 int source_x_loc,
int source_y_loc,
t_type_ptr sink_type,
523 int sink_x_loc,
int sink_y_loc,
struct s_router_opts router_opts,
531 int source_z_loc, sink_z_loc;
540 sink_type, sink_x_loc, sink_y_loc, sink_z_loc);
556 grid[source_x_loc][source_y_loc].
usage = 0;
561 return (net_delay_value);
577 for (id_x = 0; id_x <=
nx; id_x++) {
578 for (id_y = 0; id_y <=
ny; id_y++) {
582 for (id_x = 0; id_x <=
nx - 1; id_x++) {
583 for (id_y = 0; id_y <=
ny - 1; id_y++) {
587 for (id_x = 0; id_x <=
nx; id_x++) {
588 for (id_y = 0; id_y <=
ny; id_y++) {
592 for (id_x = 0; id_x <=
nx + 1; id_x++) {
593 for (id_y = 0; id_y <=
ny + 1; id_y++) {
611 t_type_ptr sink_type,
int source_x,
int source_y,
int start_x,
612 int end_x,
int start_y,
int end_y,
struct s_router_opts router_opts,
616 int delta_x, delta_y;
619 for (sink_x = start_x; sink_x <= end_x; sink_x++) {
620 for (sink_y = start_y; sink_y <= end_y; sink_y++) {
621 delta_x = abs(sink_x - source_x);
622 delta_y = abs(sink_y - source_y);
624 if (delta_x == 0 && delta_y == 0)
629 source_type, source_x, source_y, sink_type, sink_x, sink_y,
630 router_opts, det_routing_arch, segment_inf, timing_inf);
648 int source_x, source_y, sink_x, sink_y;
649 int start_x, start_y, end_x, end_y;
650 int delta_x, delta_y;
656 if (longest_length < 0.5 * (
nx)) {
657 start_x = longest_length;
659 start_x = (int) (0.5 *
nx);
664 if (longest_length < 0.5 * (
ny)) {
665 start_y = longest_length;
667 start_y = (int) (0.5 *
ny);
673 for (sink_x = start_x; sink_x <= end_x - 1; sink_x++) {
674 for (sink_y = start_y; sink_y <= end_y - 1; sink_y++) {
675 delta_x = abs(sink_x - source_x);
676 delta_y = abs(sink_y - source_y);
678 if (delta_x == 0 && delta_y == 0) {
683 source_type, source_x, source_y, sink_type, sink_x, sink_y,
684 router_opts, det_routing_arch, segment_inf, timing_inf);
692 for (source_x = start_x - 1; source_x >= 1; source_x--) {
693 for (source_y = start_y; source_y <= end_y - 1; source_y++) {
694 delta_x = abs(sink_x - source_x);
695 delta_y = abs(sink_y - source_y);
698 source_type, source_x, source_y, sink_type, sink_x, sink_y,
699 router_opts, det_routing_arch, segment_inf, timing_inf);
703 for (source_x = 1; source_x <= end_x - 1; source_x++) {
704 for (source_y = 1; source_y < start_y; source_y++) {
705 delta_x = abs(sink_x - source_x);
706 delta_y = abs(sink_y - source_y);
709 source_type, source_x, source_y, sink_type, sink_x, sink_y,
710 router_opts, det_routing_arch, segment_inf, timing_inf);
718 for (source_y = 1; source_y <= end_y; source_y++) {
719 delta_x = abs(sink_x - source_x);
720 delta_y = abs(sink_y - source_y);
723 source_type, source_x, source_y, sink_type, sink_x, sink_y,
724 router_opts, det_routing_arch, segment_inf, timing_inf);
731 for (source_x = 1; source_x <= end_x; source_x++) {
732 delta_x = abs(sink_x - source_x);
733 delta_y = abs(sink_y - source_y);
736 source_type, source_x, source_y, sink_type, sink_x, sink_y,
737 router_opts, det_routing_arch, segment_inf, timing_inf);
745 int source_x, source_y;
746 int start_x, start_y, end_x, end_y;
763 source_y, start_x, end_x, start_y, end_y, router_opts,
764 det_routing_arch, segment_inf, timing_inf);
774 source_y, start_x, end_x, start_y, end_y, router_opts,
775 det_routing_arch, segment_inf, timing_inf);
782 source_y, start_x, end_x, start_y, end_y, router_opts,
783 det_routing_arch, segment_inf, timing_inf);
790 int source_x, source_y, sink_x, sink_y;
791 int delta_x, delta_y;
802 for (source_x = 1; source_x <=
nx; source_x++) {
803 for (source_y = 1; source_y <=
ny; source_y++) {
804 delta_x = abs(source_x - sink_x);
805 delta_y = abs(source_y - sink_y);
808 source_type, source_x, source_y, sink_type, sink_x, sink_y,
809 router_opts, det_routing_arch, segment_inf, timing_inf);
816 delta_x = abs(source_x - sink_x);
817 for (source_y = 1; source_y <=
ny; source_y++) {
818 delta_y = abs(source_y - sink_y);
820 source_type, source_x, source_y, sink_type, sink_x, sink_y,
821 router_opts, det_routing_arch, segment_inf, timing_inf);
827 delta_y = abs(source_y - sink_y);
828 for (source_x = 2; source_x <=
nx; source_x++) {
829 delta_x = abs(source_x - sink_x);
831 source_type, source_x, source_y, sink_type, sink_x, sink_y,
832 router_opts, det_routing_arch, segment_inf, timing_inf);
840 int source_x, source_y, sink_x, sink_y;
841 int delta_x, delta_y;
857 delta_x = abs(sink_x - source_x);
859 for (sink_y = 2; sink_y <=
ny; sink_y++) {
860 delta_y = abs(sink_y - source_y);
862 source_type, source_x, source_y, sink_type, sink_x, sink_y,
863 router_opts, det_routing_arch, segment_inf, timing_inf);
870 delta_x = abs(sink_x - source_x);
872 for (sink_y = 1; sink_y <=
ny; sink_y++) {
873 delta_y = abs(sink_y - source_y);
875 source_type, source_x, source_y, sink_type, sink_x, sink_y,
876 router_opts, det_routing_arch, segment_inf, timing_inf);
883 delta_y = abs(sink_y - source_y);
885 for (sink_x = 2; sink_x <=
nx; sink_x++) {
886 delta_x = abs(sink_x - source_x);
888 source_type, source_x, source_y, sink_type, sink_x, sink_y,
889 router_opts, det_routing_arch, segment_inf, timing_inf);
896 delta_y = abs(sink_y - source_y);
898 for (sink_x = 1; sink_x <=
nx; sink_x++) {
899 delta_x = abs(sink_x - source_x);
901 source_type, source_x, source_y, sink_type, sink_x, sink_y,
902 router_opts, det_routing_arch, segment_inf, timing_inf);
908 for (source_y = 1; source_y <=
ny; source_y++) {
909 for (sink_x = 1; sink_x <=
nx; sink_x++) {
910 delta_y = abs(source_y - sink_y);
911 delta_x = abs(source_x - sink_x);
913 source_type, source_x, source_y, sink_type, sink_x, sink_y,
914 router_opts, det_routing_arch, segment_inf, timing_inf);
923 print_array(
float **array_to_print,
932 fprintf(lookup_dump,
"\nPrinting Array \n\n");
934 for (idx_y = y2; idx_y >= y1; idx_y--)
936 for (idx_x = x1; idx_x <= x2; idx_x++)
938 fprintf(lookup_dump,
" %9.2e",
939 array_to_print[idx_x][idx_y]);
941 fprintf(lookup_dump,
"\n");
943 fprintf(lookup_dump,
"\n\n");
951 vpr_printf(TIO_MESSAGE_INFO,
"Computing delta_io_to_io lookup matrix, may take a few seconds, please wait...\n");
953 vpr_printf(TIO_MESSAGE_INFO,
"Computing delta_io_to_clb lookup matrix, may take a few seconds, please wait...\n");
955 vpr_printf(TIO_MESSAGE_INFO,
"Computing delta_clb_to_io lookup matrix, may take a few seconds, please wait...\n");
957 vpr_printf(TIO_MESSAGE_INFO,
"Computing delta_clb_to_clb lookup matrix, may take a few seconds, please wait...\n");
962 fprintf(lookup_dump,
"\n\nprinting delta_clb_to_clb\n");
964 fprintf(lookup_dump,
"\n\nprinting delta_io_to_clb\n");
966 fprintf(lookup_dump,
"\n\nprinting delta_clb_to_io\n");
968 fprintf(lookup_dump,
"\n\nprinting delta_io_to_io\n");
981 INP int num_directs) {
983 static struct s_net *original_net;
988 static struct s_block *original_block;
990 static int original_num_nets;
991 static int original_num_blocks;
992 static int longest_length;
997 &original_num_nets, &original_num_blocks);
1001 timing_inf, directs, num_directs);
1017 original_num_nets, original_num_blocks);
static int get_first_pin(enum e_pin_type pintype, t_type_ptr type)
static struct s_grid_tile ** grid_backup
static void load_simplified_device(void)
FILE * my_fopen(const char *fname, const char *flag, int prompt)
void free_timing_driven_route_structs(float *pin_criticality, int *sink_order, t_rt_node **rt_node_of_sink)
void ** alloc_matrix(int nrmin, int nrmax, int ncmin, int ncmax, size_t elsize)
static t_type_ptr EMPTY_TYPE_BACKUP
static void compute_delta_io_to_io(struct s_router_opts router_opts, struct s_det_routing_arch det_routing_arch, t_segment_inf *segment_inf, t_timing_inf timing_inf)
static void alloc_net(void)
struct s_class * class_inf
void free_matrix(void *vptr, int nrmin, int nrmax, int ncmin, size_t elsize)
static void alloc_block(void)
short global_route_switch
static void alloc_delta_arrays(void)
static void free_and_reset_internal_structures(struct s_net *original_net, struct s_block *original_block, int original_num_nets, int original_num_blocks)
static void assign_locations(t_type_ptr source_type, int source_x_loc, int source_y_loc, int source_z_loc, t_type_ptr sink_type, int sink_x_loc, int sink_y_loc, int sink_z_loc)
static float ** net_delay
enum e_graph_type t_graph_type
float ** delta_clb_to_clb
static t_type_ptr IO_TYPE_BACKUP
#define NET_USED_SOURCE_BLOCK
void free_trace_structs(void)
void free_place_lookup_structs(void)
static void free_routing_structs(struct s_router_opts router_opts, struct s_det_routing_arch det_routing_arch, t_segment_inf *segment_inf, t_timing_inf timing_inf)
static void compute_delta_clb_to_io(struct s_router_opts router_opts, struct s_det_routing_arch det_routing_arch, t_segment_inf *segment_inf, t_timing_inf timing_inf)
static t_type_descriptor * type_descriptors_backup
static void compute_delta_arrays(struct s_router_opts router_opts, struct s_det_routing_arch det_routing_arch, t_segment_inf *segment_inf, t_timing_inf timing_inf, int longest_length)
void load_net_rr_terminals(t_ivec ***L_rr_node_indices)
static void setup_chan_width(struct s_router_opts router_opts, t_chan_width_dist chan_width_dist)
static void reset_placement(void)
static t_ivec ** clb_opins_used_locally
static t_type_ptr FILL_TYPE_BACKUP
static void * my_malloc(int ibytes)
void alloc_and_load_rr_node_route_structs(void)
void init_route_structs(int bb_factor)
enum e_directionality directionality
void build_rr_graph(INP t_graph_type graph_type, INP int L_num_types, INP t_type_ptr types, INP int L_nx, INP int L_ny, INP struct s_grid_tile **L_grid, INP int chan_width, INP struct s_chan_width_dist *chan_capacity_inf, INP enum e_switch_block_type sb_type, INP int Fs, INP int num_seg_types, INP int num_switches, INP t_segment_inf *segment_inf, INP int global_route_switch, INP int delayless_switch, INP t_timing_inf timing_inf, INP int wire_to_ipin_switch, INP enum e_base_cost_type base_cost_type, INP t_direct_inf *directs, INP int num_directs, INP boolean ignore_Fc_0, OUTP int *Warnings)
static float * pin_criticality
void init_chan(int cfactor, t_chan_width_dist chan_width_dist)
void free_ivec_vector(struct s_ivec *ivec_vector, int nrmin, int nrmax)
t_ivec ** alloc_route_structs(void)
void alloc_timing_driven_route_structs(float **pin_criticality_ptr, int **sink_order_ptr, t_rt_node ***rt_node_of_sink_ptr)
enum e_route_type route_type
struct s_grid_tile ** grid
void compute_delay_lookup_tables(struct s_router_opts router_opts, struct s_det_routing_arch det_routing_arch, t_segment_inf *segment_inf, t_timing_inf timing_inf, t_chan_width_dist chan_width_dist, INP t_direct_inf *directs, INP int num_directs)
static int get_longest_segment_length(struct s_det_routing_arch det_routing_arch, t_segment_inf *segment_inf)
static void restore_original_device(void)
t_ivec *** rr_node_indices
boolean timing_driven_route_net(int inet, float pres_fac, float max_criticality, float criticality_exp, float astar_fac, float bend_cost, float *pin_criticality, int *sink_order, t_rt_node **rt_node_of_sink, float *net_delay, t_slack *slacks)
static int num_types_backup
enum e_switch_block_type switch_block_type
#define NO_FIXED_CHANNEL_WIDTH
static t_type_descriptor dummy_type_descriptors[NUM_TYPES_USED]
static void alloc_routing_structs(struct s_router_opts router_opts, struct s_det_routing_arch det_routing_arch, t_segment_inf *segment_inf, t_timing_inf timing_inf, INP t_direct_inf *directs, INP int num_directs)
void free_rr_node_route_structs(void)
struct s_type_descriptor * type_descriptors
static t_rt_node ** rt_node_of_sink
static void compute_delta_clb_to_clb(struct s_router_opts router_opts, struct s_det_routing_arch det_routing_arch, t_segment_inf *segment_inf, t_timing_inf timing_inf, int longest_length)
#define NET_USED_SINK_BLOCK
void free_route_structs()
static float assign_blocks_and_route_net(t_type_ptr source_type, int source_x_loc, int source_y_loc, t_type_ptr sink_type, int sink_x_loc, int sink_y_loc, struct s_router_opts router_opts, struct s_det_routing_arch det_routing_arch, t_segment_inf *segment_inf, t_timing_inf timing_inf)
short wire_to_ipin_switch
enum e_base_cost_type base_cost_type
static void alloc_and_assign_internal_structures(struct s_net **original_net, struct s_block **original_block, int *original_num_nets, int *original_num_blocks)
static void free_delta_arrays(void)
static void generic_compute_matrix(float ***matrix_ptr, t_type_ptr source_type, t_type_ptr sink_type, int source_x, int source_y, int start_x, int end_x, int start_y, int end_y, struct s_router_opts router_opts, struct s_det_routing_arch det_routing_arch, t_segment_inf *segment_inf, t_timing_inf timing_inf)
static void compute_delta_io_to_clb(struct s_router_opts router_opts, struct s_det_routing_arch det_routing_arch, t_segment_inf *segment_inf, t_timing_inf timing_inf)