#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "types.h"
#include "types.h"
#include "read_xml_arch_file.h"
#include "string_cache.h"
#include "odin_util.h"
#include "util.h"
Go to the source code of this file.
Defines | |
#define | DEFAULT_STATIC_PROBABILITY .5 |
#define | DEFAULT_TRANSITION_DENSITY .5 |
#define | ACT_NUM_ITER 3 |
#define | activation_t struct activation_t_t |
Functions | |
void | initialize_probabilities (char *input_file, netlist_t *netlist) |
void | calc_transition_density (netlist_t *netlist) |
void | calc_probabilities_and_init_act_data (netlist_t *netlist) |
short * | boolean_difference (nnode_t *node, int variable_spot) |
double | calc_density (nnode_t *node, int variable_spot, short *boolean_difference) |
void | output_activation_file_ace_and_function_file (char *output_filename, int lut_size, netlist_t *LUT_netlist, netlist_t *CLUSTER_netlist) |
void | cleanup_activation (netlist_t *netlist) |
void | activity_estimation (char *input_filename, char *output_filename, int lut_size, netlist_t *LUT_netlist, netlist_t *CLUSTER_netlist) |
#define ACT_NUM_ITER 3 |
Definition at line 40 of file activity_estimation.c.
#define activation_t struct activation_t_t |
Definition at line 42 of file activity_estimation.c.
#define DEFAULT_STATIC_PROBABILITY .5 |
Definition at line 37 of file activity_estimation.c.
#define DEFAULT_TRANSITION_DENSITY .5 |
Definition at line 38 of file activity_estimation.c.
void activity_estimation | ( | char * | input_filename, | |
char * | output_filename, | |||
int | lut_size, | |||
netlist_t * | LUT_netlist, | |||
netlist_t * | CLUSTER_netlist | |||
) |
Definition at line 61 of file activity_estimation.c.
00062 { 00063 /* levelize the graph. Note, can't levelize the ClUSTER_netlist since there are loops */ 00064 levelize_and_check_for_combinational_loop_and_liveness(FALSE, LUT_netlist); 00065 00066 /* initializes the data structures and the PI */ 00067 initialize_probabilities(input_filename, LUT_netlist); 00068 00069 /* Calculate the probabilities for each of the nodes in the LUT_netlist */ 00070 calc_probabilities_and_init_act_data(LUT_netlist); 00071 00072 /* calculate the transition density for each node */ 00073 calc_transition_density(LUT_netlist); 00074 00075 /* Output file with the transition densities */ 00076 output_activation_file_ace_and_function_file(output_filename, lut_size, LUT_netlist, CLUSTER_netlist); 00077 00078 /* cleanup the data structures so we can use node_data in another algorithm */ 00079 cleanup_activation(LUT_netlist); 00080 00081 /* Path is where we are */ 00082 // graphVizOutputNetlist(configuration.debug_output_path, "blif", 1, blif_gnd_node, blif_vcc_node, blif_input_nodes, num_blif_input_nodes); 00083 }
short * boolean_difference | ( | nnode_t * | node, | |
int | variable_spot | |||
) |
Definition at line 393 of file activity_estimation.c.
00394 { 00395 int i, l; 00396 short *return_function; 00397 int function_size; 00398 long long skip_size = 1 << variable_spot; 00399 int index; 00400 00401 oassert(node->num_input_pins < sizeof (long long int)*8); 00402 oassert(node->associated_function != NULL); 00403 oassert(node->num_input_pins > 1); 00404 00405 /* calculate the size of the boolean difference */ 00406 function_size = pow2(node->num_input_pins-1); 00407 00408 return_function = (short*)calloc(sizeof(short), function_size); 00409 00410 for (i = 0; i < function_size; i++) 00411 { 00412 long long int place = 1; 00413 long long int index_plus = 1; 00414 index = 0; 00415 00416 /* IF - this function value is on then calculate the probability */ 00417 for (l = 0; l < node->num_input_pins-1; l++) 00418 { 00419 /* move the bit collumn */ 00420 if (l == variable_spot) 00421 { 00422 index_plus = index_plus << 1; 00423 } 00424 00425 if ((i & place) > 0) // if this bit is high 00426 { 00427 index += index_plus; 00428 } 00429 00430 place = place << 1; 00431 index_plus = index_plus << 1; 00432 } 00433 00434 /* do the boolean xor of this element */ 00435 return_function[i] = node->associated_function[index] ^ node->associated_function[index+skip_size]; 00436 } 00437 00438 return return_function; 00439 }
double calc_density | ( | nnode_t * | node, | |
int | variable_spot, | |||
short * | boolean_difference | |||
) |
Definition at line 444 of file activity_estimation.c.
00445 { 00446 int i, l; 00447 int function_size; 00448 double totalProb = 0; 00449 double input_density; 00450 00451 oassert(node->num_input_pins < sizeof (long long int)*8); 00452 00453 if ((node->input_pins[variable_spot] != NULL) && (node->input_pins[variable_spot]->net->driver_pin != NULL) && (node->input_pins[variable_spot]->net->driver_pin->node != NULL)) 00454 { 00455 nnode_t *input_node = node->input_pins[variable_spot]->net->driver_pin->node; 00456 int input_node_pin = node->input_pins[variable_spot]->net->driver_pin->pin_node_idx; 00457 activation_t *input_data = (activation_t*)input_node->node_data; 00458 oassert(input_node->unique_node_data_id == ACTIVATION); 00459 00460 input_density = input_data->transition_density[input_node_pin]; 00461 } 00462 else 00463 { 00464 oassert(FALSE); 00465 } 00466 00467 /* calculate the size of the boolean difference */ 00468 function_size = pow2(node->num_input_pins-1); 00469 00470 for (i = 0; i < function_size; i++) 00471 { 00472 long long int place = 1; 00473 double probVal = 1; 00474 int index = -1; 00475 00476 if (boolean_difference[i] == 1) 00477 { 00478 /* IF - this function value is on then calculate the probability */ 00479 for (l = 0; l < node->num_input_pins-1; l++) 00480 { 00481 nnode_t *input_node; 00482 activation_t *input_data; 00483 int input_node_pin; 00484 00485 /* move the bit collumn */ 00486 if (l == variable_spot) 00487 { 00488 /* skip this one */ 00489 index += 2; 00490 } 00491 else 00492 { 00493 index ++; 00494 } 00495 00496 input_node = node->input_pins[index]->net->driver_pin->node; 00497 input_node_pin = node->input_pins[index]->net->driver_pin->pin_node_idx; 00498 input_data = (activation_t*)input_node->node_data; 00499 oassert(input_node->unique_node_data_id == ACTIVATION); 00500 00501 if ((i & place) > 0) // if this bit is high 00502 { 00503 probVal = probVal * input_data->static_probability[input_node_pin]; 00504 } 00505 else 00506 { 00507 probVal = probVal * (1-input_data->static_probability[input_node_pin]); 00508 } 00509 00510 place = place << 1; 00511 } 00512 totalProb += probVal; 00513 } 00514 } 00515 00516 oassert(totalProb <= 1.1); 00517 if (totalProb > 1) 00518 totalProb = 1; // for rounding errors 00519 00520 // oassert(totalProb * input_density < 1); 00521 return totalProb * input_density; 00522 }
void calc_probabilities_and_init_act_data | ( | netlist_t * | netlist | ) |
Definition at line 275 of file activity_estimation.c.
00276 { 00277 int i, j, k, l, rep; 00278 activation_t *act_data; 00279 00280 for (rep = 0; rep < ACT_NUM_ITER; rep++) 00281 { 00282 /* progress from the primary inputs (in the forward level 0) to each stage */ 00283 for (i = 0; i < netlist->num_forward_levels; i++) 00284 { 00285 for (j = 0; j < netlist->num_at_forward_level[i]; j++) 00286 { 00287 /* initialize the activation data */ 00288 nnode_t *current_node = netlist->forward_levels[i][j]; 00289 act_data = (activation_t*)current_node->node_data; 00290 00291 /* All other levels we pass through the probabilities and calculate Transition prbability for the DEnsity calculation */ 00292 if (current_node->type == BLIF_FUNCTION) 00293 { 00294 double totalProb = 0; 00295 int function_size = pow2(current_node->num_input_pins); 00296 00297 if (rep == 0) 00298 { 00299 /* only one output */ 00300 act_data->static_probability = (double*)malloc(sizeof(double)); 00301 } 00302 00303 for (k = 0; k < function_size; k++) 00304 { 00305 long long int place = 1; 00306 double probVal = 1; 00307 00308 if (current_node->associated_function[k] == 1) 00309 { 00310 /* IF - this function value is on then calculate the probability */ 00311 for (l = 0; l < current_node->num_input_pins; l++) 00312 { 00313 nnode_t *input_node = current_node->input_pins[l]->net->driver_pin->node; 00314 int input_node_pin = current_node->input_pins[l]->net->driver_pin->pin_node_idx; 00315 activation_t *input_data = (activation_t*)input_node->node_data; 00316 oassert(input_node->unique_node_data_id == ACTIVATION); 00317 00318 if ((k & place) > 0) // if this bit is high 00319 { 00320 probVal = probVal * input_data->static_probability[input_node_pin]; 00321 } 00322 else 00323 { 00324 probVal = probVal * (1-input_data->static_probability[input_node_pin]); 00325 } 00326 /* move the bit collumn */ 00327 place = place << 1; 00328 } 00329 00330 totalProb += probVal; 00331 } 00332 00333 } 00334 /* store the total probability */ 00335 act_data->static_probability[0] = totalProb; 00336 } 00337 else if (current_node->type == FF_NODE) 00338 { 00339 if (rep != 0) 00340 { 00341 /* ONLY do calculations after first repetition */ 00342 nnode_t *input_node = current_node->input_pins[0]->net->driver_pin->node; 00343 int input_node_pin = current_node->input_pins[0]->net->driver_pin->pin_node_idx; 00344 activation_t *input_data = (activation_t*)input_node->node_data; 00345 oassert(input_node->unique_node_data_id == ACTIVATION); 00346 00347 act_data->static_probability[0] = input_data->static_probability[input_node_pin]; 00348 } 00349 } 00350 else if (current_node->type == OUTPUT_NODE) 00351 { 00352 nnode_t *input_node = current_node->input_pins[0]->net->driver_pin->node; 00353 int input_node_pin = current_node->input_pins[0]->net->driver_pin->pin_node_idx; 00354 activation_t *input_data = (activation_t*)input_node->node_data; 00355 oassert(input_node->unique_node_data_id == ACTIVATION); 00356 00357 if (rep == 0) 00358 { 00359 /* only one output */ 00360 act_data->static_probability = (double*)malloc(sizeof(double)); 00361 } 00362 00363 act_data->static_probability[0] = input_data->static_probability[input_node_pin]; 00364 } 00365 else if ((current_node->type == INPUT_NODE) || (current_node->type == VCC_NODE) || (current_node->type == GND_NODE)) 00366 { 00367 oassert(current_node->unique_node_data_id == ACTIVATION); 00368 continue; // skip transition probability calculation 00369 } 00370 else 00371 { 00372 oassert(FALSE); 00373 } 00374 00375 if (rep == 0) 00376 { 00377 /* calculate transition probability */ 00378 act_data->transition_probability = (double*)malloc(sizeof(double)*current_node->num_output_pins); 00379 } 00380 00381 for (k = 0; k < current_node->num_output_pins; k++) 00382 { 00383 act_data->transition_probability[k] = 2 * (act_data->static_probability[k] * (1-act_data->static_probability[k])); 00384 } 00385 } 00386 } 00387 } 00388 }
void calc_transition_density | ( | netlist_t * | netlist | ) |
Definition at line 88 of file activity_estimation.c.
00089 { 00090 int i, j, m; 00091 activation_t *act_data; 00092 00093 /* progress from the primary inputs (in the forward level 0) to each stage */ 00094 for (i = 0; i < netlist->num_forward_levels; i++) 00095 { 00096 for (j = 0; j < netlist->num_at_forward_level[i]; j++) 00097 { 00098 /* initialize the activation data */ 00099 nnode_t *current_node = netlist->forward_levels[i][j]; 00100 act_data = (activation_t*)current_node->node_data; 00101 00102 /* All other levels we pass through the probabilities and calculate Transition prbability for the DEnsity calculation */ 00103 if (current_node->type == BLIF_FUNCTION) 00104 { 00105 /* only one output */ 00106 act_data->transition_density = (double*)malloc(sizeof(double)); // only one output 00107 00108 if (current_node->num_input_pins == 1) 00109 { 00110 /* If this is a Constant, NOT or a BUFFER then the transition density is easy to calculate */ 00111 nnode_t *input_node = current_node->input_pins[0]->net->driver_pin->node; 00112 int input_node_pin = current_node->input_pins[0]->net->driver_pin->pin_node_idx; 00113 activation_t *input_data = (activation_t*)input_node->node_data; 00114 oassert(input_node->unique_node_data_id == ACTIVATION); 00115 00116 if ((current_node->associated_function[0] == 0) && (current_node->associated_function[1] == 0)) 00117 /* CONSTANT 0 */ 00118 act_data->transition_density[0] = 0; 00119 if ((current_node->associated_function[0] == 0) && (current_node->associated_function[1] == 1)) 00120 /* BUFFER */ 00121 act_data->transition_density[0] = input_data->transition_density[input_node_pin]; 00122 if ((current_node->associated_function[0] == 1) && (current_node->associated_function[1] == 0)) 00123 /* NOT */ 00124 act_data->transition_density[0] = input_data->transition_density[input_node_pin]; 00125 if ((current_node->associated_function[0] == 1) && (current_node->associated_function[1] == 1)) 00126 /* CONSTANT 1 */ 00127 act_data->transition_density[0] = 0; 00128 } 00129 else 00130 { 00131 double density_val = 0.0; 00132 00133 /* calculate the transition densities sumof(D(y)*P(boolean_diff, y) */ 00134 for (m = 0; m < current_node->num_input_pins; m++) 00135 { 00136 short *boolean_difference_function; 00137 00138 /* calculate hte boolean difference */ 00139 boolean_difference_function = boolean_difference(current_node, m); 00140 00141 /* now calculate the denisty of this input ... sum of */ 00142 density_val = density_val + calc_density(current_node, m, boolean_difference_function); 00143 00144 /* free the array */ 00145 free(boolean_difference_function); 00146 } 00147 00148 act_data->transition_density[0] = density_val; 00149 } 00150 } 00151 else if (current_node->type == FF_NODE) 00152 { 00153 nnode_t *input_node = current_node->input_pins[0]->net->driver_pin->node; 00154 int input_node_pin = current_node->input_pins[0]->net->driver_pin->pin_node_idx; 00155 activation_t *input_data = (activation_t*)input_node->node_data; 00156 oassert(input_node->unique_node_data_id == ACTIVATION); 00157 00158 /* just store since allocated in the initialization */ 00159 act_data->transition_density = (double*)malloc(sizeof(double)); 00160 act_data->transition_density[0] = 2 * (input_data->static_probability[input_node_pin] * (1-input_data->static_probability[input_node_pin])); 00161 } 00162 else if (current_node->type == OUTPUT_NODE) 00163 { 00164 nnode_t *input_node = current_node->input_pins[0]->net->driver_pin->node; 00165 int input_node_pin = current_node->input_pins[0]->net->driver_pin->pin_node_idx; 00166 activation_t *input_data = (activation_t*)input_node->node_data; 00167 oassert(input_node->unique_node_data_id == ACTIVATION); 00168 00169 /* allocate and stre through */ 00170 act_data->transition_density = (double*)malloc(sizeof(double)); 00171 act_data->transition_density[0] = input_data->static_probability[input_node_pin]; 00172 } 00173 else if ((current_node->type == INPUT_NODE) || (current_node->type == VCC_NODE) || (current_node->type == GND_NODE)) 00174 { 00175 oassert(current_node->unique_node_data_id == ACTIVATION); 00176 } 00177 else 00178 { 00179 oassert(FALSE); 00180 } 00181 } 00182 } 00183 }
void cleanup_activation | ( | netlist_t * | netlist | ) |
Definition at line 852 of file activity_estimation.c.
00853 { 00854 int i, j; 00855 00856 for (i = 0; i < netlist->num_forward_levels; i++) 00857 { 00858 for (j = 0; j < netlist->num_at_forward_level[i]; j++) 00859 { 00860 /* initialize the activation data */ 00861 nnode_t *current_node = netlist->forward_levels[i][j]; 00862 activation_t *act_data = (activation_t*)current_node->node_data; 00863 oassert(act_data != NULL); 00864 00865 if (act_data->static_probability != NULL) 00866 free(act_data->static_probability); 00867 if (act_data->transition_density != NULL) 00868 free(act_data->transition_density); 00869 if (act_data->transition_probability != NULL) 00870 free(act_data->transition_probability); 00871 00872 free(act_data); 00873 current_node->unique_node_data_id = RESET; 00874 } 00875 } 00876 }
void initialize_probabilities | ( | char * | input_file, | |
netlist_t * | netlist | |||
) |
Definition at line 188 of file activity_estimation.c.
00189 { 00190 int i, j; 00191 activation_t *act_data; 00192 00193 for (i = 0; i < netlist->num_forward_levels; i++) 00194 { 00195 for (j = 0; j < netlist->num_at_forward_level[i]; j++) 00196 { 00197 /* initialize the activation data */ 00198 nnode_t *current_node = netlist->forward_levels[i][j]; 00199 oassert(current_node->unique_node_data_id == RESET); 00200 00201 current_node->unique_node_data_id = ACTIVATION; 00202 act_data = (activation_t*)malloc(sizeof(activation_t)); 00203 current_node->node_data = (void*)act_data; 00204 00205 if (current_node->type == INPUT_NODE) 00206 { 00207 oassert(i == 0); 00208 /* IF - PI and FFs, then we set their probability */ 00209 if (input_file != NULL) 00210 { 00211 /* READ input probabilities */ 00212 oassert(FALSE); 00213 00214 /* READ in the input file */ 00215 00216 /* exit since all read */ 00217 i = netlist->num_forward_levels; 00218 } 00219 else 00220 { 00221 /* initialize all the initial probabilities */ 00222 act_data->static_probability = (double*)malloc(sizeof(double)); 00223 act_data->transition_probability = (double*)malloc(sizeof(double)); 00224 act_data->transition_density = (double*)malloc(sizeof(double)); 00225 00226 act_data->static_probability[0] = DEFAULT_STATIC_PROBABILITY; 00227 act_data->transition_probability[0] = -1; 00228 act_data->transition_density[0] = DEFAULT_TRANSITION_DENSITY; 00229 } 00230 } 00231 else if (current_node->type == GND_NODE) 00232 { 00233 /* initialize all the initial probabilities */ 00234 act_data->static_probability = (double*)malloc(sizeof(double)); 00235 act_data->transition_probability = (double*)malloc(sizeof(double)); 00236 act_data->transition_density = (double*)malloc(sizeof(double)); 00237 00238 act_data->static_probability[0] = 0.0; 00239 act_data->transition_probability[0] = -1; 00240 act_data->transition_density[0] = 0; 00241 00242 } 00243 else if (current_node->type == VCC_NODE) 00244 { 00245 /* initialize all the initial probabilities */ 00246 act_data->static_probability = (double*)malloc(sizeof(double)); 00247 act_data->transition_probability = (double*)malloc(sizeof(double)); 00248 act_data->transition_density = (double*)malloc(sizeof(double)); 00249 00250 act_data->static_probability[0] = 1.0; 00251 act_data->transition_probability[0] = -1; 00252 act_data->transition_density[0] = 0; 00253 00254 } 00255 else if (current_node->type == FF_NODE) 00256 { 00257 /* initialize all the initial probabilities */ 00258 act_data->static_probability = (double*)malloc(sizeof(double)); 00259 act_data->transition_probability = (double*)malloc(sizeof(double)); 00260 act_data->transition_density = (double*)malloc(sizeof(double)); 00261 00262 act_data->static_probability[0] = DEFAULT_STATIC_PROBABILITY; 00263 act_data->transition_probability[0] = -1; 00264 act_data->transition_density[0] = -1; 00265 } 00266 } 00267 } 00268 }
void output_activation_file_ace_and_function_file | ( | char * | output_filename, | |
int | lut_size, | |||
netlist_t * | LUT_netlist, | |||
netlist_t * | CLUSTER_netlist | |||
) |
Definition at line 531 of file activity_estimation.c.
00532 { 00533 char *ace_file_name = (char*)malloc(sizeof(char)*(strlen(output_filename)+4+1)); 00534 char *ac2_file_name = (char*)malloc(sizeof(char)*(strlen(output_filename)+4+1)); 00535 char *function_file_name = (char*)malloc(sizeof(char)*(strlen(output_filename)+4+1)); 00536 int i, j, k, l; 00537 FILE *ace_out; 00538 FILE *ac2_out; 00539 FILE *function_out; 00540 long sc_spot; 00541 nnode_t *lut_node; 00542 activation_t *act_data; 00543 00544 sprintf(ace_file_name, "%s.ace", output_filename); 00545 sprintf(ac2_file_name, "%s.ac2", output_filename); 00546 sprintf(function_file_name, "%s.fun", output_filename); 00547 00548 ace_out = fopen(ace_file_name, "w"); 00549 if (ace_out == NULL) 00550 { 00551 error_message(ACTIVATION_ERROR, -1, -1, "Could not open output file %s\n", ace_file_name); 00552 } 00553 ac2_out = fopen(ac2_file_name, "w"); 00554 if (ac2_out == NULL) 00555 { 00556 error_message(ACTIVATION_ERROR, -1, -1, "Could not open output file %s\n", ac2_file_name); 00557 } 00558 function_out = fopen(function_file_name, "w"); 00559 if (function_out == NULL) 00560 { 00561 error_message(ACTIVATION_ERROR, -1, -1, "Could not open output file %s\n", function_file_name); 00562 } 00563 00564 /* Go through the LUT netlist and print out the ace files */ 00565 for (i = 0; i < LUT_netlist->num_forward_levels; i++) 00566 { 00567 for (j = 0; j < LUT_netlist->num_at_forward_level[i]; j++) 00568 { 00569 /* initialize the activation data */ 00570 nnode_t *current_node = LUT_netlist->forward_levels[i][j]; 00571 activation_t *act_data = (activation_t*)current_node->node_data; 00572 00573 if (current_node->type != OUTPUT_NODE) 00574 { 00575 for (k = 0; k < current_node->num_output_pins; k++) 00576 { 00577 if (current_node->output_pins[0]->net->num_fanout_pins != 0) 00578 { 00579 /* IF this node fans out */ 00580 fprintf(ace_out, "%s %f %f\n", current_node->name, act_data->static_probability[k], act_data->transition_density[k]); 00581 } 00582 } 00583 } 00584 else 00585 { 00586 fprintf(ace_out, "out:%s %f %f\n", current_node->name, act_data->static_probability[0], act_data->transition_density[0]); 00587 } 00588 } 00589 } 00590 00591 fclose(ace_out); 00592 00593 /* now create the ac2 file and function file */ 00594 00595 /* first we spit out the clocks */ 00596 for (i = 0; i < CLUSTER_netlist->num_clocks; i++) 00597 { 00598 nnode_t *cluster_node = CLUSTER_netlist->clocks[i]; 00599 fprintf (ac2_out, "global_net_probability %s 0.5\n", cluster_node->name); 00600 fprintf (ac2_out, "global_net_density %s 2.0\n", cluster_node->name); 00601 } 00602 00603 /* next we make the intercluster probabilities for inputs */ 00604 for (i = 0; i < CLUSTER_netlist->num_top_input_nodes; i++) 00605 { 00606 nnode_t *cluster_node = CLUSTER_netlist->top_input_nodes[i]; 00607 00608 if (cluster_node->type == CLOCK_NODE) 00609 { 00610 continue; 00611 } 00612 00613 /* find the equivalent blif point */ 00614 if ((sc_spot = sc_lookup_string(LUT_netlist->nodes_sc, cluster_node->name)) == -1) 00615 { 00616 warning_message(ACTIVATION_ERROR, -1, -1, "Could not find %s INPUT in LUT netlist ...\n", cluster_node->name); 00617 continue; 00618 } 00619 lut_node = (nnode_t *)LUT_netlist->nodes_sc->data[sc_spot]; 00620 act_data = (activation_t*)lut_node->node_data; 00621 00622 oassert(lut_node->num_output_pins == 1); /* assumption now, but will change with heterognenous blocks */ 00623 fprintf (ac2_out, "intercluster_net_probability %s %f\n", cluster_node->name, act_data->static_probability[0]); 00624 fprintf (ac2_out, "intercluster_net_density %s %f\n", cluster_node->name, act_data->transition_density[0]); 00625 } 00626 00627 /* next we make the intercluster probabilities for inputs */ 00628 for (i = 0; i < CLUSTER_netlist->num_top_output_nodes; i++) 00629 { 00630 nnode_t *cluster_node = CLUSTER_netlist->top_output_nodes[i]; 00631 00632 /* find the equivalent blif point */ 00633 if ((sc_spot = sc_lookup_string(LUT_netlist->nodes_sc, cluster_node->name)) == -1) 00634 { 00635 warning_message(ACTIVATION_ERROR, -1, -1, "Could not find %s OUTPUT in LUT netlist ...\n", cluster_node->name); 00636 continue; 00637 } 00638 lut_node = (nnode_t *)LUT_netlist->nodes_sc->data[sc_spot]; 00639 act_data = (activation_t*)lut_node->node_data; 00640 00641 oassert(lut_node->num_output_pins == 0); /* assumption now, but will change with heterognenous blocks */ 00642 fprintf (ac2_out, "intercluster_net_probability %s %f\n", (cluster_node->name+4), act_data->static_probability[0]); /* +4 to skip "out:" that isn't needed in output */ 00643 fprintf (ac2_out, "intercluster_net_density %s %f\n", (cluster_node->name+4), act_data->transition_density[0]); 00644 } 00645 00646 /* next we make the intercluster probabilities */ 00647 for (i = 0; i < CLUSTER_netlist->num_internal_nodes; i++) 00648 { 00649 nnode_t *cluster_node = CLUSTER_netlist->internal_nodes[i]; 00650 netlist_t* internal_subblocks = cluster_node->internal_netlist; 00651 00652 if (internal_subblocks == NULL) 00653 { 00654 /* INPUT/OUTPUT pins and globals (clocks) have no subblocks */ 00655 continue; 00656 } 00657 00658 /* now we process the internal structure of the node, which represents the subblocks. This is stored in an internall netlist. */ 00659 for (k = 0; k < internal_subblocks->num_internal_nodes; k++) 00660 { 00661 nnode_t *current_subblock = internal_subblocks->internal_nodes[k]; 00662 char *output_search_name = (char*)malloc(sizeof(char)*(strlen(current_subblock->name)+1+4)); 00663 sprintf(output_search_name, "out:%s", current_subblock->name); 00664 00665 if ((sc_spot = sc_lookup_string(internal_subblocks->nodes_sc, output_search_name)) != -1) 00666 { 00667 /* IF - this is an output of the cluster then we need inter cluster info */ 00668 00669 /* now find this node */ 00670 /* find the equivalent blif point */ 00671 if ((sc_spot = sc_lookup_string(LUT_netlist->nodes_sc, current_subblock->name)) == -1) 00672 { 00673 error_message(ACTIVATION_ERROR, -1, -1, "Could not find %s in LUT netlist ...\n", current_subblock->name); 00674 } 00675 lut_node = (nnode_t *)LUT_netlist->nodes_sc->data[sc_spot]; 00676 act_data = (activation_t*)lut_node->node_data; 00677 00678 /* Finally, put in th output switching values */ 00679 fprintf (ac2_out, "intercluster_net_probability %s %f\n", current_subblock->name, act_data->static_probability[0]); 00680 fprintf (ac2_out, "intercluster_net_density %s %f\n", current_subblock->name, act_data->transition_density[0]); 00681 } 00682 00683 free(output_search_name); 00684 } 00685 } 00686 00687 /* next we process the subblocks */ 00688 for (i = 0; i < CLUSTER_netlist->num_internal_nodes; i++) 00689 { 00690 nnode_t *cluster_node = CLUSTER_netlist->internal_nodes[i]; 00691 netlist_t* internal_subblocks = cluster_node->internal_netlist; 00692 00693 if (internal_subblocks == NULL) 00694 { 00695 /* INPUT/OUTPUT pins and globals (clocks) have no subblocks */ 00696 oassert(FALSE); 00697 continue; 00698 } 00699 00700 /* now we process the internal structure of the node, which represents the subblocks. This is stored in an internall netlist. */ 00701 for (k = 0; k < internal_subblocks->num_internal_nodes; k++) 00702 { 00703 nnode_t *current_subblock = internal_subblocks->internal_nodes[k]; 00704 char probability_string[4096]; 00705 char density_string[4096]; 00706 int input_active_count = 0; 00707 short is_clock = FALSE; 00708 int input_index = 0; 00709 00710 sprintf(probability_string, "subblock_probability %s", current_subblock->name); 00711 sprintf(density_string, "subblock_density %s", current_subblock->name); 00712 00713 /* first get all the input values */ 00714 for (l = 0; l < lut_size+1; l++) 00715 { 00716 if (current_subblock->input_pins[input_index] != NULL) 00717 { 00718 nnode_t *input_node = current_subblock->input_pins[input_index]->net->driver_pin->node; 00719 00720 /* find the equivalent blif point */ 00721 if ((sc_spot = sc_lookup_string(LUT_netlist->nodes_sc, input_node->name)) == -1) 00722 { 00723 error_message(ACTIVATION_ERROR, -1, -1, "Could not find %s in LUT netlist ...\n", input_node->name); 00724 } 00725 lut_node = (nnode_t *)LUT_netlist->nodes_sc->data[sc_spot]; 00726 act_data = (activation_t*)lut_node->node_data; 00727 00728 if (lut_node->type == CLOCK_NODE) 00729 { 00730 /* IF - the clock spot */ 00731 if (l == lut_size) 00732 { 00733 /* only print it out if this is the last spot */ 00734 sprintf(probability_string, "%s %f", probability_string, act_data->static_probability[0]); 00735 sprintf(density_string, "%s %f", density_string, act_data->transition_density[0]); 00736 is_clock = TRUE; 00737 } 00738 else 00739 { 00740 sprintf(probability_string, "%s 0.0", probability_string); 00741 sprintf(density_string, "%s 0.0", density_string); 00742 } 00743 } 00744 else 00745 { 00746 sprintf(probability_string, "%s %f", probability_string, act_data->static_probability[0]); 00747 sprintf(density_string, "%s %f", density_string, act_data->transition_density[0]); 00748 00749 input_index++; 00750 } 00751 00752 input_active_count ++; 00753 } 00754 else 00755 { 00756 /* No connection to this input */ 00757 sprintf(probability_string, "%s 0.0", probability_string); 00758 sprintf(density_string, "%s 0.0", density_string); 00759 } 00760 } 00761 00762 if (is_clock == FALSE) 00763 { 00764 /* IF - there is no clock meaning this is just a LUT, output the probabilities */ 00765 sprintf(probability_string, "%s 0.0", probability_string); 00766 sprintf(density_string, "%s 0.0", density_string); 00767 } 00768 00769 /* now find this node */ 00770 /* find the equivalent blif point */ 00771 if ((sc_spot = sc_lookup_string(LUT_netlist->nodes_sc, current_subblock->name)) == -1) 00772 { 00773 error_message(ACTIVATION_ERROR, -1, -1, "Could not find %s in LUT netlist ...\n", current_subblock->name); 00774 } 00775 lut_node = (nnode_t *)LUT_netlist->nodes_sc->data[sc_spot]; 00776 act_data = (activation_t*)lut_node->node_data; 00777 00778 /* find the values of the switching between LUT and FF */ 00779 if ((lut_node->type == FF_NODE) && (input_active_count > 0)) 00780 { 00781 /* LUT + FF */ 00782 /* IF - this is a FF node and has more than 1 input, then it's a LUT-FF */ 00783 activation_t *input_node_to_ff_act_data = (activation_t *)lut_node->input_pins[0]->net->driver_pin->node->node_data; 00784 sprintf(probability_string, "%s %f", probability_string, input_node_to_ff_act_data->static_probability[0]); 00785 sprintf(density_string, "%s %f", density_string, input_node_to_ff_act_data->transition_density[0]); 00786 00787 /* print out the function of this node based on it's inputs function */ 00788 oassert (lut_node->input_pins[0]->net->driver_pin->node->associated_function != NULL) 00789 fprintf(function_out, "subblock_function %s ", lut_node->name); 00790 00791 for (l = 0; l < pow2(lut_size); l++) 00792 { 00793 fprintf(function_out, "%d", lut_node->input_pins[0]->net->driver_pin->node->associated_function[l]); 00794 } 00795 00796 fprintf(function_out, "\n"); 00797 } 00798 else if (lut_node->type == FF_NODE) 00799 { 00800 /* FF */ 00801 /* ELSE - this is a FF_NODE only */ 00802 sprintf(probability_string, "%s 0.0", probability_string); 00803 sprintf(density_string, "%s 0.0", density_string); 00804 00805 /* output function is just a buffer since this is just a FF */ 00806 fprintf(function_out, "subblock_function %s ", lut_node->name); 00807 for (l = 0; l < pow2(lut_size); l++) 00808 { 00809 if (l % 2 == 0) 00810 { 00811 fprintf(function_out, "0"); 00812 } 00813 else 00814 { 00815 fprintf(function_out, "1"); 00816 } 00817 } 00818 fprintf(function_out, "\n"); 00819 } 00820 else 00821 { 00822 /* LUT */ 00823 /* print out the function of this node based on it's just a LUT */ 00824 oassert (lut_node->associated_function != NULL) 00825 fprintf(function_out, "subblock_function %s ", lut_node->name); 00826 00827 for (l = 0; l < pow2(lut_size); l++) 00828 { 00829 fprintf(function_out, "%d", lut_node->associated_function[l]); 00830 } 00831 00832 fprintf(function_out, "\n"); 00833 } 00834 00835 /* Finally, put in th output switching values */ 00836 sprintf(probability_string, "%s %f", probability_string, act_data->static_probability[0]); 00837 sprintf(density_string, "%s %f", density_string, act_data->transition_density[0]); 00838 00839 /* output the values created for the subblock */ 00840 fprintf(ac2_out, "%s\n", probability_string); 00841 fprintf(ac2_out, "%s\n", density_string); 00842 } 00843 } 00844 00845 fclose(function_out); 00846 fclose(ac2_out); 00847 }