Forum Discussion

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

ALTFP_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 code

int 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