VPR-7.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
power_callibrate.h File Reference
#include "power.h"
+ Include dependency graph for power_callibrate.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  e_power_callib_component {
  POWER_CALLIB_COMPONENT_BUFFER = 0, POWER_CALLIB_COMPONENT_BUFFER_WITH_LEVR, POWER_CALLIB_COMPONENT_FF, POWER_CALLIB_COMPONENT_MUX,
  POWER_CALLIB_COMPONENT_LUT, POWER_CALLIB_COMPONENT_MAX
}
 

Functions

void power_print_spice_comparison (void)
 
void power_callibrate (void)
 
float power_usage_buf_for_callibration (int num_inputs, float transistor_size)
 
float power_usage_buf_levr_for_callibration (int num_inputs, float transistor_size)
 
float power_usage_mux_for_callibration (int num_inputs, float transistor_size)
 
float power_usage_lut_for_callibration (int num_inputs, float transistor_size)
 
float power_usage_ff_for_callibration (int num_inputs, float transistor_size)
 

Variables

const float power_callib_period = 5e-9
 

Enumeration Type Documentation

Enumerator
POWER_CALLIB_COMPONENT_BUFFER 
POWER_CALLIB_COMPONENT_BUFFER_WITH_LEVR 
POWER_CALLIB_COMPONENT_FF 
POWER_CALLIB_COMPONENT_MUX 
POWER_CALLIB_COMPONENT_LUT 
POWER_CALLIB_COMPONENT_MAX 

Definition at line 33 of file power_callibrate.h.

Function Documentation

void power_print_spice_comparison ( void  )

Definition at line 40 of file power_callibrate.c.

