🔬 Lab
Lab Projects
In order to earn a grade above B+ for the first and second lab self-assessments, you’ll need to complete a mini-project for each self-assessment. Mini-projects are individual, although you can get help from tutors or instructors. You should not get help from classmates with your mini-project.
Each mini-project should take ~2-4 hours, and if you finish some labs early, it may be possible to complete one entirely using spare lab time, although this is not the expectation. If you find yourself spending more than 5 hours on your mini-project, you should stop and check in with your lab instructor.
The primary goal for the mini-project is to learn and understand more, NOT necessarily to complete a working prototype (although that’s a secondary goal).
For each mini-project, you’ll check in with your instructor during lab to propose a project, and then again to demonstrate it when you’ve completed it. These check-ins need to happen during lab so that they can be interactive conversations, although let your instructor know if you need an exception to this rule.
In theory, any project that relates to the course material and has an appropriate scope is allowed, but we offer some examples below to help you design your project, and you are free to pick one of the example ideas instead of generating your own (except the ones with a pre-worked solution).
Assessment
When you have completed your project and demo it during lab, that conversation will include discussion of your implementation choices, your progress if you weren’t able to put together a complete demo, and your understanding of and ability to explain how your project works. If everything is working, we might also discuss potential next steps. You’ll also be expected to explain something that the project helped you learn or understand better. Your instructor will then recommend a grade (A-, A, or A+) based on the learning, effort, and/or understanding you demonstrated. You can negotiate that grade to determine your unit 1 grade. You should still fill out the self-assessment form. If you don’t do a project, you’ll just fill out the self-assessment form to assign yourself a grade.
Unit 1
Proposals are accepted in labs 2, 3, 4, and 5 (Data as Bits through Processor Datapath). Completed projects may be demonstrated at any point up through the end of lab 7 (completing them before the first exam will be most useful to you).
Example project ideas here are listed by which lab you might propose them in. Some of these are more complex than others and might take more time. You might have to study ahead a bit for some of the advanced options:
- (Lab 2+) Build a moderately-complex digital circuit for a common
device such as a traffic light, car gear shifter, or air purifier. This
can be done in simulation or with actual electronics on a mini-board
(these need to stay in the lab room and must be individually checked
out). Your proposal should specify:
- What are the inputs to the circuit? How are you going to translate real-world things like button presses or pedal force into digital signals (you can assume such translations happen outside the circuit you build, and you don’t need to worry about how they work). For example, maybe a car shifter circuit assumes that accelerator and break pedal forces have been converted into unsigned 4-bit binary values.
- What are the outputs of your circuit? If necessary, how will they be translated from digital signals into something else. For example, maybe a car shifter circuit assumes that an 4-bit binary output can be treated as an 4-bit signed two’s-complement number, then divided by 7 to get a number between +1 and -8/7, and then that will drive the motor either forwards (+1 = full force) or backwards (-1 or lower = full reverse). In this case again you just build the circuit to produce the 4-bit number, and assume the translation circuitry can be built by someone who has studied analog circuits.
- Roughly, what kind of dynamics do you want the circuit to have? Summarize how it will respond to different inputs. For example, for a car transmission, you might include park, neutral, forward, and reverse options, and say something like: “If you’re braking, the car will slow down (via a brake strength signal), and when not breaking and in either forward or reverse, the car will drive the motor in the appropriate direction when the accelerator pedal is used.” Or for traffic lights: “When the lights in one direction are green, those in the other direction will be red. A timer will switch between greens for both directions giving equal time to each. Before a light turns from green to red, it will briefly turn yellow.”
- (Lab 4+) Add a new operator to the simulated 4-bit ALU in the lab 4
circuits file. Some operators might be too simple (TODO); pick something
that doesn’t just require modification of the 1-bit ALU, like a shift
operator, bang (
!), or absolute value. Your proposal should specify:- What operator you want to add.
- Your idea about what change(s) will be necessary to the 4-bit ALU, and why a change to the 1-bit ALU can’t achieve what you want.
- At least 3 example test cases showing inputs & correct outputs for your operator.
- (Lab 5) Add a new instruction to the full CPU circuit from the lab 5
circuits file. This would be challenging but would definitely maximize
your understanding of the CPU circuit. For example, you might add
“conditional add” (add R2 to R1, storing in R1, only if R3 != 0) or
“divide by 2” (requires ALU modification or additional circuit) or “safe
add” (doesn’t modify destination register if result would overflow) or
“branch if overflow” (jumps if previous instruction resulted in
overflow). Make sure your change modifies the CPU circuit somehow
instead of just adding an operation to the ALU (in that case, focus on
the ALU alone and don’t worry about the full CPU circuit). Your
proposal should specify:
- What your new instruction will do, and what its opcode will be.
- An idea of what change(s) will be necessary to the CPU circuit.
- At least two programs that use the new operator along with expected results, which you can use later to test its correctness.
- Note: Since the CPU circuit does not implement the JUMP instruction, your example programs shouldn’t use it.
- (Lab 5) Write a short program using the HW ISA that uses one or more
loops and a “sub-routine” (part of the program that accomplishes some
simpler task like multiplication) to compute some interesting value. For
example, develop a multiply subroutine and then use it to write a
factorial program. Your proposal should specify:
- What subroutine you plan to use.
- What value your program will compute.
- What registers the “inputs” are going to be in and what registers the output will be in when the program ends.
- At least 3 input/output example pairs to be used to test the program when it’s done.
Unit 2
Proposals are accepted in labs 8, 9, and 10 (Call Stack through Buffer Overflow)). Completed projects may be demonstrated at any point up through the end of lab 11 (Processes; last lab before the second exam).
Projects may be either a review project or a research project. In either case, you’ll spend about 2-5 hours learning stuff and programming, and then report on what you’ve learned in lab, with a demo of what you were able to accomplish.
For a review project, identify one topic area where there’s some part you feel you understand well and another you feel you don’t understand fully. Your goal is to put together a small code project (or read and explain some existing code) that will help you shore up your understanding, and then explain the answer to your question once you’re finished. Your project proposal should include:
- What you do understand.
- The part you’re uncertain about.
- What program you will write or what code you will analyze to help explore the concept you’re uncertain of (be specific).
Your presentation will include a demo of your working code and an explanation of the concept you focused on.
For a research project, you’ll pick something beyond what’s covered in class that you’d like to know and spend some time writing or reading code and/or documentation to figure that out. Your project proposal should include:
- What topic you want to learn more about (be at least somewhat concrete).
- What code/documentation you plan to read and/or write to learn more.
Your presentation will include details of what you were able to learn as well as a demo of your code and/or a walkthrough of code you read.
Example review projects:
- I understand how pointers store an address to reference other
memory, but I don’t feel solid on how to use them practically in C code
or how
malloc&freeshould be used. I’m going to write some string-processing functions to understand this better: ‘reverse’ which takes in and modifies an already-allocated string using pointer code instead of array indexing, ‘concatenate’ which takes two allocated strings, frees both, and returns a newly-allocated string containing the two joined together, and ‘substring’ which takes a string, a start index, and an end index and returns a newly-allocated string that copies the indicated part of the original string. - I understand how a basic buffer-overflow corrupts data, but not really how this ends up letting the attacker control the program. I’m going to build my own example program that is vulnerable to a buffer-overflow attack and then demonstrate an exploit that calls an otherwise unused function in that program.
- I understand the basics of how arguments and returns values work in assembly code and how the stack is used for local variables, but I don’t feel clear about caller- and callee-saved registers and how the stack is used for those. I’m going to write a program in assembly code that uses several functions which call each other and has examples of both caller-saved and callee-saved register usage. I’m going to demonstrate what happens when the proper push/pop instructions for those are not included.
Example research projects:
- I’d like to know how Rust works to prevent issues like the ones we’re seeing in C in this class. I’ll work through some Rust tutorials and read documentation to learn the basics, and come up with a demo program in C that makes a memory access mistake like an out-of-bounds array access or a use-after-free issue, and then I’ll write a similar program in Rust and how how the Rust program ends up with either a compile-time or run-time error.
- I’d like to understand how Python (or Java) can function without the
use of
malloc&free. I’ll find information about this and write some Python (or Java) code that uses the heap and tests a complex case for automatic memory management. - I want to learn more about how caches affect performance, I’ll read a chapter of our textbook about caches and implement and figure out how to use a profiler to measure code performance. I’ll profile some example code demonstrating both good and bad cache access performance.
- I’d like to learn more about Linux and the command line and how to set up and maintain an operating system. I’ll pick a Linux distribution and install it on a virtual machine and then install some basic programs like a web browser or IDE using the package manager. I’ll take notes and demonstrate the steps I had to go through to set things up and any issues I encountered along the way.
- I’d like to learn more about a specific open-source library. I’ll compile it myself and then make a small change to the source code and re-compile my own custom version. I’ll look up the process for code review and patches, and I’ll present my tweaked version along with an explanation of the steps that would be necessary to get my change integrated into the main project.
If you’ve got your own project idea that doesn’t quite fit into either of these categories, feel free to run it by me. It should relate in some way to the concepts that we’re learning in this class.
