Ejemplo n.º 1
0
void main(){

// Configure the timers
 e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX); 

 // Start the timer (countdown from 0xFFFFFFFF)
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	init();
	int i = 0;
	// wait for the go (which means actors are connected)
	while(Mailbox.pGo[me.corenum] == 0);

timerValue = e_ctimer_get(E_CTIMER_0);
Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX); 
e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);

	while(i < IN_BUFFER_SIZE)
	{
		// action a0
		int D0, D1;

		D0 = port_read(&X);
		D1 = port_read(&X);
		// end of a0

		// action a1
		int d2, d3;

		d2 = port_read(&X);
		d3 = port_read(&X);

#if 1
		port_write(&Y, D0 + d2); i++;
		port_write(&Y, D0 - d2); i++;
		port_write(&Y, D1 + d3); i++;
		port_write(&Y, D1 - d3); i++;
		// end of a1
#endif

#if 0
		Mailbox.pOutputBuffer[i] = D0 + d2; i++;
		Mailbox.pOutputBuffer[i] = D0 - d2; i++;
		Mailbox.pOutputBuffer[i] = D1 + d3; i++;
		Mailbox.pOutputBuffer[i] = D1 - d3; i++;
#endif
	}
#if 0
*Mailbox.pOutputReady = 10;
#endif

// Get timer value, find the elapsed time and stop 
timerValue = e_ctimer_get(E_CTIMER_1);
Mailbox.pTimer1[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_1);
}
Ejemplo n.º 2
0
void main()
{
  // Configure the timers
 e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX); 

 // Start the timer (countdown from 0xFFFFFFFF)
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	init();
	int i = 0;
	int a, b;
	int w0, w1;

	// Wait until we get the go message from the host
	while(Mailbox.pGo[me.corenum] == 0); 

timerValue = e_ctimer_get(E_CTIMER_0);
Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX); 
e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);
	// Run continuously
	while(i < (IN_BUFFER_SIZE * 2))//temporary value 128
	{
	  w0 = ww0;
	  w1 = ww1;
		index0 = (index0 + 1) & 3;

		ww0 = W0[index0];
		ww1 = W1[index0];

		a = port_read(&X);
		b = port_read(&X);

// For full version we need to change the following line to #ifdef FULL
#if 1
		port_write(&Y, a * w0); i++;
		port_write(&Y, a * w1); i++;
		port_write(&Y, b * w0); i++;
		port_write(&Y, b * w1); i++;
#endif

#if 0
		// Send the outputs to the host
		Mailbox.pOutputBuffer[i] = a * w0; i++;
		Mailbox.pOutputBuffer[i] = a * w1; i++;
		Mailbox.pOutputBuffer[i] = b * w0; i++;
		Mailbox.pOutputBuffer[i] = b * w1; i++;
#endif
	}
	
// Get timer value, find the elapsed time and stop 
timerValue = e_ctimer_get(E_CTIMER_1);
Mailbox.pTimer1[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_1);
}
Ejemplo n.º 3
0
void main(){

  // Configure the timers
 e_ctimer_set(E_CTIMER_0, E_CTIMER_CLK, E_CTIMER_MAX); 

 // Start the timer (countdown from 0xFFFFFFFF)
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	init();
	int i = 0;

	// wait for the go (which means actors are connected)
	while(Mailbox.pGo[me.corenum] == 0);

timerValue = e_ctimer_get(E_CTIMER_0);
Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

e_ctimer_set(E_CTIMER_1, E_CTIMER_CLK, E_CTIMER_MAX); 
e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);

	while(i < IN_BUFFER_SIZE)
	{
		// action a0
		int a, b, c, d;
	
		a = port_read(&X);
		b = port_read(&X);
		c = port_read(&X);
		d = port_read(&X);

#if 1
		port_write(&Y, (a + c) >> 8); i++;
		port_write(&Y, (a - c) >> 8); i++;
		port_write(&Y, (b + d) >> 8); i++;
		port_write(&Y, (b - d) >> 8); i++;
		// end of action a0
#endif

#if 0
		Mailbox.pOutputBuffer[i] = (a + c) >> 8; i++;
		Mailbox.pOutputBuffer[i] = (a - c) >> 8; i++;
		Mailbox.pOutputBuffer[i] = (b + d) >> 8; i++;
		Mailbox.pOutputBuffer[i] = (b - d) >> 8; i++;
#endif

	}

#if 0
*Mailbox.pOutputReady = 12;
#endif

// Get timer value, find the elapsed time and stop 
timerValue = e_ctimer_get(E_CTIMER_1);
Mailbox.pTimer1[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_1);
}
Ejemplo n.º 4
0
/**
 * stop this trace, free resources
 */
