Altera_Forum
Honored Contributor
16 years agoNiosII is slow? Or something I am doing wrong.
Hi all,
I am playing with Cyclone II chip. It is custom board and there is ATMEGA16 running at 12MHz and FPGA with master clock 50MHz. FPGA is translating data from internal dualport memory via LVDS to other board with lots of RGB LEDs. Just for fun and for learning purposes I wrote small program for Mandelbrot fractal calculation in C. First of all, I compiled it with GNU C for ATMEGA. When I copy-pasted same code to Nios II. The difference between tests: a) when runing from ATMEGA, CPU clock is 12MHz, data passed to FPGA via 4 wires + control line. Both nibles are joined in FPGA and RAM adr is calculated in hardware. b) when runing from NIOS II, CPU clock is 50MHz, data passed to RAM in 8 wires, RAM adr is passed via 12 wires directly. No need for calculation. Nios II is configured with hardware float multiplication. All RAM is on-chip. Guess who is faster? I didn't made exact measurement. But BOTH system looks like runing on same speed! :eek: What is wrong? Testing software: #include "main.h" static float zeta;   void pushbyte(char x, int adr) { IOWR_ALTERA_AVALON_PIO_DATA(RAMADR_BASE,adr); IOWR_ALTERA_AVALON_PIO_DATA(PORTB_BASE, x); IOWR_ALTERA_AVALON_PIO_DATA(PORTA_BASE, 1); IOWR_ALTERA_AVALON_PIO_DATA(PORTA_BASE, 0); }     void pumprgb(void) { int adr; float cx, cy, scale, a1, b1, a2, b2, ax, ay; signedint x,y; long color; float a12, b12; int limit; int lp; cx=-1.52; cy=0; scale=0.05001-(zeta*0.002); limit=4; if (zeta>128) {zeta=0;} //sitas netelpa! 100 baitu reikia.   y=-12; while (y<12) { x=-40; ay=cy+y*scale; while(x<40) { ax=cx+x*scale;   b1=ay; a1=ax; a12=a1*a1; b12=b1*b1; lp=0; while ((lp<255) && ((a12+b12)<limit)) { lp++; a12=a1*a1; b12=b1*b1;   a2=a12-b12+ax; b2=2*a1*b1+ay; a1=a2; b1=b2; } color=lp; color=color*45536; adr=((int) ((x+40)*3+((y+12)*240))) & 0x1FFF; //adr=adr & 0x1FFF; pushbyte((color>>16),adr); // red pushbyte((color>>8),adr+1); // green pushbyte(color,adr+2); //blue x++; } y++; } zeta++; }   int main(void) { zeta=0; while(1) { pumpRGB(); } return(0); }