Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Custom Instruction

Altera_Forum
Honored Contributor II
1,658 Views

I need help in creating an "External Interface Custom Instruction". 

 

Are there any tutorial about it? 

 

 

thanks http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/wink.gif
0 Kudos
10 Replies
Altera_Forum
Honored Contributor II
637 Views

I assume that you are using Nios II? 

If so, in the tutorials folder under the install there is a folder named tutorials. There is a custom instruction folder there. Try that.
0 Kudos
Altera_Forum
Honored Contributor II
637 Views

 

--- Quote Start ---  

originally posted by matteo@Sep 8 2004, 04:46 AM 

i need help in creating an "external interface custom instruction". 

 

are there any tutorial about it? 

 

 

thanks  http://forum.niosforum.com/work2/style_emoticons/<#emo_dir#>/wink.gif  

--- Quote End ---  

 

Did you mean Custom instruction or add hardware to the external interface? 

 

http://www.altera.com/literature/ug/ug_nio...instruction.pdf (http://www.altera.com/literature/ug/ug_nios2_custom_instruction.pdf

 

That tells you everything you need to know. Make sure you carefully read the part about the timing (I usually manage to be off by a clock cycle everytime I make custom hardware http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif ) If you don&#39;t know how long your hardware takes to execute use the "done" signal (really wish that was in NIOS I). 

 

Cheers
0 Kudos
Altera_Forum
Honored Contributor II
637 Views

Thanks for your answer! 

 

However, I&#39;ve already read that tutorial but it&#39;s about a "Combinatorial Custom Instruction" example (the leading_zero instruction). 

 

I&#39;m looking for info about "External Interface Custom Instruction"..... http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/dry.gif  

 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

I assume that you are using Nios II?[/b] 

--- Quote End ---  

You&#39;re right! 

 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

Did you mean Custom instruction or add hardware to the external interface?[/b] 

--- Quote End ---  

I need both... http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/blink.gif  

 

 

Bye
0 Kudos
Altera_Forum
Honored Contributor II
637 Views

Ok if I understood correctly it sounds like you might be thinking these are the same thing (they are not). 

 

Custom instructions have hardware with ports like clk, dataa, dataab, etc....... and they get mapped to an instruction in the assembly language of the NIOS itself (it becomes a part of the ALU reallly). 

 

The custom hardware interface is a core that makes communication from the avalon bus to the outside world (outside of the NIOS) much easier using address/data and a few strobes. 

 

If what you need to do is something like 1/2 inputs and 1 output back to the software then custom instructions are for you. However if you have some processing to do outside the NIOS on more then 2 inputs then I recommend the custom hardware interface (and use a done signal to find out when it is complete)
0 Kudos
Altera_Forum
Honored Contributor II
637 Views

Hi Matteo, 

I&#39;ve designed an "external interface custom istruction" that outputs a bit signal read by Nios II through a one bit PIO, so if u have some specific questions i can try to answer... 

Bye
0 Kudos
Altera_Forum
Honored Contributor II
637 Views

Yes! http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/rolleyes.gif  

 

Thank you for your answer! 

 

I&#39;d like to know how I can implement it in hardware (with SOPC?)... 

 

PS: does the output bit signal you&#39;ve designed go out of the chip? 

 

 

Bye
0 Kudos
Altera_Forum
Honored Contributor II
637 Views

....... to make things easier can you describe what you are trying to do (there&#39;s more then one way to interface to the hardware so we might be able to provide better info that way). 

 

Just describe inputs, outputs, and how you want software to work with them (don&#39;t need to know what it does, just what kind of data is going back and forth)
0 Kudos
Altera_Forum
Honored Contributor II
637 Views

Ok, BadOmen: 

 

I&#39;ve a multiple Nios II architecture inside a single Stratix. 

 

I&#39;d like to add a 1 bit input and a 1 bit output (some sort of /req and /ack) to each Nios II to interface a custom hardware. 

 

Is it possible to built this hardware inside the Stratix chip? How can I do that? 

 

Then I need also the custom instruction... => this is why I was speaking about "external interface custom instruction" (see "NiosII Custom Instruction User Guide; chapter 1, page 12) 

 

 

Bye!
0 Kudos
Altera_Forum
Honored Contributor II
637 Views

Hi Matteo, 

i don&#39;t know if this is the right answer to your question but, to implement a custom instruction, first of all you have to edit the VHDL file (or another HDL description) that implements the functionality of your custom instruction; your top level module must have the I\O signal dataa, datab, result and so on, as described in the document "NiosII Custom Instruction User Guide"; each I\O signal not recognized as this kind of signals, will be an I/O signal of the NIOS II block. 

Then you have to enter the HDL file (.vhd if you use VHDL) on the custom instruction field of your NIOS II cpu menù, inside SOPC builder (this is described in the same document). Generate and you will have your custom istruction included in the NIOS II architecture. 

The output bit signal of my custom intruction doesn&#39;t go out of the chip, but it&#39;d be very easy to do... 

bye
0 Kudos
Altera_Forum
Honored Contributor II
637 Views

Ok, basically the one you are looking at adds additional functionality to the ALU of the NIOS core. I have never seen a custom instruction shared amungst multiple cores before but it should be doable (but you need some arbitration to prevent collisions). 

 

Is clcok cycle time an issue because this is a lot easier to do using the custom avolon bus interface. (if that sounds good to you let me know and I&#39;ll explain it a bit more). 

 

But under usual circumstances you would use the custom hardware in each instance of the NIOS core. The fact that you want to share the hardware would suggest that a couple of extra clock cycles is not going to hurt you so you may want to look at the interface to custom hardware core in the SOPC builder (usually near the top of the core list) since you can do a lot more with it (custom instructions are pretty restricting since they get used with the ALU). 

 

Cheers
0 Kudos
Reply