int trace_stop()
{
	// make sure we stop things
	e_ctimer_stop(E_CTIMER_1);
	e_irq_mask(E_TIMER1_INT, 1);
	// unregister ISR?
	return 0;
}
Ejemplo n.º 5
0
/**
 * Initialize data structures, call this first before using trace functions
 */
int trace_init()
{
	// If I am the master
	if(e_get_coreid() == TRACE_MASTER_ID) {
		// setup my DMA engine
		setupDMA2(); // REMEMBER TO CHANGE
	}

	//register timer ISR
	e_irq_global_mask(0);
	e_irq_attach(E_TIMER1_INT, timer1_trace_isr);
	e_irq_mask(E_TIMER1_INT, 0);

	// setup timer 1 for work
	e_ctimer_stop(E_CTIMER_1);
	e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX);
	logCoreid = (e_get_coreid()& 0xFFF) << 8; // make it easy to use core-id
	return 0;
}
Ejemplo n.º 6
0
int main () {
  
  e_coreid_t coreid;
  unsigned int row, col, core, trow, tcol, *ec;
  volatile msg_block_t *msg = (msg_block_t *) BUF_ADDRESS;
  
  e_ctimer_set(E_CTIMER_0, 0xffffffff);
  e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
 
  ec = (unsigned int *) 0x4000;
  *ec = 0;
  
  coreid = e_get_coreid();
  e_coords_from_coreid(coreid, &row, &col);
   
  core = row*e_group_config.group_cols + col;
  
  srand(msg->shared_msg[core].seed);
  msg->shared_msg[core].seed = msg->shared_msg[core].seed + 10;
  
  trow = ((core + 1) % E_GROUP_CORES) / e_group_config.group_rows;
  tcol =  (core + 1) % e_group_config.group_cols;
  
  ec = e_get_global_address(trow, tcol, ec);
  e_write(&e_group_config, &coreid, 0, 0, ec, sizeof(e_coreid_t));
  /**ec = coreid;*/
  msg->shared_msg[core].msg = e_coreid_from_coords(trow, tcol);
  msg->shared_msg[core].external = *(unsigned int *) 0x4000;
    
  /* Sync */
  e_wait(E_CTIMER_1, 2000); 
  msg->shared_msg[core].timer = 0xffffffff - e_ctimer_get(E_CTIMER_0);
  msg->shared_msg[core].coreid = coreid;

  e_ctimer_stop(E_CTIMER_0);
  
  return 0;
  
}
Ejemplo n.º 7
0
int main(void)
{
    e_coreid_t coreid;
    unsigned int i;
    unsigned int num;
    unsigned int time_p;
    unsigned int time_c;
    unsigned int time_compare;
    unsigned int list[14] = {4, 3, 3, 144953, 68892, 24971, 52908, 96970, 19531, 17676, 10459, 10458, 357432, 36235};
    unsigned int index = 0;
    unsigned *mailbox;
    float volatile af;
    float volatile bf;
    float volatile cf;
    float volatile df;
    float volatile ref;
    unsigned int temp;

    float volatile in_sin;
    float volatile in_cos;
    float volatile in_sqt;
    float volatile in_ceil;
    float volatile in_log;
    float re_f0, re_f1, re_f2, re_f3, re_f4, re_f5;

    af = 3.5f;
    bf = 2.8f;
    cf = 8.0f;
    df = 3.0f;
    in_sin = (float) pi;
    in_sin = in_sin / 6 ;
    in_cos = (float) pi;
    in_cos = in_cos / 3 ;
    in_sqt = 0.25f;
    in_ceil = 2.5f;
    in_log = 100.0f;
    mailbox = (unsigned *)0x6000;
    mailbox[0] = 0;

    // Who am I? Query the CoreID from hardware.
    coreid = e_get_coreid();
    sprintf(outbuf, "");

    // Get time waste on functions
    e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
    time_p = e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);
    time_compare = time_p - time_c ;

    // Addition
    // E_CTIMER0
    e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    ref = bf + af ;


    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if (!((ref > 6.299f)&&(ref < 6.301f)) )
    {
        sprintf(outbuf, "\n Addition is wrong!\n");
    } else
    {
        if ( (temp >=(list[0] - 2)) && (temp <=(list[0] + 2)) )
        {
            index++;//sprintf(outbuf , "\nPASS for addition!\n");
        } else
        {
            sprintf(outbuf , "\nThe clock cycle for addition is %d instead of %d.\n", temp, list[0]);
        }
    }

    // Subtraction
    // E_CTIMER0
    e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    ref =  af - bf;


    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if ( !((ref > 0.699f)&&(ref < 0.701f)))
    {
        sprintf(outbuf+strlen(outbuf), "\n Subtraction is wrong!\n");
    } else
    {
        if ((temp >= (list[1] - 2)) && (temp <= (list[1] + 2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf) , "\nPASS for substraction!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for subtraction is %d instead of %d.\n", temp, list[1]);
        }
    }

    // Mul
    //E_CTIMER0
    e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    ref = af * bf;

    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if (!((ref > 9.799f)&&(ref < 9.801f)))
    {
        sprintf(outbuf+strlen(outbuf), "\n Multiplication is wrong!\n");
    } else
    {
        if ((temp >=(unsigned) (list[2] -2)) && (temp <=(unsigned) (list[2]+2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for multiplication!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for multiplication is %d instead of %d.\n", temp, list[2]);
        }
    }

    // Div
    //E_CTIMER0
    e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    ref = ( af / bf);

    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if (!((ref > 1.2499f)&&(ref < 1.2501f)))
    {
        sprintf(outbuf+strlen(outbuf), "\n Division is wrong!\n");
    } else
    {
        if ( (temp > (unsigned) (list[3] * 0.8)) && (temp < (unsigned) (list[3] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for division!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for division is %d instead of %d.\n", temp, list[3]);
        }
    }

    // Mod
    // E_CTIMER0
    e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    ref = fmodf(cf,df);


    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if (!((ref > 1.99f)&&(ref < 2.01f)))
    {
        sprintf(outbuf+strlen(outbuf), "\n Mod is wrong!\n");
    } else
    {
        if ( (temp > (unsigned)(list[4] * 0.8)) && (temp < (unsigned)(list[4] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for mod!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for mod is %d instead of %d.\n", temp, list[4]);
        }
    }

    // Sin
    // E_CTIMER0
    e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    re_f0 = sinf(in_sin);

    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if ( !((re_f0 > 0.499) && (re_f0 < 0.501)) )
    {
        sprintf(outbuf+strlen(outbuf), "\n Sin is wrong!\n");
    } else
    {
        if ( (temp > (unsigned)(list[5] * 0.8)) && (temp < (unsigned)(list[5] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for sin!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for sin is %d instead of %d.\n", temp, list[5]);
        }
    }

    // Cos
    // E_CTIMER0
    e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    re_f1 = cosf(in_cos);

    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if (  !((re_f1 > 0.499) && (re_f1 < 0.501)))
    {
        sprintf(outbuf+strlen(outbuf), "\n Cos is wrong!\n");
    } else
    {
        if ( (temp > (unsigned)(list[6] * 0.8)) && (temp < (unsigned)(list[6] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for cos!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for cos is %d instead of %d.\n", temp, list[6]);
        }
    }


    // Sqrt
    e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    re_f2 = sqrtf(in_sqt);

    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if ( !((re_f2 > 0.499) && (re_f2 < 0.501)) )
    {
        sprintf(outbuf+strlen(outbuf), "\n Sqrt is wrong!\n");
    } else
    {
        if ( (temp > (list[7] * 0.8)) && (temp < (list[7] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for square root!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for sqrt is %d instead of %d.\n", temp, list[7]);
        }
    }

    // Ceil
    e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    re_f3 = ceilf(in_ceil);

    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if ( !((re_f3 > 2.99) && (re_f3 < 3.01)) )
    {
        sprintf(outbuf+strlen(outbuf), "\n Ceil is wrong!\n");
    } else
    {
        if ( (temp > (list[8] * 0.8)) && (temp < (list[8] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for ceil!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for ceil is %d instead of %d.\n", temp, list[8]);
        }
    }

    // Floor
    e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    re_f5 = floorf(in_ceil);

    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if ( !((re_f5 > 1.99f) && (re_f5 < 2.01f))  )
    {
        sprintf(outbuf+strlen(outbuf), "\n Floor is wrong!\n");
    } else
    {
        if ( (temp > (list[9] * 0.8)) && (temp < (list[9] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for floor!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for floor is %d instead of %d.\n", temp, list[9]);
        }
    }


    // Log10
    e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_1);

    re_f4 = log10f(df);

    time_c = e_ctimer_get(E_CTIMER_1);
    e_ctimer_stop(E_CTIMER_1);

    temp = time_p - time_c - time_compare;

    if ( !((re_f4 > 0.477f) && (re_f4 < 0.478f)) )
    {
        sprintf(outbuf+strlen(outbuf), "\n Log10 is wrong!\n");
    } else
    {
        if ( (temp > (list[11] * 0.8)) && (temp < (list[11] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for log10!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for log10 is %d instead of %d.\n", temp, list[10]);
        }
    }


    // Ln
    e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    re_f4 = logf(in_log);

    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if (!((re_f4 > 4.6f) && (re_f4 < 4.61f)) )
    {
        sprintf(outbuf+strlen(outbuf), "\n Ln is wrong!\n");
    } else
    {
        if ( (temp > (list[11] * 0.8)) && (temp < (list[11] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for ln!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for ln is %d instead of %d.\n", temp, list[11]);
        }
    }

    // Power
    e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_1);

    re_f4 = powf(cf,df);

    time_c = e_ctimer_get(E_CTIMER_1);
    e_ctimer_stop(E_CTIMER_1);

    temp = time_p - time_c - time_compare;

    if (!( (re_f4 > 511.99f) && (re_f4 < 512.01f) ))
    {
        sprintf(outbuf+strlen(outbuf), "\n Power is wrong!\n");
    } else
    {
        if ( (temp > (list[12] * 0.8)) && (temp < (list[12] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for power!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for power is %d instead of %d.\n", temp, list[12]);
        }
    }

    // Ldexp
    e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_1);

    re_f4 = ldexpf(cf,df);

    time_c = e_ctimer_get(E_CTIMER_1);
    e_ctimer_stop(E_CTIMER_1);

    temp = time_p - time_c - time_compare;

    if ( !((re_f4 > 63.99f) && (re_f4 < 64.01f)) )
    {
        sprintf(outbuf+strlen(outbuf), "\n Ldexp is wrong!\n");
    } else
    {
        if ( (temp > (list[13] * 0.8)) && (temp < (list[13] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for ldexp!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for ldexp is %d instead of %d.\n", temp, list[13]);
        }
    }

    mailbox[0] = index;

    return EXIT_SUCCESS;

}
Ejemplo n.º 8
0
void main()
{
  // Configure the timers
 e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX); 

 // Start the timer (countdown from 0xFFFFFFFF)
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	int x0, x1, x2, x3, x5;
	int i = 0;
#if 0
int j = 0;
#endif
	// Initialize data structures - mainly target pointers
	init();

	// Wait for the connect actors signal
	while(*Mailbox.pConnectActors == 0);
	connect_actors();

	// Reset the connect actors signal to inform the host that actors are connected
	*Mailbox.pConnectActors = 0;

	// Wait for the trigger from the host
	while(Mailbox.pGo[me.corenum] == 0);

timerValue = e_ctimer_get(E_CTIMER_0);
Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX); 
e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);
	while(i < IN_BUFFER_SIZE)
	{

		// Read x0, x1, x2, x3
		x0 = Mailbox.pInBuffer[i]; i++;
		x1 = Mailbox.pInBuffer[i]; i++;
		x2 = Mailbox.pInBuffer[i]; i++;
		x3 = Mailbox.pInBuffer[i]; i++;

		// Write x0 and read an input and write it directly to the output

		port_write(&Y, x0);
		port_write(&Y, Mailbox.pInBuffer[i]); i++;

#if 0
Mailbox.pOutputBuffer[j] = x0; j++;
Mailbox.pOutputBuffer[j] = Mailbox.pInBuffer[i - 1]; j++;
#endif

		// Read x5
		x5 = Mailbox.pInBuffer[i]; i++;

		// Write x2 and read an input and write it directly to the output
		port_write(&Y, x2);
		port_write(&Y, Mailbox.pInBuffer[i]); i++;

#if 0
Mailbox.pOutputBuffer[j] = x2; j++;
Mailbox.pOutputBuffer[j] = Mailbox.pInBuffer[i - 1]; j++;
#endif
		// write x1 and read an input and write it directly to the output
		port_write(&Y, x1);
		port_write(&Y, Mailbox.pInBuffer[i]); i++;
#if 0
Mailbox.pOutputBuffer[j] = x1; j++;
Mailbox.pOutputBuffer[j] = Mailbox.pInBuffer[i - 1]; j++;
#endif

		// Write x5 and x3
		port_write(&Y, x5);
		port_write(&Y, x3);

#if 0
Mailbox.pOutputBuffer[j] = x5; j++;
Mailbox.pOutputBuffer[j] = x3; j++;
#endif
	}

// Get timer value, find the elapsed time and stop 
timerValue = e_ctimer_get(E_CTIMER_1);
Mailbox.pTimer1[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_1);

}
Ejemplo n.º 9
0
int main(void) {
	//initialize
	unsigned time_s, time_e, time;
	unsigned expect;
	int *p0, *p1;
	unsigned ctimer;
	int i, j;
	int a;	
	int fault;
	int row, col;

	sprintf(outbuf,"\t");

	row = e_group_config.core_row;
	col = e_group_config.core_col;
	ctimer = (unsigned)e_get_global_address(row,col,(void *)0xf0438);
	fault = 0x0;
	//ctimer = 0x849f0438;
	p0 = (int *)0x5200;
	*p0 = 0x0;
	//*p0 = 0x10;
	//p1 = (int *)0x80a05200;

	for(i=0;i<4;i++)
	{	
		for(j=0;j<4;j++)
		{	

			p1 = e_get_global_address(i,j,(void *)0x5100);
			//p1 = e_get_global_address(0,0,(void *)0x5200);
			*p1 = 0x210;
			a = 0x0;
	
	
			e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
			e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
			//record the ctimer
			__asm__ __volatile__("ldr %0, [%1]":"=r"(time_s):"r"(ctimer):);
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
				
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	

			__asm__ __volatile__("ldr %0, [%1]":"=r"(time_e):"r"(ctimer):);


			

			//time_e = e_ctimer_get(E_CTIMER_0);
			e_ctimer_stop(E_CTIMER_0);
			time = time_s - time_e;
			//if(time = (i+j)*)
			expect = ((abs(row - i) + abs(col - j)) * 3 + 17)*10 + 17;
			if(time != expect)
				*p0++;
			
			
			//sprintf(outbuf,"time = %d cycles!", fault);
		}
	}

/*
	if(fault == 0)
		sprintf(outbuf+strlen(outbuf),"test20 emesh_read_latency Passed!");
	else
		sprintf(outbuf+strlen(outbuf),"test20 emesh_read_latency failed!\t\t\tWarnning, failed!");
*/
	
	return EXIT_SUCCESS;
}
Ejemplo n.º 10
0
void main(){

 e_ctimer_set(E_CTIMER_0, E_CTIMER_CLK, E_CTIMER_MAX); 
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	init();

	// wait for the go (which means actors are connected)
	while(Mailbox.pGo[me.corenum] == 0);


timerValue = e_ctimer_get(E_CTIMER_0);
Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

  // Timer functions 1
  e_ctimer_set(E_CTIMER_1, E_CTIMER_CLK, E_CTIMER_MAX);
  e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);

	int j = 0;	
	int signed_counter = 0;

	// Run until there is no input left
	while(j < IN_BUFFER_SIZE)
	{
		//action read_signed
		if(clip.count < 0){

			//clip.sflag = port_read(&SIGNED);
			clip.sflag = Mailbox.pSignedBuffer[signed_counter++];
			clip.count = 63;
		} // end of action read_signed
		else { // action limit


			int i = port_read(&I);	


			if(i > 255){
#if 0
			  port_write(&O, 255); j++;
#endif

#if 1
Mailbox.pOutputBuffer[j] = 255; j++;
#endif
// j++;
			}
			else if(clip.sflag == 0 && i < 0){
#if 0
			  port_write(&O, 0); j++;
#endif

#if 1
Mailbox.pOutputBuffer[j] = 0; j++;
#endif
//j++;
			}
			else if(i < -255){
#if 0
			  port_write(&O, -255); j++;
#endif

#if 1
Mailbox.pOutputBuffer[j] = -255; j++;
#endif
//j++;
			}
			else{
#if 0
			  port_write(&O, i); j++;
#endif

#if 1
Mailbox.pOutputBuffer[j] = i; j++;
#endif
//j++;
			}

			clip.count = clip.count - 1;	
		}
		
	}

	timerValue = e_ctimer_get(E_CTIMER_1);
	Mailbox.pTimer1[me.corenum] = E_CTIMER_MAX - timerValue;
#if 1
	*Mailbox.pOutputReady = 1;
#endif
	
	e_ctimer_stop(E_CTIMER_1);
}
Ejemplo n.º 11
0
int main()
{
  msg_t *m = (msg_t *) 0x4000;
  uint64_t d64;
  uint32_t d32;
  uint16_t d16;
  uint8_t  d8;
  unsigned int dt;
  void *da, *dua, *dc;
  for (unsigned int row = 0; row < E_ROWS; row++) {
    for (unsigned int col = 0; col < E_COLS; col++) {
      if (row == 0 && col == 0) continue;
      unsigned int tcore = row * E_COLS + col;

      da = e_get_global_address(row, col, (void *) MEM_ALINEADA);
      dua = e_get_global_address(row, col, (void *) MEM_NO_ALINEADA);
      dc = e_get_global_address(row, col, (void *) MEM_A_CABALLO);

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d64, da, sizeof(d64));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].t64 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d32, da, sizeof(d32));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].t32 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d16, da, sizeof(d16));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].t16 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d8, da, sizeof(d8));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].t8 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d64, dua, sizeof(d64));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].ua64 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d32, dua, sizeof(d32));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].ua32 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d16, dua, sizeof(d16));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].ua16 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d8, dua, sizeof(d8));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].ua8 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d64, dua, sizeof(d64));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].c64 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d32, dc, sizeof(d32));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].c32 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d16, dc, sizeof(d16));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].c16 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d8, dc, sizeof(d8));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].c8 = (dt - DUMMY_WAIT) / (double) VECES;
    }
  }
  m->finalizado = E_TRUE;

  return 0;
}
Ejemplo n.º 12
0
static uint64_t platform_clock(void)
{
    static mach_timebase_info_data_t tb_info = {
        .numer = 0,
        .denom = 0,
    };
    uint64_t abs_time, nanosec;

    abs_time = mach_absolute_time();
    if (tb_info.denom == 0) {
        (void) mach_timebase_info(&tb_info);
    }
    nanosec = abs_time;
    nanosec /= tb_info.denom;
    nanosec *= tb_info.numer;

    return nanosec;
}
#elif defined(HAVE_E_LIB_H)
static uint64_t platform_clock(void)
{
    // Assuming 600MHz clock 10^9 / (600 * 10^6)
    const float factor = 1.6666666666666666666f;

    static uint64_t clock = 0;
    uint64_t diff, nanosec;

    static bool initialized = false;

    if (!initialized) {
        e_ctimer_stop(E_CTIMER_0);
        e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
        e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
        initialized = true;
        return 0;
    }

    /* Clock will drift here */
    diff = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);

    e_ctimer_stop(E_CTIMER_0);
    e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

    clock += diff;

    nanosec = (uint64_t) ((float) clock * factor);

    return nanosec;
}
#else
#error "No timing function"
#endif

