Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Full On-Chip Memory

Hi,

I'd like to know how to determine if the memory space of an on-chip memory is full.

In my nios II system, I generated an on-chip M4K memory. It's size is 4096 bytes with a 32 bits data width. So I've done some trial and error and some calculation about the specifications and have concluded that I have 1023 addressable spaces from 0x000 - 0x3ff. I have calculated that each addressable space can contain 32 bits of data.

I tested this with the following code:

IOWR(ONCHIP_MEMORY2_1_BASE, 0x3fe, "THIS IS TO TEST HOW MUCH DATA CAN A MEMORY SPACE CONTAIN");
alt_printf("%s\n", IORD(ONCHIP_MEMORY2_1_BASE, 0x3fe));
alt_printf("%s\n", IORD(ONCHIP_MEMORY2_1_BASE, 0x3ff));

The problem I face now is I don't know how big 32 bits of data is because I know that a character is 1 byte and so I hypothesized that a memory space addressed by 0x3fe for example would contain just 4 characters. However it held more than that (the string "this is to test how much data can a memory space contain").

How big is a string anyway? and when I try to read out on a memory space that I didn't write to I get the garbage values below.

nios2-terminal: connected to hardware target using JTAG UART on cable
nios2-terminal: "USB-Blaster ", device 1, instance 0
nios2-terminal: (Use the IDE stop button or Ctrl-C to terminate)
Hello onchip mem!
THIS IS TO TEST HOW MUCH DATA CAN A MEMORY SPACE CONTAIN
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
... (goes on for around 400+ lines)

What happened here?

Thanks in advanced!

Regards,

27 Replies