Hi,I'm John. O NOT COPY Introduction elcome to the world of digital design.Perhaps you're a com outer science student who computer s trying to figure out how all that fancy hardware could possibly work.Or perhaps you're an electrical engineering student who already knows some- thing about analog electronics and circuit design,but you wouldn't know a bit if it bit you.No matter.Starting from a fairly basic level,this book will show you how to design digital circuits and subsystems. We'll give you the basic principles that you need to figure things out. 会二。 ou lots of examples.Along with principles,we'll try to di nt ible.And I,the autho will often walking through the learning process together. 1.1 About Digital Design Some people call it"logic design."That's OK,but ultimately the goal of design is to build systems.To that end,we'll cover a whole lot more in this text than just logic equations and theorems. This book claims to be about principles and practices.Most of the prin- ciples that we present will continue to be important years from now;some Copyright1999 by John F.Wakerly Copying Prohibited
DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • Copyright © 1999 by John F. Wakerly Copying Prohibited 1 chapter 1 Introduction elcome to the world of digital design. Perhaps you’re a computer science student who knows all about computer software and programming, but you’re still trying to figure out how all that fancy hardware could possibly work. Or perhaps you’re an electrical engineering student who already knows something about analog electronics and circuit design, but you wouldn’t know a bit if it bit you. No matter. Starting from a fairly basic level, this book will show you how to design digital circuits and subsystems. We’ll give you the basic principles that you need to figure things out, and we’ll give you lots of examples. Along with principles, we’ll try to convey the flavor of real-world digital design by discussing current, practical considerations whenever possible. And I, the author, will often refer to myself as “we” in the hope that you’ll be drawn in and feel that we’re walking through the learning process together. 1.1 About Digital Design Some people call it “logic design.” That’s OK, but ultimately the goal of design is to build systems. To that end, we’ll cover a whole lot more in this text than just logic equations and theorems. This book claims to be about principles and practices. Most of the principles that we present will continue to be important years from now; some W Hi, I'm John . . .
2 Chapter 1 Introduction may be applied in ways that have not even been discovered yet.As for practices. they may be from what's presented here by the time you start working in the field,and they will certainly continue to change throughout your career.So you should treat the "practices"material in this book as a way to rein- force principles,and as a way to leam design methods by example. One of the book's goals is to present enough about basic principles for you to know what's happening when you use software tools to turn the crank for you. The same basic principles can help you get to the root of problems when the tools happen to get in your way. Listed in the box on this page,there are several key points that you should learn through your studies with this text.Most of these items probably make no sense to you right now,but you should come back and review them later. Digital design is engineering,and engineering means"problem solving." My experience is that only 5%-10%of digital design is "the fun stuff"-the is much easier now than it was 20 or even 10 years ago,but you still can't spend 100%or even 50%of your time on the fun stuff. IMPORTANT Good tools do not guarantee good design,but they help a lot by taking the pain out THEMES IN of doing things right. DIGITAL DESIGN Digital circuits have analog characteristics Know when to worry and when not to worry about the analog aspects of digital design Always document your designs to make them understandable by yourselfand others Associate active levels with signal names and practice bubble-to-bubble logi design Understand and use standard functional building blocks Design for minimum cost at the system level,including your own engineering effort as part of the cost. State-machine design is like programming;approach it that way. Use programmable logic to simplify designs,reduce cost,and accommodate last- .Avoid asynchronous design.Practice synchronous design until a better methodology comes along Pinpoint the unavoidable asynchronous interfaces between different subsystems and the outside world,and provide reliable synchronizers. Catching a glitch in time saves nine Copyright1999 by John F.Wakerly Copying Prohibited
2 Chapter 1 Introduction DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY Copyright © 1999 by John F. Wakerly Copying Prohibited may be applied in ways that have not even been discovered yet. As for practices, they may be a little different from what’s presented here by the time you start working in the field, and they will certainly continue to change throughout your career. So you should treat the “practices” material in this book as a way to reinforce principles, and as a way to learn design methods by example. One of the book's goals is to present enough about basic principles for you to know what's happening when you use software tools to turn the crank for you. The same basic principles can help you get to the root of problems when the tools happen to get in your way. Listed in the box on this page, there are several key points that you should learn through your studies with this text. Most of these items probably make no sense to you right now, but you should come back and review them later. Digital design is engineering, and engineering means “problem solving.” My experience is that only 5%–10% of digital design is “the fun stuff”—the creative part of design, the flash of insight, the invention of a new approach. Much of the rest is just “turning the crank.” To be sure, turning the crank is much easier now than it was 20 or even 10 years ago, but you still can’t spend 100% or even 50% of your time on the fun stuff. IMPORTANT THEMES IN DIGITAL DESIGN • Good tools do not guarantee good design, but they help a lot by taking the pain out of doing things right. • Digital circuits have analog characteristics. • Know when to worry and when not to worry about the analog aspects of digital design. • Always document your designs to make them understandable by yourself and others. • Associate active levels with signal names and practice bubble-to-bubble logic design. • Understand and use standard functional building blocks. • Design for minimum cost at the system level, including your own engineering effort as part of the cost. • State-machine design is like programming; approach it that way. • Use programmable logic to simplify designs, reduce cost, and accommodate lastminute modifications. • Avoid asynchronous design. Practice synchronous design until a better methodology comes along. • Pinpoint the unavoidable asynchronous interfaces between different subsystems and the outside world, and provide reliable synchronizers. • Catching a glitch in time saves nine
Section1.2 Analog versus Digital 3 Besides the fun stuff and turning the crank,there are many other areas in which a successful digital designer must be competent,including the following: .Debugging.It's next to impossible to be a good designer without being a good troubleshooter.Successful debugging takes planning,a systematic approach,patience,and logic:if you can't discover where a problem is, find out where it is not! Business requirements and practices.A digital designer's work is affected by a lot of non factors,including documentation standards. component availability,feature definitions,target specifications,task scheduling,office politics,and going to lunch with vendors. Risk-taking.When you begin a design project you must carefully balance risks against potential rewards and consequences,in areas ranging from new-component selection(will it be available when I'm ready to build the first prototype?)to schedule commitments (will I still have a job if I'm late?). Communication.Eventually,you'll hand off your successful designs to other engineers,other departments,and customers.Without good commu- nication skils,you'll never complete this step successfully.Keep in mind that communication includes not just transmitting but also receiving;learn to be a good listener! In the rest of this chapter,and throughout the text,I'll continue to state smopinionsabout what's important nd what is notIthinkIietodo so as a moderately successful practitioner of digital design.Of course,you are always welcome to share your own opinions and experience (send email to john@wakerly.com) 1.2 Analog versus Digital Analog devices and systems process time-varying signals that can take on any value across a continuous range of voltage,current,or other metric.So do digita digita circuits and systems;the difference is that we can pretend that they don't!A digital signal is modeled as taking on,at any time.only one of two discrete values,which we call 0 and /(or LOW and HIGH,FALSE and TRUE,negated 0 and asserted,Sam and Fred,or whatever). Digital computers have been around since the 1940s,and have been in widespread commercial use since the 1960s.Yet only in the past 10 to 20 years has thedigital revolutionspread to many other aspects of life.Examples of once-analog systems that have now"gone digital"include the following: Still pictures.The majority of cameras still use silver-halide film to record images However,the increasing density of digital memory chips has allowed the development of digital cameras which record a picture as a Copyright 1999 by John F.Wakerly Copying Prohibited
Section 1.2 Analog versus Digital 3 DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY Copyright © 1999 by John F. Wakerly Copying Prohibited Besides the fun stuff and turning the crank, there are many other areas in which a successful digital designer must be competent, including the following: • Debugging. It’s next to impossible to be a good designer without being a good troubleshooter. Successful debugging takes planning, a systematic approach, patience, and logic: if you can’t discover where a problem is, find out where it is not! • Business requirements and practices. A digital designer’s work is affected by a lot of non-engineering factors, including documentation standards, component availability, feature definitions, target specifications, task scheduling, office politics, and going to lunch with vendors. • Risk-taking. When you begin a design project you must carefully balance risks against potential rewards and consequences, in areas ranging from new-component selection (will it be available when I’m ready to build the first prototype?) to schedule commitments (will I still have a job if I’m late?). • Communication. Eventually, you’ll hand off your successful designs to other engineers, other departments, and customers. Without good communication skills, you’ll never complete this step successfully. Keep in mind that communication includes not just transmitting but also receiving; learn to be a good listener! In the rest of this chapter, and throughout the text, I’ll continue to state some opinions about what’s important and what is not. I think I’m entitled to do so as a moderately successful practitioner of digital design. Of course, you are always welcome to share your own opinions and experience (send email to john@wakerly.com). 1.2 Analog versus Digital Analog devices and systems process time-varying signals that can take on any value across a continuous range of voltage, current, or other metric. So do digital circuits and systems; the difference is that we can pretend that they don’t! A digital signal is modeled as taking on, at any time, only one of two discrete values, which we call 0 and 1 (or LOW and HIGH, FALSE and TRUE, negated and asserted, Sam and Fred, or whatever). Digital computers have been around since the 1940s, and have been in widespread commercial use since the 1960s. Yet only in the past 10 to 20 years has the “digital revolution” spread to many other aspects of life. Examples of once-analog systems that have now “gone digital” include the following: • Still pictures. The majority of cameras still use silver-halide film to record images. However, the increasing density of digital memory chips has allowed the development of digital cameras which record a picture as a analog digital 0 1
4 Chapter 1 Introduction 640x480 or larger array of pixels,where each pixel stores the intensities of compressed into a format called JPEG with as little as 5%of the original storage size,depending on the amount of picture detail.So,digital cameras rely on both digital storage and digital processing. Video recordings.A digital versatile disc(DVD)stores video in a highly compressed digital format called MPEG-2.This standard encodes a small fraction of the individual video frames in a compressed format similar to JPEG,and encodes each other frame as the difference between it and the previous one.The capacity of a single-layer,single-sided DVD is about 35 billion bits,sufficient for about 2 hours of high-quality video,and a two- layer,double-sided disc has four times that capacity Audio recordings.Once made exclusively by impressing analog wave forms onto vinyl or magnetic tape,audio recordings now commonly use digital compact discs(CDs).A CD stores music as a sequence of 16-bit numbers corresponding to samples of the original analog waveform,one sample per stereo channel every 22.7 microseconds.A full-length CD recording(73 minutes)contains over six billion bits of information. Automobile carburetors.Once controlled strictly by mechanical linkages microprocessors.Various electronic and electromechanical sensors con- vert engine conditions into numbers that the microprocessor can examine to determine how to control the flow of fuel and oxygen to the engine.The microprocessor's output is a time-varying sequence of numbers that operate electromechanical actuators which,in turn,control the engine The telephone system.It started out a hundred years ago with analog microphones and receivers connected to the ends of a pair of copper wires (or was it string?).Even today,most homes still use analog telephones. which transmit analog signals to the phone company's central office(CO). However,in the majority of COs,these analog signals are converted into a digital format before they are routed to their destinations,be they in the same CO or across the world.For many years the private branch exchanges (PBXs)used by businesses have carried the digital format all the way to the desktop.Now many businesses,COs,and traditional telephony service providers are converting to integrated systems that combine digital voice with data traffic over a single IP(Internet Protocol)network. Traffic lights.Stop lights used to be controlled by electromechanical timers that would give the green light to each direction for a predetermined amount of time.Later,relays were used in controllers that could activate Copyright1999 by John F.Wakerly Copying Prohibited
4 Chapter 1 Introduction DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY Copyright © 1999 by John F. Wakerly Copying Prohibited 640×480 or larger array of pixels, where each pixel stores the intensities of its red, green and blue color components as 8 bits each. This large amount of data, over seven million bits in this example, may be processed and compressed into a format called JPEG with as little as 5% of the original storage size, depending on the amount of picture detail. So, digital cameras rely on both digital storage and digital processing. • Video recordings. A digital versatile disc (DVD) stores video in a highly compressed digital format called MPEG-2. This standard encodes a small fraction of the individual video frames in a compressed format similar to JPEG, and encodes each other frame as the difference between it and the previous one. The capacity of a single-layer, single-sided DVD is about 35 billion bits, sufficient for about 2 hours of high-quality video, and a twolayer, double-sided disc has four times that capacity. • Audio recordings. Once made exclusively by impressing analog waveforms onto vinyl or magnetic tape, audio recordings now commonly use digital compact discs (CDs). A CD stores music as a sequence of 16-bit numbers corresponding to samples of the original analog waveform, one sample per stereo channel every 22.7 microseconds. A full-length CD recording (73 minutes) contains over six billion bits of information. • Automobile carburetors. Once controlled strictly by mechanical linkages (including clever “analog” mechanical devices that sensed temperature, pressure, etc.), automobile engines are now controlled by embedded microprocessors. Various electronic and electromechanical sensors convert engine conditions into numbers that the microprocessor can examine to determine how to control the flow of fuel and oxygen to the engine. The microprocessor’s output is a time-varying sequence of numbers that operate electromechanical actuators which, in turn, control the engine. • The telephone system. It started out a hundred years ago with analog microphones and receivers connected to the ends of a pair of copper wires (or was it string?). Even today, most homes still use analog telephones, which transmit analog signals to the phone company’s central office (CO). However, in the majority of COs, these analog signals are converted into a digital format before they are routed to their destinations, be they in the same CO or across the world. For many years the private branch exchanges (PBXs) used by businesses have carried the digital format all the way to the desktop. Now many businesses, COs, and traditional telephony service providers are converting to integrated systems that combine digital voice with data traffic over a single IP (Internet Protocol) network. • Traffic lights. Stop lights used to be controlled by electromechanical timers that would give the green light to each direction for a predetermined amount of time. Later, relays were used in controllers that could activate
Section1.2 Analog versus Digital 5 the lights according to the pattern of traffic detected by sensors embedded in the pavement.Today's controllers use microprocessors,and can control the lights in ways that maximize vehicle throughput or,in some California cities,frustrate drivers in all kinds of creative ways. Movie effects.Special effects used to be made exclusively with miniature clay models,stop action,trick photography,and numerous overlays of film on a frame-by-frame basis.Today,spaceships,bugs,other-worldly scenes and even babies from hell(in Pixar's animated feature Tin Toy)are synthe- sized entirely using digital computers.Might the stunt man or woman someday no longer be needed,either? The electronics revolution has been going on for quite some time now,and the "solid-state"revolution began with analog devices and applications like transistors and transistor radios.So why has there now been a digital revolution? There are in fact many reasons to favor digita: Reproducibility ofresults.Given the same set of inputs (in both value and power-supply voltage,component aging,and other factors. Ease ofdesign.Digital design,often called"logic design,"is logical.No special math skills are needed,and the behavior of small logic circuits can capacitors,transistors,or other devices that require calculus to model Flexibility and functionality.Once a problem has been reduced to digital form,it can be solved using a set of logical steps in space and time.For example,you can design a digital circuit that scrambles your recorded voice so that it is absolutely indecipherable by anyone who does not have your"key"(password),but can be heard virtually undistorted by anyone who does.Try doing that with an analog circuit. Progy You're probably aready quite familiar with digital com puters which you.and ebug programs for them.Well,guess what?Much of digital design is carried out today by writing programs.too in hardhvare description languages (HDLs)These languages allow both structure and function of specified or modeled.Besides a compiler,a typical HDL come hardware model simulation and synthesis programs.These software tools are used to test the hardware model's behavior before any real hardware is built,and then synthesize the model into a circuit in a particular component technology. Speed.Today's digital devices are very fast.Individual transistors in the fastest integrated circuits can switch in less than 10 picoseconds,and a complete,complex device built from these transistors can examine its Copyright 1999 by John F.Wakerly Copying Prohibited
Section 1.2 Analog versus Digital 5 DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY Copyright © 1999 by John F. Wakerly Copying Prohibited the lights according to the pattern of traffic detected by sensors embedded in the pavement. Today’s controllers use microprocessors, and can control the lights in ways that maximize vehicle throughput or, in some California cities, frustrate drivers in all kinds of creative ways. • Movie effects. Special effects used to be made exclusively with miniature clay models, stop action, trick photography, and numerous overlays of film on a frame-by-frame basis. Today, spaceships, bugs, other-worldly scenes, and even babies from hell (in Pixar’s animated feature Tin Toy) are synthesized entirely using digital computers. Might the stunt man or woman someday no longer be needed, either? The electronics revolution has been going on for quite some time now, and the “solid-state” revolution began with analog devices and applications like transistors and transistor radios. So why has there now been a digital revolution? There are in fact many reasons to favor digital circuits over analog ones: • Reproducibility of results. Given the same set of inputs (in both value and time sequence), a properly designed digital circuit always produces exactly the same results. The outputs of an analog circuit vary with temperature, power-supply voltage, component aging, and other factors. • Ease of design. Digital design, often called “logic design,” is logical. No special math skills are needed, and the behavior of small logic circuits can be visualized mentally without any special insights about the operation of capacitors, transistors, or other devices that require calculus to model. • Flexibility and functionality. Once a problem has been reduced to digital form, it can be solved using a set of logical steps in space and time. For example, you can design a digital circuit that scrambles your recorded voice so that it is absolutely indecipherable by anyone who does not have your “key” (password), but can be heard virtually undistorted by anyone who does. Try doing that with an analog circuit. • Programmability. You’re probably already quite familiar with digital computers and the ease with which you can design, write, and debug programs for them. Well, guess what? Much of digital design is carried out today by writing programs, too, in hardware description languages (HDLs). These languages allow both structure and function of a digital circuit to be specified or modeled. Besides a compiler, a typical HDL also comes with simulation and synthesis programs. These software tools are used to test the hardware model’s behavior before any real hardware is built, and then synthesize the model into a circuit in a particular component technology. • Speed. Today’s digital devices are very fast. Individual transistors in the fastest integrated circuits can switch in less than 10 picoseconds, and a complete, complex device built from these transistors can examine its hardware description language (HDL) hardware model