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 Basic Doubts !! Urgent

Altera_Forum
명예로운 기여자 II
1,255 조회수

Hi all, 

 

am pretty new to using NIOS processor. I have been using Quartus II for cyclone for making block diagrams. I have moved to NIOS as i need reduction in Logic cells. 

 

I have installed NIOS II IDE 10.1 

I have installed Quartus II 10.1 

 

Please help me to write a simple assembly program to take 2 inputs using a i/o port and output the sum into an output port which i would configure using SOPC builder. 

 

Am very new to the technology please help me out regarding the same.  

 

thanks in advance.
0 포인트
5 응답
Altera_Forum
명예로운 기여자 II
498 조회수

Start with one of the 'hello world' samples from Altera. 

You might need one of the 'small footprint' versions.
0 포인트
Altera_Forum
명예로운 기여자 II
498 조회수

I have been trying to do some basic stuff as follows, 

 

I have made a basic cpu with one in-port and one out-port 

given a constant value at the inport 

want to read the value in the outport by implementing the CPU using assembly prog. 

 

.text 

.global _start 

_start: 

movia r15, 0x00000000 /*base address of input port*/ 

movia r16, 0x00000010 /*base address of output port*/ 

ldwio r4, 0(r15) 

stwio r4, 0(r16) 

.end 

 

how shud i compile this and write into the FPGA ??? 

 

I much complicated project is awaiting me... if i get through these basics i and pick up and go ahead. please help.
0 포인트
Altera_Forum
명예로운 기여자 II
498 조회수

Most people write most of their code in C. 

Often with a view to expecting the compiler to generate specific instructions!
0 포인트
Altera_Forum
명예로운 기여자 II
498 조회수

For stuff like this unless you prefer doing things the hard way just write this in C. 

# include "altera_avalon_pio_regs.h" 

 

int main () 

unsigned long read_data; 

read_data = IORD_ALTERA_AVALON_PIO_DATA(INPUT_PIO_BASE); 

IOWR_ALTERA_AVALON_PIO_DATA(OUTPUT_PIO_BASE, read_data); 

return 1; 

}
0 포인트
Altera_Forum
명예로운 기여자 II
498 조회수

And if you still want to do it the hard way, you could do something like the following in the Nios command shell: 

nios2-elf-gcc -nostdlib -Ttext=0x1000 test.S elf2hex --input a.out --output test.hex --width 32 --base 0x1000 --end 0x1FFFThe above assumes you have put your source in a file named "test.S" and that your on chip memory starts at 0x1000 and ends at 0x1FFF. You can adjust accordingly. If you assign the resulting test.hex file to on chip memory and set your Nios reset vector to this memory, it should run. 

 

Note that your program should have some kind of loop or something at the end so it doesn't keep executing beyond the end of your source with unpredictable results.
0 포인트
응답