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.
12435 Discussions

Custom Instruction Internal Registers Files

Altera_Forum
Honored Contributor II
1,134 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
109 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; }
Altera_Forum
Honored Contributor II
109 Views

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

Altera_Forum
Honored Contributor II
109 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".
Altera_Forum
Honored Contributor II
109 Views

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

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