Reed CSCI 221 Fall 2020Homework 06: digital circuitsDue: Thursday, October 15th In this homework we continue to construct digital circuits using only AND, OR, and NOT gates. In all of these, there is some collection of inputs, and those inputs should simply feed forward into gates, continuing in this way to produce some outputs. Soon we’ll add memory and feedback to our digital circuits, but these ones do not have that. Instead, they are just combinatorial circuits. They take their inputs and “combine” them (again using AND, OR, and NOT logic) to produce their outputs. For such circuits it’s possible to apply a “truth table method” to devise the boolean expression for each output of the circuit. Here is that method’s algorithm:
This always builds a circuit of depth 2 or 3, that is, each path you can draw between an input and an output passes through either two or three gate “layers.” There is the final OR gate layer that forms the outputs. There is a middle AND gate layer where each feeds into the OR gates. And then there is the possible first layer of NOT gates. This layering directly corresponds to the “sum of products” logical expressions we’ve devised. Now, in class we also talked about ways of simplifying the logic. This involved using properties of AND, OR, and NOT, the boolean laws for performing algebraic simplification of our logical expressions. A lot of these laws are built into the Karnaugh map method, which we’ll continue to demonstrate in class. This allowed us, for example to simplify the number of products for the 2:1 MUX from four products down to only two products. Finally, we are now seeing in class how integers can be coded as 0s and 1s. This means that integer operations, things like addition or multiplication, and integer comparisons can also be reduced to logical expressions. Several of the exercises below rely on reasoning about the binary encoding of integers, and reasoning about their bits. You should already have downloaded a copy of LogiSim which allows you
to draw digital circuit diagrams and test their circuit’s logic and
behavior. In this folder we’ve placed several LogiSim files (ending in
Exercise 1: a 2:4 decoderA decoder circuit takes n inputs and produces 2^n outputs. For example, there are 1:2, 2:4, 3:8, etc decoder circuits. A decoder takes an n-bit binary code as input. It’s 2^n output lines are labelled with each possible n-bit binary code. When fed an input code, exactly one of those outputs is 1—namely, the one with that code—and all the other outputs are 0. For example, a 3:8 decoder would have outputs labelled
Build a circuit for the 2:4 decoder using only AND, OR, and NOT
gates. You’ll need to develop a boolean expression for each of the 4
outputs. Hint: you won’t need any Exercise 2. comparisonConsider the comparison of two integers x and y
encoded in binary with 3 bits as bits
Mimic this left-to-right lexicographic comparison when you build the circuit’s logic. If you get stuck figuring out the logic, instead try to build the circuit for 2-bit inputs and see what’s at play. Or even just compare 1-bit inputs. What is the condition on the bits that make the one number less than the other? Exercise 3. 3-bit Gray sequence logicA Gray sequence is a circular sequence of all the binary codes of the same length, where each successive code differs by exactly one bit. For example, the periodic sequence 00, 01, 11, 10, 00, 01, 11, 10, 00, etc. shows a 2-bit Gray code that repeats every four codes. The successive 00 and 01 codes differ in their right bit, 01 and 11 differ by their left bit, 11 and 10 differ by their right bit, and so on. The cycle of codes hits every possible 2-bit code, but in this special order. A single bit is flipped with each successive code. Note that the sequence 000, 001, 011, 010, 110, 111, 101, 100 gives a 3-bit Gray code. After 100 we just repeat the sequence again. Again, all eight possible codes are listed, and each successive code differs by only one bit. Just below this paragraph is a table of the “next codes” for this
particular Gray code. For example, in the row where
Build a 3-input, 3-output circuit for this table. |