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
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
12748 Discussions

using register-file in custom instruction

Altera_Forum
Honored Contributor II
1,134 Views

hello, 

 

i want to create a custom instruction with more than two inputs, that can be changed randomly. 

 

The custom instructions user guide 

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

says, that you can use the internal registers of the custom instruction instead of the nios register-file, if you instantiate a custom instruction with the following IOs 

 

dataa[31..0] 

 

datab[31..0] 

result[31..0] 

clk 

clk_en 

start 

reset 

done 

n[7..0] 

a[4..0] 

readra 

b[4..0] 

readrb 

c[4..0] 

writerc 

 

 

 

where a,b and c are the adresses of these internal registers. The problem is, that the system.h only gives me a makro, with A (=dataa), B (=datab) and n (= extended opcode). 

 

#define ALT_CI_GP_ALU_NIOS_CUSTOM_INSTR_WRAPPER_INST(n,A,B) __builtin_custom_inii(ALT_CI_GP_ALU_NIOS_CUSTOM_INSTR_WRAPPER_INST_N+(n&ALT_CI_GP_ALU_NIOS_CUSTOM_INSTR_WRAPPER_INST_N_MASK),(A),(B))  

 

so, how can i set the internal register file adresses (a,b and c) ? 

 

Tanks 

keitall
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
451 Views

Hi  

I am not sure but i think either you might have forgotten to specify as Internal register file while preparing the SOPC Builder or may you can do one thing you specify in the main itself the a(internal register address) b(internal register address ) and c(internal register address) and try if whether the compiler will take the values  

 

Please let me know if you are able to solve the issue  

 

 

Thanks and regards 

M Kalyan srinivas
0 Kudos
Altera_Forum
Honored Contributor II
451 Views

hi, 

 

i think there is really no Makro to handle those register-files, which means you have to handle them yourself.  

 

i tried with the assembler instruction 

 

asm("custom n, xC, xA, xB"); 

 

where n is the id of the cutom instruction. if you replace the 'x' with a 'c', you address the vhdl-description of the custom instruction. 

 

the only problem is, that if you disassemble the code, he doesn't even use this insturction. 

instead of 

 

asm("custom 8, c7, c8, c9"); 

 

it translates 

 

custum 8, c1, c2, c3
0 Kudos
Reply