static void platform_print_duration(uint64_t start,
                                    uint64_t end)
{
    if (end < start)
        bench_printf("%" PRIu64, 0xffffffffffffffffUL);
    else
        bench_printf("%" PRIu64, end - start);
}

/* end of platform specific section */

struct item_data
{
    uint64_t start;
    uint64_t end;
};
Ejemplo n.º 13
0
void main()
{

// Configure the timers
 e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX); 

 // Start the timer (countdown from 0xFFFFFFFF)
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	init();
	int i = 0;
	int a, b;
	int w0, w1;

	// Wait until we get the go message from the host
	while(Mailbox.pGo[me.corenum] == 0); 

timerValue = e_ctimer_get(E_CTIMER_0);
 Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX); 
e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);

	while(i < (IN_BUFFER_SIZE * 2))
	{
		w0 = ww0;
		w1 = ww1;

		index0 = (index0 + 1) & 3;

		ww0 = W0[index0];
		ww1 = W1[index0];

		a = port_read(&X);
		b = port_read(&X);

#if 1
		port_write(&Y, a * w0); i++;
		port_write(&Y, a * w1); i++;
		port_write(&Y, b * w0); i++;
		port_write(&Y, b * w1); i++;
#endif

#if 0
		Mailbox.pOutputBuffer[i] = a * w0; i++;
		Mailbox.pOutputBuffer[i] = a * w1; i++;
		Mailbox.pOutputBuffer[i] = b * w0; i++;
		Mailbox.pOutputBuffer[i] = b * w1; i++;
#endif

	}

