EGR 2131 Unit 6 Combinational Building Blocks Read Mano & Ciletti, Sections 4.9 to 4.15. Midterm Exam next week. Homework #6 and Lab #6 due next week. -Preview Midterm Exam. Handouts: Quiz, Unit 6 practice sheet. Fire up Quartus & Multisim.
Enable Pins Many of the chips we’ll study have enable inputs. Depending on the logic level at this pin, the chip is either enabled or disabled. When the chip is enabled, it performs its intended function and the outputs behave as you would expect. When the chip is disabled, then (usually) all outputs are forced to their inactive state, regardless of the other inputs to the chip. Common names for enable pins include EN, G (for “gate”), and CS (for “chip select”). -Example: enable line on a 2-bit comparator chip. 2
Active-High versus Active-Low Pins Each input pin and output pin on a chip is either active-high or active-low. In a logic symbol: Active-low pins are marked with a bubble or triangle. Active-high pins have no bubble or triangle. Active-high pins: the pin is active when there’s a HIGH on that pin. Many chips have active-low pins: the pin is active when there’s a LOW on that pin. -Input example: enable line on a comparator chip. -Output example: output pins on a comparator.
Example of a Chip With Enable Inputs and Some Active-Low Pins: 74154 Decoder -Note different pin names as well as different conventions for active-low. -Note: Individual pins are either active-high or active-low. It’s not correct to refer to a chip as being active-high or active-low. From Floyd, p. 306 From Texas Instrument datasheet
Review: Useful Building-Block Circuits Here are some kinds of digital circuits we’ve studied or will study in the weeks ahead: Adders Comparators Decoders Encoders Chapter 4 Combinational Code converters Multiplexers Latches & Flip-flops Chapter 5 Shift registers Chapter 6 Counters Sequential Memory Chapter 7
Decoders, Encoders, & Code Converters Decoders convert a binary code into a single active output representing the code’s value. Encoders generate a coded output from a single active input line. Code converters take one input code (such as BCD) and convert it to another code (such as binary). -Demo a decoder with 5 students: me as 2-bit input, one student as decoder, the other four as outputs. -Demo an encoder with 5 students: four students as inputs, one student as encoder.
Decoders A decoder is a logic circuit that detects the presence of a specific combination of bits at its input. Two simple decoders that detect the presence of the binary code 0011 are shown. The first has an active HIGH output; the second has an active LOW output. A0 A0 A1 X A1 X A2 A2 A3 A3 Active HIGH decoder for 0011 Active LOW decoder for 0011
Decoders Assume the output of the decoder shown is a logic 1. What are the inputs to the decoder? Question -Do Practice Question 1.
Decoders IC decoders have multiple outputs to decode any combination of inputs. For example the hex decoder shown here has 16 outputs – one for each combination of binary inputs. Question For the input shown, what is the output? -Do Practice Question 2.
Decoders X/Y A specific integrated circuit decoder is the 74154, a 4-to-16 decoder. It includes two active LOW chip select lines which must be at the active level to enable the outputs. These lines can be used to expand the decoder to larger inputs. A0 A1 A2 A3 CS1 CS2 EN 74154
Octal Decoder 3 data input pins for input code. 8 output pins. Also called 1-of-8 decoder or 3-line-to-8-line decoder. May have other inputs and outputs too, such as enable inputs. Example chip: 74138 -Follow link for pin-out and logic symbol. -Active-high data inputs, active-low outputs, mixture of enable inputs. -Pins are laid out sensibly. -Do Practice Question 3.
Hex Decoder 4 data input pins for input code. 16 output pins. Also called 1-of-16 decoder or 4-line-to-16-line decoder. May have other inputs and outputs too, such as enable inputs. Example chip: 74154 -Follow link for pin-out and logic symbol. -Active-high data inputs, active-low outputs, active-low enable inputs. -Pins are laid out sensibly.
BCD Decoder 4 data input pins for input code. 10 output pins. Also called 1-of-10 decoder or 4-line-to-10-line decoder. May have other inputs and outputs too, such as enable inputs. Example chip: 7442 - Follow link for pin-out and logic symbol. -Active-high data inputs, active-low outputs, no enable inputs. -Pins are laid out sensibly.
Encoders An encoder accepts an active logic level on one of its inputs and converts it to a coded output, such as BCD or binary. 1 The basic logic diagram is shown. This encoder has an input for each decimal digit, and four outputs that represent the binary code for the active input digit. There is no zero input because the outputs are all LOW when the input is zero. A0 2 3 A1 4 5 A2 6 7 Go straight to next slide. 8 A3 9
Example Solution Encoders Show how the BCD encoder converts the decimal number 3 into a BCD 0011. Example The top two OR gates have ones as indicated with the red lines. Thus the output is 0011. Solution 1 1 1 A0 2 3 1 A1 -Do Practice Questions 4, 5, 6. -Note what happens if inputs 3 and 5 are high at same time. 4 5 A2 6 7 8 A3 9
Encoders The 74147 is an example of an IC encoder. It is has ten active-LOW inputs and converts the active input to an active-LOW BCD output. VCC This device offers additional flexibility in that it is a priority encoder. This means that if more than one input is active, the one with the highest order decimal digit will be active. HPRI/BCD Decimal input BCD output -Could call this a 10-line-to-4-line encoder. -Do Practice Question 7. 74HC147 The next slide shows an application … GND
Encoders Keyboard encoder VCC Encoders Keyboard encoder HPRI/BCD BCD complement of key press 74HC147 The zero line is not needed by the encoder, but may be used by other circuits to detect a key press.
BCD Encoder 10 input pins. 4 output pins for output code. Also called 10-line-to-4-line encoder. May have other inputs and outputs too, such as enable inputs. Example chip: 74147 -Follow link for pin-out and logic symbol. -Active-low data inputs, active-low outputs, no enable inputs. -Pins are not laid out sensibly. -Priority encoder. -Do Practice Question 8.
Octal Encoder 8 input pins. 3 output pins for output code. Also called 8-line-to-3-line encoder. May have other inputs and outputs too, such as enable inputs. Example chip: 74148 -Follow link for pin-out and logic symbol. -Active-low data inputs, active-low outputs, other inputs & outputs. -Pins are not laid out sensibly. -Priority encoder.
Different Numeric Codes Several different codes exist for using 1s and 0s to represent positive integers. Standard binary code Example: In standard binary, 15 is 1111. Binary-coded decimal (BCD) Example: In BCD, 15 is 0001 0101. Gray code Example: In Gray code, 15 is 1000.
Four-Bit Gray Code The key feature of Gray code is that only one bit changes when we increase a number by one. This is not true of standard binary.
Why is Gray Code Useful? Gray code is used for rotary encoders that sense the angular position of a shaft or axle. From Wikipedia article on rotary encoders: -Do Practice Questions 9, 10, 11, 12. Standard 3-bit binary code: no good! 3-bit Gray code: better!
Code Converters If a digital system needs to handle numbers using two different codes, it needs circuitry to convert between the two codes. Examples of code converters: 74184 BCD-to-binary and binary-to-BCD converter Binary-to-Gray code or Gray-code-to-binary converters (see next slide)
Gray Code/Binary Converters -Do Practice Question 13. Figure 8-40. Binary-to-Gray-code converter Figure 8-41. Gray-code-to-binary converter
Question Multiplexers A multiplexer (MUX) selects one data line from two or more input lines and routes data from the selected line to the output. The particular data line that is selected is determined by the select inputs. Two select lines are shown here to choose any of the four data inputs. Select inputs S0 1 S1 D0 Data output Question Data inputs D1 -MUX = Data selector; DEMUX = data distributor. -Introduce examples of MUXes and DEMUXes as traffic routers: such as phone lines from Dayton to Phoenix. -Data can be analog or digital. -Do practice Question 14. D2 Which data line is selected if S1S0 = 10? D3 D2
Some Multiplexer Chips 74150 (16-input MUX) 74151 (8-input MUX) 74153 (dual 4-input MUX) 74157 (quad 2-input MUX) -Discuss common control block on symbols for ‘53 and ‘157. -Do practice Questions 15 & 16.
Demultiplexers A demultiplexer (DEMUX) performs the opposite function from a MUX. It switches data from one input line to two or more data lines depending on the select inputs. The 74LS138 was introduced previously as a decoder but can also serve as a DEMUX. When connected as a DEMUX, data is applied to one of the enable inputs, and routed to the selected output line depending on the select variables. Note that the outputs are active-LOW as illustrated in the following example… Data select lines Data outputs Enable inputs First go back to previous MUX slide and sketch a hypothetical DEMUX. 74LS138
Example Solution Demultiplexers A A A G G LOW LOW G Y Y Y Y Y Y Y Y A Demultiplexers 1 A Determine the outputs, given the inputs shown. 2 Example G 1 Solution G LOW 2A The output logic is opposite to the input because of the active-LOW convention. (Red shows the selected line). G LOW 2B Y Y 1 Data select lines Y 2 Y Data outputs -Do as practice Question 17. 3 Y 4 Enable inputs Y 5 Y 6 Y 74LS138 7
Some Demultiplexer Chips 74138 (3-line to 8-line Decoder/DEMUX) 74154 (4-line to 16-line Decoder/DEMUX) 74139 (dual 2-line to 4-line Decoder/DEMUX) -Do practice Question 18.
Choices in Quartus II In Quartus II you have your choice of generic muxes, decoders, adders, and so on, or ones having the same features as the ones in 74XX-series chips. To use the latter, you must know the 74XX number for the chip you want. Some examples are listed here. Recall that Wikipedia has a complete list of 74XX chips (not all of which are available in Quartus.) Type Sample Chips 3-to-8 decoder 74138 Dual 4-input MUX 74153 4-bit full adder 7483 30
Choices in Quartus II (Cont’d.) Generic: 74XX: A 74153 chip contains two 4-input muxes, each of which has its own inputs named GN, C0, C1, C2, C3, and its own output named Y. (The A and B inputs are shared between the two muxes.) 31
Choices in Quartus II (Cont’d.) The choices on the previous slide assumed that you’re using schematic entry to draw a diagram of your design. Another alternative is to use text entry with VHDL. Later we’ll see examples of VHDL code for decoders, encoders, multiplexers, and so on. 32