VPR-7.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
pack.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <assert.h>
3 #include <string.h>
4 #include "read_xml_arch_file.h"
5 #include "util.h"
6 #include "vpr_types.h"
7 #include "globals.h"
8 #include "prepack.h"
9 #include "pack.h"
10 #include "read_blif.h"
11 #include "cluster.h"
12 #include "output_clustering.h"
13 #include "ReadOptions.h"
14 
15 /* #define DUMP_PB_GRAPH 1 */
16 /* #define DUMP_BLIF_INPUT 1 */
17 
18 static boolean *alloc_and_load_is_clock(boolean global_clocks);
19 
20 void try_pack(INP struct s_packer_opts *packer_opts, INP const t_arch * arch,
21  INP t_model *user_models, INP t_model *library_models, t_timing_inf timing_inf, float interc_delay) {
22  boolean *is_clock;
23  int num_models;
24  t_model *cur_model;
25  t_pack_patterns *list_of_packing_patterns;
26  int num_packing_patterns;
27  t_pack_molecule *list_of_pack_molecules, * cur_pack_molecule;
28  int num_pack_molecules;
29 
30  vpr_printf(TIO_MESSAGE_INFO, "Begin packing '%s'.\n", packer_opts->blif_file_name);
31 
32  /* determine number of models in the architecture */
33  num_models = 0;
34  cur_model = user_models;
35  while (cur_model) {
36  num_models++;
37  cur_model = cur_model->next;
38  }
39  cur_model = library_models;
40  while (cur_model) {
41  num_models++;
42  cur_model = cur_model->next;
43  }
44 
45 
46  is_clock = alloc_and_load_is_clock(packer_opts->global_clocks);
47 
48  vpr_printf(TIO_MESSAGE_INFO, "\n");
49  vpr_printf(TIO_MESSAGE_INFO, "After removing unused inputs...\n");
50  vpr_printf(TIO_MESSAGE_INFO, "\ttotal blocks: %d, total nets: %d, total inputs: %d, total outputs: %d\n",
52 
53  vpr_printf(TIO_MESSAGE_INFO, "Begin prepacking.\n");
54  list_of_packing_patterns = alloc_and_load_pack_patterns(
55  &num_packing_patterns);
56  list_of_pack_molecules = alloc_and_load_pack_molecules(
57  list_of_packing_patterns, num_packing_patterns,
58  &num_pack_molecules);
59  vpr_printf(TIO_MESSAGE_INFO, "Finish prepacking.\n");
60 
61  if(packer_opts->auto_compute_inter_cluster_net_delay) {
62  packer_opts->inter_cluster_net_delay = interc_delay;
63  vpr_printf(TIO_MESSAGE_INFO, "Using inter-cluster delay: %g\n", packer_opts->inter_cluster_net_delay);
64  }
65 
66  /* Uncomment line below if you want a dump of compressed netlist. */
67  /* if (getEchoEnabled()){
68  echo_input (packer_opts->blif_file_name, packer_opts->lut_size, "packed.echo");
69  }else; */
70 
71  if (packer_opts->skip_clustering == FALSE) {
72  do_clustering(arch, list_of_pack_molecules, num_models,
73  packer_opts->global_clocks, is_clock,
74  packer_opts->hill_climbing_flag, packer_opts->output_file,
75  packer_opts->timing_driven, packer_opts->cluster_seed_type,
76  packer_opts->alpha, packer_opts->beta,
77  packer_opts->recompute_timing_after, packer_opts->block_delay,
78  packer_opts->intra_cluster_net_delay,
79  packer_opts->inter_cluster_net_delay, packer_opts->aspect,
80  packer_opts->allow_unrelated_clustering,
81  packer_opts->allow_early_exit, packer_opts->connection_driven,
82  packer_opts->packer_algorithm, timing_inf);
83  } else {
84  vpr_printf(TIO_MESSAGE_ERROR, "Skip clustering no longer supported.\n");
85  exit(1);
86  }
87 
88  free(is_clock);
89 
90  /*free list_of_pack_molecules*/
91  free_list_of_pack_patterns(list_of_packing_patterns, num_packing_patterns);
92 
93  cur_pack_molecule = list_of_pack_molecules;
94  while (cur_pack_molecule != NULL){
95  if (cur_pack_molecule->logical_block_ptrs != NULL)
96  free(cur_pack_molecule->logical_block_ptrs);
97  cur_pack_molecule = list_of_pack_molecules->next;
98  free(list_of_pack_molecules);
99  list_of_pack_molecules = cur_pack_molecule;
100  }
101 
102  vpr_printf(TIO_MESSAGE_INFO, "\n");
103  vpr_printf(TIO_MESSAGE_INFO, "Netlist conversion complete.\n");
104  vpr_printf(TIO_MESSAGE_INFO, "\n");
105 }
106 
107 float get_switch_info(short switch_index, float &Tdel_switch, float &R_switch, float &Cout_switch) {
108  /* Fetches delay, resistance and output capacitance of the switch at switch_index.
109  Returns the total delay through the switch. Used to calculate inter-cluster net delay. */
110 
111  Tdel_switch = switch_inf[switch_index].Tdel; /* Delay when unloaded */
112  R_switch = switch_inf[switch_index].R;
113  Cout_switch = switch_inf[switch_index].Cout;
114 
115  /* The delay through a loaded switch is its intrinsic (unloaded)
116  delay plus the product of its resistance and output capacitance. */
117  return Tdel_switch + R_switch * Cout_switch;
118 }
119 
120 boolean *alloc_and_load_is_clock(boolean global_clocks) {
121 
122  /* Looks through all the logical_block to find and mark all the clocks, by setting *
123  * the corresponding entry in is_clock to true. global_clocks is used *
124  * only for an error check. */
125 
126  int num_clocks, bnum, clock_net;
127  boolean * is_clock;
128 
129  num_clocks = 0;
130 
131  is_clock = (boolean *) my_calloc(num_logical_nets, sizeof(boolean));
132 
133  /* Want to identify all the clock nets. */
134 
135  for (bnum = 0; bnum < num_logical_blocks; bnum++) {
136  if (logical_block[bnum].type == VPACK_LATCH) {
137  clock_net = logical_block[bnum].clock_net;
138  assert(clock_net != OPEN);
139  if (is_clock[clock_net] == FALSE) {
140  is_clock[clock_net] = TRUE;
141  num_clocks++;
142  }
143  } else {
144  if (logical_block[bnum].clock_net != OPEN) {
145  clock_net = logical_block[bnum].clock_net;
146  if (is_clock[clock_net] == FALSE) {
147  is_clock[clock_net] = TRUE;
148  num_clocks++;
149  }
150  }
151  }
152  }
153 
154  /* If we have multiple clocks and we're supposed to declare them global, *
155  * print a warning message, since it looks like this circuit may have *
156  * locally generated clocks. */
157 
158  if (num_clocks > 1 && global_clocks) {
159  vpr_printf(TIO_MESSAGE_WARNING, "Circuit contains %d clocks. All clocks will be marked global.\n", num_clocks);
160  }
161 
162  return (is_clock);
163 }
164 
165 
int num_p_inputs
Definition: globals.c:18
float get_switch_info(short switch_index, float &Tdel_switch, float &R_switch, float &Cout_switch)
Definition: pack.c:107
void * my_calloc(size_t nelem, size_t size)
Definition: util.c:132
int num_logical_nets
Definition: globals.c:17
Definition: util.h:12
void free_list_of_pack_patterns(INP t_pack_patterns *list_of_pack_patterns, INP int num_packing_patterns)
Definition: prepack.c:319
struct s_model * next
Definition: logic_types.h:40
#define INP
Definition: util.h:19
int num_p_outputs
Definition: globals.c:18
struct s_switch_inf * switch_inf
Definition: globals.c:83
void do_clustering(const t_arch *arch, t_pack_molecule *molecule_head, int num_models, boolean global_clocks, boolean *is_clock, boolean hill_climbing_flag, char *out_fname, boolean timing_driven, enum e_cluster_seed cluster_seed_type, float alpha, float beta, int recompute_timing_after, float block_delay, float intra_cluster_net_delay, float inter_cluster_net_delay, float aspect, boolean allow_unrelated_clustering, boolean allow_early_exit, boolean connection_driven, enum e_packer_algorithm packer_algorithm, t_timing_inf timing_inf)
Definition: cluster.c:232
t_pack_patterns * alloc_and_load_pack_patterns(OUTP int *num_packing_patterns)
Definition: prepack.c:75
struct s_pack_molecule * next
Definition: vpr_types.h:257
t_pack_molecule * alloc_and_load_pack_molecules(INP t_pack_patterns *list_of_pack_patterns, INP int num_packing_patterns, OUTP int *num_pack_molecule)
Definition: prepack.c:756
static boolean * alloc_and_load_is_clock(boolean global_clocks)
Definition: pack.c:120
int num_logical_blocks
Definition: globals.c:17
Definition: slre.c:50
t_logical_block ** logical_block_ptrs
Definition: vpr_types.h:248
messagelogger vpr_printf
Definition: util.c:17
struct s_logical_block * logical_block
Definition: globals.c:20
Definition: util.h:12
void try_pack(INP struct s_packer_opts *packer_opts, INP const t_arch *arch, INP t_model *user_models, INP t_model *library_models, t_timing_inf timing_inf, float interc_delay)
Definition: pack.c:20