I’m still working on how to initialize Block RAMs using DATA2MEM software. I have managed to produce a bit file with initialized RAMs. What’s left is to write a linker script to suit our addressing space, write a C file to blink the LEDs using GPIOs and finally get this working on the board.
In this post I will give a step by step guide regarding using DATA2MEM starting from the initial system design to the production of a BIT stream file with initialized RAMs.
- The common system that requires the use of DATA2MEM is a Soft processor and a Block RAM integrated with various IO devices. The RAMs are meant to hold the program instructions for the processor as well as it’s data memory. This is the case with our project.
- Design the system and SOC and correctly wire the processor with other peripherals and with the Block RAMs. The way you infer your block RAMs in terms of width and depth should be decided after understanding how DATA2MEM recognizes your RAMs and fills them with data. Moreover, the available Block RAMs in the target device should be kept in mind
- Synthesize the system and ensure that the correct number of Block RAMs has been inferred.
- Map and Place and Route the design.
- After ISE is done with implementing the device it’s advisable to use any constraint editor such as plan ahead to lock your RAMs. This ensures that on future implementations your RAMs will take the same sites hence eliminating the need to edit your BMM file. Moreover, you can use the locked site for each RAM to associate with it’s corresponding RAM in the BMM file.
- Finally create your BIT stream file
- Write the BMM file that describes your memory and address space. Refer to the DATA2MEM user guide for rules and examples and to this Answer by Xilinx.
- Create your C program and compile it. Make sure to produce .elf output files in your compilation. Moreover, if you need to specify where your program fits in the memory you have to create your own linker file. In my project I am referring to Xilinx Microblaze user guide to create my linker file since we are using the micro-blaze compiler. You can start by this document specifically the section for MicroBlaze Address Management.
- Here we will start using the data2mem tool. First of all check the syntax of your BMM file using the following command
data2mem -bm file.bmm
- Next you can produce a .mem output from your elf file. This file can help you ensure that your elf file arranges the data in the correct address space for your device. Use the following command.
data2mem -bd code.elf -d -o m code.mem
- Lastly you use your ELF file, BMM file and BIT stream as input to the DATA2MEM to produce a new BIT stream file with initialized block RAMs. The overall process is that the DATA2MEM tool uses the BMM file to identify the BLOCK RAMs in the BIT stream file and fills them with the data from the ELF file according to it’s address. Here is the command for this process
data2mem -bm file.bmm -bd code.elf -bt file.bit -o b new.bit
You can use your new.bit to program your FPGA. If later on you changed your software without changing your design you can use the last command to update the bit stream without having to repeat this long process.