Saturday, 14 December 2019

MAX1000 NIOS

SYSIN and SYSOUT
With a working NIOS processor available to us, thoughts turn more to software.  Programs are written in C and compile by Eclipse.  The first requirement for C programs is to have SYSIN and SYSOUT available.  If we have a single serial port, for example MAX1000 JTAG UART SYSIN/OUT are assigned by default to JTAG.  If we have multiple serial ports we can choose (in BSP) which ones to use.

Hello World
The simplest way to create C applications is to "create new application and BSP " in Eclipse.  There is a basic "Hello World" program which sends a SYSOUT message.  Tutorials generally instruct you to ensure you are using small C library and reduced device drivers to save space and the "Hello World small" causes these to be used.

Typically C "Hello World" specifies <stdio.h> and calls printf for terminal output.
If you select the small option you use an alternative library and functions.


Our first processor has about 40KB on-chip memory defined which is just about enough for printf output but not for input as well.  To have a program including input and output we use the small libraries and alt_putstr/alt_getchar.  These can use as little as 800B program memory.

SDRAM
The physical Altera FPGA chip has 64kB on-chip RAM and 64MB SDRAM so it makes sense to use SDRAM for our C programs and data.A tutorial from University of Las Vegas suggests that you can simply add SDRAM and directly replace on-chip memory with it.
I ran into difficulties when I tried to add SDRAM as it requires lots of pins to be defined.  I found that the test_board project provided with CycloneIV documentation checks SDRAM so I used the pin assignments from this for my SDRAM.

Once I had added SDRAM in platform designer I removed on-chip memory and pointed reset and exception vectors to SDRAM.
Now when I download programs from Eclipse to NIOS I can make them as large as I like.  A simple C program with printf and scanf takes about 100KB.

MICRIUM
There is a third variant Hello World program provided in Eclipse which uses MicroC-OS/II  RTOS.  It seems sensible to me to have an RTOS in an embedded processor.  I could compile the RTOS Hello World quite easily and it only took 60KB.  In fact it started two threads which run simultaneously.  It will be useful for multi-tasking but it doesn't have a user shell (unless I write it myself).





No comments:

Post a Comment