FPGA Center



 * Project Definition

 * Create Quartus Project

  * Create Nios Project

Project Definition

In this tutorial   you will create a simple soft processor by using SOPC Builder in the Quartus II. This Soft processor contains

                          

You will write your program in C by using NIOS software.

A Simple C Program

Lets get started the design by writing the C program.

The program determines a 8 bit (255) binary counter. And in order to see the counter we connect the counter to the 8 Leds via 8 bit PIO called LED. We also define a button PIO (1 bit)  and connect it to a external button on the board. When this button is pressed, we can see the a warring message in PC via JTAG UART.

S#include "system.h"
#include "alt_types.h"
#include "altera_avalon_pio_regs.h"
#include "sys/alt_irq.h"

#include<stdio.h>
#include<stdlib.h>
int i,button;

int main (void)
   {
      printf("Hello world\n");
      usleep(1000000);
      while(1)
           {
                for( i=1; i<255;i++)
                      {
                       IOWR_ALTERA_AVALON_PIO_DATA(LED_BASE,i );
                       button = IORD_ALTERA_AVALON_PIO_DATA(BUTTON_BASE);
                       if(button==0) printf("switch pressed\n");
                       usleep(1000000);
                      }
           }
return 0;
}

 

 

                                                                                                                                                                                  Vhdl_Code

 

Home | Fpga | VHDL | VHDL Dictionary | Digital Design | Simulation | PCB | Examples | Contact Us
Copyright © 2010 - 2013 FPGAcenter. All Rights Reserved.