Forum Discussion
Altera_Forum
Honored Contributor
11 years agoALTFP_MUL as custom instruction not reseting variable value.
Hello.
I´m trying to do a simple float point multiplier for Nios E. My custom instruction is just ALTFP_MUL block with a top level with clk, clk_en, reset, and the two 32bits inputs and one 32bits output. It seemed to be working fine, I could sintetize and download to the board. However the results are wrong. It appears as the registers get the values from previous execution. Looking at this codeint main(int argc, char* argv) {
float value = 10;
int i = 0;
for(;i < 10; i++)
{
value = ALT_CI_MULTIPLICADOR_0(5, (float)i );
printf("FINAL = %.9f, run = %d\n", value, i );
}
}
I have this out put final = 90.000000000, run = 0 final = 0.000000000, run = 1 final = 5.000000000, run = 2 final = 10.000000000, run = 3 final = 15.000000000, run = 4 final = 20.000000000, run = 5 final = 25.000000000, run = 6 final = 30.000000000, run = 7 final = 35.000000000, run = 8 final = 40.000000000, run = 9
The first interation is from a previous test where the the first value passed was 10. Running again I get thisfinal = 45.000000000, run = 0 final = 0.000000000, run = 1 final = 5.000000000, run = 2 final = 10.000000000, run = 3 final = 15.000000000, run = 4 final = 20.000000000, run = 5 final = 25.000000000, run = 6 final = 30.000000000, run = 7 final = 35.000000000, run = 8 final = 40.000000000, run = 9 Any one has any idea how to sync the cleaning?
3 Replies
- Altera_Forum
Honored Contributor
See "Multicycle Custom Instructions" in the manual: https://www.altera.com/content/dam/altera-www/global/en_us/pdfs/literature/ug/ug_nios2_custom_instruction.pdf
It sounds like your custom instruction isn't delaying for the ALTFP_MUL pipeline. - Altera_Forum
Honored Contributor
Ted, my custom instruction has the same latency than the ALTFP_MULT module (11 cycles).
I´m going to change to 12 or more to see what might happens. Thank you. - Altera_Forum
Honored Contributor
Changing the instruction latency to 12 works.
So, I conclude it has to be at least one more cycle than the float point block.