Combinational Logic
Total Page:16
File Type:pdf, Size:1020Kb
Fundamentals of Computer Systems Combinational Logic Martha A. Kim Columbia University Fall 2013 1 / 1 Combinational Circuits Combinational circuits are stateless. Their output is a function only of the current input. Combinational Inputs Outputs Circuit 2 / 1 3 / 1 Enablers 4 / 1 Overview: Enabler An enabler has two inputs: É data: can be several bits, but 1 bit examples for now É enable/disable: 1 bit on/off switch When enabled, the circuit’s output is its input data. When disabled, the output is 0. 1 0 ENABLE ENABLE X DATA OUTPUT X X DATA OUTPUT 0 When enabled When disabled 5 / 1 Enabler Implementation Note abbreviated truth table: input, A, listed in output column EN F EN F 0 0 0 1 1 A 1 A A A F F EN EN In both cases, output is enabled when EN = 1, but they handle the disabled (EN = 0) cases differently. 6 / 1 Encoders and Decoders 7 / 1 Overview: Decoder A decoder takes a k bit input and produces 2k single-bit outputs. − The input determines which output will be 1, all others 0. This representation is called one-hot encoding. O3 1 1 I1 O2 0 1 I0 O1 0 O0 0 8 / 1 1:2 Decoder The smallest decoder: one bit input, two bit outputs A A A 9 / 1 2:4 Decoder Decoder outputs are simply minterms. Those values can be constructed as a flat schematic (manageable at small sizes) or hierarchically, as below. B AB B 1:2 DEC B AB A A 1:2 DEC AB A A B 10 / 1 3:8 Decoder Applying hierarchical design again, the 2:4 DEC helps construct a 3:8 DEC. ABC A A 1:2 DEC ABC A ABC AB C BC ABC B BC 2:4 DEC ABC C BC A BC B C A B C 11 / 1 Implementing a function with a decoder E.g., F = AC + BC CBAF 0 0 0 0 7 0 0 1 1 6 5 0 1 0 0 C 4 0 1 1 1 B 3 F A 1 0 0 0 2 1 0 1 0 1 1 1 0 1 0 1 1 1 1 Warning: Easy, but not a minimal circuit. 12 / 1 Encoders and Decoders k bits 3:8 DEC 2k bits BCD One-Hot 000 00000001 001 00000010 010 00000100 011 00001000 100 00010000 101 00100000 110 01000000 111 10000000 k bits 3:8 ENC 2k bits 13 / 1 Priority Encoder An encoder designed to accept any input bit pattern. I3 I2 I1 I0 VO1 O0 0 0 0 0 0 X X 0 0 0 1 1 0 0 0 0 1 X 1 0 1 0 1 X X 1 1 0 1 X X X 1 1 1 V = I3 + I2 + I1 + I0 O1 = I3 + I3I2 O0 = I3 + I3 I2I1 14 / 1 Multiplexers 15 / 1 Overview: Multiplexer (or Mux) A mux has a k bit selector input and 2k data inputs (multi or single− bit). It outputs a single data output, which has the value of one of the data inputs, according to the selector. D IN3 C IN2 OUT B B IN1 A IN0 S0 S1 1 0 16 / 1 Enabler! I1 O I0 Enabler! S 1:2 Decoder! 2:1 Mux Circuit There are a handful of implementation strategies. E.g., a truth table and k-map are feasible for a design of this size. SI1 I0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 17 / 1 Enabler! Enabler! 1:2 Decoder! 2:1 Mux Circuit There are a handful of implementation strategies. E.g., a truth table and k-map are feasible for a design of this size. SI1 I0 0 I1 0 0 0 0 0 0 1 1 0 1 0 0 O 0 1 1 1 I0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 S 17 / 1 2:1 Mux Circuit There are a handful of implementation strategies. E.g., a truth table and k-map are feasible for a design of this size. SI1 I0 0 Enabler! I1 0 0 0 0 0 0 1 1 0 1 0 0 O 0 1 1 1 I0 1 0 0 0 1 0 1 0 Enabler! 1 1 0 1 1 1 1 1 S 1:2 Decoder! 17 / 1 4:1 Mux Circuit I3 I2 O I1 I0 EN3 EN2 EN1 EN0 2:4 DEC S1 S0 18 / 1 Muxing Wider Values (Overview) I3 I2 O I1 I0 EN3 EN2 EN1 EN0 2:4 DEC S1 S0 19 / 1 Muxing Wider Values (Components) X3 X2 X1 X0 Y3 Y2 Y1 Y0 EN X3 X2 X1 X0 Z3 Z2 Z1 Z0 Y3 Y2 Y1 Y0 20 / 1 Using a Mux to Implement an Arbitrary Function Version 1 Think of a function as using k input bits to choose from 2k outputs. E.g., F = BC + AC ABCF 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 2 0 1 1 1 1 3 F 1 0 0 1 1 4 1 0 1 0 0 5 1 1 0 1 1 6 1 1 1 1 1 7 A B C 21 / 1 Using a Mux to Implement an Arbitrary Function Version 1 Think of a function as using k input bits to choose from 2k outputs. E.g., F = BC + AC ABCF 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 2 0 1 1 1 1 3 F 1 0 0 1 1 4 1 0 1 0 0 5 1 1 0 1 1 6 1 1 1 1 1 7 A B C 21 / 1 ABF 0 0 0 0 0 0 1 C C 1 F 1 0 C 2 1 1 1 1 3 A B Using a Mux to Implement an Arbitrary Function Version 2 Can we use a smaller MUX? ABCF 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 1 22 / 1 ABF 0 0 0 0 0 0 1 C C 1 F 1 0 C 2 1 1 1 1 3 A B Using a Mux to Implement an Arbitrary Function Version 2 Can we use a smaller MUX? ABCF 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 1 22 / 1 ABF 0 0 0 0 0 0 1 C C 1 F 1 0 C 2 1 1 1 1 3 A B Using a Mux to Implement an Arbitrary Function Version 2 Can we use a smaller MUX? ABCF 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 1 22 / 1 0 0 C 1 F 2 1 3 A B Using a Mux to Implement an Arbitrary Function Version 2 Can we use a smaller MUX? ABCF ABF 0 0 0 0 0 0 0 0 0 1 0 0 1 C 0 1 0 0 1 0 C 0 1 1 1 1 1 1 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 1 22 / 1 Using a Mux to Implement an Arbitrary Function Version 2 Can we use a smaller MUX? ABCF ABF 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 C C 1 F 0 1 0 0 1 0 C 2 0 1 1 1 1 1 1 1 3 1 0 0 1 1 0 1 0 A B 1 1 0 1 1 1 1 1 Instead of feeding just 0 or 1 into the mux, as in Version 1, one can remove a bit from the select, and feed it into the data ports along with the constant. 22 / 1 Shifters 23 / 1 Overview: Shifters A shifter shifts the inputs bits to the left or to the right. IN n SHIFTER k CNTL n OUT There are various types of shifters. É Barrel: Selector bits indicate (in binary) how far to the left to shift the input. É L/R with enable: Two control bits (upper enables, lower indicates direction). In either case, bits may “roll out” or “wraparound” 24 / 1 Example: Barrel Shifter with Wraparound 11001010 8 3 SHIFTER 011 8 01010110 25 / 1 CNTL1, CNTL0 Implementation of Barrel Shifter with Wraparound (Part 2) Main idea: wire up all possible shift amounts and use muxes to select correct one. IN3 IN2 IN1 IN0 3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0 OUT3 OUT2 OUT1 OUT0 26 / 1 Implementation of Barrel Shifter with Wraparound (Part 2) Main idea: wire up all possible shift amounts and use muxes to select correct one. IN3 IN2 IN1 IN0 3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0 CNTL1, CNTL0 OUT3 OUT2 OUT1 OUT0 26 / 1 Implementation of Barrel Shifter with Wraparound (Part 2) Main idea: wire up all possible shift amounts and use muxes to select correct one.