Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21587 Discussions

writing information into avalon slave in c

Altera_Forum
Honored Contributor II
1,530 Views

Hi, 

 

I have a NIOS II which is connected to a vga component with avalon memory mapped slave.  

In the VHDL entity, i have address, writedata, readdata, and chip select. the address base of the avalon memory mapped slave is 0x3008.  

 

I am not sure how to write information into the memory mapped slave. The address is used so i can write data into different signals.  

 

So far i have something like this in c: 

# define x (char *) 0x3008 

 

main(){ 

while(1) 

*x=0x0F; 

// whatever values i need to pass. 

}
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
461 Views

From NIOS you just treat it as if it is any other bit of memory and the processor will take care of the signalling (hence they are called memory-mapped). 

 

There are handy functions provided in the NIOS BSP that are useful when writing to slave devices such as: 

IOWR_32DIRECT(<base address>,<offset in bytes>,<32bit data>); 

IORD_32DIRECT(<base address>,<offset in bytes>); 

And similar ones for 8bit and 16 bit data. 

 

Alternative you can do something like: 

 

int main(){ 

char* x = 0x3008; 

*x = 0x0F; 

}
0 Kudos
Altera_Forum
Honored Contributor II
461 Views

 

--- Quote Start ---  

From NIOS you just treat it as if it is any other bit of memory and the processor will take care of the signalling (hence they are called memory-mapped). 

 

There are handy functions provided in the NIOS BSP that are useful when writing to slave devices such as: 

IOWR_32DIRECT(<base address>,<offset in bytes>,<32bit data>); 

IORD_32DIRECT(<base address>,<offset in bytes>); 

And similar ones for 8bit and 16 bit data. 

 

Alternative you can do something like: 

 

int main(){ 

char* x = 0x3008; 

*x = 0x0F; 

--- Quote End ---  

 

 

 

Thanks i got it working. Another question i have has regards to the altera monitor program. Has anyone used it? 

 

I'm trying to use the sleep function included from the unistd.h. However when i compile it tells me there is an undefined reference to sleep(). any ideas? 

 

ps. usleep() gives the same error
0 Kudos
Reply