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

Some Basic Doubts !! Urgent

Altera_Forum
Collaboratore onorario II
1.250Visualizzazioni

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 Kudos
5 Risposte
Altera_Forum
Collaboratore onorario II
493Visualizzazioni

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

You might need one of the 'small footprint' versions.
Altera_Forum
Collaboratore onorario II
493Visualizzazioni

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.
Altera_Forum
Collaboratore onorario II
493Visualizzazioni

Most people write most of their code in C. 

Often with a view to expecting the compiler to generate specific instructions!
Altera_Forum
Collaboratore onorario II
493Visualizzazioni

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; 

}
Altera_Forum
Collaboratore onorario II
493Visualizzazioni

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.
Rispondere