EE 576: Laboratory 3
NiosII graphics interface.
Introduction.
In this assignment you will implement a video interface to the NiosII processor, including lines and text, then use it to animate a ball dropping. You will use the SOPC builder to construct a NiosII processor, QuartusII to add a VGA video interface, and the NiosII IDE to write a GCC program to animate the ball.
Procedures:
- You must handle the boards only on on the ESD mat. These boards are expensive and you must be careful of them.
- Make sure the Altera DE2 board is connected to power and to the PC as specified
in the evaluation board description. Turn on the power supply with the red switch
on the board. Make sure the toggle switch on the left edge of the board marked (
Run/Prog
) is in the Run
position and leave it there at all times.
The FPGA will program in the Run
position. Putting the switch in the Prog
position writes your design to flash memory, which you do not want to do.
- The default top level module for the DE2 defines all of the logical i/o signals.
- You can define the mapping from logical signal to FPGA pins (pin assignment in QuartusII) for all the pins at once by importing this file using the menu item
Assignments... Import Assignments...
and specifying the file name. There is no need to define pins one-by-one.
- A hardware VGA interface is shown on the DE2 page. Read VGA example 1 Verilog code.
Setting up a project in the NiosII IDE:
- Start the IDE and specify a workspace. When you designed the cpu and top-level module, the design was stored in a folder. In the Workspace selection dialog box, browse for that folder, then add the string
\software
to the folder path. This new folder will be used to store all of the software projects associated with the specific cpu you built in the SOPC. After you press OK, you may need to click on the workbench
icon to do anything useful.
- Create a new software project. Select
File>New>project
. A series of dialog boxes will open.
- Choose
C/C++
application, then click Next
.
- Give the project a
name
, specify the ptf
file from SOPC builder, use the default location
, and specify a blank project
.
Then click Next
.
- Select
creat new system library
then click finish
.
- Back in the main IDE window, right-click on the
syslib
entry in the C/C++ Projects
pane, then select Properties
.
- In the dialog box, select
system library
on the left.
- Associate the desired device with
stdout
, stdin
, and stderr
. These will usually default to the JTAG UART.
- From the pulldown menu, select whether you are going to use
single threaded
or microC/OS
. Note that the web-version of the IDE does not support the operating system.
- Select the memory location, usually defaults to SDRAM.
- Click
OK
to proceed.
- Back in the main IDE window, right-click on the
syslib
entry in the C/C++ Projects
pane, then select Build Project
.
Wait for it to finish.
- Create header files using
File>New>headerfile
and C files using File>New>file.
Assignment
- You will design the cpu system, plus timers, UARTs and parallel interfaces in SOPC, then use Verilog to add the VGA hardware interface. Don't use schematic entry or VHDL.
- The VGA graphics interface should include the ability to draw arbitrary lines and text. It is acceptable to run the VGA at 320x240 resolution. You will need to implement a character generator either in hardware or software (on the NiosII). You will also need to implement a breshenham line drawing scheme in hardware or software. Full credit will only be given if at least one of the two (character generator, line generator) is in hardware.
- I suggest using SDRAM as memory for the NiosII and SRAM as the VGA display memory. Be sure to follow the suggestions in the SDRAM tutorial to get the SDRAM timing correct.
- When KEY3 is pressed to indicate reset, the region in which a ball will bounce should be drawn. The region will include the upper left and lower left corner of the screen, plus two points chosen randomly, one on the top half of the right screen boundary, and one on the bottom screen boundary.
- Once you can draw boundary lines, animate a ball released from the upper-left corner of the screen with some horizontal velocity, falling under the influence of gravity, and with energy loss at each bounce. Pressing KEY3 should reset the ball to the upper left corner. The ball should bounce off the inside of a box drawn as straight lines. The elapsed time in sceonds should be shown in the lower right corner.
- You will need to come up with a command scheme so that the cpu can communicate with the VGA graphics interface. Minimally, there needs to be commands to:
- erase the screen
- draw a point at x,y in any color
- draw a line from x1,y1 to x2,y2 in any color (if the line generator is in hardware)
- draw a character at x,y in any color (if the character generator is in hardware)
There
also needs to feedback to the cpu from the graphics system to:
- read a point at x,y
- signal the cpu that the graphics system is ready for another command
Be prepared to demo your design to your TA in lab.
Your written lab report should include:
- How you made the character and line generators.
- A detailed dsecritpion of your SOPC design.
- A heavily commented listing of your Verilog design and GCC code.
Copyright Cornell University July 2006