Data Clarification

Data Clarification

par Jérôme Savary,
Number of replies: 2

Hello,

I am currently writing the vhdl for the second laboratory. My question concerns the implementation as a custom instruction. If I understand correctly, we need to make a slave custom IP which take a 32 bits, make the operations (switch, etc.), and returns it. How exactly are we supposed to proceed ? For instance, we could generate an interrupt when the conversion is finished, or polling a flag and then read it ? 

Thank you for your time,

Jérôme Savary

In reply to Jérôme Savary

Re: Data Clarification

par Sahand Kashani-Akhavan,
I think you are confusing what a custom instruction is with what a slave peripheral is.

A slave peripheral (what you've been designing in previous labs with GPIOs, timers, ...) are external to the CPU. The CPU accesses these peripherals using non-cacheable reads/writes the with IORD_xxDIRECT/IOWR_xxDIRECT macros.

A custom instruction is internal to the CPU and is directly in the CPU's datapath: It is a special instruction that you, the programmer, define the semantics of. This instruction is directly emitted by the compiler (GCC) and can be seen in the instruction memory that your CPU fetches from. Since custom instructions are internal to the CPU, they cannot generate interrupts. You may want to check section 2.1 of the "Nios II Custom Instruction User Guide" below and see that there are only data input/output pins.
https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/ug/ug_nios2_custom_instruction.pdf

You can add a custom instruction to your CPU in qsys. The Nios processor's configuration window should have a tab or something similar where you can define what the custom instructions are.
In reply to Sahand Kashani-Akhavan

Re: Data Clarification

par René Beuchat,

You creat e a custom instruction as a a new component, but you select custom instruction in the list of all the units you can define.

You select all the signals and the associated type, the number of instructions in your module. And save it with a good name.

Then in NIOSII you add it and specify the base instruction number, a multiple of its size.

Best.

RB