Read onchip memory from NIOS II


Onchip memory is shared with NIOS II, when i execute…


it returns jibrish “unknown character” :: I think it is able to read that memory location but not able to decode it in HEX…

how to read onchip memory through NIOS II and display in hex values ?

on reading onchip memory with IORD instruction,

It returns same value. even if there is different value present in the address…

It’s a printf formatting/“variable type” issue.

printf() doesn’t natively understand anything other than quoted strings…i.e.: printf(“Hello, World!”);

You’d need to use one of %x, %i…for the details of how to do that you can use Google as well as I. :wink:



1 Like

Thank you for the reply… But what if i want to store it in a integer type variable…?

Okay…sorry for the massive response delay on my end.

Usually, when displaying values I read from memory I, I use hex format for output.

So, for your above example, it would be something like so:

printf(“Value = 0x%x.\n”, IORD(…));

You may need to “cast” the IORD() result to a type that printf supports. In that case, you’d have something like so:

printf(“Value = 0x%x.\n”, (alt_u32)IORD(…));

Being pedantic, but the dots (…) represent your particular register reads.