42 float * out_dens,
float * v_out,
t_mux_node * mux_node,
44 float * primary_input_prob,
float * primary_input_dens,
45 boolean v_out_restored,
float period);
110 float D_dens,
float Q_prob,
float Q_dens,
float clk_prob,
111 float clk_dens,
float period) {
113 float mux_in_dens[2];
114 float mux_in_prob[2];
127 mux_in_dens[0] = D_dens;
128 mux_in_dens[1] = (1 - clk_prob) * D_dens;
129 mux_in_prob[0] = D_prob;
130 mux_in_prob[1] = D_prob;
132 mux_in_prob, clk_dens, (1 - clk_prob) * D_dens, period);
144 mux_in_dens[0] = Q_dens;
145 mux_in_dens[1] = (1 - clk_prob) * D_dens;
146 mux_in_prob[0] = (1 - Q_prob);
147 mux_in_prob[1] = (1 - D_prob);
149 mux_in_prob, clk_dens, Q_dens, period);
209 float transistor_size,
char * SRAM_values,
float * input_prob,
210 float * input_dens,
float period) {
211 float **internal_prob;
212 float **internal_dens;
221 boolean level_restorer_this_level =
FALSE;
225 num_SRAM_bits = 1 << lut_size;
228 internal_prob = (
float**)
my_calloc(lut_size + 1,
sizeof(
float*));
229 internal_dens = (
float**)
my_calloc(lut_size + 1,
sizeof(
float*));
230 internal_v = (
float**)
my_calloc(lut_size + 1,
sizeof(
float*));
231 for (i = 0; i <= lut_size; i++) {
232 internal_prob[i] = (
float*)
my_calloc(1 << (lut_size - i),
234 internal_dens[i] = (
float*)
my_calloc(1 << (lut_size - i),
236 internal_v[i] = (
float*)
my_calloc(1 << (lut_size - i),
sizeof(float));
240 for (i = 0; i < num_SRAM_bits; i++) {
241 if (SRAM_values[i] ==
'0') {
242 internal_prob[0][i] = 0.;
244 internal_prob[0][i] = 1.;
246 internal_dens[0][i] = 0.;
250 for (level_idx = 0; level_idx < lut_size; level_idx++) {
254 int reverse_idx = lut_size - level_idx - 1;
256 MUXs_this_level = 1 << (reverse_idx);
260 input_prob[reverse_idx], 1.0, period);
264 input_prob[reverse_idx], 2.0, period);
268 1 - input_prob[reverse_idx], 2.0, period);
276 if (((level_idx % 2 == 1) && (level_idx != lut_size - 2))
277 || (level_idx == lut_size - 1)) {
278 level_restorer_this_level =
TRUE;
280 level_restorer_this_level =
FALSE;
284 for (MUX_idx = 0; MUX_idx < MUXs_this_level; MUX_idx++) {
289 int sram_offset = MUX_idx *
ipow(2, level_idx + 1);
290 int sram_per_branch =
ipow(2, level_idx);
296 out_prob = internal_prob[level_idx][MUX_idx * 2]
297 * (1 - input_prob[reverse_idx])
298 + internal_prob[level_idx][MUX_idx * 2 + 1]
299 * input_prob[reverse_idx];
302 out_dens = internal_dens[level_idx][MUX_idx * 2]
303 * (1 - input_prob[reverse_idx])
304 + internal_dens[level_idx][MUX_idx * 2 + 1]
305 * input_prob[reverse_idx];
307 #ifdef POWER_LUT_FAST
308 out_dens += ((1 - internal_prob[level_idx][MUX_idx * 2]) * internal_prob[level_idx][MUX_idx * 2 + 1]
309 + internal_prob[level_idx][MUX_idx * 2] * (1 - internal_prob[level_idx][MUX_idx * 2 + 1]))
310 * input_dens[reverse_idx];
311 #elif defined(POWER_LUT_SLOW)
312 for (sram_idx = sram_offset;
313 sram_idx < sram_offset + sram_per_branch; sram_idx++) {
314 float branch_prob = 1.;
315 if (SRAM_values[sram_idx]
316 == SRAM_values[sram_idx + sram_per_branch]) {
319 for (branch_lvl_idx = 0; branch_lvl_idx < level_idx;
321 int branch_lvl_reverse_idx = lut_size - branch_lvl_idx - 1;
322 int even_odd = sram_idx /
ipow(2, branch_lvl_idx);
323 if (even_odd % 2 == 0) {
324 branch_prob *= (1 - input_prob[branch_lvl_reverse_idx]);
326 branch_prob *= input_prob[branch_lvl_reverse_idx];
329 sum_prob += branch_prob;
331 out_dens += sum_prob * input_dens[reverse_idx];
335 if (level_restorer_this_level) {
338 v_out = (1 - input_prob[reverse_idx])
340 internal_v[level_idx][MUX_idx * 2],
341 internal_prob[level_idx][MUX_idx * 2 + 1])
342 + input_prob[reverse_idx]
344 internal_v[level_idx][MUX_idx * 2 + 1],
345 internal_prob[level_idx][MUX_idx * 2]);
349 internal_dens[level_idx + 1][MUX_idx] = out_dens;
350 internal_prob[level_idx + 1][MUX_idx] = out_prob;
351 internal_v[level_idx + 1][MUX_idx] = v_out;
355 internal_dens[level_idx + 1][MUX_idx],
356 internal_v[level_idx + 1][MUX_idx],
357 &internal_prob[level_idx][MUX_idx * 2],
358 &internal_dens[level_idx][MUX_idx * 2],
359 &internal_v[level_idx][MUX_idx * 2],
360 input_dens[reverse_idx], input_prob[reverse_idx],
361 transistor_size, period);
365 if (level_restorer_this_level) {
368 internal_prob[level_idx + 1][MUX_idx],
369 internal_dens[level_idx + 1][MUX_idx],
TRUE, period);
377 for (i = 0; i <= lut_size; i++) {
378 free(internal_prob[i]);
379 free(internal_dens[i]);
390 scale_factor = callibration->
scale_factor(lut_size, transistor_size);
445 for (out_port_idx = 0;
452 int selected_input =
OPEN;
455 for (in_port_idx = 0;
459 in_dens[in_port_idx] = 0.;
460 in_prob[in_port_idx] = 0.;
468 if (output_pin_net ==
OPEN) {
471 for (in_port_idx = 0;
476 interc_pins->
input_pins[in_port_idx][pin_idx];
481 if (output_pin_net == input_pin_net) {
482 selected_input = in_port_idx;
486 if (input_pin_net !=
OPEN) {
487 in_dens[in_port_idx] =
pin_dens(pb, input_pin);
488 in_prob[in_port_idx] =
pin_prob(pb, input_pin);
493 assert(selected_input !=
OPEN);
531 t_mux_arch * mux_arch,
float * in_prob,
float * in_dens,
532 int selected_input,
boolean output_level_restored,
float period) {
533 float output_density;
539 int * selector_values = (
int*)
my_calloc(mux_arch->
levels,
sizeof(
int));
541 assert(selected_input !=
OPEN);
554 in_dens, output_level_restored, period);
556 free(selector_values);
572 float * out_dens,
float * v_out,
t_mux_node * mux_node,
574 float * primary_input_prob,
float * primary_input_dens,
575 boolean v_out_restored,
float period) {
585 assert(mux_node->
level == 0);
590 if (mux_node->
level == 0) {
595 for (input_idx = 0; input_idx < mux_node->
num_inputs; input_idx++) {
603 for (input_idx = 0; input_idx < mux_node->
num_inputs; input_idx++) {
606 &in_dens[input_idx], &v_in[input_idx],
607 &mux_node->
children[input_idx], mux_arch, selector_values,
608 primary_input_prob, primary_input_dens,
FALSE, period);
618 if (mux_node->
level != 0) {
634 float in_dens,
boolean level_restorer,
float period) {
638 float stage_inv_size;
640 float input_dyn_power;
654 stage_in_prob = in_prob;
655 for (i = 0; i < num_stages; i++) {
656 stage_inv_size = pow(stage_effort, i);
659 if (level_restorer) {
662 in_dens, stage_in_prob, period);
665 stage_inv_size, period);
669 stage_inv_size, period);
673 stage_in_prob = 1 - stage_in_prob;
677 if (level_restorer) {
t_power_tech * g_power_tech
t_power_arch * g_power_arch
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)
float power_component_get_usage_sum(e_power_component_type component_idx)
void power_usage_mux_singlelevel_static(t_power_usage *power_usage, float *out_prob, float *out_dens, float *v_out, int num_inputs, int selected_idx, float *in_prob, float *in_dens, float *v_in, float transistor_size, boolean v_out_restored, float period)
struct s_rr_node * rr_graph
int ipow(int base, int exp)
PowerSpicedComponent ** component_callibration
void power_usage_level_restorer(t_power_usage *power_usage, float *dyn_power_in, float in_dens, float in_prob, float period)
float logical_effort_factor
t_power_commonly_used * g_power_commonly_used
void power_usage_local_interc_mux(t_power_usage *power_usage, t_pb *pb, t_interconnect_pins *interc_pins)
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)
int power_calc_buffer_num_stages(float final_stage_size, float desired_stage_effort)
t_interconnect * interconnect
void power_components_uninit(void)
t_solution_inf g_solution_inf
struct s_pb_graph_pin *** output_pins
t_mux_arch * power_get_mux_arch(int num_mux_inputs, float transistor_size)
void power_components_init(void)
float pin_prob(t_pb *pb, t_pb_graph_pin *pin)
void power_add_usage(t_power_usage *dest, const t_power_usage *src)
bool is_done_callibration(void)
void power_zero_usage(t_power_usage *power_usage)
void power_usage_MUX2_transmission(t_power_usage *power_usage, float size, float *in_dens, float *in_prob, float sel_dens, float out_dens, float period)
static void power_usage_mux_rec(t_power_usage *power_usage, float *out_prob, float *out_dens, float *v_out, t_mux_node *mux_node, t_mux_arch *mux_arch, int *selector_values, float *primary_input_prob, float *primary_input_dens, boolean v_out_restored, float period)
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)
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)
void power_usage_mux_singlelevel_dynamic(t_power_usage *power_usage, int num_inputs, float out_density, float v_out, float *in_prob, float *in_dens, float *v_in, float sel_dens, float sel_prob, float transistor_size, float period)
float power_sum_usage(t_power_usage *power_usage)
struct s_pb_graph_pin *** input_pins
void power_scale_usage(t_power_usage *power_usage, float scale_factor)
void power_component_get_usage(t_power_usage *power_usage, e_power_component_type component_idx)
boolean mux_find_selector_values(int *selector_values, t_mux_node *mux_node, int selected_input_pin)
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
float power_calc_mux_v_out(int num_inputs, float transistor_size, float v_in, float in_prob_avg)
float mux_transistor_size
float scale_factor(int num_inputs, float transistor_size)
t_interconnect_power * interconnect_power
float calc_buffer_stage_effort(int N, float final_stage_size)
t_power_usage * components
void power_usage_inverter(t_power_usage *power_usage, float in_dens, float in_prob, float size, float period)