Uso el IDE de Nios 2 de Altera con el Altera DE2. Agrego un archivo Functions.c
con código que necesita un temporizador, por ejemplo,
int main ()
{
int w[8192];
int a, b;
int size = M;
printf("Working Set\n\n");
printf("Information about the system:\n");
printf("\n");
printf("Processor Type: %s\n", NIOS2_CPU_IMPLEMENTATION);
printf("Size Instruction Cache: %d\n", NIOS2_ICACHE_SIZE);
printf("Line Size Instruction Cache: %d\n", NIOS2_ICACHE_LINE_SIZE);
printf("Size Data Cache: %d\n", NIOS2_DCACHE_SIZE);
printf("Line Size Data Cache: %d\n\n\n", NIOS2_DCACHE_LINE_SIZE);
/* Check if timer available */
if (alt_timestamp_start() < 0)
printf("No timestamp device available!");
else
{
/* Print Information about the system */
printf("Information about the system:\n");
printf("\n");
/* Print frequency and period */
printf("Timestamp frequency: %3.1f MHz\n", (float)alt_timestamp_freq()/1000000.0);
printf("Timestamp period: %f ms\n\n", 1000.0/(float)alt_timestamp_freq());
/* Calculate Timer Overhead */
// Average of 10 measurements */
int i;
timer_overhead = 0;
for (i = 0; i < 10; i++) {
start_measurement();
stop_measurement();
timer_overhead = timer_overhead + time_2 - time_1;
}
timer_overhead = timer_overhead / 10;
printf("Timer overhead in ticks: %d\n", (int) timer_overhead);
printf("Timer overhead in ms: %f\n",
1000.0 * (float)timer_overhead/(float)alt_timestamp_freq());
// === Task 1 : Block Sizes ===
// Function 1.1
initArray(w, 8192);
printf("Function 1.1: ");
start_measurement();
for (i = 0; i < 128; i++)
w[i]++;
stop_measurement();
printf("%5.2f us", (float) microseconds(ticks - timer_overhead));
printf("(%d ticks)\n", (int) (ticks - timer_overhead));
printf("Done!\n");
}
return 0;
}
Pero recibo errores de compilación al intentar con diferentes temporizadores en el tiempo de las propiedades del sistema. ¿Puedes decirme cómo debo conectar los temporizadores?
Supongo que no debería compilar sin un temporizador del sistema y agregar el archivo requiere un temporizador. Cuando agrego el archivo obtengo estos errores.
make -s all includes
Compiling Functions.c...
../Functions.c: In function 'microseconds':
../Functions.c:20: warning: implicit declaration of function 'alt_timestamp_freq'
../Functions.c: In function 'start_measurement':
../Functions.c:35: warning: implicit declaration of function 'alt_dcache_flush_all'
../Functions.c:36: warning: implicit declaration of function 'alt_icache_flush_all'
../Functions.c:38: warning: implicit declaration of function 'alt_timestamp_start'
../Functions.c:39: warning: implicit declaration of function 'alt_timestamp'
../Functions.c: In function 'main':
../Functions.c:58: error: 'NIOS2_CPU_IMPLEMENTATION' undeclared (first use in this function)
../Functions.c:58: error: (Each undeclared identifier is reported only once
../Functions.c:58: error: for each function it appears in.)
../Functions.c:59: error: 'NIOS2_ICACHE_SIZE' undeclared (first use in this function)
../Functions.c:60: error: 'NIOS2_ICACHE_LINE_SIZE' undeclared (first use in this function)
../Functions.c:61: error: 'NIOS2_DCACHE_SIZE' undeclared (first use in this function)
../Functions.c:62: error: 'NIOS2_DCACHE_LINE_SIZE' undeclared (first use in this function)
../Functions.c:52: warning: unused variable 'a'
../Functions.c:52: warning: unused variable 'b'
../Functions.c:53: warning: unused variable 'size'
make: *** [obj/Functions.o] Error 1
Build completed in 2.3 seconds