VPR-7.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
pb_type_graph_annotations.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include "util.h"
#include "arch_types.h"
#include "vpr_types.h"
#include "globals.h"
#include "vpr_utils.h"
#include "pb_type_graph.h"
#include "token.h"
#include "pb_type_graph_annotations.h"
+ Include dependency graph for pb_type_graph_annotations.c:

Go to the source code of this file.

Functions

static void load_pack_pattern_annotations (INP int line_num, INOUTP t_pb_graph_node *pb_graph_node, INP int mode, INP char *annot_in_pins, INP char *annot_out_pins, INP char *value)
 
static void load_critical_path_annotations (INP int line_num, INOUTP t_pb_graph_node *pb_graph_node, INP int mode, INP enum e_pin_to_pin_annotation_format input_format, INP enum e_pin_to_pin_delay_annotations delay_type, INP char *annot_in_pins, INP char *annot_out_pins, INP char *value)
 
void load_pb_graph_pin_to_pin_annotations (INOUTP t_pb_graph_node *pb_graph_node)
 

Function Documentation

static void load_critical_path_annotations ( INP int  line_num,
INOUTP t_pb_graph_node pb_graph_node,
INP int  mode,
INP enum e_pin_to_pin_annotation_format  input_format,
INP enum e_pin_to_pin_delay_annotations  delay_type,
INP char *  annot_in_pins,
INP char *  annot_out_pins,
INP char *  value 
)
static

Definition at line 186 of file pb_type_graph_annotations.c.

