Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12597 Discussions

why software's speed is so slowly run on nios II

Altera_Forum
Honored Contributor II
1,069 Views

hi! 

I write a software programm run on the nios II ,but the speed is slowly when it is running on the nios II. I use the singalTap catch the singal to analyse the speed ,I found when I add a equal ,like as: 

a=3; 

 

the speed will increase about 5 clock'time,The Nios II is 50MHz, 

I feel that the speed shoud't so slowly,but I can't find the reason.so I want to get some advise from you. 

thanks.
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
328 Views

Hi gerger, 

 

What kind of Nios II core type?? if you have used Nios II e-version, change Nios II core type to Nios II f-version. 

 

Regards.
0 Kudos
Altera_Forum
Honored Contributor II
328 Views

Hello Gerger, 

 

What is your code optimization set to in the properties for you project? 

 

Try using optimization -O3 this may help! 

 

Good Luck!
0 Kudos
Altera_Forum
Honored Contributor II
328 Views

yes ,I have use the NIos II f_version and g _o3,there are a little progress,but the speed is not very highly increase

0 Kudos
Altera_Forum
Honored Contributor II
328 Views

A statement like a=3 takes one cycle to execute on the Nios II/f assuming the instruction is in the cache. 

Are you familiar with the operation of caches? Also, what signals are you observing in signaltap to see the 

instructions flow down the pipeline? If you only look at the Avalon instruction master, you'll only see instruction 

cache line fills, not instruction execution. 

 

If you post more of your program (maybe a portion of the hot loop), we can give you more information.
0 Kudos
Altera_Forum
Honored Contributor II
328 Views

hello,my code is like this  

word1=1; 

word2=2; 

word3=3; 

word4=4; 

word5=5; 

//from this  

check_sum=(word1&0x0000ffff)+(word1>>16) 

+(word2&0x0000ffff)+(word2>>16) 

+(word3&0x0000ffff)+(word3>>16) 

+(word4&0x0000ffff)+(word4>>16) 

(word5&0x0000ffff)+(word5>>16); 

while(check_sum>>16) 

check_sum=(check_sum&0x0000ffff)+(check_sum>>16); 

if(check_sum==0x0000ffff) 

errflag=0; 

else 

errflag=1; 

//end this  

I had found do check_sum need about 100 cycles with Nios/f and _g3 .is it true ? 

In addition £¬if a=3,the data isn't in cache ,how many cycles will spend?
0 Kudos
Altera_Forum
Honored Contributor II
328 Views

100 cycles sounds fine to me. If you do a checksum in hardware it will be 'n' cycles, with 'n' being the width. Like James said before data cache can play a big role in the calculation time. I recommend you take a look at the Nios II documentation since the cycle time of each instruction is listed in the hardware documentation.

0 Kudos
Altera_Forum
Honored Contributor II
328 Views

thanks£¡ 

->100 cycles sounds fine to me. it sounds the speed is normally.before your replied,I had thought that my code was wrong in somewhere to result these . 

 

I had done the check_sum with custom_instruction of NIos II ,but the LE is not so much .so I had to do the check _sum with software .if did the check_sum with hardware ,the cycle is about 10 cycls .
0 Kudos
Reply