cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jameswarnock
Observer
Observer
7,435 Views
Registered: ‎10-18-2013

Microblaze interface to MIG DDR3

Jump to solution

I have been tasked with developing an FPGA image to validate DDR3 operation on an upcoming board we are designing. For now, I am using a VC709 Development Kit Platform to develop the image. I am using the IP Integrator tool with Vivado 2013.2.

 

The system is really very simple. I have a MicroBlaze subsystem as well as a MIG. The interface is an AXI4 bus. I would like to be able to use the MicroBlaze to manually write data to the DDR3.

 

I have built a system and exported to SDK. At this point I am used to finding a generated API file ( .h file ) with macros to allow using each AXI slave. The macros usually include address offsets for configuration/FIFO registers. A long time ago in school I created an IP Core that connected to the AXI Bus and I configured certain parts of the memory space to be configuration registers. I was expecting a similar situation for the MIG Interface but there was no API file and I can't figure out how to use the MIG interface. Looking at the MIG User Guide UG586, I notice that there are address and data FIFOs but I can't figure out where in the memory space those FIFOs are. 

 

So my question is, how do I manually write data into the DDR3 from the software running on the MicroBlaze? 

0 Kudos
1 Solution

Accepted Solutions
gszakacs
Professor
Professor
9,901 Views
Registered: ‎08-14-2007

Unless you have a very unusual connection between the MicroBlaze and MIG, the external DDR3 memory just shows up in the MB's address space.  You can write or read it just by dereferencing a pointer.  If your system has cache, you need to take this into account, because for example writing and then reading back a small enough area of memory that it would all fit in cache may not show errors in the external memory.  Generally there are ways to disable cache or invalidate it to force data to be read from the external memory.  Otherwise a memory test that first writes a very large area of memory and then reads it back would show memory problems even with cache enabled.

 

Also, I haven't used Vivado, but in the older XPS you would always get a memory test C program when you built a MicroBlaze with external memory.  If that's still the case, you could use it as a starting point.

-- Gabor

View solution in original post

0 Kudos
6 Replies
gszakacs
Professor
Professor
9,902 Views
Registered: ‎08-14-2007

Unless you have a very unusual connection between the MicroBlaze and MIG, the external DDR3 memory just shows up in the MB's address space.  You can write or read it just by dereferencing a pointer.  If your system has cache, you need to take this into account, because for example writing and then reading back a small enough area of memory that it would all fit in cache may not show errors in the external memory.  Generally there are ways to disable cache or invalidate it to force data to be read from the external memory.  Otherwise a memory test that first writes a very large area of memory and then reads it back would show memory problems even with cache enabled.

 

Also, I haven't used Vivado, but in the older XPS you would always get a memory test C program when you built a MicroBlaze with external memory.  If that's still the case, you could use it as a starting point.

-- Gabor

View solution in original post

0 Kudos
jameswarnock
Observer
Observer
7,405 Views
Registered: ‎10-18-2013

Thank you for your response.

 

To make sure I understand, if my MIG encompasses AXI addresses 0x80000000-0xffffffff then i should be able to write to any address with that range and the data will end up in the DDR3? 

 

Thanks again,

James

0 Kudos
gszakacs
Professor
Professor
7,397 Views
Registered: ‎08-14-2007

@jameswarnock wrote:

Thank you for your response.

 

To make sure I understand, if my MIG encompasses AXI addresses 0x80000000-0xffffffff then i should be able to write to any address with that range and the data will end up in the DDR3? 

 

Thanks again,

James


Yes.  That's the way it's supposed to work.  Just remember that if you have cache, the writes may be delayed, and if you read back before that cache line became invalid you'd be reading the cached value.  Thus it would not be a good memory test to write each memory location and immediately read the same location back, for example.  Also even if you don't have cache enabled, the test I just mentioned might not actually read back the memory because the compiler is smart enough to know that the value you want is still sitting in a local register.  In that case you'd also have to make sure that the memory (or pointer to it) is declared "volatile" to prevent such compiler optimizations.  Still I imagine the standard method of writing all memory before starting to read back is the best test.  It will catch problems like address line shorts or opens, while a test that immediately reads back would not.

-- Gabor
meta1360
Explorer
Explorer
6,750 Views
Registered: ‎01-29-2014

Hi James and Gabor,

 

I was reading your conversation and realized that you wanted to do the same as I am doing now. My problem is that when I connected Memory controller generated by MIG and connected to Microblaze and use this program mentioned as follows it got stalled in the point I show;  I mean that the first loop (for) is going correctly and everything is ok but when it enters to the second loop (while) it stalled and never went forward.

 

If you can help me out of this problem I really appreciate it.  

  


#include <stdio.h>
#include "platform.h"
#include "xil_io.h"
#include "xil_printf.h"

void print(char *str);

int main()
{
u32 address = 0 ;
u32 address1 = 0;
u8 value = 0;
u8 rvalue = 0;
u8 em_rvalue = 0;
init_platform();
// writing the the output of counter in memory

for (address = 0x80000000; address < 0xA0000000; address = address + 1)
{
Xil_Out8(address , value);
value = value + 1;
em_rvalue = Xil_In8(address);
}

// reading from memory and show in UART
address1 = 0x80000000;
// for (address1 = 0x80000000; address1 < 0xA0000000; address1 = address1 + 1)

get stalled here at this point 
while (address1 < 0xA0000000)
{
rvalue = Xil_In8(address1);
address1 = address1 + 1;
// print (address = %)
}

print("Hello World\n\r");

return 0;
}

 

 

Regards,

Meysam

0 Kudos
initechnology
Newbie
Newbie
4,181 Views
Registered: ‎08-05-2015

hi....!

i am also doing same as you are......

but i am confused from where i would know the commands that would proform read and write.....

as you have done from a start address and XIl_out8 where are descriptions of such commands...

 

0 Kudos
martinmde
Newbie
Newbie
688 Views
Registered: ‎05-14-2020

Remember that  you cannot use the area immediately starting at 0x80000000

because code , stack and heap are located there.

 

Check your linker file, it will tell you where is some free space.

2020-05-14_18h34_57.png