VPR-7.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
read_sdc.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void read_sdc (t_timing_inf timing_inf)
 
void free_sdc_related_structs (void)
 
void free_override_constraint (t_override_constraint *&constraint_array, int num_constraints)
 

Variables

t_timing_constraintsg_sdc
 

Function Documentation

void free_override_constraint ( t_override_constraint *&  constraint_array,
int  num_constraints 
)

Definition at line 1297 of file read_sdc.c.

1297  {
1298  int i, j;
1299 
1300  if (!constraint_array) return;
1301 
1302  for (i = 0; i < num_constraints; i++) {
1303  for (j = 0; j < constraint_array[i].num_source; j++) {
1304  free(constraint_array[i].source_list[j]);
1305  constraint_array[i].source_list[j] = NULL;
1306  }
1307  for (j = 0; j < constraint_array[i].num_sink; j++) {
1308  free(constraint_array[i].sink_list[j]);
1309  constraint_array[i].sink_list[j] = NULL;
1310  }
1311  free(constraint_array[i].source_list);
1312  free(constraint_array[i].sink_list);
1313  }
1314  free(constraint_array);
1315  constraint_array = NULL;
1316 }

+ Here is the caller graph for this function:

void free_sdc_related_structs ( void  )

Definition at line 1280 of file read_sdc.c.

1280  {
1281  if (!g_sdc) return;
1282 
1284  /* Should already have been freed in process_constraints() */
1285 
1292  free_matrix(g_sdc->domain_constraint, 0, g_sdc->num_constrained_clocks - 1, 0, sizeof(float));
1293  free(g_sdc);
1294  g_sdc = NULL;
1295 }
static void free_clock_constraint(t_clock *&clock_array, int num_clocks)
Definition: read_sdc.c:1329
void free_override_constraint(t_override_constraint *&constraint_array, int num_constraints)
Definition: read_sdc.c:1297
void free_matrix(void *vptr, int nrmin, int nrmax, int ncmin, size_t elsize)
Definition: util.c:573
float ** domain_constraint
Definition: vpr_types.h:431
t_override_constraint * fc_constraints
Definition: vpr_types.h:446
t_override_constraint * cf_constraints
Definition: vpr_types.h:443
t_clock * constrained_clocks
Definition: vpr_types.h:429
static void free_io_constraint(t_io *&io_array, int num_ios)
Definition: read_sdc.c:1318
t_io * constrained_outputs
Definition: vpr_types.h:437
t_override_constraint * ff_constraints
Definition: vpr_types.h:449
t_override_constraint * cc_constraints
Definition: vpr_types.h:440
t_timing_constraints * g_sdc
Definition: read_sdc.c:65
t_io * constrained_inputs
Definition: vpr_types.h:434

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void read_sdc ( t_timing_inf  timing_inf)

Definition at line 115 of file read_sdc.c.

