COSC 065 Hardware Systems

Fall 2008

Homework Assignment #9

Off With The Training Wheels.

Due: Tuesday, Nov 18, 11:59PM CST

Submit: Turn in your source files using the turnin command on Morbius. Please name your files "main-q1.S", "main-q2.S", "main-q3.S",and "main-q4.S". Failure to follow this simple convention may significantly delay grading of your assignment. Include your answers to analysis sections as comments in your code.

Work may be completed in teams of two. The names of both partners must appear in a comment block at the top of your file for credit to be given.

Background

Take time to familiarize yourself with the UNIX environment, using the tutorial here.

Always start your MIPS programming assignments using the MIPS Playground tarball. Download the tarball, and open it in your working directory using the UNIX command "tar xvzf xinu-cosc065.tgz". The file main.S is ready for you to begin programming in MIPS assembly language.

Your work must be compiled on a machine with the proper tools, such as the dual-head Linux boxen in the Systems Lab (CU 310). Consult the professor for advice on connecting remotely if the lab is full or you must work from elsewhere.

In order to assemble your program, use the command "make". In order to run your program, use the command "mips-console". At any time, you can shutdown the MIPS remote console system by hitting Ctrl-Space, followed by the letter 'q', for 'quit'.

Few rules govern the format of assembly language programs. Make an effort to keep your programs readable and well-documented; sometimes the professor gives partial credit if he can tell what you were trying to do, even if it doesn't quite make it.

Q1 - Serial Output

Create a MIPS function sendchar that outputs a single character to the secondary UART on our backend machines. The UART (Universal Asynchronous Receiver / Transmitter, aka "serial port") is a member of the venerable 16550 family of UARTs, documented here. Of particular interest to us is section 8 of the specification, starting on page 14, which describes the registers accessible to programmers. The UART control and status registers are memory-mapped, starting with base address 0xB8000400. The second UART is available through the XINU console daemon system by running xinu-console with the name of your mips-console backend followed by a "2". Thus, if running mips-console gave you backend "voc", running xinu-console voc2 in a second terminal window will give you access to voc's secondary UART interface. Provide a main function that demonstrates your sendchar function works properly.

Q2 - Serial Input

Create a MIPS function readchar that reads a single character from the secondary UART on our backend machines. Provide a main program that inputs characters from the second UART using readchar, and echoes them back using sendchar until an EOF character is seen.

Q3 - String output

Write a MIPS function sendstr that writes an entire string to the secondary UART using your sendchar function. Note that well-formed character strings end in a null terminator, which is ASCII value 0x00.

Q4 - I/O Latency

Your synchronous I/O functions above must wait on the UART hardware before reading or writing the next value. Devise a mechanism for measuring how long sendchar and readchar wait, and answer the following analysis questions in comments in the file.

Analysis Questions:

  • How long does sendchar usually have to wait before sending the next character?
  • What factors affect the waiting time?
  • How quickly can the UART send characters as a result? (Hint: Our MIPS backends have a clock frequency of 250 MHz.)
  • Repeat the questions above for the readchar function.

  • Back
    [Revised 2008 Nov 11 15:36 DWB]