600.102: Foundations of Computer Science

Fall Semester 2005: September 8, 2005 - December 12, 2005

Assignment 8: Recursive Circuits

Out on: November 15, 2005
Due by: November 21, 2005 by 5:59 pm for full credit (11:59 pm for 10% off, hard deadline)
Collaboration: Teams
Grading: Packaging 10%, Style 20%, Performance 10%, Design 20%, Functionality 40%

Overview

The eigth assignment for 600.102: Foundations of Computer Science covers material from Weeks 8 and 9 and the corresponding reading. This is a team assignment, and all of you should know which team you're in (I hope). Each member of a team will receive the same score for the product you submit together.

Problem 1: Recursive Circuits (80%)

Your first task (and the main task for this assignment in fact, check the percentages) is to extend your existing circuit simulator to process recursive circuits. That is, circuits can now import other circuits as "black boxes," enabling abstraction and reuse of existing component circuits. The simulator still outputs the truth table for the circuit it is started with (i.e. the "main" circuit); it you computed gate delays for the previous assignment, those should be computed for recursive circuits as well.

The format of the circuit files from the previous assignment is extended and modified as follows:

The description above might be a little confusing, but here is a simple example that should make the details clear. Consider the following circuit for a NAND gate, stored in file nand.cir:

# INPUTS and OUTPUTS
left: IN
right: IN
out: OUT
# GATES
X: AND
Y: NOT
# INPUT WIRES
A: WIRE left TO X.0
B: WIRE right TO X.1
C: WIRE out TO Y.OUT
# INTERNAL WIRES
D: WIRE X.OUT TO Y.0
# OUTPUT WIRES
E: WIRE Y.OUT TO out

This circuit should already "work" in your existing simulator. We can now use the nand.cir circuit (and another circuit called nor.cir) as part of example.cir as follows:

# INPUTS and OUTPUTS
a: IN
b: IN
c: IN
d: IN
e: OUT
f: OUT
# GATES
X: CIRCUIT "nand"
Y: CIRCUIT "nor"
# INPUT WIRES
A: WIRE a TO X.left
B: WIRE b TO X.right
C: WIRE c TO Y.left
D: WIRE d TO Y.right
# OUTPUT WIRES
E: WIRE X.out TO e
F: WIRE Y.out TO f

You may want to "adapt" the existing syntax for "built-in" gates like AND, OR, and NOT to be consistent with this new syntax, but you don't have to.

In your implementation you probably want to encapsulate a complete circuit into a class Circuit derived from the existing Component class. Note that a Circuit object can itself contain a number of Component objects, including other circuits. Thus the name "recursive" circuit. :-)

Aside from the code for this problem, please hand in at least four new test cases. Describe how and why you chose those test cases in your README file. Each test case should consist of three or more files, the input circuits and the output truth table. One test case should be a four-bit adder built out of three full adders and a half adder as discussed in lecture. Please do not use the extension .tt for these files as they would be overwritten by the simulator; use .tt.expected instead; you can use the diff tool to check whether the output you're generating is really the output you were expecting.

Problem 2: Circuit Errors (10%)

In case your error checking was incomplete last week, you can earn some points here by completing it now. Nothing has changed in the specification for error checking, and if everything works perfectly already you don't have to worry about much. Except, of course, that your changes for Problem 1 may have broken your error check from the previous assignment. :-)

Remember to hand in test cases for this problem as well, and please describe them in your README file.

Problem 3: Boolean Algebra (10%)

Consider the NAND circuit given above once again. If we express it in terms of boolean algebra instead of the circuit file format, the equation for it would be as follows:

out = NOT (left AND right)

Extend your circuit simulator to create a file with the extension .bool that contains the boolean algebra equations for each output pin of the circuit in terms of its input pins. The example above is exactly what should be in the file nand.bool after you run your simulator on nand.cir. Enjoy. :-)

Remember to hand in test cases for this problem as well, and please describe them in your README file.

Deliverables

Please turn in a gzip compressed tarball of your assignment (the extension should be .tar.gz). The tarball should uncompress into a directory cs102-assignment-8-teamname with teamname replaced by your team's name (as used for the repository and the mailing list); uncompressing should not create any other files in the current directory. Include a README file that briefly explains what your programs do and contains any other notes you want us to check out before grading (and of course your answers to "written" problems). Make sure you include contact information for each team member as well! This file should be a plain Unix text file (not M$ Word, not PDF); it should be formatted in a decent way and it should contain your contact information.

Grading

For reference, here is a short explanation of the grading criteria. Packaging refers to the proper organization of the stuff you hand in, following the guidelines for Deliverables above. Style refers to programming style, including things like consistent indentation, appropriate identifiers, useful comments, etc. Simple, clean, readable code is what you should be aiming for. Performance refers to how fast your program can produce the required results compared to other submissions. Design refers to proper modularization and the proper choice of algorithms and data structures. Functionality refers to your programs being able to do what they should according to the specification given above; if the specification is ambiguous and you had to make a certain choice, defend that choice in your README file.

If your programs do not run because of syntax errors you will get no points whatsoever. If your programs fail miserably, i.e. terminate with an exception of any kind, we will take off 10%.

Bonus Problem

Here's a neat idea: Instead of writing out the "boolean formulas" for a circuit, you could actually write out MIPS code that can be used to simulate the circuit when we run it with SPIM. This would make your circuit simulator into a "circuit compiler" of sorts. Note that we won't give you extra points for this, but we'll give you extra kudos. :-)

Updated: $Id: assignment-8.html 85 2005-11-16 06:26:34Z phf $ Validate: XHTML CSS
Copyright © 2005 Peter H. Fröhlich. All rights reserved.