115  {
116 
117  char buf[BUFSIZE];
118  int source_clock_domain, sink_clock_domain, iinput, ioutput, icc, isource, isink;
119  boolean found;
120 
121  /* Make sure we haven't called this subroutine before. */
122  assert(!g_sdc);
123 
124  /* Allocate container structure for SDC constraints. */
126 
127  /* Reset file line number. */
128  file_line_number = 0;
129 
130  /* If no SDC file is included or specified, or timing analysis is off,
131  use default behaviour of cutting paths between domains and optimizing each clock separately */
132 
133  if (!timing_inf.timing_analysis_enabled) {
134  vpr_printf(TIO_MESSAGE_INFO, "\n");
135  vpr_printf(TIO_MESSAGE_INFO, "Timing analysis off; using default timing constraints.\n");
137  return;
138  }
139 
140  if ((sdc = fopen(timing_inf.SDCFile, "r")) == NULL) {
141  vpr_printf(TIO_MESSAGE_INFO, "\n");
142  vpr_printf(TIO_MESSAGE_INFO, "SDC file '%s' blank or not found.\n", timing_inf.SDCFile);
144  return;
145  }
146 
147  /* Now we have an SDC file. */
148 
149  /* Count how many clocks and I/Os are in the netlist.
150  Store the names of each clock and each I/O in netlist_clocks and netlist_ios.
151  The only purpose of these two lists is to compare clock names in the SDC file against them.
152  As a result, they will be freed after the SDC file is parsed. */
154 
155  /* Parse the file line-by-line. */
156  found = FALSE;
157  while (my_fgets(buf, BUFSIZE, sdc) != NULL) {
158  if (get_sdc_tok(buf)) {
159  found = TRUE;
160  }
161  }
162  if (!found) { /* blank file or only comments found */
163  vpr_printf(TIO_MESSAGE_INFO, "\n");
164  vpr_printf(TIO_MESSAGE_INFO, "SDC file '%s' blank or not found.\n", timing_inf.SDCFile);
166  free(netlist_clocks);
167  free(netlist_ios);
168  return;
169  }
170 
171  fclose(sdc);
172 
173  /* Make sure that all virtual clocks referenced in g_sdc->constrained_inputs and g_sdc->constrained_outputs have been constrained. */
174  for (iinput = 0; iinput < g_sdc->num_constrained_inputs; iinput++) {
176  vpr_printf(TIO_MESSAGE_ERROR, "[SDC line %d] Input %s is associated with an unconstrained clock %s.\n",
178  g_sdc->constrained_inputs[iinput].name,
180  exit(1);
181  }
182  }
183 
184  for (ioutput = 0; ioutput < g_sdc->num_constrained_outputs; ioutput++) {
186  vpr_printf(TIO_MESSAGE_ERROR, "[SDC line %d] Output %s is associated with an unconstrained clock %s.\n",
188  g_sdc->constrained_outputs[ioutput].name,
190  exit(1);
191  }
192  }
193 
194  /* Make sure that all clocks referenced in g_sdc->cc_constraints have been constrained. */
195  for (icc = 0; icc < g_sdc->num_cc_constraints; icc++) {
196  for (isource = 0; isource < g_sdc->cc_constraints[icc].num_source; isource++) {
197  if ((find_constrained_clock(g_sdc->cc_constraints[icc].source_list[isource])) == -1) {
198  vpr_printf(TIO_MESSAGE_ERROR, "[SDC line %d] Token %s is not a constrained clock.\n",
200  g_sdc->cc_constraints[icc].source_list[isource]);
201  exit(1);
202  }
203  }
204  for (isink = 0; isink < g_sdc->cc_constraints[icc].num_sink; isink++) {
205  if ((find_constrained_clock(g_sdc->cc_constraints[icc].sink_list[isink])) == -1) {
206  vpr_printf(TIO_MESSAGE_ERROR, "[SDC line %d] Token %s is not a constrained clock.\n",
208  g_sdc->cc_constraints[icc].sink_list[isink]);
209  exit(1);
210  }
211  }
212  }
213 
214  /* Allocate matrix of timing constraints [0..g_sdc->num_constrained_clocks-1][0..g_sdc->num_constrained_clocks-1] and initialize to 0 */
216 
217  /* Based on the information from sdc_clocks, calculate constraints for all paths except ones with an override constraint. */
218  for (source_clock_domain = 0; source_clock_domain < g_sdc->num_constrained_clocks; source_clock_domain++) {
219  for (sink_clock_domain = 0; sink_clock_domain < g_sdc->num_constrained_clocks; sink_clock_domain++) {
220  if ((icc = find_cc_constraint(g_sdc->constrained_clocks[source_clock_domain].name, g_sdc->constrained_clocks[sink_clock_domain].name)) != -1) {
221  if (g_sdc->cc_constraints[icc].num_multicycles == 0) {
222  /* There's a special constraint from set_false_path, set_clock_groups
223  -exclusive or set_max_delay which overrides the default constraint. */
224  g_sdc->domain_constraint[source_clock_domain][sink_clock_domain] = g_sdc->cc_constraints[icc].constraint;
225  } else {
226  /* There's a special constraint from set_multicycle_path which overrides the default constraint.
227  This constraint = default constraint (obtained via edge counting) + (num_multicycles - 1) * period of sink clock domain. */
228  g_sdc->domain_constraint[source_clock_domain][sink_clock_domain] =
229  calculate_constraint(sdc_clocks[source_clock_domain], sdc_clocks[sink_clock_domain])
230  + (g_sdc->cc_constraints[icc].num_multicycles - 1) * sdc_clocks[sink_clock_domain].period;
231  }
232  } else {
233  /* There's no special override constraint. */
234  /* Calculate the constraint between clock domains by finding the smallest positive
235  difference between a posedge in the source domain and one in the sink domain. */
236  g_sdc->domain_constraint[source_clock_domain][sink_clock_domain] =
237  calculate_constraint(sdc_clocks[source_clock_domain], sdc_clocks[sink_clock_domain]);
238  }
239  }
240  }
241 
242  vpr_printf(TIO_MESSAGE_INFO, "\n");
243  vpr_printf(TIO_MESSAGE_INFO, "SDC file '%s' parsed successfully.\n",
244  timing_inf.SDCFile );
245  vpr_printf(TIO_MESSAGE_INFO, "%d clocks (including virtual clocks), %d inputs and %d outputs were constrained.\n",
247  vpr_printf(TIO_MESSAGE_INFO, "\n");
248 
249  /* Since all the information we need is stored in g_sdc->domain_constraint, g_sdc->constrained_clocks,
250  and constrained_ios, free other data structures used in this routine */
251  free(sdc_clocks);
252  free(netlist_clocks);
253  free(netlist_ios);
254  return;
255 }
void ** alloc_matrix(int nrmin, int nrmax, int ncmin, int ncmax, size_t elsize)
Definition: util.c:551
boolean timing_analysis_enabled
void * my_calloc(size_t nelem, size_t size)
Definition: util.c:132
static FILE * sdc
Definition: read_sdc.c:86
float ** domain_constraint
Definition: vpr_types.h:431
char ** netlist_ios
Definition: read_sdc.c:93
#define BUFSIZE
Definition: graphics.c:184
Definition: util.h:12
t_sdc_clock * sdc_clocks
Definition: read_sdc.c:87
char * name
Definition: vpr_types.h:377
int file_line_number
Definition: vpr_types.h:380
char * name
Definition: vpr_types.h:369
static boolean get_sdc_tok(char *buf)
Definition: read_sdc.c:448
static void use_default_timing_constraints(void)
Definition: read_sdc.c:257
static float calculate_constraint(t_sdc_clock source_domain, t_sdc_clock sink_domain)
Definition: read_sdc.c:1174
static int find_constrained_clock(char *ptr)
Definition: read_sdc.c:1084
t_clock * constrained_clocks
Definition: vpr_types.h:429
static void alloc_and_load_netlist_clocks_and_ios(void)
Definition: read_sdc.c:325
char * clock_name
Definition: vpr_types.h:378
static int find_cc_constraint(char *source_clock_domain, char *sink_clock_domain)
Definition: read_sdc.c:1096
t_io * constrained_outputs
Definition: vpr_types.h:437
char * my_fgets(char *buf, int max_size, FILE *fp)
Definition: util.c:412
int file_line_number
Definition: util.c:15
t_override_constraint * cc_constraints
Definition: vpr_types.h:440
t_timing_constraints * g_sdc
Definition: read_sdc.c:65
messagelogger vpr_printf
Definition: util.c:17
t_io * constrained_inputs
Definition: vpr_types.h:434
char ** netlist_clocks
Definition: read_sdc.c:90
Definition: util.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

Definition at line 65 of file read_sdc.c.