Forum Discussion
Altera_Forum
Honored Contributor
15 years agothank a lot for your replys.
I changed the optimizationlvl from 0 to 3. And use the register prefix for storing the time. now the function looks like:
int messure_avalon(alt_u32 base){
register int sekunden1, sekunden2;
register int nsekunden1, nsekunden2;
sekunden1 = IORD_PTPCORE_PRESENT_SECONDS(base);
nsekunden1 = IORD_PTPCORE_PRESENT_NANOSECONDS(base);
sekunden2 = IORD_PTPCORE_PRESENT_SECONDS(base);
nsekunden2 = IORD_PTPCORE_PRESENT_NANOSECONDS(base);
printf("second-diff: %i\n", sekunden2 - sekunden1);
printf("nanosecs-diff: %i\n", nsekunden2 - nsekunden1);
return 0;
}
U can find the Dissassembly at http://pastebin.com/j1ezxh91
sekunden2 = IORD_PTPCORE_PRESENT_SECONDS(base); expands to
0x0201bb08 <messure_avalon+60>: ldw r2,-4(fp)
0x0201bb0c <messure_avalon+64>: addi r2,r2,20
0x0201bb10 <messure_avalon+68>: ldwio r2,0(r2)
0x0201bb14 <messure_avalon+72>: mov r3,r2
so before the ldwio-call there are 2 instructions (i estimate 1 cycle per instruction). now it prints 576-592 ns. 28 - 30 cycles per read, still a lot. 2 cycles for the instructions, 2 cycles in my component for snapshotting. There are still 24 cycles for clock crossing and avalon-arbitration :confused:. kind regards mooresstudent