40  {
41 //
42  t_power_usage sub_power_usage;
43 //
44 // float inv_sizes[5] = { 1, 8, 16, 32, 64 };
45 //
46 // float buffer_sizes[3] = { 16, 25, 64 };
47 //
48  unsigned int LUT_sizes[3] = { 6 };
49 //
50 // float sb_buffer_sizes[6] = { 9, 9, 16, 16, 25, 25 };
51 // unsigned int sb_mux_sizes[6] = { 4, 8, 12, 16, 20, 25 };
52 //
53 // unsigned int mux_sizes[5] = { 4, 8, 12, 16, 20 };
54 //
55  unsigned int i, j;
56  float * dens = NULL;
57  float * prob = NULL;
58  char * SRAM_bits = NULL;
59  int sram_idx;
60 //
61  g_solution_inf.T_crit = 1.0e-8;
62 //
63 //
64 // fprintf(g_power_output->out, "Energy of INV (High Activity)\n");
65 // for (i = 0; i < (sizeof(inv_sizes) / sizeof(float)); i++) {
66 // power_usage_inverter(&sub_power_usage, 2, 0.5, inv_sizes[i],
67 // power_callib_period);
68 // fprintf(g_power_output->out, "%g\t%g\n", inv_sizes[i],
69 // (sub_power_usage.dynamic + sub_power_usage.leakage)
70 // * g_solution_inf.T_crit);
71 // }
72 //
73 // fprintf(g_power_output->out, "Energy of INV (No Activity)\n");
74 // for (i = 0; i < (sizeof(inv_sizes) / sizeof(float)); i++) {
75 // power_usage_inverter(&sub_power_usage, 0, 1, inv_sizes[i],
76 // power_callib_period);
77 // fprintf(g_power_output->out, "%g\t%g\n", inv_sizes[i],
78 // (sub_power_usage.dynamic + sub_power_usage.leakage)
79 // * g_solution_inf.T_crit);
80 // }
81 // }
82 //
83 // fprintf(g_power_output->out, "Energy of Mux (High Activity)\n");
84 // for (i = 0; i < (sizeof(mux_sizes) / sizeof(int)); i++) {
85 // t_power_usage mux_power_usage;
86 //
87 // power_zero_usage(&mux_power_usage);
88 //
89 // dens = (float*) my_realloc(dens, mux_sizes[i] * sizeof(float));
90 // prob = (float*) my_realloc(prob, mux_sizes[i] * sizeof(float));
91 // for (j = 0; j < mux_sizes[i]; j++) {
92 // dens[j] = 2;
93 // prob[j] = 0.5;
94 // }
95 // power_usage_mux_multilevel(&mux_power_usage,
96 // power_get_mux_arch(mux_sizes[i]), prob, dens, 0, FALSE,
97 // power_callib_period);
98 // fprintf(g_power_output->out, "%d\t%g\n", mux_sizes[i],
99 // (mux_power_usage.dynamic + mux_power_usage.leakage)
100 // * g_solution_inf.T_crit);
101 // }
102 //
103 // fprintf(g_power_output->out, "Energy of Mux (No Activity)\n");
104 // for (i = 0; i < (sizeof(mux_sizes) / sizeof(int)); i++) {
105 // t_power_usage mux_power_usage;
106 //
107 // power_zero_usage(&mux_power_usage);
108 //
109 // dens = (float*) my_realloc(dens, mux_sizes[i] * sizeof(float));
110 // prob = (float*) my_realloc(prob, mux_sizes[i] * sizeof(float));
111 // for (j = 0; j < mux_sizes[i]; j++) {
112 // if (j == 0) {
113 // dens[j] = 0;
114 // prob[j] = 1;
115 // } else {
116 // dens[j] = 0;
117 // prob[j] = 0;
118 // }
119 // }
120 // power_usage_mux_multilevel(&mux_power_usage,
121 // power_get_mux_arch(mux_sizes[i]), prob, dens, 0, FALSE,
122 // power_callib_period);
123 // fprintf(g_power_output->out, "%d\t%g\n", mux_sizes[i],
124 // (mux_power_usage.dynamic + mux_power_usage.leakage)
125 // * g_solution_inf.T_crit);
126 // }
127 //
128 // fprintf(g_power_output->out, "Energy of Buffer (High Activity)\n");
129 // for (i = 0; i < (sizeof(buffer_sizes) / sizeof(float)); i++) {
130 // power_usage_buffer(&sub_power_usage, buffer_sizes[i], 0.5, 2, FALSE,
131 // power_callib_period);
132 // fprintf(g_power_output->out, "%g\t%g\n", buffer_sizes[i],
133 // (sub_power_usage.dynamic + sub_power_usage.leakage)
134 // * g_solution_inf.T_crit);
135 // }
136 //
137 // fprintf(g_power_output->out, "Energy of Buffer (No Activity)\n");
138 // for (i = 0; i < (sizeof(buffer_sizes) / sizeof(float)); i++) {
139 // power_usage_buffer(&sub_power_usage, buffer_sizes[i], 1, 0, FALSE,
140 // power_callib_period);
141 // fprintf(g_power_output->out, "%g\t%g\n", buffer_sizes[i],
142 // (sub_power_usage.dynamic + sub_power_usage.leakage)
143 // * g_solution_inf.T_crit);
144 // }
145 //
146  fprintf(g_power_output->out, "Energy of LUT (High Activity)\n");
147  for (i = 0; i < (sizeof(LUT_sizes) / sizeof(int)); i++) {
148  for (j = 1; j <= LUT_sizes[i]; j++) {
149  SRAM_bits = (char*) my_realloc(SRAM_bits,
150  ((1 << j) + 1) * sizeof(char));
151  if (j == 1) {
152  SRAM_bits[0] = '1';
153  SRAM_bits[1] = '0';
154  } else {
155  for (sram_idx = 0; sram_idx < (1 << (j - 1)); sram_idx++) {
156  SRAM_bits[sram_idx + (1 << (j - 1))] = binary_not(
157  SRAM_bits[sram_idx]);
158  }
159  }
160  SRAM_bits[1 << j] = '\0';
161  }
162 
163  dens = (float*) my_realloc(dens, LUT_sizes[i] * sizeof(float));
164  prob = (float*) my_realloc(prob, LUT_sizes[i] * sizeof(float));
165  for (j = 0; j < LUT_sizes[i]; j++) {
166  dens[j] = 1.0 / (float) LUT_sizes[i];
167  prob[j] = 0.5;
168  }
169  power_usage_lut(&sub_power_usage, LUT_sizes[i], 1.0, SRAM_bits, prob,
170  dens, power_callib_period);
171 
172  t_power_usage power_usage_mux;
173 
174  float p[6] = { 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 };
175  float d[6] = { 1, 1, 1, 1, 1, 1 };
176  power_usage_mux_multilevel(&power_usage_mux, power_get_mux_arch(6, 1.0),
177  p, d, 0, TRUE, g_solution_inf.T_crit);
178 
179  power_add_usage(&sub_power_usage, &power_usage_mux);
180 
181  fprintf(g_power_output->out, "%d\t%g\n", LUT_sizes[i],
182  power_sum_usage(&sub_power_usage));
183  }
184 //
185 // fprintf(g_power_output->out, "Energy of LUT (No Activity)\n");
186 // for (i = 0; i < (sizeof(LUT_sizes) / sizeof(int)); i++) {
187 // for (j = 1; j <= LUT_sizes[i]; j++) {
188 // SRAM_bits = (char*) my_realloc(SRAM_bits,
189 // ((1 << j) + 1) * sizeof(char));
190 // if (j == 1) {
191 // SRAM_bits[0] = '1';
192 // SRAM_bits[1] = '0';
193 // } else {
194 // for (sram_idx = 0; sram_idx < (1 << (j - 1)); sram_idx++) {
195 // SRAM_bits[sram_idx + (1 << (j - 1))] = binary_not(
196 // SRAM_bits[sram_idx]);
197 // }
198 // }
199 // SRAM_bits[1 << j] = '\0';
200 // }
201 //
202 // dens = (float*) my_realloc(dens, LUT_sizes[i] * sizeof(float));
203 // prob = (float*) my_realloc(prob, LUT_sizes[i] * sizeof(float));
204 // for (j = 0; j < LUT_sizes[i]; j++) {
205 // dens[j] = 0;
206 // prob[j] = 1;
207 // }
208 // power_usage_lut(&sub_power_usage, LUT_sizes[i], SRAM_bits, prob, dens,
209 // power_callib_period);
210 // fprintf(g_power_output->out, "%d\t%g\n", LUT_sizes[i],
211 // (sub_power_usage.dynamic + sub_power_usage.leakage)
212 // * g_solution_inf.T_crit * 2);
213 // }
214 //
215  fprintf(g_power_output->out, "Energy of FF (High Activity)\n");
216  power_usage_ff(&sub_power_usage, 1.0, 0.5, 3, 0.5, 1, 0.5, 2,
218  fprintf(g_power_output->out, "%g\n",
219  (sub_power_usage.dynamic + sub_power_usage.leakage));
220 //
221 // fprintf(g_power_output->out, "Energy of FF (No Activity)\n");
222 // power_usage_ff(&sub_power_usage, 1, 0, 1, 0, 1, 0, power_callib_period);
223 // fprintf(g_power_output->out, "%g\n",
224 // (sub_power_usage.dynamic + sub_power_usage.leakage)
225 // * g_solution_inf.T_crit * 2);
226 //
227 // fprintf(g_power_output->out, "Energy of SB (High Activity)\n");
228 // for (i = 0; i < (sizeof(sb_buffer_sizes) / sizeof(float)); i++) {
229 // t_power_usage sb_power_usage;
230 //
231 // power_zero_usage(&sb_power_usage);
232 //
233 // dens = (float*) my_realloc(dens, sb_mux_sizes[i] * sizeof(float));
234 // prob = (float*) my_realloc(prob, sb_mux_sizes[i] * sizeof(float));
235 // for (j = 0; j < sb_mux_sizes[i]; j++) {
236 // dens[j] = 2;
237 // prob[j] = 0.5;
238 // }
239 //
240 // power_usage_mux_multilevel(&sub_power_usage,
241 // power_get_mux_arch(sb_mux_sizes[i]), prob, dens, 0, TRUE,
242 // power_callib_period);
243 // power_add_usage(&sb_power_usage, &sub_power_usage);
244 //
245 // power_usage_buffer(&sub_power_usage, sb_buffer_sizes[i], 0.5, 2, TRUE,
246 // power_callib_period);
247 // power_add_usage(&sb_power_usage, &sub_power_usage);
248 //
249 // fprintf(g_power_output->out, "%d\t%.0f\t%g\n", sb_mux_sizes[i],
250 // sb_buffer_sizes[i],
251 // (sb_power_usage.dynamic + sb_power_usage.leakage)
252 // * g_solution_inf.T_crit);
253 // }
254 //
255 // fprintf(g_power_output->out, "Energy of SB (No Activity)\n");
256 // for (i = 0; i < (sizeof(sb_buffer_sizes) / sizeof(float)); i++) {
257 // t_power_usage sb_power_usage;
258 //
259 // power_zero_usage(&sb_power_usage);
260 //
261 // dens = (float*) my_realloc(dens, sb_mux_sizes[i] * sizeof(float));
262 // prob = (float*) my_realloc(prob, sb_mux_sizes[i] * sizeof(float));
263 // for (j = 0; j < sb_mux_sizes[i]; j++) {
264 // if (j == 0) {
265 // dens[j] = 0;
266 // prob[j] = 1;
267 // } else {
268 // dens[j] = 0;
269 // prob[j] = 0;
270 // }
271 // }
272 //
273 // power_usage_mux_multilevel(&sub_power_usage,
274 // power_get_mux_arch(sb_mux_sizes[i]), prob, dens, 0, TRUE,
275 // power_callib_period);
276 // power_add_usage(&sb_power_usage, &sub_power_usage);
277 //
278 // power_usage_buffer(&sub_power_usage, sb_buffer_sizes[i], 1, 0, TRUE,
279 // power_callib_period);
280 // power_add_usage(&sb_power_usage, &sub_power_usage);
281 //
282 // fprintf(g_power_output->out, "%d\t%.0f\t%g\n", sb_mux_sizes[i],
283 // sb_buffer_sizes[i],
284 // (sb_power_usage.dynamic + sb_power_usage.leakage)
285 // * g_solution_inf.T_crit);
286 //}
287 
288 }
FILE * out
Definition: power.h:200
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)
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)
t_power_output * g_power_output
Definition: power.c:65
t_solution_inf g_solution_inf
Definition: power.c:64
t_mux_arch * power_get_mux_arch(int num_mux_inputs, float transistor_size)
Definition: power_util.c:490
void power_add_usage(t_power_usage *dest, const t_power_usage *src)
Definition: power_util.c:49
static char binary_not(char c)
const float power_callib_period
float T_crit
Definition: power.h:83
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)
float power_sum_usage(t_power_usage *power_usage)
Definition: power_util.c:59
static void * my_realloc(void *memblk, int ibytes)
Definition: graphics.c:512
Definition: util.h:12

