Forum Discussion

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

How to use the niosii custom instructiont?

http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/ph34r.gif hello,

I did a niosii custom instructiont mode,and input it into my system via SOPC,but I ran

into troublesome when I oprate the custom instructiont mode in NIOSII IDE.

According to the Example B(p2-1,Bit-Swap Custom Instruction) of Software Interface of

"Nios II Custom Istrucrion User Guide" ,the custom instruction used in applacation code

should be as follows the form:

1.#include "system.h"

2int main(void)

{

int a = 0x12345678;

int a_swap =0;

a_swap= ALT_CT_BSWAP(a);

return 0;

}

According to this kind of form,my custom instructiont mode in applacation code do not

work !

I fined the Another example of User Guid is different from this form.

...

alt_u8 zeros_hardware[NUM_SAMPLES];

alt_u32 numbers[NUM_SAMPLES];

...

void hardware_leading_zeros(void);

compare_leading_zeros(void);

...# ifdef ALT_CT_LEADING_ZERO_DETECTOR

hardware_leading_zeros(void);

compare_leading_zeros(void);# endif ALT_CT_LEADING_ZERO_DETECTOR

...# ifdef ALT_CT_LEADING_ZERO_DETECTOR

zeros_hardware = alt_ct_leading_zero_detector(numbers);# endif ALT_CT_LEADING_ZERO_DETECTOR

...

When I put my custom instructiont mode into the leading-zeros-detector example running

well ,my custom instructiont mode can work well! but when I put my custom instructiont

mode into my system without sysid,it can not work again.

why ?!

whether the custom instructiont mode in applacation code want a limited_times sysid or

other condition?

thank you. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/rolleyes.gif

sbgxg123_zhb@21cn.net

zhgxg@163.net

1 Reply

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

    I don&#39;t see any reason why the SysID peripheral would have anything to do with it (I suggest you keep it in your design to make sure you are using the correct hardware). One thing to make sure of is that you have the correct name of the custom instruction (in your case " ALT_CT_BSWAP(a)"). If the C compile occured with no errors then this wouldn&#39;t be the cause.

    Can you describe further what you are seeing and how you set up the custom instruction?