My name is Sven Andersson and I
work as a consultant in embedded
system design, implemented in ASIC
In my spare time I write this blog
and I hope it will inspire others to
learn more about this fantastic field.
I live in Stockholm Sweden and have
my own company
You are welcome to contact me
and ask questions or make comments
about my blog.
How can we run a simulation using ISim and let the MicroBlaze processor execute the c-program we just compiled? Let's find out. The first thing we have to do is specify the ELF file that contains the compiled c-program. When we start a simulation this file will be converted to data files that will be loaded to the MicroBlaze instruction and data RAMs. The ELF file is specified in the Sim Executable entry under Project Files in XPS.
Generate memory initialization files
The program simgen is used for generating the HDL files and the memory initialization files.
Data2MEM is a command line executable that transforms CPU execution code (in the form of an ELF file), or pure data, into Block RAM initialization records. Simgen will use Data2MEM to convert the elf file to a VHDL file that can be used to initialize the BRAM. Here is more information about Data2Mem. The memory initialization files are stored in the directory simulation/behavioral.
Start the simulation We start the simulation from the menu Simulation->Launch HDL Simulation. When the compilation and elaboration have finished the ISim GUI is displayed. We are interested in looking at the LEDs_Positions block.
And to the signal gpio_io_o
Here is what to output signal looks like. It seems like we have a working system.
What happens during program execution.
To find out what the program execution looks like let's disassembly the ELF file using this command: mb-objdump --disassemble /home/svan/projects/ETC_SYSTEM_EDK/SDK/gpio_register_rw/Debug/gpio_register_rw.elf
Here is the beginning of the disassembled code:
After reset the MicroBlaze processor will start at address 0 and execute instruction. The first instruction is a branch to address 0x50. We can see that a few things will happen before our program starts to execute. The whole program will reside in the MicroBlaze instruction and data BRAM.
Use the following command to display all headers: mb-objdump --headers /home/svan/projects/ETC_SYSTEM_EDK/SDK/gpio_register_rw/Debug/gpio_register_rw.elf