Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

using register-file in custom instruction

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

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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