Goals
There are two parts to this lab. In the first part, you will be learning how to use the remaining essential parts of logisim, in particular, splitters to take a subset of bits on a wire, and to rejoin them. In the second part, you will prepare for your project 3 by designing a basic ALU.
Reading
P&H 4.5, 4.6
Refer to the Logisim Website
or last week's lab for a refresher on Logisim.
Setup
For part A, start all Logisim circuits from scratch. Feel free to do each exercise as separate sub-circuits in the same Logisim file.
For part B, we've provided you with a starter Logisim circuit.
$ cp -r ~cs61c/labs/06 [appropriate directory]
Alternatively, you can download the file here.
Exercises
The following exercises will introduce you to more advanced techniques/concepts in Logisim.
Exercise A.1: Splitters
This is the last essential tool you will need in this class. To demonstrate its use you will construct a circuit that manipulates an 8-bit number.- Create a new subcircuit and name it "Ex1".
- Add an 8-bit input pin to your circuit and label it.
- Add a 1-bit output pin labeled "Out1" and an 8-bit output pin labeled "Out2" to your circuit.
- Go to the Wiring folder and select the Splitter circuit. This circuit will take a wire and split it into a smaller set of wires. Conversely, it can also take many sets of wires and combine them into a larger bus.
- Before you place your circuit, change the "Bit Width In" property (bus width) to 8, and "Fan Out" property (# of branches) to 3. If you move your cursor over the schematic, your cursor should look as follows:
- Now, select which bits to send out to which part of your fan. The least significant bit is bit 0 and the most significant bit is bit 7. Change the splitter output so bit 0 is coming out on fan arm 0, bits 1 through 6 are coming out on fan arm 1 (the middle one), and bit 7 is coming out on fan arm 2. FYI: the "None" option means that the selected bit will not come out on ANY of the fan arms.
- Once you configure your splitter, you can place your splitter into your circuit.
- Attach a 2-input AND gate to fan arms 0 and 2 and route the output of the AND gate to Out1.
- Now we interpret the input as a "sign and magnitude" value. We want Out2 (when interpeted as a "sign and magnitude" number) to be the negative of the input. How do we multiply a "sign and magnitude" number by -1?
- We will need another splitter to recombine the fans into a single 8-bit bus. Place another splitter with the proper properties (Bit Width In: 8, Fan Out: 3, correct fan widths). Play with the Facing and Appearance properties to make your final circuit as clean-looking as possible.
Checkoff
- Show your Ex1 circuit to your TA.
- If we read the input as a "2's complement" number, what types of inputs will produce Out1 = 1?
Exercise A.2: Rotate Right
With your knowledge of splitters and your knowledge and experience with multiplexers from the last lab, you are ready to implement a non-trivial combinational logic block:rotr
, which stands for "Rotate Right". The idea is that rotr A,B
will "rotate" the bit pattern of input A to the right by B bits. So, if A were 0b1011010101110011 and B were 0b0101 (5 in decimal), the output of the block would be 0b1001110110101011. Notice that the rightmost 5 bits were rotated off the right end of the value and back onto the left end. In RTL, the operation would be something like "R = A >> B | A << (16 - B)
".
You must implement a subcircuit named "rotr" with the following inputs:
- A, 16 bits, the input to be rotated
- B, 4 bits, the rotation amount (Why 4 bits?)
rotr
subcircuit in the main subcircuit.
Hint: Before you start wiring, you should think very carefully about how you might decompose this problem into smaller ones and join them together. You should feel very free to use subcircuits when implementing rotr
. If you don't, expect to regret it.
Hint, the second: Just because we gave you an RTL representation doesn't mean it's the best way to look at this problem. Think about the input bits of B and think about how to effectively use splitters!
Tip: In exercise A.1, you practiced adjusting the splitters so you can have one bit coming out of one fan output, and multiple bits coming out of another. Try to keep your fan-out to a minimum to keep your circuits easy to work with.
Checkoff
- Show your TA your rotr circuit and verify that it works.