Forum Discussion

MK_ABQ's avatar
MK_ABQ
Icon for Contributor rankContributor
2 years ago

How to read write registers in qsys through NIOS?

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

9 Replies

  • sstrell's avatar
    sstrell
    Icon for Super Contributor rankSuper Contributor

    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

  • 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

  • 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.

    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:

    system.h file showing the dummy_register info:

    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

  • sstrell's avatar
    sstrell
    Icon for Super Contributor rankSuper Contributor

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

  • 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.

    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.

  • KellyJialin_Goh's avatar
    KellyJialin_Goh
    Icon for Frequent Contributor rankFrequent Contributor

    Hi,

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


    Thank you.


    Regards,

    Kelly


  • Hi,

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

    Thanks for your responses.

  • KellyJialin_Goh's avatar
    KellyJialin_Goh
    Icon for Frequent Contributor rankFrequent Contributor

    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