Exemplo n.º 1
0
int SIM_arbiter_init(SIM_power_arbiter_t *arb, int arbiter_model, int ff_model, u_int req_width, double length, SIM_power_array_info_t *info)
{
  if ((arb->model = arbiter_model) && arbiter_model < ARBITER_MAX_MODEL) {
    arb->req_width = req_width;
    SIM_arbiter_clear_stat(arb);
    /* redundant field */
    arb->mask = HAMM_MASK(req_width);

    switch (arbiter_model) {
      case RR_ARBITER:
	   arb->e_chg_req = SIM_rr_arbiter_req_cap(length) / 2 * EnergyFactor;
	   /* two grant signals switch together, so no 1/2 */
	   arb->e_chg_grant = SIM_rr_arbiter_grant_cap() * EnergyFactor;
	   arb->e_chg_carry = SIM_rr_arbiter_carry_cap() / 2 * EnergyFactor;
	   arb->e_chg_carry_in = SIM_rr_arbiter_carry_in_cap() / 2 * EnergyFactor;
	   arb->e_chg_mint = 0;

	   if (SIM_fpfp_init(&arb->pri_ff, ff_model, SIM_rr_arbiter_pri_cap()))
	     return -1;
	   break;

      case MATRIX_ARBITER:
	   arb->e_chg_req = SIM_matrix_arbiter_req_cap(req_width, length) / 2 * EnergyFactor;
	   /* 2 grant signals switch together, so no 1/2 */
	   arb->e_chg_grant = SIM_matrix_arbiter_grant_cap(req_width) * EnergyFactor;
	   arb->e_chg_mint = SIM_matrix_arbiter_int_cap() / 2 * EnergyFactor;
	   arb->e_chg_carry = arb->e_chg_carry_in = 0;

	   if (SIM_fpfp_init(&arb->pri_ff, ff_model, SIM_matrix_arbiter_pri_cap(req_width)))
	     return -1;
	   break;

      case QUEUE_ARBITER:
	   arb->e_chg_req = arb->e_chg_grant = arb->e_chg_mint = 0;
	   arb->e_chg_carry = arb->e_chg_carry_in = 0;

	   return SIM_array_power_init(info, &arb->queue);
	   break;

      default:	/* some error handler */
	break;
    }

    return 0;
  }
  else
    return -1;
}
Exemplo n.º 2
0
int SIM_arbiter_init(SIM_arbiter_t *arb, int arbiter_model, int ff_model, u_int req_width, double length, SIM_array_info_t *info)
{
    if ((arb->model = arbiter_model) && arbiter_model < ARBITER_MAX_MODEL)
    {
        arb->req_width = req_width;
        SIM_arbiter_clear_stat(arb);
        /* redundant field */
        arb->mask = HAMM_MASK(req_width);
        double I_static;
        switch (arbiter_model)
        {
        case RR_ARBITER:
            arb->e_chg_req = SIM_rr_arbiter_req_cap(length) / 2 * EnergyFactor;
            /* two grant signals switch together, so no 1/2 */
            arb->e_chg_grant = SIM_rr_arbiter_grant_cap() * EnergyFactor;
            arb->e_chg_carry = SIM_rr_arbiter_carry_cap() / 2 * EnergyFactor;
            arb->e_chg_carry_in = SIM_rr_arbiter_carry_in_cap() / 2 * EnergyFactor;
            arb->e_chg_mint = 0;

            if (SIM_fpfp_init(&arb->pri_ff, ff_model, SIM_rr_arbiter_pri_cap()))
                return -1;

            /*arbiter static power */
            I_static = 0;
            /* NOR */
            I_static += (6 * arb->req_width * ((WdecNORp*NOR2_TAB[0] + WdecNORn*(NOR2_TAB[1] + NOR2_TAB[2] + NOR2_TAB[3]))/4));

            /* inverter */
            I_static += 2 * arb->req_width * ((Wdecinvn*NMOS_TAB[0] + Wdecinvp*PMOS_TAB[0])/2);
            /* DFF */
            I_static += (arb->req_width * Wdff*DFF_TAB[0]);
            arb->I_static = I_static;

            break;

        case MATRIX_ARBITER:
            arb->e_chg_req = SIM_matrix_arbiter_req_cap(req_width, length) / 2 * EnergyFactor;
            /* 2 grant signals switch together, so no 1/2 */
            arb->e_chg_grant = SIM_matrix_arbiter_grant_cap(req_width) * EnergyFactor;
            arb->e_chg_mint = SIM_matrix_arbiter_int_cap() / 2 * EnergyFactor;
            arb->e_chg_carry = arb->e_chg_carry_in = 0;

            if (SIM_fpfp_init(&arb->pri_ff, ff_model, SIM_matrix_arbiter_pri_cap(req_width)))
                return -1;
            /*arbiter static power */
            I_static = 0;
            /* NOR */
            I_static += ((2 * arb->req_width - 1) * arb->req_width) * ((WdecNORp*NOR2_TAB[0] + WdecNORn*(NOR2_TAB[1] + NOR2_TAB[2] + NOR2_TAB[3]))/4);
            /* inverter */
            I_static += arb->req_width * ((Wdecinvn*NMOS_TAB[0] + Wdecinvp*PMOS_TAB[0])/2);
            /* DFF */
            I_static += (arb->req_width * (arb->req_width - 1) / 2) * (Wdff*DFF_TAB[0]);
            arb->I_static = I_static;

            break;

        case QUEUE_ARBITER:
            arb->e_chg_req = arb->e_chg_grant = arb->e_chg_mint = 0;
            arb->e_chg_carry = arb->e_chg_carry_in = 0;

            return SIM_array_power_init(info, &arb->queue);
            break;

        default:
            printf ("error\n"); /* some error handler */
        }

        return 0;
    }
    else
        return -1;
}