38 int num_inputs,
float transistor_size);
40 int num_primary_inputs,
int level,
int starting_pin_idx);
55 power_usage->
dynamic *= scale_factor;
56 power_usage->
leakage *= scale_factor;
74 }
else if (type ==
PMOS) {
88 if (net_num !=
OPEN) {
104 if (net_num !=
OPEN) {
120 int selected_input_pin) {
121 if (mux_node->
level == 0) {
123 && (selected_input_pin
125 selector_values[mux_node->
level] = selected_input_pin
131 for (input_idx = 0; input_idx < mux_node->
num_inputs; input_idx++) {
133 &mux_node->
children[input_idx], selected_input_pin)) {
134 selector_values[mux_node->
level] = input_idx;
146 for (msg_idx = 0; msg_idx < log_ptr->
num_messages; msg_idx++) {
147 if (strcmp(log_ptr->
messages[msg_idx], msg) == 0) {
162 const char * full_msg =
"\n***LOG IS FULL***\n";
164 strlen(full_msg) + 1,
sizeof(char));
169 strlen(msg) + 1,
sizeof(char));
180 float desired_stage_effort) {
183 if (final_stage_size <= 1.0) {
185 }
else if (final_stage_size < desired_stage_effort)
188 N = (int) (log(final_stage_size) / log(desired_stage_effort) + 1);
206 return pow((
double) final_stage_size, (1.0 / ((
double) N - 1)));
212 void integer_to_SRAMvalues(
int SRAM_num,
int input_integer,
char SRAM_values[]) {
214 int binary_str_counter;
218 binary_str_counter = 0;
220 local_integer = input_integer;
222 while (local_integer > 0) {
223 if (local_integer % 2 == 0) {
224 SRAM_values[binary_str_counter++] =
'0';
226 SRAM_values[binary_str_counter++] =
'1';
228 local_integer = local_integer / 2;
231 while (binary_str_counter < SRAM_num) {
232 SRAM_values[binary_str_counter++] =
'0';
235 SRAM_values[binary_str_counter] =
'\0';
237 for (i = 0; i < binary_str_counter; i++) {
238 binary_str[i] = SRAM_values[binary_str_counter - 1 - i];
241 binary_str[binary_str_counter] =
'\0';
256 binary_str[str_length] =
'\0';
258 for (i = str_length - 1; i >= 0; i--, value >>= 1) {
287 int dont_care_start_pos;
289 num_SRAM_bits = 1 << LUT_size;
290 SRAM_values = (
char*)
my_calloc(num_SRAM_bits + 1,
sizeof(
char));
291 SRAM_values[num_SRAM_bits] =
'\0';
294 for (i = 0; i < num_SRAM_bits; i++) {
295 SRAM_values[i] =
'1';
300 binary_str = (
char*)
my_calloc(LUT_size + 1,
sizeof(
char));
301 buffer = (
char*)
my_calloc(LUT_size + 10,
sizeof(
char));
303 strcpy(buffer, (
char*) truth_table->
data_vptr);
308 if (strcmp(buffer,
" 0") == 0) {
312 }
else if (strcmp(buffer,
" 1") == 0) {
313 for (i = 0; i < num_SRAM_bits; i++) {
314 SRAM_values[i] =
'1';
322 str_loc = strtok(buffer,
" \t");
323 dont_care_start_pos = strlen(str_loc);
326 str_loc = strtok(NULL,
" \t");
328 if (str_loc[0] ==
'1') {
329 }
else if (str_loc[0] ==
'0') {
337 for (list_ptr = truth_table; list_ptr != NULL; list_ptr = list_ptr->
next) {
340 terms = (
char**)
my_calloc(num_terms,
sizeof(
char *));
343 for (list_ptr = truth_table, term_idx = 0; list_ptr != NULL; list_ptr =
344 list_ptr->
next, term_idx++) {
345 terms[term_idx] = (
char*)
my_calloc(LUT_size + 1,
sizeof(
char));
347 strcpy(buffer, (
char*) list_ptr->
data_vptr);
348 str_loc = strtok(buffer,
" \t");
349 strcpy(terms[term_idx], str_loc);
352 for (bit_idx = dont_care_start_pos; bit_idx < LUT_size; bit_idx++) {
353 terms[term_idx][bit_idx] =
'-';
357 str_loc = strtok(NULL,
" \t");
359 assert(str_loc[0] ==
'1');
361 assert(str_loc[0] ==
'0');
366 for (i = 0; i < num_SRAM_bits; i++) {
369 SRAM_values[i] =
'0';
371 SRAM_values[i] =
'1';
378 for (term_idx = 0; term_idx < num_terms; term_idx++) {
381 for (bit_idx = 0; bit_idx < LUT_size; bit_idx++) {
382 if ((terms[term_idx][bit_idx] !=
'-')
383 && (terms[term_idx][bit_idx] != binary_str[bit_idx])) {
391 SRAM_values[i] =
'1';
393 SRAM_values[i] =
'0';
404 for (term_idx = 0; term_idx < num_terms; term_idx++) {
405 free(terms[term_idx]);
415 && (mux_arch->
levels > 1)) {
421 if (net_idx ==
OPEN) {
429 if (net_idx ==
OPEN) {
452 for (msg_idx = 0; msg_idx < log_ptr->
num_messages; msg_idx++) {
453 fprintf(fp,
"%s\n", log_ptr->
messages[msg_idx]);
460 for (log_idx = 0; log_idx < num_logs; log_idx++) {
461 if (logs[log_idx].num_messages) {
477 const int width = 80;
479 int firsthalf = (width - strlen(title) - 2) / 2;
480 int secondhalf = width - strlen(title) - 2 - firsthalf;
482 for (i = 1; i <= firsthalf; i++)
484 fprintf(fp,
" %s ", title);
485 for (i = 1; i <= secondhalf; i++)
496 std::map<float, t_power_mux_info*>::iterator it;
506 mux_info = it->second;
519 return &mux_info->
mux_arch[num_mux_inputs];
526 int num_inputs,
float transistor_size) {
528 mux_arch->
levels = levels;
552 int num_primary_inputs,
int level,
int starting_pin_idx) {
554 int pin_idx = starting_pin_idx;
556 node->
num_inputs = (int) (pow(num_primary_inputs, 1 / ((
float) level + 1))
564 for (child_idx = 0; child_idx < node->
num_inputs; child_idx++) {
565 int num_child_pi = num_primary_inputs / node->
num_inputs;
566 if (child_idx < (num_primary_inputs % node->
num_inputs)) {
570 num_child_pi, level - 1, pin_idx);
571 pin_idx += num_child_pi;
578 switch (estimation_method) {
t_power_arch * g_power_arch
static void alloc_and_load_mux_graph_recursive(t_mux_node *node, int num_primary_inputs, int level, int starting_pin_idx)
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 clb_net_prob(int net_idx)
struct s_rr_node * rr_graph
static void log_msg(t_log *log_ptr, char *msg)
float logical_effort_factor
float power_buffer_size_from_logical_effort(float C_load)
static void int_2_binary_str(char *binary_str, int value, int str_length)
t_power_commonly_used * g_power_commonly_used
void * my_calloc(size_t nelem, size_t size)
int power_calc_buffer_num_stages(float final_stage_size, float desired_stage_effort)
struct s_mux_arch t_mux_arch
char * alloc_SRAM_values_from_truth_table(int LUT_size, t_linked_vptr *truth_table)
std::map< float, t_power_mux_info * > mux_info
char * interconnect_type_name(enum e_interconnect type)
t_power_output * g_power_output
t_mux_arch * power_get_mux_arch(int num_mux_inputs, float transistor_size)
boolean power_method_is_transistor_level(e_power_estimation_method estimation_method)
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)
static t_mux_node * alloc_and_load_mux_graph(int num_inputs, int levels)
void power_zero_usage(t_power_usage *power_usage)
struct s_linked_vptr * next
void output_log(t_log *log_ptr, FILE *fp)
float pin_dens(t_pb *pb, t_pb_graph_pin *pin)
void mux_arch_fix_levels(t_mux_arch *mux_arch)
float clb_net_density(int net_idx)
float power_sum_usage(t_power_usage *power_usage)
static void * my_realloc(void *memblk, int ibytes)
struct s_power_mux_info t_power_mux_info
static void init_mux_arch_default(t_mux_arch *mux_arch, int levels, int num_inputs, float transistor_size)
float power_perc_dynamic(t_power_usage *power_usage)
void power_scale_usage(t_power_usage *power_usage, float scale_factor)
boolean mux_find_selector_values(int *selector_values, t_mux_node *mux_node, int selected_input_pin)
t_mux_node * mux_graph_head
char * transistor_type_name(e_tx_type type)
static const char * match(const struct slre *, int, const char *, int, int *, struct cap *)
float calc_buffer_stage_effort(int N, float final_stage_size)
void power_log_msg(e_power_log_type log_type, char *msg)
void output_logs(FILE *fp, t_log *logs, int num_logs)