Forum Discussion
23 Replies
- Altera_Forum
Honored Contributor
You'll want to use the IOWR(),IORD() functions to access Avalon-MM registers in your peripheral (assuming that you're trying to read/write registers). See the software handbook (http://www.altera.com/literature/hb/nios2/n2sw_nii5v2.pdf), page 9-4 in particular. Or you can use the direct functions (ex IORD_32DIRECT()).
- Altera_Forum
Honored Contributor
Thanks.. that helped.
Other than this i have a very basic confusion. In my project, i want to transfer 128 16-bit values to the custom component (slave) and this values will be used by component to evaluate the final output and that output will again be sent back to NIOS (master). So should i just write IOWR_32DIRECT() 128 times as below: IOWR_32DIRECT(BASE, OFFSET0, DATA0);IOWR_32DIRECT(BASE, OFFSET0, DATA1); IOWR_32DIRECT(BASE, OFFSET0, DATA2); | | IOWR_32DIRECT(BASE, OFFSET0, DATA127); And then read the final output register as: IORD_32DIRECT(BASE, OFFSET1); If this is correct, does the nios II automatically sends the data sequentially ? Then how does the custom component gets to know when the new data arrives ?? And how NIOS will know when to read the final output register. Thanks for your time & effort, Anuj - Altera_Forum
Honored Contributor
Your custom component uses 16 bit Avalon data bus or 32 bit Avalon data bus.If it is using 16 bit Avalon data bus then you should write IOWR_16DIRECT instead of IOWR_32DIRECT and same way for IORD function also.
Other then that your C code is correct. Whenever you use IOWR function,Avalon Master generate Avalon write request and provide address of Slave Component Register on Avalon address bus line and provides data on Avalon data bus.Avalon Slave component uses this write request and address information to update its registers.Same way for IORD function,Avalon Master generates read request and address of the Slave component register.In this case slave component provides data on Avalon data bus. - Altera_Forum
Honored Contributor
OK.. I got it. Thanks.
Now when i am compiling my system in Quartus it gives warning as "Warning (20028): Parallel compilation is not licensed and has been disabled" and also says ".sdc file not found". Please guide - Altera_Forum
Honored Contributor
If you wanted to burst the data to be a little more efficient, you could DMA the data over. Or, I THINK if you have a data cache, you could move data as pointers and that might burst (i.e. don't use the IOWR/RD macros that bypass the cache), but I'm not sure, I've never done that - just read about it on this forum before. If a few wasted clock cycles don't matter, then you could just do a bunch of IORD/WR ops.
I'm guessing you're using Quartus Web Edition? It doesn't support parallel compilation. - Altera_Forum
Honored Contributor
Do you mean to include a DMA block in between Master & Slave ??
As per the forum discussions, it suggests to optimize the code to avoid parallel computing. But i cannot understand which part of my design is creating this issue and what should i optimize? Is this the data bus width i.e. 16 bit that i am sending in parallel?? And i did not use Avalon Bridge in the interface.. Is it recommended? I saw in the online lectures that it is necessary but i compiled my code without that too. - Altera_Forum
Honored Contributor
A DMA core could be used for efficient burst transfer between memory locations. See the embedded IP user's guide (http://www.altera.com/literature/ug/ug_embedded_ip.pdf), chapters 25 & 26 for the SGDMA and DMA cores. There's also the modular SGDMA (mSGMDA) available on the wiki (http://www.alterawiki.com/wiki/modular_sgdma), but I don't have any experience with it.
The warning (20028) just means that Quartus II won't use multiple cores to synthesize/fit your design. I.e. it may take a little longer to build the image. The standard edition of Quartus II does support it - but I honestly do see a huge improvement, it still uses 1 core on my quad core xeon for the most part. When you say "Avalon Bridge", are you referring to the pipelined bridge? You can use those to break up your bus if you have a lot of components and you're having trouble meeting timing. If you just have a few peripherals, and a reasonable clock speed, you probably don't have to bother with it. - Altera_Forum
Honored Contributor
I have one more question...
I made a new component in Qsys to implement my custom design. And from there i got the base address allocated to that component that will be used during the communication through the avalon MM interface (in NIOS). But I got one more option to implement the custom component.. I created the design in Qsys w/o custom component. Got that design imported in quartus and manually instantiated the HDL file of custom component in the TOP Level file generated by Qsys. I was successful in compiling the code. "But how to get the base address allocated to my custom block in this case ?? I need that address while coding in NIOS." - Altera_Forum
Honored Contributor
--- Quote Start --- "But how to get the base address allocated to my custom block in this case ?? I need that address while coding in NIOS." --- Quote End --- I don't think so you can access your custom component which is not having Avalon Interface using NIOS. Would you please tell what do you want to do with your custom component? - Altera_Forum
Honored Contributor
Hi,
I succeeded in implementing the system on board. My custom component is a 128 tap FIR filter which is to be started by NIOS and stimuli is also provided by nios. I made the custom component in Qsys and implemented the system. Now i am able to write the c code successfully on the NIOS without any tool errors. But, i am not able to communicate properly. Below is my code: int var =1234; IOWR(20496,0,11); printf("%d\n",var); //prints 1234 var = IORD(20496,0); printf("%d\n",var); // prints 0 When I am reading the same address and offset, it gives 0.