I am using a 12K on chip memory for my Nios II system. In my software code, I am using an Integer array of length 500000. But I am wondering how it can be implemented on a 12k on chip memory?!!!. the project is built succesfully with no shortage of memory. Here is my code:
#include "system.h"
int main(void)
{
volatile unsigned int * read_ptr = (unsigned int *) (READ_PORT_BASE + 1);
volatile unsigned int * write_ptr = (unsigned int *) (WRITE_PORT_BASE + 1);
unsigned int temp;
int length = 500000;
unsigned int buff[length];
while(1)
{
buff[0] = (* read_ptr);
for (int i = 1; i < length - 1; i++)
{
temp = buff[i];
buff[i] = buff[i - 1];
buff[i + 1] = temp;
}
temp = buff[0] + buff[length];
(* write_ptr) = temp;
}
}
#include "system.h"
int main(void)
{
volatile unsigned int * read_ptr = (unsigned int *) (READ_PORT_BASE + 1);
volatile unsigned int * write_ptr = (unsigned int *) (WRITE_PORT_BASE + 1);
unsigned int temp;
int length = 500000;
unsigned int buff[length];
while(1)
{
buff[0] = (* read_ptr);
for (int i = 1; i < length - 1; i++)
{
temp = buff[i];
buff[i] = buff[i - 1];
buff[i + 1] = temp;
}
temp = buff[0] + buff[length];
(* write_ptr) = temp;
}
}