190  {
191 
192  int i, j, k, m, n, p, iedge;
193  t_pb_graph_pin ***in_port, ***out_port;
194  int *num_in_ptrs, *num_out_ptrs, num_in_sets, num_out_sets;
195  float **delay_matrix;
196  t_pb_graph_node **children = NULL;
197 
198  int count, prior_offset;
199  int num_inputs, num_outputs;
200 
201  in_port = out_port = NULL;
202  num_out_sets = num_in_sets = 0;
203  num_out_ptrs = num_in_ptrs = NULL;
204 
205  /* Primarily 3 kinds of delays that affect critical path:
206  1. Intrablock interconnect delays
207  2. Combinational primitives (pin-to-pin delays of primitive)
208  3. Sequential primitives (setup and clock-to-q times)
209 
210  Note: Proper I/O modelling requires knowledge of the extra-chip world (eg. the load that pin is driving, drive strength, etc)
211  For now, I/O delays are modelled as a constant in the architecture file by setting the pad-I/O block interconnect delay to be a constant I/O delay
212 
213  Algorithm: Intrablock and combinational primitive delays apply to edges
214  Sequential delays apply to pins
215  1. Determine if delay applies to pin or edge
216  2. Format the delay information
217  3. Load delay information
218  */
219 
220  /* Determine what pins to read based on delay type */
221  num_inputs = num_outputs = 0;
222  if (mode == OPEN) {
223  children = NULL;
224  } else {
225  children = pb_graph_node->child_pb_graph_nodes[mode];
226  }
227  if (delay_type == E_ANNOT_PIN_TO_PIN_DELAY_TSETUP) {
228  assert(pb_graph_node->pb_type->blif_model != NULL);
229  in_port = alloc_and_load_port_pin_ptrs_from_string(line_num, pb_graph_node,
230  children, annot_in_pins, &num_in_ptrs, &num_in_sets, FALSE,
231  FALSE);
232  } else if (delay_type == E_ANNOT_PIN_TO_PIN_DELAY_CLOCK_TO_Q_MAX) {
233  assert(pb_graph_node->pb_type->blif_model != NULL);
234  in_port = alloc_and_load_port_pin_ptrs_from_string(line_num, pb_graph_node,
235  children, annot_in_pins, &num_in_ptrs, &num_in_sets, FALSE,
236  FALSE);
237  } else {
238  assert(delay_type == E_ANNOT_PIN_TO_PIN_DELAY_MAX);
239  in_port = alloc_and_load_port_pin_ptrs_from_string(line_num, pb_graph_node,
240  children, annot_in_pins, &num_in_ptrs, &num_in_sets, FALSE,
241  FALSE);
242  out_port = alloc_and_load_port_pin_ptrs_from_string(line_num, pb_graph_node,
243  children, annot_out_pins, &num_out_ptrs, &num_out_sets, FALSE,
244  FALSE);
245  }
246 
247  num_inputs = 0;
248  for (i = 0; i < num_in_sets; i++) {
249  num_inputs += num_in_ptrs[i];
250  }
251 
252  if (out_port != NULL) {
253  num_outputs = 0;
254  for (i = 0; i < num_out_sets; i++) {
255  num_outputs += num_out_ptrs[i];
256  }
257  } else {
258  num_outputs = 1;
259  }
260 
261  delay_matrix = (float**)my_malloc(sizeof(float*) * num_inputs);
262  for (i = 0; i < num_inputs; i++) {
263  delay_matrix[i] = (float*)my_malloc(sizeof(float) * num_outputs);
264  }
265 
266  if (input_format == E_ANNOT_PIN_TO_PIN_MATRIX) {
267  my_atof_2D(delay_matrix, num_inputs, num_outputs, value);
268  } else {
269  assert(input_format == E_ANNOT_PIN_TO_PIN_CONSTANT);
270  for (i = 0; i < num_inputs; i++) {
271  for (j = 0; j < num_outputs; j++) {
272  delay_matrix[i][j] = atof(value);
273  }
274  }
275  }
276 
277  if (delay_type == E_ANNOT_PIN_TO_PIN_DELAY_TSETUP
278  || delay_type == E_ANNOT_PIN_TO_PIN_DELAY_CLOCK_TO_Q_MAX) {
279  k = 0;
280  for (i = 0; i < num_in_sets; i++) {
281  for (j = 0; j < num_in_ptrs[i]; j++) {
282  in_port[i][j]->tsu_tco = delay_matrix[k][0];
283  k++;
284  }
285  }
286  } else {
287  if (pb_graph_node->pb_type->num_modes != 0) {
288  /* Not a primitive, find pb_graph_edge */
289  k = 0;
290  for (i = 0; i < num_in_sets; i++) {
291  for (j = 0; j < num_in_ptrs[i]; j++) {
292  p = 0;
293  for (m = 0; m < num_out_sets; m++) {
294  for (n = 0; n < num_out_ptrs[m]; n++) {
295  for (iedge = 0;
296  iedge < in_port[i][j]->num_output_edges;
297  iedge++) {
298  if (in_port[i][j]->output_edges[iedge]->output_pins[0]
299  == out_port[m][n]) {
300  assert(
301  in_port[i][j]->output_edges[iedge]->delay_max == 0);
302  break;
303  }
304  }
305  /* jluu Todo: This is inefficient, I know the interconnect so I know what edges exist
306  can use this info to only annotate existing edges */
307  if (iedge != in_port[i][j]->num_output_edges) {
308  in_port[i][j]->output_edges[iedge]->delay_max =
309  delay_matrix[k][p];
310  }
311  p++;
312  }
313  }
314  k++;
315  }
316  }
317  } else {
318  /* Primitive, allocate appropriate nodes */
319  k = 0;
320  for (i = 0; i < num_in_sets; i++) {
321  for (j = 0; j < num_in_ptrs[i]; j++) {
322  count = p = 0;
323  for (m = 0; m < num_out_sets; m++) {
324  for (n = 0; n < num_out_ptrs[m]; n++) {
325  /* OPEN indicates that connection does not exist */
326  if (delay_matrix[k][p] != OPEN) {
327  count++;
328  }
329  p++;
330  }
331  }
332  prior_offset = in_port[i][j]->num_pin_timing;
333  in_port[i][j]->num_pin_timing = prior_offset + count;
334  in_port[i][j]->pin_timing_del_max = (float*) my_realloc(in_port[i][j]->pin_timing_del_max,
335  sizeof(float) * in_port[i][j]->num_pin_timing);
336  in_port[i][j]->pin_timing = (t_pb_graph_pin**)my_realloc(in_port[i][j]->pin_timing,
337  sizeof(t_pb_graph_pin*) * in_port[i][j]->num_pin_timing);
338  p = 0;
339  count = 0;
340  for (m = 0; m < num_out_sets; m++) {
341  for (n = 0; n < num_out_ptrs[m]; n++) {
342  if (delay_matrix[k][p] != OPEN) {
343  in_port[i][j]->pin_timing_del_max[prior_offset + count] =
344  delay_matrix[k][p];
345  in_port[i][j]->pin_timing[prior_offset + count] =
346  out_port[m][n];
347  count++;
348  }
349  p++;
350  }
351  }
352  assert(in_port[i][j]->num_pin_timing == prior_offset + count);
353  k++;
354  }
355  }
356  }
357  }
358  if (in_port != NULL) {
359  for (i = 0; i < num_in_sets; i++) {
360  free(in_port[i]);
361  }
362  free(in_port);
363  free(num_in_ptrs);
364  }
365  if (out_port != NULL) {
366  for (i = 0; i < num_out_sets; i++) {
367  free(out_port[i]);
368  }
369  free(out_port);
370  free(num_out_ptrs);
371  }
372  for (i = 0; i < num_inputs; i++) {
373  free(delay_matrix[i]);
374  }
375  free(delay_matrix);
376 }
float * pin_timing_del_max
void my_atof_2D(INOUTP float **matrix, INP int max_i, INP int max_j, INP char *instring)
Definition: token.c:133
struct s_pb_graph_edge ** output_edges
struct s_pb_graph_pin ** pin_timing
Definition: util.h:12
static void * my_malloc(int ibytes)
Definition: graphics.c:499
struct s_pb_graph_node *** child_pb_graph_nodes
static void * my_realloc(void *memblk, int ibytes)
Definition: graphics.c:512
t_pb_graph_pin *** alloc_and_load_port_pin_ptrs_from_string(INP int line_num, INP const t_pb_graph_node *pb_graph_parent_node, INP t_pb_graph_node **pb_graph_children_nodes, INP const char *port_string, OUTP int **num_ptrs, OUTP int *num_sets, INP boolean is_input_to_interc, INP boolean interconnect_error_check)
Definition: slre.c:50

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void load_pack_pattern_annotations ( INP int  line_num,
INOUTP t_pb_graph_node pb_graph_node,
INP int  mode,
INP char *  annot_in_pins,
INP char *  annot_out_pins,
INP char *  value 
)
static

