Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Memory access from Nios I

Altera_Forum
Honored Contributor II
1,130 Views

Hej ! 

I'm quite a newbie to Nios 1 so it may be quite easy but I don't figure out how to do this : I have a peripheral which I declared as a user-logic component in SOPC Builder and as a memory for the type because I have to read and write it.  

 

The problems I have now are 

-how do I write to my peripheral any data (i think about using sprintf ?) ? 

-how do I read it, knowing that my peripheral generates an interrupt whenever a data is ready to be read, and so on how do I detect this interruption (name of the ISR ?) ? 

I know how to do all of this with a traditionnal PIO, but not with a user-logic peripheral plugged as a memory (the type of this in the file excalibur.h is not anymore a pio* but a void*). 

 

Thanks for your help cause I'm completely stuck there. 

 

Cheers, 

 

Flyjuju2
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
411 Views

I have some user logic that generates an interrupt, I just feed the interrupt line into a 1-bit PIO and make that generate the IRQ to NIOS in the traditional manner. 

Banx.
0 Kudos
Altera_Forum
Honored Contributor II
411 Views

 

--- Quote Start ---  

originally posted by banx@May 12 2006, 01:14 PM 

i have some user logic that generates an interrupt, i just feed the interrupt line into a 1-bit pio and make that generate the irq to nios in the traditional manner. 

banx. 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15328) 

--- quote end ---  

 

--- Quote End ---  

 

Ok now the irq problem is solved thanks http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif ! but how do I deal with my software code to read and write data to my peripheral ? I started to write some assembly code but it just looks too complicate http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/blink.gif , I guess there is a way to do this in C, no ?
0 Kudos
Altera_Forum
Honored Contributor II
411 Views

Hello Fly, 

 

I presume excalibur.h has given you an address for your block of user logic and has cast it to be a pointer to void like this na_mylogic ((void*) 0x0002010) 

 

If your logic expects to be written and read in 32-bit wide accesses (ints) then just declare an integer pointer and make it point to your logic using a cast. 

 

unsigned int *my_pointer = (unsigned int*)na_mylogic; 

 

You could now use my_pointer to access your logic as if it were a memory array (of integers). You could easily modify the above to suit the width of your logic. 

 

I hope this is what you were asking, and it is of some help. 

 

Banx.
0 Kudos
Altera_Forum
Honored Contributor II
411 Views

 

--- Quote Start ---  

originally posted by banx@May 15 2006, 05:42 PM 

hello fly, 

 

i presume excalibur.h has given you an address for your block of user logic and has cast it to be a pointer to void like this  na_mylogic  ((void*) 0x0002010) 

 

if your logic expects to be written and read in 32-bit wide accesses (ints) then just declare an integer pointer and make it point to your logic using a cast. 

 

unsigned int  *my_pointer = (unsigned int*)na_mylogic; 

 

you could now use my_pointer to access your logic as if it were a memory array (of integers). you could easily modify the above to suit the width of your logic. 

 

i hope this is what you were asking, and it is of some help. 

 

banx. 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15382) 

--- quote end ---  

 

--- Quote End ---  

 

It&#39;s exactly what I was expecting ! but just one question : will the Nios automatically assert my read and write and chip_select signal correctly when I will write to it ? Moreover, when I have an interrupt from my logic, how can I clear the flag ? because i don&#39;t have anymore any pioedgecapture available ! 

thanx a lot for your help banx ! 

Flyjuju2
0 Kudos
Altera_Forum
Honored Contributor II
411 Views

Hello Fly, 

Yes, all your CS and R/W should be ok. 

The behaviour of your own logic and how you have setup the PIO will determine the code you need to clear the interrupt. I&#39;m presuming that your logic has a register, or something, that you must write in order to clear its interrupt line, you can then clear the PIO interrupt by writing zero to the edgecapture bit. 

Is it possible the PIO is setup for level and you aren&#39;t clearing the interrupt in your own logic yet? This would cause continuous interrupts. 

Banx.
0 Kudos
Reply