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++

Some questions about C2H

Altera_Forum
Honored Contributor II
1,018 Views

When I used C2H to accelerate my code,I met some problems. 

I chose a fuction to accelerate,but the report told me that:"The code does not contain any loop...".But it has 6 loops. 

I don't know what's wrong.Please help me.Thank you! 

-------------------------------------My code below------------------------------------------- 

void HistogramEql(alt_16 nWidth, alt_16 nHeight, alt_u8 *lpInput, alt_u8 *lpOutput) 

alt_16 x, y; 

# define Point1(x, y) lpInput[(x) + (y) * nWidth] 

# define Point(x, y) lpOutput[(x) + (y) * nWidth] 

 

alt_16 r[256], s[256]; 

alt_16 i; 

i=0; 

do{ 

r=s=0; 

i++; 

}while(i<256); 

 

 

for (y = 0; y < nHeight; y++) 

for (x = 0; x < nWidth; x++) 

r[Point1(x, y)]++; 

 

 

s[0] = r[0]; 

 

for (y = 1; y < 256; y++) 

s[y] = s[y - 1]; 

s[y] += r[y]; 

 

for (y = 0; y < nHeight; y++) 

{  

for (x = 0; x < nWidth; x++) 

Point(x, y) = s[Point1(x, y)] * 255 / nWidth / nHeight; 

 

}
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
258 Views

Did you try without using the# define Point(...) macro&#39;s, and use the formulas directly. Maybe the C2H compiler is not intelligent enough?? 

 

Does the code works in software mode??
0 Kudos
Altera_Forum
Honored Contributor II
258 Views

Hi Try to remove any ALTERA NIOS specific HAL use and also ignore# define statement. 

Because C2H only accelerate the function which is purely C/C++ and used only their library. They will never work with NIOS HAL function and etc.. 

 

Best Regards, 

slsnios
0 Kudos
Reply