50 #define CONVERT_NM_PER_M 1000000000
51 #define CONVERT_UM_PER_M 1000000
105 float total_power,
float perc_dyn,
char * method);
134 float * input_probabilities;
135 float * input_densities;
143 input_probabilities = (
float*)
my_calloc(LUT_size,
sizeof(
float));
144 input_densities = (
float*)
my_calloc(LUT_size,
sizeof(
float));
146 for (pin_idx = 0; pin_idx < LUT_size; pin_idx++) {
149 input_probabilities[pin_idx] =
pin_prob(pb, pin);
150 input_densities[pin_idx] =
pin_dens(pb, pin);
164 free(input_probabilities);
165 free(input_densities);
193 sprintf(msg,
"No dynamic power defined for BLIF model: %s",
197 sprintf(msg,
"No leakage power defined for BLIF model: %s",
213 scale_factor = 1 - scale_factor;
220 power_usage->
dynamic += scale_factor
228 float buffer_size = 0.;
316 boolean estimate_buffers_and_wire =
FALSE;
317 boolean estimate_multiplexers =
FALSE;
318 boolean estimate_primitives =
FALSE;
319 boolean recursive_children;
363 dens_avg = dens_avg / num_pins;
416 power_usage_pin_toggle.
leakage +=
427 estimate_buffers_and_wire =
TRUE;
428 estimate_multiplexers =
TRUE;
429 estimate_primitives =
TRUE;
432 estimate_buffers_and_wire =
TRUE;
433 estimate_multiplexers =
TRUE;
434 estimate_primitives =
TRUE;
448 estimate_buffers_and_wire =
FALSE;
449 estimate_multiplexers =
FALSE;
454 if (estimate_primitives) {
474 if (estimate_buffers_and_wire) {
482 &power_usage_bufs_wires);
487 if (estimate_multiplexers) {
507 &power_usage_local_muxes);
511 if (recursive_children) {
513 for (pb_type_idx = 0;
521 t_pb * child_pb = NULL;
526 child_pb = &pb->
child_pbs[pb_type_idx][pb_idx];
528 child_pb_graph_node =
532 child_pb_graph_node);
542 &power_usage_children);
558 for (mode_idx = 0; mode_idx < pb_type->
num_modes; mode_idx++) {
582 for (type_idx = 0; type_idx <
num_types; type_idx++) {
600 for (x = 0; x <
nx + 2; x++) {
601 for (y = 0; y <
ny + 2; y++) {
700 if (single_clock->
dens) {
714 single_clock->
prob, buffer_size, single_clock->
period);
719 length += (
ny + 2) / 2;
722 length +=
ny / 2 + 2 *
nx;
725 length +=
nx / 2 *
ny;
751 if (node->
level != 0) {
752 for (child_idx = 0; child_idx < node->
num_inputs; child_idx++) {
777 for (rr_node_idx = 0; rr_node_idx <
num_rr_nodes; rr_node_idx++) {
784 for (net_idx = 0; net_idx <
num_nets; net_idx++) {
787 for (trace =
trace_head[net_idx]; trace != NULL; trace = trace->
next) {
793 for (net_idx = 0; net_idx <
num_nets; net_idx++) {
796 for (trace =
trace_head[net_idx]; trace != NULL; trace = trace->
next) {
806 for (edge_idx = 0; edge_idx < node->
num_edges; edge_idx++) {
812 switch (next_node->
type) {
826 printf(
"%d %d\n", next_node_power->
num_inputs,
843 for (rr_node_idx = 0; rr_node_idx <
num_rr_nodes; rr_node_idx++) {
850 int connectionbox_fanout;
851 int switchbox_fanout;
855 switch (node->
type) {
894 wire_length = node->
xhigh - node->
xlow + 1;
896 wire_length = node->
yhigh - node->
ylow + 1;
931 buffer_size =
max(buffer_size, 1.0F);
969 connectionbox_fanout = 0;
970 switchbox_fanout = 0;
971 for (switch_idx = 0; switch_idx < node->
num_edges; switch_idx++) {
974 connectionbox_fanout++;
975 }
else if (node->
switches[switch_idx]
984 if (switchbox_fanout) {
997 if (connectionbox_fanout) {
1000 connectionbox_fanout
1020 "The global routing-resource graph contains an unknown node type.");
1133 for (type_idx = 0; type_idx <
num_types; type_idx++) {
1145 int max_seg_to_IPIN_fanout;
1146 int max_seg_to_seg_fanout;
1150 for (net_idx = 0; net_idx <
num_nets; net_idx++) {
1151 if (!
clb_net[net_idx].net_power) {
1163 for (rr_node_idx = 0; rr_node_idx <
num_rr_nodes; rr_node_idx++) {
1171 max_seg_to_seg_fanout = 0;
1172 max_seg_to_IPIN_fanout = 0;
1173 for (rr_node_idx = 0; rr_node_idx <
num_rr_nodes; rr_node_idx++) {
1175 int fanout_to_IPIN = 0;
1176 int fanout_to_seg = 0;
1180 switch (node->
type) {
1182 max_IPIN_fanin =
max(max_IPIN_fanin,
1183 static_cast<int>(node->
fan_in));
1184 max_fanin =
max(max_fanin, static_cast<int>(node->
fan_in));
1193 for (switch_idx = 0; switch_idx < node->
num_edges; switch_idx++) {
1197 }
else if (node->
switches[switch_idx]
1202 max_seg_to_IPIN_fanout =
max(max_seg_to_IPIN_fanout,
1204 max_seg_to_seg_fanout =
max(max_seg_to_seg_fanout, fanout_to_seg);
1205 max_fanin =
max(max_fanin, static_cast<int>(node->
fan_in));
1222 #if (PRINT_SPICE_COMPARISON)
1228 for (rr_node_idx = 0; rr_node_idx <
num_rr_nodes; rr_node_idx++) {
1232 for (edge_idx = 0; edge_idx < node->
num_edges; edge_idx++) {
1249 for (rr_node_idx = 0; rr_node_idx <
num_rr_nodes; rr_node_idx++) {
1252 switch (node->
type) {
1271 char * cmos_tech_behavior_filepath,
t_arch * arch,
1273 boolean error =
FALSE;
1331 boolean error =
FALSE;
1333 for (rr_node_idx = 0; rr_node_idx <
num_rr_nodes; rr_node_idx++) {
1337 switch (node->
type) {
1354 for (std::map<float, t_power_mux_info*>::iterator it =
1389 static void power_print_pb_usage_recursive(FILE * fp,
t_pb_type * type,
1390 int indent_level,
float parent_power,
float total_power) {
1395 float pb_type_power;
1402 "<pb_type name=\"%s\" P=\"%.4g\" P_parent=\"%.3g\" P_total=\"%.3g\" P_dyn=\"%.3g\" >\n",
1403 type->
name, pb_type_power, pb_type_power / parent_power * 100,
1404 pb_type_power / total_power * 100,
1412 for (mode_idx = 0; mode_idx < type->
num_modes; mode_idx++) {
1420 "<mode name=\"%s\" P=\"%.4g\" P_parent=\"%.3g\" P_total=\"%.3g\" P_dyn=\"%.3g\">\n",
1422 mode_power / pb_type_power * 100,
1423 mode_power / total_power * 100,
1431 float interc_total_power;
1434 for (interc_idx = 0;
1440 interc_total_power = interc_power_usage.
dynamic
1444 print_tabs(fp, indent_level + mode_indent + 1);
1446 "<interconnect P=\"%.4g\" P_parent=\"%.3g\" P_total=\"%.3g\" P_dyn=\"%.3g\">\n",
1447 interc_total_power, interc_total_power / mode_power * 100,
1448 interc_total_power / total_power * 100,
1449 interc_power_usage.
dynamic / interc_total_power);
1450 for (interc_idx = 0;
1453 float interc_power =
1457 print_tabs(fp, indent_level + mode_indent + 2);
1459 "<%s name=\"%s\" P=\"%.4g\" P_parent=\"%.3g\" P_total=\"%.3g\" P_dyn=\"%.3g\"/>\n",
1463 interc_power, interc_power / interc_total_power * 100,
1464 interc_power / total_power * 100,
1468 print_tabs(fp, indent_level + mode_indent + 1);
1469 fprintf(fp,
"</interconnect>\n");
1475 power_print_pb_usage_recursive(fp,
1477 indent_level + mode_indent + 1,
1485 fprintf(fp,
"</mode>\n");
1490 fprintf(fp,
"</pb_type>\n");
1493 static void power_print_clb_detailed(FILE * fp) {
1498 for (type_idx = 0; type_idx <
num_types; type_idx++) {
1504 0, clb_power_total, clb_power_total);
1537 switch (power_method) {
1543 return "Transistor Auto-Size";
1545 return "Transistor Specify-Size";
1547 return "Pin-Toggle";
1549 return "C-Internal";
1553 return "Sum of Children";
1574 for (i = 0; i < indent; i++) {
1577 strncpy(buf + indent, pb_type->
name, 50 - indent);
1579 buf[strlen((pb_type->
name)) + indent] =
'\0';
1597 child_indent = indent + 2;
1599 child_indent = indent + 1;
1602 for (mode_idx = 0; mode_idx < pb_type->
num_modes; mode_idx++) {
1603 mode = &pb_type->
modes[mode_idx];
1670 arch = arch_new + 1;
1674 arch = arch_new + 1;
1679 fprintf(fp,
"Technology (nm): %.0f\n",
1684 fprintf(fp,
"Size of FPGA: %d x %d\n",
nx,
ny);
1709 "Cannot calculate routing power for bi-directional architectures");
1752 *run_time_s = (float) (t_end - t_start) / CLOCKS_PER_SEC;
1777 "This sections provides a detailed breakdown of power usage by PB (physical\n"
1778 "block). For each PB, the power is listed, which is the sum power of all\n"
1779 "instances of the block. It also indicates its percentage of total power (entire\n"
1780 "FPGA), as well as the percentage of its power that is dynamic (vs. static). It\n"
1781 "also indicates the method used for power estimation.\n\n"
1782 "The data includes:\n"
1783 "\tModes:\t\tWhen a pb contains multiple modes, each mode is "
1784 "listed, with\n\t\t\t\tits power statistics.\n"
1785 "\tBufs/Wires:\tPower of all local "
1786 "buffers and local wire switching\n"
1787 "\t\t\t\t(transistor-level estimation only).\n"
1788 "\tInterc:\t\tPower of local interconnect multiplexers (transistor-\n"
1789 "\t\t\t\tlevel estimation only)\n\n"
1790 "Description of Estimation Methods:\n"
1791 "\tTransistor Auto-Size: Transistor-level power estimation. Local buffers and\n"
1792 "\t\twire lengths are automatically sized. This is the default estimation\n"
1794 "\tTransistor Specify-Size: Transistor-level power estimation. Local buffers\n"
1795 "\t\tand wire lengths are only inserted where specified by the user in the\n"
1796 "\t\tarchitecture file.\n"
1797 "\tPin-Toggle: Dynamic power is calculated using enery-per-toggle of the PB\n"
1798 "\t\tinput pins. Static power is absolute.\n"
1799 "\tC-Internal: Dynamic power is calculated using an internal equivalent\n"
1800 "\t\tcapacitance for PB type. Static power is absolute.\n"
1801 "\tAbsolute: Dynamic and static power are absolutes from the architecture file.\n"
1802 "\tSum of Children: Power of PB is only the sum of all child PBs; interconnect\n"
1803 "\t\tbetween the PB and its children is ignored.\n"
1804 "\tIgnore: Power of PB is ignored.\n\n\n");
1809 for (
int type_idx = 0; type_idx <
num_types; type_idx++) {
1872 float total_power,
float perc_dyn,
char * method) {
1873 const int buf_size = 32;
1878 fprintf(fp,
"%-*s%-12s%-12s%-12s%-12s\n\n", buf_size,
"Component",
1879 "Power (W)",
"%-Total",
"%-Dynamic",
"Method");
1882 for (
int i = 0; i < indent; i++)
1884 strcpy(buf + indent,
"Mode:");
1885 strncpy(buf + indent + 5, name, buf_size - indent - 6);
1886 fprintf(fp,
"%-*s%-12.4g%-12.4g%-12.4g\n", buf_size, buf, power,
1887 power / total_power, perc_dyn);
1892 for (
int i = 0; i < indent; i++)
1894 strncpy(buf + indent, name, buf_size - indent - 1);
1895 buf[buf_size - 1] =
'\0';
1897 fprintf(fp,
"%-*s%-12.4g%-12.4g%-12.4g\n", buf_size, buf, power,
1898 power / total_power, perc_dyn);
1901 for (
int i = 0; i < indent; i++)
1903 strncpy(buf + indent, name, buf_size - indent - 1);
1904 buf[buf_size - 1] =
'\0';
1906 fprintf(fp,
"%-*s%-12.4g%-12.4g%-12.4g%-12s\n", buf_size, buf, power,
1907 power / total_power, perc_dyn, method);
void power_usage_wire(t_power_usage *power_usage, float capacitance, float density, float period)
static void power_usage_blocks(t_power_usage *power_usage)
static char * power_estimation_method_name(e_power_estimation_method power_method)
struct s_net_power t_net_power
static void dealloc_mux_graph_rec(t_mux_node *node)
t_clock_network * clock_inf
t_interconnect * interconnect
t_pb_graph_pin ** clock_pins
t_power_tech * g_power_tech
enum e_pb_type_class class_type
t_power_arch * g_power_arch
FILE * my_fopen(const char *fname, const char *flag, int prompt)
t_port_power * port_power
void power_callibrate(void)
float total_cb_buffer_size
void power_usage_mux_multilevel(t_power_usage *power_usage, t_mux_arch *mux_arch, float *in_prob, float *in_dens, int selected_input, boolean output_level_restored, float period)
struct s_pb_type * pb_type_children
void power_print_title(FILE *fp, char *title)
enum e_power_estimation_method_ e_power_estimation_method
boolean power_method_is_recursive(e_power_estimation_method method)
float power_component_get_usage_sum(e_power_component_type component_idx)
e_power_estimation_method estimation_method
float clb_net_prob(int net_idx)
int * clb_to_vpack_net_mapping
static void power_usage_routing(t_power_usage *power_usage, t_det_routing_arch *routing_arch, t_segment_inf *segment_inf)
t_rr_indexed_data * rr_indexed_data
t_power_usage power_usage
static void power_print_breakdown_component(FILE *fp, char *name, e_power_component_type type, int indent_level)
float power_buffer_size_from_logical_effort(float C_load)
struct s_power_commonly_used t_power_commonly_used
boolean power_init(char *power_out_filepath, char *cmos_tech_behavior_filepath, t_arch *arch, t_det_routing_arch *routing_arch)
t_power_commonly_used * g_power_commonly_used
void power_routing_init(t_det_routing_arch *routing_arch)
float power_calc_node_switching(float capacitance, float density, float period)
void power_usage_local_interc_mux(t_power_usage *power_usage, t_pb *pb, t_interconnect_pins *interc_pins)
static void power_print_breakdown_pb(FILE *fp)
void power_usage_ff(t_power_usage *power_usage, float size, float D_prob, float D_dens, float Q_prob, float Q_dens, float clk_prob, float clk_dens, float period)
void * my_calloc(size_t nelem, size_t size)
t_pb_type_power * pb_type_power
static void power_print_breakdown_pb_rec(FILE *fp, t_pb_type *pb_type, int indent)
void power_sizing_init(t_arch *arch)
void power_lowlevel_init()
t_clock_arch * g_clock_arch
e_power_breakdown_entry_type
struct s_linked_vptr * truth_table
char * alloc_SRAM_values_from_truth_table(int LUT_size, t_linked_vptr *truth_table)
t_pb_graph_pin ** output_pins
static void power_print_summary(FILE *fp, t_vpr_setup vpr_setup)
std::map< float, t_power_mux_info * > mux_info
t_pb_graph_pin * scaled_by_pin
struct s_file_name_opts FileNameOpts
char * interconnect_type_name(enum e_interconnect type)
boolean power_uninit(void)
t_power_output * g_power_output
t_solution_inf g_solution_inf
t_power_usage absolute_power_per_instance
t_mux_arch * power_get_mux_arch(int num_mux_inputs, float transistor_size)
int max_seg_to_IPIN_fanout
boolean power_method_is_transistor_level(e_power_estimation_method estimation_method)
static t_rr_node_power * rr_node_power
void power_components_init(void)
int max_seg_to_seg_fanout
float pin_prob(t_pb *pb, t_pb_graph_pin *pin)
void power_add_usage(t_power_usage *dest, const t_power_usage *src)
static void * my_malloc(int ibytes)
void power_alloc_and_init_pb_pin(t_pb_graph_pin *pin)
enum e_directionality directionality
static void power_usage_clock_single(t_power_usage *power_usage, t_clock_network *clock_inf)
void power_tech_init(char *cmos_tech_behavior_filepath)
struct s_pb_graph_node * parent_node
struct s_trace ** trace_head
void power_zero_usage(t_power_usage *power_usage)
struct s_switch_inf * switch_inf
static void power_print_breakdown_summary(FILE *fp)
struct s_pb_graph_node *** child_pb_graph_nodes
int scaled_by_port_pin_idx
float total_sb_buffer_size
static void power_reset_tile_usage(void)
struct s_grid_tile ** grid
static void power_reset_pb_type(t_pb_type *pb_type)
float pin_dens(t_pb *pb, t_pb_graph_pin *pin)
void power_component_add_usage(t_power_usage *power_usage, e_power_component_type component_idx)
float LUT_transistor_size
void power_usage_lut(t_power_usage *power_usage, int lut_size, float transistor_size, char *SRAM_values, float *input_prob, float *input_dens, float period)
struct s_pb_type * pb_type
void power_usage_local_pin_toggle(t_power_usage *power_usage, t_pb *pb, t_pb_graph_pin *pin)
float clb_net_density(int net_idx)
struct s_pb_type * pb_type
float power_sum_usage(t_power_usage *power_usage)
static void power_usage_local_buffers_and_wires(t_power_usage *power_usage, t_pb *pb, t_pb_graph_node *pb_node)
float power_calc_buffer_size_from_Cout(float C_out)
static void power_usage_pb(t_power_usage *power_usage, t_pb *pb, t_pb_graph_node *pb_node)
static void power_usage_primitive(t_power_usage *power_usage, t_pb *pb, t_pb_graph_node *pb_graph_node)
void power_pb_pins_init()
float power_perc_dynamic(t_power_usage *power_usage)
static void power_print_breakdown_entry(FILE *fp, int indent, e_power_breakdown_entry_type type, char *name, float power, float total_power, float perc_dyn, char *method)
struct s_type_descriptor * type_descriptors
e_power_buffer_type power_buffer_type
static void print_tabs(FILE *fpout, int num_tabs)
t_power_usage power_usage
t_mux_node * mux_graph_head
t_power_usage power_usage
void power_usage_buffer(t_power_usage *power_usage, float size, float in_prob, float in_dens, boolean level_restorer, float period)
t_power_components g_power_by_component
t_power_usage power_usage_bufs_wires
char * my_strdup(const char *str)
t_mode_power * mode_power
float mux_transistor_size
void power_init_pb_pins_rec(t_pb_graph_node *pb_node)
short wire_to_ipin_switch
static void dealloc_mux_graph(t_mux_node *node)
t_interconnect_power * interconnect_power
static void power_usage_clock(t_power_usage *power_usage, t_clock_arch *clock_arch)
void power_usage_local_pin_buffer_and_wire(t_power_usage *power_usage, t_pb *pb, t_pb_graph_pin *pin)
t_pb_graph_pin_power * pin_power
t_pb_graph_pin ** input_pins
struct s_logical_block * logical_block
t_interconnect_pins ** interconnect_pins
e_power_ret_code power_total(float *run_time_s, t_vpr_setup vpr_setup, t_arch *arch, t_det_routing_arch *routing_arch)
void power_log_msg(e_power_log_type log_type, char *msg)
t_power_usage * components
void output_logs(FILE *fp, t_log *logs, int num_logs)
void power_usage_inverter(t_power_usage *power_usage, float in_dens, float in_prob, float size, float period)