Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

Nios2 Custom Instruction

Altera_Forum
Honored Contributor II
817 Views

Hello everybody; 

I made my custom logic that accepts 2 inputs each of 128 bits wide and produces 128 bits reault, is this any way to integrate my logic with Nios2 and deal with it by a custom instruction.
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
104 Views

If the several clocks necessary is OK, then yes you can use a multi-cycle custom instruction that accesses the NIOS register file to read the two 128-bit inputs and then write the 128-bit output. See page 1-9 of http://www.altera.com/literature/ug/ug_nios2_custom_instruction.pdf 

 

However, if you wish to achieve relatively high throughput, you would be better off putting your accelerator in a custom IP block with an Avalon-MM Slave interface for control and one or more Avalon-MM Master ports to read/write your data directly from memory.
Altera_Forum
Honored Contributor II
104 Views

Thank you Mr ted for your attension; 

I have already defined my avalon memory mapped slave component with Qsys, but how can I access it through eclipse. 

Thanks.
Altera_Forum
Honored Contributor II
104 Views

You should read this: 

http://www.altera.com/literature/hb/nios2/n2sw_nii52005.pdf 

 

The short answer is to use IORD/IOWR macros against the base address in <system.h>
Altera_Forum
Honored Contributor II
104 Views

For a custom instruction you'd have to use mutiple opcodes to write the 128bit values and then multiple opcodes to retrieve the result. 

It could all be done with a single clocked (not combinatorial) custom instruction opcode. 

If 'readrc' is zero use the 5 bit C value to select where to save the 32bit rA and rB values. 

If 'readrc' is one use the A field to determine which result to return. 

(Actually you can look at the writera bit and the 32bit A value as well, and all the B ones.) 

 

I didn't ever look to see if the writera/writerb bits have any effect on the cpu logic. I strongly suspect that the pipeline stall (for an earlier 'late result') always happens. All other instructions stall on the A field, a B field stall is needed if the low two bits of the opcode differ. It seems highly unlikely that the custom opcode bits get fed in to that logic, it is even possible that it applies to jmpi and call instructions.
Altera_Forum
Honored Contributor II
104 Views

Oh Thanks dsl; 

I will try now what you say.
Reply