+ Here is the call graph for this function:

float power_usage_buf_for_callibration ( int  num_inputs,
float  transistor_size 
)

Definition at line 298 of file power_callibrate.c.

298  {
299  t_power_usage power_usage;
300 
301  assert(num_inputs == 1);
302 
303  power_usage_buffer(&power_usage, transistor_size, 0.5, 2.0, FALSE,
305 
306  return power_sum_usage(&power_usage);
307 }
Definition: util.h:12
const float power_callib_period
float power_sum_usage(t_power_usage *power_usage)
Definition: power_util.c:59
void power_usage_buffer(t_power_usage *power_usage, float size, float in_prob, float in_dens, boolean level_restorer, float period)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float power_usage_buf_levr_for_callibration ( int  num_inputs,
float  transistor_size 
)

Definition at line 309 of file power_callibrate.c.

310  {
311  t_power_usage power_usage;
312 
313  assert(num_inputs == 1);
314 
315  power_usage_buffer(&power_usage, transistor_size, 0.5, 2.0, TRUE,
317 
318  return power_sum_usage(&power_usage);
319 }
const float power_callib_period
float power_sum_usage(t_power_usage *power_usage)
Definition: power_util.c:59
void power_usage_buffer(t_power_usage *power_usage, float size, float in_prob, float in_dens, boolean level_restorer, float period)
Definition: util.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float power_usage_ff_for_callibration ( int  num_inputs,
float  transistor_size 
)

Definition at line 383 of file power_callibrate.c.

383  {
384  t_power_usage power_usage;
385 
386  assert(num_inputs == 1);
387 
388  power_usage_ff(&power_usage, transistor_size, 0.5, 3, 0.5, 1, 0.5, 2,
390 
391  return power_sum_usage(&power_usage);
392 }
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)
const float power_callib_period
float power_sum_usage(t_power_usage *power_usage)
Definition: power_util.c:59

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float power_usage_lut_for_callibration ( int  num_inputs,
float  transistor_size 
)

Definition at line 343 of file power_callibrate.c.

343  {
344  t_power_usage power_usage;
345  char * SRAM_bits;
346  float * dens;
347  float * prob;
348  int lut_size = num_inputs;
349 
350  /* Initialize an SRAM pattern that guarantees the outputs toggle with
351  * every input toggle.
352  */
353  SRAM_bits = (char*) my_malloc(((1 << lut_size) + 1) * sizeof(char));
354  for (int i = 1; i <= lut_size; i++) {
355  if (i == 1) {
356  SRAM_bits[0] = '1';
357  SRAM_bits[1] = '0';
358  } else {
359  for (int sram_idx = 0; sram_idx < (1 << (i - 1)); sram_idx++) {
360  SRAM_bits[sram_idx + (1 << (i - 1))] = binary_not(
361  SRAM_bits[sram_idx]);
362  }
363  }
364  SRAM_bits[1 << i] = '\0';
365  }
366 
367  dens = (float*) my_malloc(lut_size * sizeof(float));
368  prob = (float*) my_malloc(lut_size * sizeof(float));
369  for (int i = 0; i < lut_size; i++) {
370  dens[i] = 1;
371  prob[i] = 0.5;
372  }
373  power_usage_lut(&power_usage, lut_size, transistor_size, SRAM_bits, prob,
374  dens, power_callib_period);
375 
376  free(SRAM_bits);
377  free(dens);
378  free(prob);
379 
380  return power_sum_usage(&power_usage);
381 }
static void * my_malloc(int ibytes)
Definition: graphics.c:499
static char binary_not(char c)
const float power_callib_period
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)
float power_sum_usage(t_power_usage *power_usage)
Definition: power_util.c:59

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float power_usage_mux_for_callibration ( int  num_inputs,
float  transistor_size 
)

Definition at line 321 of file power_callibrate.c.

321  {
322  t_power_usage power_usage;
323  float * dens;
324  float * prob;
325 
326  dens = (float*) my_malloc(num_inputs * sizeof(float));
327  prob = (float*) my_malloc(num_inputs * sizeof(float));
328  for (int i = 0; i < num_inputs; i++) {
329  dens[i] = 2;
330  prob[i] = 0.5;
331  }
332 
333  power_usage_mux_multilevel(&power_usage,
334  power_get_mux_arch(num_inputs, transistor_size), prob, dens, 0,
336 
337  free(dens);
338  free(prob);
339 
340  return power_sum_usage(&power_usage);
341 }
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)
Definition: util.h:12
t_mux_arch * power_get_mux_arch(int num_mux_inputs, float transistor_size)
Definition: power_util.c:490
static void * my_malloc(int ibytes)
Definition: graphics.c:499
const float power_callib_period
float power_sum_usage(t_power_usage *power_usage)
Definition: power_util.c:59

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const float power_callib_period = 5e-9

Definition at line 29 of file power_callibrate.h.