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

How to read write registers in qsys through NIOS?

MK_ABQ
New Contributor II
1,447 Views

Hi,

I have created a qsys system with NIOS fast core processor. 

I have added a custom register component with avalon memory mapped interface. Now, how do I use NIOS(eclipse) and read and write the register that I created in qsys?.

I am specifically looking for functions, format to use from Eclipse. Is there any tutorial, or document for this?

 

Thanks,

MK

0 Kudos
9 Replies
KellyJialin_Goh
Employee
1,426 Views

Hi,

Greetings and welcome to Intel's forum.


I have here a tutorial which might help you understand further about the NIOS II avalon interface.

https://www.uio.no/studier/emner/matnat/fys/FYS4220/h20/lecture-slides/embedded_niosii_avalon_bus.pdf


Hope this clarify your doubts.


Thank you.


Regards,

Kelly



0 Kudos
MK_ABQ
New Contributor II
1,410 Views

Hello Kelly,

I am basically looking for help on functions/ways to access it from NIOS in C code. I have added registers in Qsys ( VHDL part). Now I want to access these registers from NIOS. So I am looking on functions/how to access it from NIOS?.

 

For example, lets say if I connect few led in VHDL, then the following NIOS code will help me to write these LED.

IOWR_ALTERA_AVALON_PIO_DATA(LED_BASE,cnt&0x0f);

 

So I am looking for similar function as shown above to read/write the custom registers that I created in qsys.

 

Thanks

0 Kudos
sstrell
Honored Contributor III
1,403 Views

You can only read it if it's readable, meaning your custom design has a readdata signal (read enable is optional if you've designed it as an always read except when writing design).  You'd use an IORD command in a similar fashion to what you have there for IOWR.  This training talks about it: https://cdrdv2.intel.com/v1/dl/getContent/653092

MK_ABQ
New Contributor II
1,390 Views

Thanks for your response sstrell and Kelly. I tried the steps and have reached a certain point, but with no success yet. 

I tried adding a custom block in qsys (it's a test register with avalon interface which enables read and write to the register). My intention is to read/write this register from NIOS. But, I am facing issue with that. 

 

My qsys information below:

"dummy_register" is the component that I added as a custom logic, and would like to access from NIOS. 

MK_ABQ_0-1681324301572.png

In my "dummy_register", I have set all the default values of the register to be hex"5555_5555".  I created a NIOS project, and tried to read the register as follows, but getting a wrong value. 

My C code and output in console hereby:

MK_ABQ_3-1681324542064.png

 

 

system.h file showing the dummy_register info:

MK_ABQ_2-1681324509787.png

 

Can you kindly point me out if I am missing something or doing anything wrong? Let me know if you need more info.

 

Thanks,

MK

 

 

0 Kudos
sstrell
Honored Contributor III
1,389 Views

You don't specify the design of dummy_register, but perhaps you need to connect the instruction master to it.

0 Kudos
MK_ABQ
New Contributor II
1,363 Views

Hi Sstrell,

I am hereby attaching my dummy_register code. I am just hardcoding register values to couple of registers, and try to read from NIOS. 

 

My Qsys is hereby. 

MK_ABQ_1-1681400562844.png

Do you mean to say I should also connect the avalon slave port from dummy register to the CPU instruction master in the image above?.

 

I updated the C code to more simpler one as shown here. I am not sure why I am getting "zero" as the read back value. 

MK_ABQ_2-1681400654045.png

 

0 Kudos
KellyJialin_Goh
Employee
1,353 Views

Hi,

Thank you for your response. I will get back to you shortly if I have any findings.


Thank you.


Regards,

Kelly


0 Kudos
MK_ABQ
New Contributor II
1,337 Views

Hi,

It got resolved.  I mistakenly was trying to read the wrong offset which did not exist in my VHDL. 

 

Thanks for your responses. 

 

 

0 Kudos
KellyJialin_Goh
Employee
1,276 Views

Hi,

I’m glad that your question has been addressed, I now transition this thread to community support. If you have a new question, Please login to ‘https://supporttickets.intel.com’, view details of the desire request, and post a feed/response within the next 15 days to allow me to continue to support you. After 15 days, this thread will be transitioned to community support. The community users will be able to help you on your follow-up questions.

 

p/s: If any answer from the community or Intel Support are helpful, please feel free to give best answer or rate 4/5 survey.


Thank you.


Regards,

Kelly Jialin, GOH


0 Kudos
Reply