Definition at line 123 of file pb_type_graph_annotations.c.

125  {
126  int i, j, k, m, n, p, iedge;
127  t_pb_graph_pin ***in_port, ***out_port;
128  int *num_in_ptrs, *num_out_ptrs, num_in_sets, num_out_sets;
129  t_pb_graph_node **children = NULL;
130 
131  children = pb_graph_node->child_pb_graph_nodes[mode];
132  in_port = alloc_and_load_port_pin_ptrs_from_string(line_num, pb_graph_node, children,
133  annot_in_pins, &num_in_ptrs, &num_in_sets, FALSE, FALSE);
134  out_port = alloc_and_load_port_pin_ptrs_from_string(line_num, pb_graph_node, children,
135  annot_out_pins, &num_out_ptrs, &num_out_sets, FALSE, FALSE);
136 
137  /* Discover edge then annotate edge with name of pack pattern */
138  k = 0;
139  for (i = 0; i < num_in_sets; i++) {
140  for (j = 0; j < num_in_ptrs[i]; j++) {
141  p = 0;
142  for (m = 0; m < num_out_sets; m++) {
143  for (n = 0; n < num_out_ptrs[m]; n++) {
144  for (iedge = 0; iedge < in_port[i][j]->num_output_edges;
145  iedge++) {
146  if (in_port[i][j]->output_edges[iedge]->output_pins[0]
147  == out_port[m][n]) {
148  break;
149  }
150  }
151  /* jluu Todo: This is inefficient, I know the interconnect so I know what edges exist
152  can use this info to only annotate existing edges */
153  if (iedge != in_port[i][j]->num_output_edges) {
154  in_port[i][j]->output_edges[iedge]->num_pack_patterns++;
155  in_port[i][j]->output_edges[iedge]->pack_pattern_names = (char**)
156  my_realloc(
157  in_port[i][j]->output_edges[iedge]->pack_pattern_names,
158  sizeof(char*)
159  * in_port[i][j]->output_edges[iedge]->num_pack_patterns);
160  in_port[i][j]->output_edges[iedge]->pack_pattern_names[in_port[i][j]->output_edges[iedge]->num_pack_patterns
161  - 1] = value;
162  }
163  p++;
164  }
165  }
166  k++;
167  }
168  }
169 
170  if (in_port != NULL) {
171  for (i = 0; i < num_in_sets; i++) {
172  free(in_port[i]);
173  }
174  free(in_port);
175  free(num_in_ptrs);
176  }
177  if (out_port != NULL) {
178  for (i = 0; i < num_out_sets; i++) {
179  free(out_port[i]);
180  }
181  free(out_port);
182  free(num_out_ptrs);
183  }
184 }
struct s_pb_graph_edge ** output_edges
Definition: util.h:12
struct s_pb_graph_node *** child_pb_graph_nodes
char ** pack_pattern_names
static void * my_realloc(void *memblk, int ibytes)
Definition: graphics.c:512
t_pb_graph_pin *** alloc_and_load_port_pin_ptrs_from_string(INP int line_num, INP const t_pb_graph_node *pb_graph_parent_node, INP t_pb_graph_node **pb_graph_children_nodes, INP const char *port_string, OUTP int **num_ptrs, OUTP int *num_sets, INP boolean is_input_to_interc, INP boolean interconnect_error_check)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void load_pb_graph_pin_to_pin_annotations ( INOUTP t_pb_graph_node pb_graph_node)

Jason Luu April 15, 2011 pb_type_graph_annotations loads statistical information onto the different nodes/edges of a pb_type_graph. These statistical informations include delays, capacitance, etc.

Definition at line 29 of file pb_type_graph_annotations.c.

