How to execute microblaze C program from ZBT memory
by Yongjie Liu - the JPEG decoder team
Overview:
Microblaze uses 32-bit address, so that the address range is from 0 to 0xFFFFFFFF. Microblaze can access the memory either through Local Memory Bus (LMB) or On-chip Peripheral Bus (OPB). The BRAM memory assigned to LMB is limited to 64Kbytes for Vertex II board. This means that the user's execution code can not exceed 64Kbytes if it is going to be put into BRAM. One solution for this problem is that we may use the the on-board ZBT memory through OPB to load the execution code. The board we used supports five independent banks of 512K x 32bit ZBT RAM. By this way, the user can also allocate large data in the program (bigger than 64Kbytes).
The development software & hardware:
Using the ZBT memory in an EDK project:
In order to use the ZBT memory, there are several steps:
Fig. 1
Fig. 2
#define ZBT_BASEADDR 0x00800000
#define ZBT_START ZBT_BASEADDR
#define ZBT_SIZE 10 int main(void) { int Counter; int i; volatile unsigned int *p; volatile unsigned int *g; print("\npass # "); xil_printf("\r\n**** Writing the ZBT ****\r\n\r\n"); for (i = 0, p = (void *)ZBT_START; i < ZBT_SIZE; ++i,++p) { *p = (unsigned long)i; xil_printf("Address = %x, Data = %x\r\n", p, *p); } xil_printf("\r\n**** Reading the ZBT ****\r\n\r\n"); for (i = 0, g = (void *)ZBT_START; i < ZBT_SIZE; ++i,++g ) { if (*g != (unsigned long)i) { xil_printf("Address = %x, Data = %x\r\n", g, *g); } } }
Executing program from ZBT memory:
A linker Script is the file to control how the user's program is targeted to LMB, OPB or external memory. The linker script defines the layout and the start address of the sections for the output executable file. There is a default linker script if a new project is created in XPS. This linker script is good for program to run in the 64Kbytes BRAM and need not be changed.
To let the program run from ZBT memory, the starting address of the program has to be modified, though the complier's option (shown in Fig. 3) The linker script must be removed from the project in order to make this parameter effective. Here in the example, we define the starting address as the base address of the ZBT memory, so that the program can run in ZBT memory.
Fig. 3
Note: In the XPS ver. 6.3, there is a GUI for the linker script confiuration. The user is able to control more details of the layout and addresses of the program. In XPS 6.2, the linker script has to be modified manually for futurther control of the memory.
Last edited by Yongjie Liu on December 2, 2004