Forum Discussion

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

read write from an aonchip memory!!!!

hello,

i m a beginner, i try use an onchip memory. i can't perform read and write operation with onchip memory.

i can't found an C example that help me access to the memory.

i have writen c code:

# include "io.h"# include "system.h"# include <stdio.h># include "Data.h"# include "sys/alt_irq.h"

//=============================================================================

int i;

int h;

int *z;

int Acc0k;

long cpt_AlleleAccMaster;

int cpt_Allele;

int cpt_iteration;

int Nb_Nucleotides;

int *z1;

int *k;

void InitDNA()

{

Acc0k = 0;

cpt_Allele = 0;

cpt_AlleleAccMaster = 0;

cpt_iteration = 0;

Nb_Nucleotides = 64;

z1 = (unsigned int*)0x02100000;

for (i=0;i<Nb_Nucleotides;i=i+4)

{

h = (G[i]);

*z1 = h;

z1 = z1 + 1;

}

}

int main()

{

InitDNA(); //read (load) data from data.h

k= (unsigned int*)0x02100000;

for(i=0;i<16;i++)

{

printf("%x\t",*(k+i));// display data

}

}

can someone help me ?

thk for all members

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    doe's 0x02100000 address correspond to a on chip memory cell? did you check it at sopc builder?

    in that case you should declare you pointer as volatile

    # define ON_CHIP (*(volatile unsigned int *)0x02100000)
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    thnk you parrado, i success running my program with an onchip memory.

    best regards