cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
546 Views
Registered: ‎12-04-2019

How Do I Read Microblaze Instruction Memory From Software?

Jump to solution

I'm developing for a Microblaze microcontroller on a Spartan FPGA.  I need to calculate a checksum for the program, which resides in instruction memory.  The problem is that the Microblaze has Harvard architecture, so both Instruction and Data memories are in the same address range: 0x0000 to 0xFFFF.  So if I do a read on address 0x0000, I get what's in Data memory.

Other CPUs and microcontrollers have dedicated machine instructions for performing this.  For example, the Atmel AVR has a "Load Program Memory" (lpm) instruction.  The Microblaze has no such instruction.  So, does anyone know how this is accomplished?

1 Solution

Accepted Solutions
johnmcd
Xilinx Employee
Xilinx Employee
436 Views
Registered: ‎02-01-2008

Once a linkerscript has been created, it will never be updated. For example, if you create a hello world using the sdk/vitis templates, and your microblaze has 64KB of memory, then later you increase to 128KB of memory, the linkerscript will not be automatically updated.

So with that said, it is probably easiest to add your own _end labels.

View solution in original post

3 Replies
johnmcd
Xilinx Employee
Xilinx Employee
507 Views
Registered: ‎02-01-2008

Normally, in a microblaze design, and when working with 64KB of data/instruction, the BRAM is dual ported such that both data and instruction are accessing the same memory contents. The same is normally true if using the axi bram controller vs LMB bram controller.

To see this architecture, add a microblaze to an empty IPI design, then run the designer assistance, block configuration, wizard that shows up at the top of the IPI window and just use the defaults. Then expand the higherachy to view both LMB controllers and the single memory wizard.

0 Kudos
Reply
444 Views
Registered: ‎12-04-2019

Aha, I hadn't spotted that.  The Microblaze Core Block Diagram makes it look like two completely separate memories.  I checked the memory map and sure enough, .text and data sections (.data, .bss, etc.) have mutually exclusive addresses.

Do you know if there is a label I can use that indicates the end of the .text section (indicating end of executable instructions)?  All of the other sections have _end labels, but I don't see one for .text.  If there isn't one, what else could I use to do the same thing?

0 Kudos
Reply
johnmcd
Xilinx Employee
Xilinx Employee
437 Views
Registered: ‎02-01-2008

Once a linkerscript has been created, it will never be updated. For example, if you create a hello world using the sdk/vitis templates, and your microblaze has 64KB of memory, then later you increase to 128KB of memory, the linkerscript will not be automatically updated.

So with that said, it is probably easiest to add your own _end labels.

View solution in original post