18 #define MAX_STRING_LEN 128
61 char * port_name,
int end_pin_index,
int start_pin_index,
char * src_string,
62 int line,
int ** idirect_from_blk_pin,
int ** direct_type_from_blk_pin);
68 int iport,
int ** idirect_from_blk_pin,
int idirect,
69 int ** direct_type_from_blk_pin,
int direct_type,
int line,
char * src_string);
78 for (i = 0; i < num_tab; i++) {
90 for (j = 0; j <= (L_ny + 1); ++j) {
91 for (i = 0; i <= (L_nx + 1); ++i) {
92 L_grid[i][j].usage = 0;
93 if (L_grid[i][j].type) {
95 if (NULL == L_grid[i][j].blocks) {
97 sizeof(
int) * L_grid[i][j].type->capacity);
100 for (k = 0; k < L_grid[i][j].type->capacity; ++k) {
101 L_grid[i][j].blocks[k] =
OPEN;
109 for (i = 0; i < L_num_blocks; ++i) {
114 vpr_printf(TIO_MESSAGE_ERROR,
"Block %d is at invalid location (%d, %d, %d).\n",
121 vpr_printf(TIO_MESSAGE_ERROR,
"A block is in a grid location (%d x %d) with a conflicting type.\n",
128 vpr_printf(TIO_MESSAGE_ERROR,
"Location (%d, %d, %d) is used more than once.\n",
133 if (L_grid[
block[i].x][
block[i].y].offset != 0) {
134 vpr_printf(TIO_MESSAGE_ERROR,
"Large block not aligned in placment for block %d at (%d, %d, %d).",
143 assert(L_grid[
block[i].x][
block[i].y + j].offset == j);
163 OUTP int *class_high) {
175 int max_size, temp_size;
176 if (pb_type->
modes == 0) {
181 for (i = 0; i < pb_type->
num_modes; i++) {
187 if (temp_size > max_size) {
188 max_size = temp_size;
198 int max_nets, temp_nets;
199 if (pb_type->
modes == 0) {
203 for (i = 0; i < pb_type->
num_modes; i++) {
210 if (temp_nets > max_nets) {
211 max_nets = temp_nets;
224 int max_depth, temp_depth;
225 max_depth = pb_type->
depth;
226 for (i = 0; i < pb_type->
num_modes; i++) {
230 if (temp_depth > max_depth) {
231 max_depth = temp_depth;
246 if (cur_pb_type == NULL) {
253 while (port || !second_pass) {
259 for (i = 0; i < cur_pb_type->
num_ports; i++) {
261 for (j = cur_pb_type->
ports[i].
num_pins; j < port->size; j++) {
311 return &pb_graph_node->
input_pins[i][model_pin];
321 return &pb_graph_node->
clock_pins[i][model_pin];
349 assert(ilogical_block !=
OPEN);
358 while(port != NULL) {
367 while(port != NULL) {
379 while(port != NULL) {
387 assert(port != NULL);
392 int iblock, target_pin;
409 pb_type = pb_graph_node->
pb_type;
415 if(ipin < pb_type->num_input_pins) {
424 }
else if (ipin < pb_type->num_input_pins + pb_type->
num_output_pins) {
453 return (primitive->pb_type->num_input_pins
454 + primitive->pb_type->num_output_pins
455 + primitive->pb_type->num_clock_pins);
464 int ext_inps, output_net, ipin, opin;
473 for (ipin = 0; ipin < port->
size; ipin++) {
479 for (opin = 0; opin < out_port->
size; opin++) {
482 if (output_net ==
OPEN)
495 out_port = out_port->
next;
502 assert(ext_inps >= 0);
517 for (i = 0; i < total_nodes; i++) {
591 while (revalid_molecule != NULL) {
606 revalid_molecule = revalid_molecule->
next;
657 int inet, netpin, blk, iblk, ipin, itype, **temp_net_pin_index, max_pins_per_clb = 0;
661 for (itype = 0; itype <
num_types; itype++)
666 max_pins_per_clb - 1,
sizeof(
int));
671 for (ipin = 0; ipin < type->
num_pins; ipin++) {
672 temp_net_pin_index[iblk][ipin] =
OPEN;
677 for (inet = 0; inet <
num_nets; inet++) {
687 return temp_net_pin_index;
746 for (itype = 1; itype <
num_types; itype++) {
755 for (itype = 1; itype <
num_types; itype++) {
772 int ** temp_port_from_blk_pin = NULL;
773 int ** temp_port_pin_from_blk_pin = NULL;
774 int itype, iblk_pin, iport, iport_pin;
775 int blk_pin_count, num_port_pins, num_ports;
780 for (itype = 1; itype <
num_types; itype++) {
784 temp_port_from_blk_pin[itype] = (
int *)
my_malloc(blk_pin_count*
sizeof(
int));
785 temp_port_pin_from_blk_pin[itype] = (
int *)
my_malloc(blk_pin_count*
sizeof(
int));
787 for (iblk_pin = 0; iblk_pin < blk_pin_count; iblk_pin++) {
788 temp_port_from_blk_pin[itype][iblk_pin] =
OPEN;
789 temp_port_pin_from_blk_pin[itype][iblk_pin] =
OPEN;
795 for (itype = 1; itype <
num_types; itype++) {
800 for (iport = 0; iport < num_ports; iport++) {
804 for (iport_pin = 0; iport_pin < num_port_pins; iport_pin++) {
806 temp_port_from_blk_pin[itype][blk_pin_count] = iport;
807 temp_port_pin_from_blk_pin[itype][blk_pin_count] = iport_pin;
847 int itype, iport, num_ports;
851 for (itype = 1; itype <
num_types; itype++) {
853 for (iport = 0; iport < num_ports; iport++) {
871 int *** temp_blk_pin_from_port_pin = NULL;
872 int itype, iport, iport_pin;
873 int blk_pin_count, num_port_pins, num_ports;
877 for (itype = 1; itype <
num_types; itype++) {
879 temp_blk_pin_from_port_pin[itype] = (
int **)
my_malloc(num_ports *
sizeof(
int*));
880 for (iport = 0; iport < num_ports; iport++) {
882 temp_blk_pin_from_port_pin[itype][iport] = (
int *)
my_malloc(num_port_pins *
sizeof(
int));
884 for(iport_pin = 0; iport_pin < num_port_pins; iport_pin ++) {
885 temp_blk_pin_from_port_pin[itype][iport][iport_pin] =
OPEN;
892 for (itype = 1; itype <
num_types; itype++) {
895 for (iport = 0; iport < num_ports; iport++) {
897 for (iport_pin = 0; iport_pin < num_port_pins; iport_pin++) {
898 temp_blk_pin_from_port_pin[itype][iport][iport_pin] = blk_pin_count;
926 int * end_pin_index,
char * pb_type_name,
char * port_name){
933 char * find_format = NULL;
934 int ichar, match_count;
937 find_format = strstr(src_string,
"[");
938 if (find_format == NULL) {
940 *start_pin_index = *end_pin_index = -1;
942 strcpy (source_string, src_string);
943 for (ichar = 0; ichar < (int)(strlen(source_string)); ichar++) {
944 if (source_string[ichar] ==
'.')
945 source_string[ichar] =
' ';
948 match_count = sscanf(source_string,
"%s %s", pb_type_name, port_name);
949 if (match_count != 2){
950 vpr_printf(TIO_MESSAGE_ERROR,
"[LINE %d] Invalid pin - %s, "
951 "name should be in the format \"pb_type_name\".\"port_name\" or "
952 "\"pb_type_name\".\"port_name [end_pin_index:start_pin_index]\". "
953 " The end_pin_index and start_pin_index can be the same.\n", line,
959 strcpy (source_string, src_string);
960 for (ichar = 0; ichar < (int)(strlen(source_string)); ichar++) {
961 if (source_string[ichar] ==
'.')
962 source_string[ichar] =
' ';
965 match_count = sscanf(source_string,
"%s %s [%d:%d]",
966 pb_type_name, port_name,
967 end_pin_index, start_pin_index);
968 if (match_count != 4){
969 vpr_printf(TIO_MESSAGE_ERROR,
"[LINE %d] Invalid pin - %s, "
970 "name should be in the format \"pb_type_name\".\"port_name\" or "
971 "\"pb_type_name\".\"port_name [end_pin_index:start_pin_index]\". "
972 " The end_pin_index and start_pin_index can be the same.\n", line,
976 if (*end_pin_index < 0 || *start_pin_index < 0) {
977 vpr_printf(TIO_MESSAGE_ERROR,
"[LINE %d] Invalid pin - %s, "
978 "the pin_index [end_pin_index:start_pin_index] should not "
979 "be a negative value.\n", line, src_string);
982 if ( *end_pin_index < *start_pin_index) {
983 vpr_printf(TIO_MESSAGE_ERROR,
"[LINE %d] Invalid from_pin - %s, "
984 "the end_pin_index in [end_pin_index:start_pin_index] should "
985 "not be less than start_pin_index.\n", line, src_string);
992 int iport,
int ** idirect_from_blk_pin,
int idirect,
993 int ** direct_type_from_blk_pin,
int direct_type,
int line,
char * src_string) {
999 int iport_pin, iblk_pin;
1002 for (iport_pin = start_pin_index; iport_pin <= end_pin_index; iport_pin++) {
1007 idirect_from_blk_pin[itype][iblk_pin] = idirect;
1010 if (direct_type_from_blk_pin[itype][iblk_pin] !=
OPEN) {
1011 vpr_printf(TIO_MESSAGE_ERROR,
"[LINE %d] Invalid pin - %s, "
1012 "this pin is in more than one direct connection.\n", line,
1016 direct_type_from_blk_pin[itype][iblk_pin] = direct_type;
1024 char * port_name,
int end_pin_index,
int start_pin_index,
char * src_string,
1025 int line,
int ** idirect_from_blk_pin,
int ** direct_type_from_blk_pin) {
1033 int num_ports, num_port_pins;
1037 for (itype = 1; itype <
num_types; itype++) {
1042 for (iport = 0; iport < num_ports; iport++) {
1048 if (end_pin_index > num_port_pins) {
1049 vpr_printf(TIO_MESSAGE_ERROR,
"[LINE %d] Invalid pin - %s, "
1050 "the end_pin_index in [end_pin_index:start_pin_index] should "
1051 "be less than the num_port_pins %d.\n", line,
1052 src_string, num_port_pins);
1057 if (start_pin_index >= 0 || end_pin_index >= 0) {
1059 iport, idirect_from_blk_pin, idirect,
1060 direct_type_from_blk_pin, direct_type, line, src_string);
1063 iport, idirect_from_blk_pin, idirect,
1064 direct_type_from_blk_pin, direct_type, line, src_string);
1074 int *** idirect_from_blk_pin,
int *** direct_type_from_blk_pin) {
1094 int itype, iblk_pin, idirect, num_type_pins;
1095 int ** temp_idirect_from_blk_pin, ** temp_direct_type_from_blk_pin;
1099 int to_start_pin_index = -1, to_end_pin_index = -1;
1100 int from_start_pin_index = -1, from_end_pin_index = -1;
1105 for (itype = 1; itype <
num_types; itype++) {
1109 temp_idirect_from_blk_pin[itype] = (
int *)
my_malloc(num_type_pins *
sizeof(
int));
1110 temp_direct_type_from_blk_pin[itype] = (
int *)
my_malloc(num_type_pins *
sizeof(
int));
1113 for (iblk_pin = 0; iblk_pin < num_type_pins; iblk_pin++) {
1114 temp_idirect_from_blk_pin[itype][iblk_pin] =
OPEN;
1115 temp_direct_type_from_blk_pin[itype][iblk_pin] =
OPEN;
1121 for (idirect = 0; idirect < num_directs; idirect++) {
1125 &from_end_pin_index, &from_start_pin_index, from_pb_type_name, from_port_name);
1129 &to_end_pin_index, &to_start_pin_index, to_pb_type_name, to_port_name);
1139 from_end_pin_index, from_start_pin_index, directs[idirect].from_pin,
1140 directs[idirect].line,
1141 temp_idirect_from_blk_pin, temp_direct_type_from_blk_pin);
1145 to_end_pin_index, to_start_pin_index, directs[idirect].to_pin,
1146 directs[idirect].line,
1147 temp_idirect_from_blk_pin, temp_direct_type_from_blk_pin);
1152 *idirect_from_blk_pin = temp_idirect_from_blk_pin;
1153 *direct_type_from_blk_pin = temp_direct_type_from_blk_pin;
int get_max_depth_of_pb_type(t_pb_type *pb_type)
std::map< int, float > sharinggain
t_pb_graph_pin * get_pb_graph_node_pin_from_model_port_pin(t_model_ports *model_port, int model_pin, t_pb_graph_node *pb_graph_node)
boolean primitive_type_feasible(int iblk, const t_pb_type *cur_pb_type)
static int *** f_blk_pin_from_port_pin
t_pb_graph_pin ** clock_pins
static void mark_direct_of_ports(int idirect, int direct_type, char *pb_type_name, char *port_name, int end_pin_index, int start_pin_index, char *src_string, int line, int **idirect_from_blk_pin, int **direct_type_from_blk_pin)
t_model_ports * model_port
void ** alloc_matrix(int nrmin, int nrmax, int ncmin, int ncmax, size_t elsize)
struct s_pb_type * pb_type_children
void free_port_pin_from_blk_pin(void)
void get_blk_pin_from_port_pin(int blk_type_index, int port, int port_pin, int *blk_pin)
boolean is_opin(int ipin, t_type_ptr type)
int get_max_nets_in_pb_type(const t_pb_type *pb_type)
void get_class_range_for_block(INP int iblk, OUTP int *class_low, OUTP int *class_high)
struct s_rr_node * rr_graph
t_pb_graph_pin * get_pb_graph_node_pin_from_clb_net(int inet, int ipin)
struct s_class * class_inf
struct s_pack_molecule ** feasible_blocks
void print_tabs(FILE *fpout, int num_tab)
void free_pb_stats(t_pb *pb)
int get_max_primitives_in_pb_type(t_pb_type *pb_type)
std::map< int, int > num_pins_of_net_in_pb
struct s_model_ports * next
void sync_grid_to_blocks(INP int L_num_blocks, INP const struct s_block block_list[], INP int L_nx, INP int L_ny, INOUTP struct s_grid_tile **L_grid)
struct s_linked_vptr * packed_molecules
t_pb_graph_pin ** output_pins
struct s_pb ** rr_node_to_pb_mapping
void get_port_pin_from_blk_pin(int blk_type_index, int blk_pin, int *port, int *port_pin)
float compute_primitive_base_cost(INP t_pb_graph_node *primitive)
std::map< int, float > hillgain
int ** lookahead_output_pins_used
static void * my_malloc(int ibytes)
int get_array_size_of_molecule(t_pack_molecule *molecule)
int ** alloc_and_load_net_pin_index()
struct s_net * local_nets
std::map< int, float > connectiongain
struct s_linked_vptr * next
void free_blk_pin_from_port_pin(void)
void parse_direct_pin_name(char *src_string, int line, int *start_pin_index, int *end_pin_index, char *pb_type_name, char *port_name)
std::map< int, float > gain
struct s_pb_type * pb_type
static void alloc_and_load_port_pin_from_blk_pin(void)
static void mark_direct_of_pins(int start_pin_index, int end_pin_index, int itype, int iport, int **idirect_from_blk_pin, int idirect, int **direct_type_from_blk_pin, int direct_type, int line, char *src_string)
static int ** f_port_from_blk_pin
struct s_pb_type * pb_type
std::map< int, float > timinggain
static void alloc_and_load_blk_pin_from_port_pin(void)
struct s_type_descriptor * type_descriptors
t_logical_block ** logical_block_ptrs
int ** lookahead_input_pins_used
struct s_pb_stats * pb_stats
int num_ext_inputs_logical_block(int iblk)
static int ** f_port_pin_from_blk_pin
void alloc_and_load_idirect_from_blk_pin(t_direct_inf *directs, int num_directs, int ***idirect_from_blk_pin, int ***direct_type_from_blk_pin)
t_pb_graph_node * pb_graph_node
t_pb_graph_pin * get_pb_graph_node_pin_from_block_pin(int iblock, int ipin)
t_pb_graph_pin ** input_pins
struct s_logical_block * logical_block
t_pb_graph_pin * get_pb_graph_node_pin_from_vpack_net(int inet, int ipin)