29  {
30  int i, j, k, m;
31  const t_pb_type *pb_type;
32  t_pin_to_pin_annotation *annotations;
33 
34  pb_type = pb_graph_node->pb_type;
35 
36  /* Load primitive critical path delays */
37  if (pb_type->num_modes == 0) {
38  annotations = pb_type->annotations;
39  for (i = 0; i < pb_type->num_annotations; i++) {
40  if (annotations[i].type == E_ANNOT_PIN_TO_PIN_DELAY) {
41  for (j = 0; j < annotations[i].num_value_prop_pairs; j++) {
42  if (annotations[i].prop[j] == E_ANNOT_PIN_TO_PIN_DELAY_MAX
43  || annotations[i].prop[j]
45  || annotations[i].prop[j]
47  load_critical_path_annotations(annotations[i].line_num, pb_graph_node, OPEN,
48  annotations[i].format, (enum e_pin_to_pin_delay_annotations)annotations[i].prop[j],
49  annotations[i].input_pins,
50  annotations[i].output_pins,
51  annotations[i].value[j]);
52  } else {
53  assert(
54  annotations[i].prop[j] == E_ANNOT_PIN_TO_PIN_DELAY_MIN || annotations[i].prop[j] == E_ANNOT_PIN_TO_PIN_DELAY_CLOCK_TO_Q_MIN || annotations[i].prop[j] == E_ANNOT_PIN_TO_PIN_DELAY_THOLD);
55  }
56  }
57  } else {
58  /* Todo:
59  load_hold_time_constraints_annotations(pb_graph_node);
60  load_power_annotations(pb_graph_node);
61  */
62  }
63  }
64  } else {
65  /* Load interconnect delays */
66  for (i = 0; i < pb_type->num_modes; i++) {
67  for (j = 0; j < pb_type->modes[i].num_interconnect; j++) {
68  annotations = pb_type->modes[i].interconnect[j].annotations;
69  for (k = 0;
70  k < pb_type->modes[i].interconnect[j].num_annotations;
71  k++) {
72  if (annotations[k].type == E_ANNOT_PIN_TO_PIN_DELAY) {
73  for (m = 0; m < annotations[k].num_value_prop_pairs;
74  m++) {
75  if (annotations[k].prop[m]
77  || annotations[k].prop[m]
79  || annotations[k].prop[m]
81  load_critical_path_annotations(annotations[k].line_num, pb_graph_node, i,
82  annotations[k].format,
83  (enum e_pin_to_pin_delay_annotations)annotations[k].prop[m],
84  annotations[k].input_pins,
85  annotations[k].output_pins,
86  annotations[k].value[m]);
87  } else {
88  assert(
89  annotations[k].prop[m] == E_ANNOT_PIN_TO_PIN_DELAY_MIN || annotations[k].prop[m] == E_ANNOT_PIN_TO_PIN_DELAY_CLOCK_TO_Q_MIN || annotations[k].prop[m] == E_ANNOT_PIN_TO_PIN_DELAY_THOLD);
90  }
91  }
92  } else if (annotations[k].type
94  assert(annotations[k].num_value_prop_pairs == 1);
95  load_pack_pattern_annotations(annotations[k].line_num, pb_graph_node, i,
96  annotations[k].input_pins,
97  annotations[k].output_pins,
98  annotations[k].value[0]);
99  } else {
100  /* Todo:
101  load_hold_time_constraints_annotations(pb_graph_node);
102  load_power_annotations(pb_graph_node);
103  */
104  }
105  }
106  }
107  }
108  }
109 
110  for (i = 0; i < pb_type->num_modes; i++) {
111  for (j = 0; j < pb_type->modes[i].num_pb_type_children; j++) {
112  for (k = 0; k < pb_type->modes[i].pb_type_children[j].num_pb; k++) {
114  &pb_graph_node->child_pb_graph_nodes[i][j][k]);
115  }
116  }
117  }
118 }
t_interconnect * interconnect
void load_pb_graph_pin_to_pin_annotations(INOUTP t_pb_graph_node *pb_graph_node)
e_pin_to_pin_delay_annotations
struct s_pb_type * pb_type_children
t_mode * modes
int num_interconnect
t_pin_to_pin_annotation * annotations
int num_annotations
static void load_pack_pattern_annotations(INP int line_num, INOUTP t_pb_graph_node *pb_graph_node, INP int mode, INP char *annot_in_pins, INP char *annot_out_pins, INP char *value)
t_pin_to_pin_annotation * annotations
int num_pb_type_children
Definition: slre.c:50
static void load_critical_path_annotations(INP int line_num, INOUTP t_pb_graph_node *pb_graph_node, INP int mode, INP enum e_pin_to_pin_annotation_format input_format, INP enum e_pin_to_pin_delay_annotations delay_type, INP char *annot_in_pins, INP char *annot_out_pins, INP char *value)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: