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++
Announcements
All support for Intel NUC 7 - 13 systems has transitioned to ASUS. Read latest update.
12578 Discussions

Custom Instruction Internal Registers Files

Altera_Forum
Honored Contributor II
1,281 Views

Hi. I spent the last 10 hours trying to assert Custom Instruction Internal Registers Files (readra, readrb and writerc). I gave up. I can't believe Altera hasn't develop any Macros to do it!! I have found some tips of how to do it in Assembly, but I couldn't understand well. Please let me know if there is a way to do it in C. 

 

Thanks, 

 

Gustavo
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
256 Views

Try a variant on the following: 

/* There are 'int __builtin_custom_inii(int op, int a, int b)' * (and similar) wrappers for custom instructions defined by gcc itself. * But none for the 'c' variants that do not use the main register file. * The one below is useful when the 'b' field is used as a sub-opcode.*/ __attribute__((always_inline)) static __inline__ uint32_t custom_inic(const uint32_t op, uint32_t a, const uint32_t b) { uint32_t result; __asm__ ( "custom\t%1, %0, %2, c%3" : "=r" (result) : "n" (op), "r" (a), "n" (b)); return result; }
0 Kudos
Altera_Forum
Honored Contributor II
256 Views

Oh, and the disassembler is wrong - it needs patching in order to correctly decode custom instructions (patches on wiki).

0 Kudos
Altera_Forum
Honored Contributor II
256 Views

It works when I use the following command and when I have only one custom instruction in my VHDL code. 

 

asm volatile ("custom 0, c0, %1, %2" : "=r" (y) : "r" (x), "r" (h)); 

 

But, when I want to select one custom instruction (n=0) out of two, my Hardware in VHDL doesn't read 0 in "n".
0 Kudos
Altera_Forum
Honored Contributor II
256 Views

Have you correctly connected your custom instruction module to both numbers? 

It may be worth looking at the RTL viewer and using signaltap.
0 Kudos
Reply