The C code is:
// Bar1 is a pointer to a structure in the same form as the registers of the FPGA.
// It is initialised to point to those registers.
count = Bar1->Data_uCount;
Bar1->Data_uAddress = (uint32)address;
Bar1->Data_uWriteNotRead = 0;
Bar1->Data_uGo = 1;
Bar1->Data_uGo = 0;
readcount = Bar1->Data_uCount ; // This line is enclosed in timing diagnostics
for (i = 0; (count == readcount) && (i < 4); i++)
readcount = Bar1->Data_uCount ;
ret = Bar1->Data_uRead & 0xffff;
return ret;
The relevant part of the FPGA VI is here:
http://i167.photobucket.com/albums/u142/rurwin/MemRead.jpgThe assembler instructions I refered to:
;tail end of timing diagnostics. rdtsc reads the CPU tick counter
rdtsc
mov DWORD PTR _tsccalib+4, edx
mov DWORD PTR _tsccalib, eax
popad
popfd
; readcount = Bar1->Data_uCount ;
mov eax, DWORD PTR _Bar1
mov ecx, DWORD PTR [eax+56]
mov DWORD PTR _readcount$[ebp], ecx
; top end of timing diagnostics, time recorded is between the two rdtsc instructions.
pushfd
pushad
rdtsc