|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Lab 3: The LC-3 ALUDue dateDue Monday, July 13 by 8:00am Lab ObjectiveALU stands for Arithmetic Logic Unit. It's the major part of hardware -- in microprocessors in general and the LC-3 in particular -- responsible for most of the computations (arithmetic and logic) you perform. In this lab, you will design and build a multi-page schematic for the operation of an 8-bit ALU capable of performing addition (ADD), negation (NOT), and bitwise AND. The LC-3 ALU, which you have seen in class, operates on 16-bit numbers, but the ALU you will design in this lab is only an 8-bit ALU. A 16-bit ALU would be really messy to implement in MML, which is why our design will be only on 8 bits. Lab tutors: Go over these topicsYour lab tutor will cover the following topics in the first 40 minutes of lab.
What's required Your design should be synchronous and well-organized. You must use pages and proper logic elements (a D-flip-flop versus a bunch of NAND gates, etc). Requirements for the ALUThe ALU you design must meet at least the following criteria. It must ...
Organizing the designYou should organize your design into multiple pages. The following organization is a suggestion; yours may be different.
Example: Designing the I/O layerBelow is an example design of the I/O layer. Yours may be different. I will start by drawing out on paper what I think I will need to build. I start at the top layer, the page (or sheet) of my design that will contain all the user-interactive pieces.
The ALU will take two inputs and a set of commands, and will produce an output. As an example, my sketch is shown in Figure 1.
Figure 1: My ALU has two operands ( in1 and in2), a set of command inputs (commands), and an output (out).
Keep in mind that I will need a clock signal and a global reset signal. Also, for the adder, I will need a carry-in signal (which we will cover later). Here is my picture, in Figure 2. I am quite the artist!
Figure 2: The ALU will need an additional clock signal (like a "go" button), a global reset, and a carry-in for the adder which I'll build later. Next, I need to figure out what kind of inputs and outputs I will need. For example, the inputs require a keypad and a 7-segment display (for verification of input); the output will need a display as well; the control fields will need some switches and lights... well, you get the idea. My diagram so far is shown in Figure 3. One thing that is not shown in Figure 3 is the set of condition codes, which I'm required to add.
Figure 3: The ALU so far, with the control inputs and I/O shown.
The part I called command in the first diagram has been renamed to opcode, or operation code. This is a set of bits (a number) that will tell the ALU which action to perform. I can get the LC-3 opcodes for
Note the MaterialsNow I make a list of all the materials you have accumulated so far. This list is just an example; yours may be different.
That's all I have for now, but it's good enough to design the first page. Next I will work out the logic for page 2. Control logicControl logic is the part of the logic that decodes the opcode, checks for the reset button, checks the clock, and so on. This is a major part of the project, and should be addressed. Figure 4 may help you design your control logic. It was drawn by Andrea Di Blas, so it is much better-looking than my diagrams earlier.
Figure 4: An example of the overall structure of the control logic for an 8-bit ALU, where:
The ripple-carry full adderThere are lots of ways to make an adder. The one we will implement here is called a ripple-carry full adder. The ripple-carry part means that when we need to carry a 1, it will "ripple" down the schematic; full adder means we have a (mandatory) carry-out bit. The adder in this ALU will add the two inputs and the carry-in, and produce a sum and a carry-out. The table below shows the truth table for adding one-bit values A and B, and a carry-in. This is the same adder we saw in class. Figure 5 shows the truth table for this adder. You can also read about it on Wikipedia's page on full adders.
Figure 5: The truth table for a one-bit full adder You can probably infer the logic equation for this device, but your tutor may show you in lab how to make a ripple-carry full adder. Note that the table in Figure 5 shows you one bits' worth of truth values. To make a ripple-carry adder, you will hook several of these pieces together. The carry-out of one adder will be the carry-in of its neighbor. Figure 6 shows a crude diagram of a 4-bit adder.
Figure 6: A 4-bit full adder Extra creditIn order to receive extra credit points, the entire basic design must be fully functional, and the additional functionality must be added.
NotesCheck your workVerify that your logic works for each step of the design. Bugs are easiest to fix when they are caught early! Use the probe tool to see the values at important nodes. Attach LEDs to everything you care about, if it helps you to visualize your design. Check your work with actual numbers. Work out the solutions on paper. Other thoughts...Feel free to use other materials than those listed here. It may make your design more understandable or fun! If you like, you may refer to my interface design, shown in Figure 7.
Figure 7: Fire's lab 3 implementation (first page only -- the input and output) (click to see by itself) Grading TemplateThis is a suggested grading rubrik. Your tutor may or may not use this rubric to grade by, but it is a good general guideline before submitting your lab to check off these points. ALU requirements(15 pts) Inputs and outputs
(25 pts) Control logic and ALU operation
Extra credit (only one of the following)
40 points total Lab write-up requirementsIn the lab write-up, we will be looking for the following things. The lab report is worth 12 points. We do not break down the point values; instead, we will assess the lab report as a whole while looking for the following content in the report.
12 points |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||