Introduction

This lab is an exercise in some of the parallelism and block storage features of Handel-C. You will also look at the hardware complexity associated with division.

Description

Division Experiment

Create a new workspace named Laboratory II, and create a new project there named "Division Experiment" (or something similar). Be sure your Editor is still set to substitute spaces for tabs, and the font for the Output Window is Monaco. (These settings might have gotten lost in the process of fixing up your directory settings.)

Write a Handel-C program that computes the average of 4 sixteen-bit signed integers and display the low-order 8 bits of the answer on the two hexadecimal displays. Make sure the project works using the Debug configuration, then do the division using both the '/' and '>>' operators, and observe the quantity of FPGA resources used when you build the project using the EDIF configuration. Note: If you compute the average using all constants or variables whose variables never change in the program, the compiler will calculate the result itself and you will not see any hardware resourses being used for the calculation in the project. You need to deal with this in your program's design.

Now change the code so it computes the average of 5 numbers instead of 4, and observe the FPGA resources used.

Moving Average

Create a second project in your Laboratory II workspace named "Moving Average" (or something similar). This assignment is to have the program compute a moving average of an endless sequence of input values, with a new average computed each time the user presses one of the buttons on the side of the RC200E. To make things “interesting” (or “dumb”, depending on your point of view), use a dual-ported memory to hold the data values being averaged. Read a sequence of values from the rom port for computing the averages, and write the averages back into the wom port. Have the read and write addresses independently cycle through all the memory addresses, starting at zero. Make the memory hold 16 8-bit signed values, and initialize all sixteen values with a mix of positive and negative numbers.

First develop this code without output to the seven segment displays and without the use of a pushbutton. On each clock cycle, compute a new moving average value, store it in the wom, push the next rom value into the pipeline, and increment the wom and rom addresses. Single step through the simulation, observing the contents of the pipeline registers, the memory, the average, and the addresses. Verify that the program is manipulating the values correctly, and record the first 32 averages (in hex) on a piece of paper.

Now add the code to display the current average using the seven segment displays. To help keep track of what's happening, code the program so the left and right decimal points take turns being on on successive cycles. Have the program wait for button presses using the following logic: Have the endless loop you already coded now start with a read operation from a channel. Add a second main with its own endless loop. Whenever this loop finds that the button has been pressed, it writes a value to the channel. Use a one-bit wide channel; it's being used only for synchronization, so it doesn't matter what value is actually written to (or read from) the channel. Make sure your design calculates exactly one average per button press! (Google "switch debounce" to see what I'm talking about.)

Simulate and download the program and verify that for both configurations the first 32 values displayed agree with the values you recorded in the first simulation.

Submitting the Assignment

Write a report for the assignment:

  1. To practice writing the Method section of a research report, write a description of the procedures you followed for the two projects. Write this in the first person, and include just enough information so a reader who is already familiar with Handel-C and the RC200E would be able to do the same things you did and expect to get the same results you did. But don't tell what your results were, just the procedures you followed. It's okay to include a description of any problems you had to solve and how you solved them. Tiny snippits of code are okay to include if you think they would help, but describe algorithms verbally in general.
  2. Did the division experiment successfully show the overhead associated with division, and the difference between dividing by a power of two compared to a value that is not a power of two? Summarize your findings if it did, or suggest a better design for the experiment if it didn't.
  3. What did you learn from the second project?

Instead of emailing the assignment to me, just email me the pathname to your Laboratory II workspace directory. Leave your report in the top level of the directory, and I'll use Administrator privileges to get at everything.

Due Date: Midnight September 27.