Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
1,056 Views

Custom Instruction Internal Registers Files

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 I
31 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 I
31 Views

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

Altera_Forum
Honored Contributor I
31 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 I
31 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