DOC PREVIEW
Columbia CSEE 4840 - System Design Lab

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CSEE W4840 Em bedded System Design Lab 2Stephen A. EdwardsDue February 12, 2010AbstractLearn to use the Nios II IDE (programming environm ent) to im-plement an Ethernet cha t client on the DE2 board.Unlike the first lab, your job here is to develop sof tware. Wehave supplied a har dware design fo r the DE2 that includes theNios II processor, memory, an Ethernet controller, a VGA con-troller, and a controller for the PS/2 keyboard.Your task is to develop software that u ses this hardware toimplement an Ethern et-based chat client. This will function asa ter minal: the user should be able to type in a line of text usingthe attached keyboard and see it appear on the video display.When s/he presses enter, the contents of the line should be sentas a UDP broadcast packet.Similarly, the board should display on the screen every UDPbroadc a st packet it receives. This assumes that any such packetcomes from a similar project.To clarify who is typing what, the fir st few characters of eachpacket should contain the user’s name. Have the user type thiswhen your system starts, save it, and send it automatically at thebeginning of e a ch packet.We have connected all the boards in the lab to hubs to form alocal-area network that is not connected to the Internet to avoidcausing proble ms for others. We have also connected a Linuxworkstation operatin g as a “packet sniffer” (the tcpdump pr o-gram) that will let you observe d etails of each packet and warnyou when it is malformed.Programming the board for this lab will take two steps. First,open the lab2 pro ject in Quartus like you did for lab 1. We al-ready compiled it for you, so you can go directly to the program-mer and download the DE2_NE T.sof file to th e board. This con-figures the hardware but leaves the software unconfigured. Tobring the board to life, download and run sof tware on it usingthe Nios II IDE, described below.1 The Nios II IDEStart the Nios II IDE by typing nios2-ide. This will eventuallybring up a window. If you get a (usually bogus) “Workspace cur-rently in use” message, try deleting the “nios2 -ide-workspace-6.1” directory in your home directory. The IDE is based onEclipse, so you may find it familiar. The environment variablesSOPC_KIT_NIOS2, SOPC_BUILDER_PATH_61, and QUAR-TUS_ROOTDIR must be set. Check these if you have problemsstarting the IDE.When it starts, it may give you a few icons to choose among.Select “Workbenc h” to get started.First, set your worksp ace. This is the directory in which theIDE will put files. Select File→Switch Workspace and selectyour directory for lab2.Figure 1: The Nios II IDE workbench re ady to accept a newprojectFigure 2: Importing projects into the IDEWhen you select a new workspace location , it should beginempty (Figure 1). Start by informing the IDE about the providedprojects.To bring the software into the IDE, right-click on the “NiosII C/C++ Projects” window on the left side of the main w indowand select “Import.” Under “Altera Nios II,” select “ExistingAltera Nios II Project into Workspace” (Figure 2). Click onNext >, then choose the lab2 dir ectory in the project directory.Click “Fin ish ” to impor t it.Repeat the process by importing the lab2_syslib pro je ct,which hold s information about the hardware configuration. Youmust specify the target processor by selecting the nios_0.ptf filein the lab2 directory. The lab2 project will not build without the1Figure 3: Running a program and observing outputlab2_syslib project.After importing both lab2 and lab2_syslib, build them by se-lecting “Projects” and “Build All.” Once built, you can runit on the DE2 by selecting “Run,” “Run As...,” and “Nios IIhardware.” This choice does not app ear unless the project hasbeen built, and it will not work unless you downloaded theDE2_NET.sof file to the board using Quartus.Conveniently, after the Nios II IDE runs your program, it co n-nects a terminal to the DE2 board that allows you to print andtype to your running C program through standard printf andgetchar calls. Figure 3 shows a running project with the ter-minal co nnection.2 The Chat ApplicationThe lab2.tar. gz file has a partially-working skeleton for the ap-plication. The code we sup plied is awful, but do es illustrate afew things; do not be afraid to modify or discard it. Here is a listof things you need to do:• Make the VGA display work properly. This is a one-b it-per-pixel, 640×480 framebuffer with the ability to set theforegrou nd (“on”) and background (“off”) colors acr oss thewhole screen. There is also an odd “cursor” mode thatdraws a big cross on the screen—don’t bother with it.We have supplied a rudimentar y text-mode character gen-erator in chargen.c that displays 8×16 characters.Do the following with the display.– Clear the screen when the program starts.– Sep a rate the screen into two par ts with a horizontalline between. Use the bottom two rows as the user’stext input area, and the rest of the screen to recordwhat s/he and other users type.– When a packet arrives, print its contents in the “re-ceive” region. Don ’t forget to wrap long messagesacross multiple lines.– When printing reaches the bo ttom of the area, youmay either start again at the top, or scroll the entryregion o f the screen.– Implement a reasonable text-editing sy stem for thebottom of the screen. Have input from the keyboarddisplay characters there and allow users to erase un-wanted characters and send the message with return .Clear the bottom a rea when a message is sent.– Display a cursor where the user is typing. This couldbe a vertical line, an underline, or a white box.• Make the keyboard input work properly. Specifically,– Make both shift keys work (i.e. , do upper and lower-case charac te rs)– Make the space bar work properly (display a space)– Turn off the debugging inf ormation for the unrecog-nized keycodes– Make the left and right arrow keys work– Make the backspace key work– Ignore the other keys (e.g., tab, escape, print screen,the keypad, etc.).• When the system starts, have the user e nter his/her namebefore going into “chat” mode. Start the string sent by eachpacket with this name.• Ensure the UDP packets are well-formed:– Make the header che cksum corre c t– Make sure the packets are always at least minimumlength (64 bytes)– Make sure th e string sent in the UDP packet is alwayszero-terminated– Make sure the UDP


View Full Document

Columbia CSEE 4840 - System Design Lab

Documents in this Course
SPYCAM

SPYCAM

91 pages

PAC-XON

PAC-XON

105 pages

lab 1

lab 1

6 pages

memory

memory

3 pages

Structure

Structure

12 pages

Video

Video

3 pages

pacman

pacman

4 pages

Lab 1

Lab 1

6 pages

Scorched

Scorched

64 pages

lab 1

lab 1

3 pages

Video

Video

22 pages

Memory

Memory

23 pages

DVoiceR

DVoiceR

29 pages

MAZE

MAZE

56 pages

PAC XON

PAC XON

13 pages

PACXON

PACXON

13 pages

MP3 Player

MP3 Player

133 pages

Load more
Download System Design Lab
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view System Design Lab and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view System Design Lab 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?