
CS61c: Combinational Logic Blocks J. Wawrzynek October 12, 2007 1 Introduction Last time we saw how to represent and design combinational logic blocks. In this section we will study a few special logic blocks; data multiplexors, an arithmetic/logic unit, and a adder/subtractor circuit. These blocks will help later with implementation of the MIPS processor. 2 Data Multiplexors A data multiplexor, commonly called a mux, is a circuit that selects its output value from a set of input values. For instance, consider the mux circuit shown below: This mux has two n-bit inputs, A and B, and an n-bit output, C. Additionally, it has a special control signal labeled s, for select. The s signal is used to control which of the two input values is directed to the output. Specifically, the function of this mux can be described with these two rules: when s=0, C=A when s=1, C=B To remind us of which value of s corresponds to which input, within the mux symbol we commonly label each input with its corresponding s value. This particular mux example is a called a 2-to-1, n-bit wide multiplexor. It is 2-to-1 because it takes two data inputs and outputs one of them. It is n-bit wide because all data signals are n-bits in width. Notice, however, that the s signal is a single bit wide. As we will see in a later lecture, this particular mux finds common use within the design of a microprocessor, such as the MIPS. Whenever a circuit must choose data from multiple sources, a mux is used. Let’s take a look inside the n-bit wide 2-to-1 mux. The simplest way to understand it is to consider it to be a collection of n instances of 1-bit wide 2-to-1 muxes. Each instance of the 1-bit wide mux is 1 2 Wawrzynek 2007 c UCB responsible for generationg one bit of C from one bit of A and one bit of B. All n instances share the same control signal, s. A 1-bit wide 2-to-1 mux is shown below along with its truth-table. s ab c 0 00 0 0 01 0 0 10 1 0 11 1 1 00 0 1 01 1 1 10 0 1 11 1 To come up with the logic equation and the associated gate-level circuit diagram we can apply the technique that we studied last lecture. We write the sum-of-products canonical form and simplify through algebraic manipulation. The algebraic steps and final result is shown below. Intuitively this result makes sense; When the control input, s, is a 0, the right hand side of the equation reduces to a, and when it is a 1, the expression reduces to b. c = sab + sab + sab + sab = s(ab + ab) + s(ab + ab) = s(a(b + b)) + s((a + a)b) = s(a(1) + s((1)b) = sa + sb Often times we find the need to extend the number of data inputs of a multiplexor. For instance consider a 4-to-1 multiplexor: CS61c Lecture Notes 3 when S=00, e=a when S=01, e=b when S=10, e=c when S=11, e=d How would we come up with the circuit for this mux? We could start by enumerating the truth- table—in this case the function has 4 single bit data inputs and one 2-bit wide control input, for a total of 6 single bit inputs. The truth-table would have 26, or 64 rows. Certainly, a feasible approach. If we where to do this, we would end up with the following logic equation: e = s1 · s0a + s1s0b + s1s0c + s1s0d Another way to design the circuit is to base it on the hierarchical nature of multiplexing. We can build a 4-to-1 mux from three 2-to-1 muxes as shown below: The first layer of muxes uses the s0 input to narrow the four inputs down to two, then the second layer uses s1 to choose the final output. 3 An Arithmetic and Logic Unit (ALU) Most processor implementations include a special combinational logic block called an arithmetic and logic unit (ALU). In the MIPS, the ALU is used to compute the result in the R-type instructions, such as, add, sub, and, or addi, ori, etc. We are going to consider the design of a simpler version of the ALU than the one in the MIPS. Ours will include only for basic functions, ADD, SUB, bitwise AND, and bitwise OR. The ALU is organized 4 Wawrzynek 2007 c UCB as a CL block with two 32-bit wide data inputs, A and B, a 32-bit wide data output, R, and a 2-bit wide control input, S. S is used to indicate which of the four possible operations the ALU is to perform. Typically, the S input will be controlled by the processor based on the opcode (actually the “func” field on the MIPS) of the instruction currently executing on the processor. when S=00, R=A+B when S=01, R=A-B when S=10, R=A AND B when S=11, R=A OR B A common way to implement an ALU is to provide an instance of a CL block for each of the possible ALU functions. The inputs, A and B, get distributed to all the blocks, and the output of the proper block is selected with a mux. In this configuration, every function of the ALU is computed internally to the ALU on every cycle, but only one of the results is sent to the output. For our simple ALU will need an adder block, a subtractor block, an AND block, and an OR block. Each of these blocks will take two 32-bit inputs and produce a 32-bit output. As you might suspect, a subtractor circuit is very similar to an adder circuit. Therefore, instead of providing a separate adder and subtractor, we are going to provide a single circuit that is capable of either operation. We will see in the next section how to design such a circuit. For now, assume that we have an add/subtract circuit with a special control input, labeled SUB, which when set to 1 forces the circuit to perform the subtraction A–B. When SUB=0 the circuit performs addition. Our add/subtract block has a special output, labeled “overflow”. Upon performing an addition or subtraction, this output will be a 1 if the result is too large to fit in 32 bits. Overflow can occur when adding a pair of negative numbers or when adding a pair of positive numbers. The internal design of our simple ALU is shown below. The high bit of S, s1, is used to choose between the add/subtract unit and the output of the mux that chooses between the AND and OR blocks. The choice of AND and OR is controlled by the low bit of S, s0. The low bit of S is also used to specify the operation of the add/subtract block—1 for sub, and 0 for add. As you can see in the figure, A and B are distributed to all three blocks. CS61c Lecture Notes 5 3.1 Implementing the Internal Blocks The logical operations as defined by the MIPS instruction set are bitwise operations. That means that in the case of the AND, the resultant bit ri is generated as ai AND bi. The circuit to perform this operation is simply a collection of 32 AND gates. Each AND gate is responsible for one of the 32 resultant bits. Similarly, the OR block is a collection of 32 OR gates. The add/subtract block is a significantly more complex block than the AND or OR block. Its design is the subject of the next section. 4 Adder/Subtractor Design We will start out by studying the design of an adder circuit, then later augment it to also perform subtraction. One obvious method for arriving at the detailed gate-level circuit for the adder would be to follow the procedure we learned in the previous lecture. We would start with a truth-table, then write the canonical Boolean equation, then simplify. Unfortunately, that technique is only effective for very narrow adders, because the size of the truth-table is too large for wider adders. Therefore, we need to find a way to break the design up into smaller more manageable pieces. We will design the smaller pieces individually, then wire them together to create the entire wide adder. Long-hand addition gives us a good guide on how to break up the adder into pieces. When we add by hand, we begin by adding together the two least significant bits of A and B, a0 and b0, respectively. From that addition, we generate a result bit, s0, and possibly a carry bit. Then we move over to the next 6 Wawrzynek 2007 c UCB more significant column, adding the carry from the previous stage along with the next two bits of A and B, a1 and b1, respectively. We then continue the process by moving left one column at a time until we have finished all n columns. The truth-table representing the value of least significant sum bit, s0, and the carry out of the least significant stage, c1, is shown below. (We name a carry bit according to the stage to which it is an input.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages8 Page
-
File Size-