#if 0
*Mailbox.pOutputReady = 8;
#endif

// Get timer value, find the elapsed time and stop 
timerValue = e_ctimer_get(E_CTIMER_1);
Mailbox.pTimer1[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_1);
}
Ejemplo n.º 14
0
/**
 * Initializes the clock (using CTIMER0).
 */
static int8_t init_clock(void) {
	e_ctimer_stop(E_CTIMER_0);
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
	return 0;
}
Ejemplo n.º 15
0
void main(){

// Configure the timers
 e_ctimer_set(E_CTIMER_0, E_CTIMER_CLK, E_CTIMER_MAX); 

 // Start the timer (countdown from 0xFFFFFFFF)
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	init();
	
	int j = 0;
	int consumed_elements = 0;

	// wait for the go (which means actors are connected)
	while(Mailbox.pGo[me.corenum] == 0);

timerValue = e_ctimer_get(E_CTIMER_0);
Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

e_ctimer_set(E_CTIMER_1, E_CTIMER_CLK, E_CTIMER_MAX); 
e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);

	while(j < IN_BUFFER_SIZE)
	{
		
		// action #1
		if(transpose.rcount < 64){

			int row = (transpose.rcount >> 3);
			int quad = (transpose.rcount >> 2) & 1;
			int i;
	
			if(quad == 0){

				for(i = 0; i < 4; i++){

					if(input_available(&X)){

						switch(consumed_elements){
						case 0:
							transpose.mem[transpose.select][row][0] = port_read(&X);
							break;
						case 1:
							transpose.mem[transpose.select][row][7] = port_read(&X);
							break;
						case 2:
							transpose.mem[transpose.select][row][3] = port_read(&X);
							break;
						case 3:
							transpose.mem[transpose.select][row][4] = port_read(&X);
							transpose.rcount = transpose.rcount + 4;
							break;
						default:
							break;
						}
					
						// if we consumed 4 elements, get out of for loop
						if(consumed_elements == 3)
						  i = 4;

						consumed_elements = (consumed_elements + 1) % 4;
					}
				}
			}
			else{
				 for(i = 0; i < 4; i++){
                                        if(input_available(&X)){
                                                switch(consumed_elements){
                                                case 0:
                                                        transpose.mem[transpose.select][row][1] = port_read(&X);
                                                        break;
                                                case 1:
                                                        transpose.mem[transpose.select][row][6] = port_read(&X);
                                                        break;
                                                case 2:
                                                        transpose.mem[transpose.select][row][2] = port_read(&X);
                                                        break;
                                                case 3:
                                                        transpose.mem[transpose.select][row][5] = port_read(&X);
                                                        transpose.rcount = transpose.rcount + 4;
                                                        break;
                                                default:
							break;
                                                }

						// if we consumed 4 elements, get out of for loop
						if(consumed_elements == 3)
						  i = 4;

                                                consumed_elements = (consumed_elements + 1) % 4;
                                        }
                                }
			}
	
		}
		// end of action #1

		// action #2
		if(transpose.ccount > 0){


			int a, b;
			int col = (64 - transpose.ccount) >> 3;
			int pair = ((64 - transpose.ccount) >> 1) & 3;
			int k = transpose.select ^ 1;

			if(pair == 0){
				a = 0;
				b = 4;
			}
			else if(pair == 1){
				a = 2;
				b = 6;
			}
			else if(pair == 2){
				a = 1;
				b = 7;
			}
			else{
				a = 5;
				b = 3;
			}

#if 1
			port_write(&Y, transpose.mem[k][a][col]); j++;
			port_write(&Y, transpose.mem[k][b][col]); j++;
#endif



#if 0
			// DEBUG
			Mailbox.pOutputBuffer[j] = transpose.mem[k][a][col]; j++;
			Mailbox.pOutputBuffer[j] = transpose.mem[k][b][col]; j++;
#endif

			transpose.ccount = transpose.ccount - 2;


		}
Ejemplo n.º 16
0
int main(void)
{
	e_coreid_t coreid;
	unsigned int i;
	unsigned int num;
	unsigned int time_p;
	unsigned int time_c;
	unsigned int time_compare;
	float volatile af;
	float volatile bf;
	float volatile cf;
	float volatile df;
	float ref;	
	unsigned int temp;

	float volatile in_sin;
	float volatile in_cos;
	float volatile in_sqt;
	float volatile in_ceil;
	float volatile in_log;
	float re_f0, re_f1, re_f2, re_f3, re_f4, re_f5;

	af = 3.5f;
	bf = 2.8f;	
	cf = 8.0f;
	df = 3.0f;
	in_sin = (float) pi;
	in_sin = in_sin / 6 ;
	in_cos = (float) pi;
	in_cos = in_cos / 3 ;
	in_sqt = 0.25f;
	in_ceil = 2.5f;
	in_log = 100.0f;

	// Who am I? Query the CoreID from hardware.
	coreid = e_get_coreid();
	sprintf(outbuf, "");

	// Get time waste on functions
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);
	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
	time_compare = time_p - time_c ;

	// Addition
	// E_CTIMER0
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);
		
		ref = bf + af ;

	
	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if (!((ref > 6.299f)&&(ref < 6.301f)))
	{
		sprintf(outbuf, "\n Addition is wrong!\n");
	}else
	{
		sprintf(outbuf , "\nE_CTIMER0: The clock cycle of addition is %d.\n", temp);
	}
	
	// Subtraction
	// E_CTIMER0
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);
		
		ref =  af - bf;

	
	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( !((ref > 0.699f)&&(ref < 0.701f)))
	{
		sprintf(outbuf+strlen(outbuf), "\n Subtraction is wrong!\n");
	}else
	{
		sprintf(outbuf+strlen(outbuf) , "\n E_CTIMER0: The clock cycle of subtraction is %d.\n", temp);
	}

	// Mul
	//E_CTIMER0
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);
		
		ref = af * bf;
	
	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;


	if (!((ref > 9.799f)&&(ref < 9.801f)))
	{
		sprintf(outbuf+strlen(outbuf), "\n Multiplication is wrong!\n");
	}else
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of multiplication is %d.\n", temp);
	}

	// Div
	//E_CTIMER0
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);
	
		ref = ( af / bf);
	
	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if (!((ref > 1.2499f)&&(ref < 1.2501f)))
	{
		sprintf(outbuf+strlen(outbuf), "\n Division is wrong!\n");
	}else
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of division is %d.\n", temp);
	}

	// Mod
	// E_CTIMER0
	e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);
	
		ref = fmodf(cf,df);

	
	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if (!((ref > 1.99f)&&(ref < 2.01f)))
	{
		sprintf(outbuf+strlen(outbuf), "\n Mod is wrong!\n");
	}else
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of mod is %d.\n", temp);
	}
	
	// Sin
	// E_CTIMER0
	e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f0 = sinf(in_sin);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( (re_f0 > 0.499) && (re_f0 < 0.501) )
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of sin is %d.\n", temp);		
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Sin is wrong!\n");
	}
	
	// Cos
	// E_CTIMER0
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f1 = cosf(in_cos);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;
	
	if (  (re_f1 > 0.499) && (re_f1 < 0.501))
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of cos is %d.\n", temp);
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Cos is wrong!\n");
	}
	

	// Sqrt
	e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f2 = sqrtf(in_sqt);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( (re_f2 > 0.499) && (re_f2 < 0.501) )
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of sqrt is %d.\n", temp);		
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Sqrt is wrong!\n");
	}
	
	// Ceil
	e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f3 = ceilf(in_ceil);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( (re_f3 > 2.99) && (re_f3 < 3.01) )
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of ceil is %d.\n", temp);		
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Ceil is wrong!\n");
	}

	// Floor
	e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f5 = floorf(in_ceil);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( (re_f5 > 1.99f) && (re_f5 < 2.01f)  )
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of floor is %d.\n", temp);
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Floor is wrong!\n");
	}
	

	// Log10
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f4 = log10f(df);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( (re_f4 > 0.477f) && (re_f4 < 0.478f) )
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of log10 is %d.\n", temp);
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Log10 is wrong!\n");
	}

	// Ln
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f4 = logf(in_log);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( (re_f4 > 4.6f) && (re_f4 < 4.61f) )
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of ln is %d.\n", temp);
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Ln is wrong!\n");
	}
	
	// Power
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f4 = powf(cf,df);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( (re_f4 > 511.99f) && (re_f4 < 512.01f) )
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of power is %d.\n", temp);
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Power is wrong!\n");
	}
	
	// Ldexp
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f4 = ldexpf(cf,df);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( (re_f4 > 63.99f) && (re_f4 < 64.01f) )
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of ldexp is %d.\n", temp);
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Ldexp is wrong!\n");
	}
	return EXIT_SUCCESS;

}
Ejemplo n.º 17
0
void main(){

// Configure the timers
 e_ctimer_set(E_CTIMER_0, E_CTIMER_CLK, E_CTIMER_MAX); 

 // Start the timer (countdown from 0xFFFFFFFF)
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	init();

	int i = 0;

	// wait for the go (which means actors are connected)
	while(Mailbox.pGo[me.corenum] == 0);

timerValue = e_ctimer_get(E_CTIMER_0);
Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

e_ctimer_set(E_CTIMER_1, E_CTIMER_CLK, E_CTIMER_MAX); 
e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);

	while(i < IN_BUFFER_SIZE)
	{
		int a, b, c, d, x2, x3, x4, x5, x6h, x6l, x7h, x7l;

		// action a0
		a = port_read(&X);
		b = port_read(&X);
		c = port_read(&X);
		d = port_read(&X);

		x4 = c;
		x5 = d;
#if 1
		port_write(&Y, a); i++;
		port_write(&Y, b); i++;
		// end of action a0
#endif

#if 0
		//DEBUG
		Mailbox.pOutputBuffer[i] = a; i++;
		Mailbox.pOutputBuffer[i] = b; i++;

#endif
		// action a1
		x2 = port_read(&X);
		a = port_read(&X);
		x3 = port_read(&X);
		b = port_read(&X);
	
		int ah = a >> 8;
		int bh = b >> 8;
		int al = a & 255;
		int bl = b & 255;

		x6h = 181 * (ah + bh);
		x7h = 181 * (ah - bh);
		x6l = 181 * (al + bl) + 128;
		x7l = 181 * (al - bl) + 128;

#if 1
		port_write(&Y, x2); i++;	
		port_write(&Y, x3); i++;
		// end of action a1
#endif

#if 0
		//DEBUG
		Mailbox.pOutputBuffer[i] = x2; i++;
		Mailbox.pOutputBuffer[i] = x3; i++;

#endif

#if 1
		// action a2
		port_write(&Y, x4); i++;
		port_write(&Y, x5); i++;
		port_write(&Y, x6h + (x6l >> 8)); i++;
		port_write(&Y, x7h + (x7l >> 8)); i++;

		// end of action a2
#endif

#if 0
		//DEBUG
		Mailbox.pOutputBuffer[i] = x4; i++;
		Mailbox.pOutputBuffer[i] = x5; i++;
		Mailbox.pOutputBuffer[i] = x6h + (x6l >> 8); i++;
		Mailbox.pOutputBuffer[i] = x7h + (x7l >> 8); i++;

#endif
	}

// Get timer value, find the elapsed time and stop 
timerValue = e_ctimer_get(E_CTIMER_1);
Mailbox.pTimer1[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_1);
}