2011-02-17 03:29:05     Read-after-write behavior

Document created by Aaronwu Employee on Oct 16, 2013
Version 1Show Document
  • View in full screen mode

2011-02-17 03:29:05     Read-after-write behavior

Andrea Mannuccini (SWITZERLAND)

Message: 98218   




I am developing a bare metal application for BF534 on win32 platform using the blackfin-toolchain-win32-2008R1.5.


I have a piece of code where a read-after-write on external memory (async memory) is performed in order to check the correctness of the accesses:


#define FPGA_BASE_ADDRESS_CS1       0x20100000

#define pFPGA_BASE_ADDRESS_CS1     ((volatile unsigned short *)FPGA_BASE_ADDRESS_CS1)

#define CMD_OFFSET                                   0x1000

#define CMD(offset)                                         (*(pFPGA_BASE_ADDRESS_CS1 + CMD_OFFSET + offset))



CMD(0) = data_expected;

cmd_data0 = CMD(0);



The asm code generated is as expected:


      P2.H = 8208;

      P2.L = 8192;

      R0 = W [FP+-4] (X);

      W [P2] = R0;

      .loc 1 1079 0

      P2.H = 8208;

      P2.L = 8192;

      R0 = W [P2] (X);

      W [FP+-56] = R0;


But, looking at the RD/ WR/ signals on the BF pins, the BF actually perform the read first and then the write (initially this let me think to wrong memory access timings since I didn't read later what I wrote earlier, but this is not the case...)


If I add a CSYNC instruction after the write and before the read then everything works as expected. Also, if I read & write from different addresses, the problem is still there.


Now, I am not sure whether this is as expected (It seems quite strange to me...) or whether the problem is on the asm generated code or in the DSP hardware.


Thank you in advance for your help with ths issue,








2011-02-17 10:22:49     Re: Read-after-write behavior

Mike Frysinger (UNITED STATES)

Message: 98223   


this is expected hardware behavior.  you must use SSYNC before any read to ensure all pending writes have committed.


also, 2008R1.5 is pretty old.  you should be using 2010R1 now.




2011-02-17 11:10:13     Re: Read-after-write behavior

Steve Kilbane (UNITED KINGDOM)

Message: 98225   


You may find it helpful to refer to "Ordering of Loads and Stores" in the ADSP-BF53x/BF56x Blackfin Processor Programming Reference (that's page 6-67, in the copy on my desk).




2011-02-17 11:33:05     Re: Read-after-write behavior

Andrea Mannuccini (SWITZERLAND)

Message: 98227   


Thank you guys!