Forum Discussion

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

Custom instruction woes

Hi all, and thanks for reading this,

I've built a nios(1) cpu identical to the one in the tutorial, however when I come to add custom instructions, I always get an incorrect result.

For example, if I have a bdf design with dataa, datab, clk, clk_en, start and reset IN, and result OUT, result set to vcc, the rest grounded, calling that custom instruction instead of giving me all 1s as the result, simply gives me -1 x (data + 1). E.g. if I say:

myresult = nm_test(123, 456);

Instead of getting myresult = 4294967295 (the int value of 32 1s) I get myresult = -124.

Similarly, if I have vhdl that is to simply return the smaller of dataa and datab:

IF(dataa(31 downto 0) < datab(31 downto 0)) THEN

result <= dataa;

ELSE

result <= datab;

END IF;

The code calling that custom instruction will always be returned -1 x (dataa +1).

Any ideas?
No RepliesBe the first to reply