flip-flops - instituto tecnologico de oaxaca

advertisement
CURSO:
PRINCIPIOS ELECTRICOS Y APLICACIONES DIGITALES
UNIDAD 2: ELECTRONICA DIGITAL
INSTRUCTOR: MIGUEL ANGEL PEREZ SOLANO
Ingeniero en Comunicaciones y Electrónica
Instituto Tecnológico de Oaxaca
http://solano.orgfree.com
1
© ILCEO: ING. MIGUEL ANGEL PEREZ SOLANO
ANTECEDENTES CONCEPTUALES
•
Estados Lógicos: Niveles de una señal digital; 0(cero) y 1(uno)
•
BIT: Digito binario (BInary digiT)
•
Niveles Lógicos: Niveles de voltaje asignados a cada estado lógico
•
NIBBLE; Agrupación de 4 bits
•
BYTE: Agrupación de 8 bits.
•
WORD: Agrupacion de bits determinado por las diferentes tecnologías.
•
SISTEMAS NUMERICOS; DECIMAL, HEXADECIMAL, BINARIO
•
ARITMETICA BINARIA; Suma, resta, multiplicacion, division
2
2.1 Tablas de verdad y compuertas lógicas
•
TABLA DE VERDAD: Es un método tabular que representa el comportamiento
funcional de una compuerta o un circuito lógico
•
COMPUERTA LOGICA: Circuito Digital que realiza una operación lógica.
Existen 3 operaciones básicas; AND, OR y NOT, además de 4
provenientes de ellas; NAND, NOR, XOR y XNOR.
3
2.1.1 NOT, OR y AND
4
2.1.2 Otras (NOR, NAND, XOR, etc.)
.
5
2.1.3 Expresiones booleanas
Las expresiones booleanas se usan para determinar si un conjunto de una o más condiciones es
verdadero o falso, y el resultado de su evaluación es un valor de verdad. Los operandos de una
expresión booleana pueden ser cualquiera de los siguientes:
Los operandos de una expresión booleana pueden combinarse con los operadores siguientes:
•
•
•
NOT (NO) Este operador produce el valor Verdadero, si su operando es Falso; y el valor
Falso, si su operando es Verdadero
AND (Y) Este operador produce el valor Verdadero si ambos operandos son Verdadero. Si
cualquiera de los dos operandos es Falso, entonces el resultado será Falso;
OR (O) Este operador realiza una operación OR-inclusiva. El resultado es Verdadero si
cualquiera de los dos operandos, o ambos son Verdadero. En caso contrario, es Falso.
6
2.2 Diseño de circuitos combinacionales
.
7
2.2.1 Metodología de diseño
Una vez que se tiene la idea
1.- Establecer la variables mediante un diagrama a bloques
2..- Crear su tabla de verdad
3.- Simplificación (minimización) utilizando método; algebra
Booleana, mapas de karnaugh o Método de Quine
McCluskey
4.- Simulación
5.- Implementación
8
2.2.2 Minitérminos y maxitérminos.
.
Y= A’B’C + ABC’ +ABC’+ABC
Y = (A+B’+C’)(A+B+C)(A’+B+C)
9
2.2.3 Técnicas de simplificación
• Por algebra de Boole
• Por el método de Mapas de Karnaugh
• Por el método de Queen McCluskey
10
2.2.3.1 Teoremas y postulados del algebra de Boole
Ley Asociativa
Ley Conmutativa
Ley Distributiva
A+B+C = A+(B+C) = (A+B)+C
A+B+C = C+B+A
A(B+C)= AB + AC
Reglas del algebra booleana
Teoremas de D’morgan
11
2.2.3.2 Mapas Karnaugh
•
•
•
Un mapa de Karnaugh es una representación gráfica de la tabla de verdad
La tabla de verdad tiene un renglón por cada minitérmino
El mapa de Karnaugh tiene una celda por cada minitérmino
12
Ejemplos
http://k-map.sourceforge.net/
13
2.2.4 Implementación y aplicación de circuitos combinacionales
.
Un circuito combinacional se caracteriza por que su valor de salida solo
depende de sus valores de entrada.
PLDs
CPLDs
FPGA´s
Para simulación: Proteus y diseño en FPGAs IseWeb pack 14.7
14
2.3 Lógica secuencial
• Previously, we have considered combinational circuits where the output values
depend only on the values of signals applied to the inputs
• Another class of logic circuits have the property that the outputs depend not only on
the current inputs, but also on the past behavior of the circuit.
• Such circuits include storage elements that store the values of logic signals.
SEQUENTIAL CIRCUITS
15
STORAGE ELEMENTS
• Previously, we have considered combinational circuits where the output values
depend only on the values of signals applied to the inputs
• Another class of logic circuits have the property that the outputs depend not only on
the current inputs, but also on the past behavior of the circuit.
• Such circuits include storage elements that store the values of logic signals.
SEQUENTIAL CIRCUITS
• Contents of the storage elements represent the state of the circuit
• Input value changes may leave the circuit in the same state or cause it to change to a
new state
• Over time, the circuit changes through a sequence of states as a result of changes in
the inputs
• Circuits that exhibit this behavior are referred to as sequential circuits
16
Sequential circuits usually contain combinational
subcircuits and feedback paths.
17
BASIC SR LATCH
• A similar circuit, constructed with NOR gates can also
be constructed
• Inputs, Set and Reset, provide the means to
changing the state, Q, of the circuit
• This circuit is referred to as a basic latch
• When R=S=0 the circuit remains in its current state
(either
Qa=1 and Qb=0 or Qa=0 and Qb=1).
• When S=1 and R=0, the latch is set into a state where
Qa=1 and Qb=0
• When S=0 and R=1, the latch is reset into a state
where Qa=0 and Qb=1
• Where S=1 and R=1, Qa=Qb=0 (there are actually
problems with this state as we will see)
18
19
Basic SR latch timing diagram
20
GATED SR LATCH
• The basic SR latch changes its state whenever its inputs change
• It may be desirable to add an enable signal to the basic SR latch that
allows us to control when the circuit can change states
• Such a circuit is referred to as a gated SR
latch
21
22
GATED SR LATCH TIMING DIAGRAM
GATED SR LATCH WITH NAND GATES
23
GATED D LATCH
• Another useful latch has a single data input, D, and it stores the value of
this input under the control of a clock signal
• This is referred to as a gated D latch
– Useful in circuits where we want to store some value
– The output of an adder/subtractor circuit would be one example
24
GATED D LATCH
25
LEVEL VERSUS EDGE SENSITIVITY
• Since the output of the D latch is controlled by the level (0 or 1) of
the clock input, the latch is said to be level sensitive
– All of the latches we have seen have been level sensitive
• It is possible to design a storage element for which the output only
changes a the point in time when the clock changes from one value
to another
• Such circuits are said to be edge triggered
26
EFFECTS OF PROPAGATION DELAYS
• Previously we have ignored the effects of propagation delay. In practical
circuits, it is essential to account for these delays
• For the gated D latch (and others as well), it is important that the value of D not
change at the time the clock (clk) goes from 1 to 0
– The designer must make sure the signal is stable when the critical change in
the clock takes place
• The minimum time the D signal must remain stable prior to the negative edge
(1->0) of the clock signal is called the setup time (tsu)
• The minimum time the D signal must remain stable after the negative edge of
clock is the hold time (th)
– Typical CMOS values are: tsu=3ns and th=2ns
27
SETUP AND HOLD TIMES
28
FLIP-FLOPS
• The gated latch circuits presented are level sensitive and can
change states more than once during the ‘active’ period of the clock
signal
• Circuits (storage elements) that can change their state no more
than once during a clock period are also useful
• Two types of circuits with such behavior
– Master-slave flip-flip
– Edge-triggered flip-flop
29
MASTER-SLAVE D FLIP-FLOP
• Consists of 2 gated D latches:
– The first, master, changes its state while clock=1
– The second, slave, changes its state while clock=0
30
MASTER-SLAVE D FLIP-FLOP
• When clock=1, the master tracks the values of the D input signal and the
slave does not change
– Thus Qm follows any changes in D and Qs remains constant
• When the clock signal changes to 0, the master stage stops following the
changes in the D input signal
• At the same time, the slave stage responds to the value of Qm and changes
states accordingly
• Since Qm does not change when clock=0, the slave stage undergoes at most
one change of state during a clock cycle
• From an output point of view, the circuit changes Qs (its output) at the
negative edge of the clock signal
31
MASTER-SLAVE D FLIP-FLOP
32
EDGE-TRIGGERED FLIP-FLOP
• A circuit, similar in functionality to the master-slave D flip-flop,
can be constructed with 6 NAND gates
33
EDGE-TRIGGERED FLIP-FLOP
• The previous circuit responds on the positive edge of the clock signal
• A negative-edge triggered D flip-flop can be constructed by replacing
the NAND with NOR gates
34
COMPARING D STORAGE ELEMENTS
35
CLEAR AND PRESET INPUTS
• It may be desirable to specifically set (Q=1) or clear (Q=0) a flip-flop
• Practical flip-flops often have preset and clear inputs
– Generally, these inputs are asynchronous (they do not depend on
the clock signal)
36
T FLIP-FLOP
• Another flip-flop type, the T flip-flop, can be derived from the basic D
flip-flop presented
• Feedback connections make the input signal D equal to the value of Q
or Q’ under control of a signal labeled T
37
T FLIP-FLOP
• The name T derives from the behavior of the circuit, which ‘toggles’ its
state when T=1
– This feature makes the T flip-flop a useful element when constructing
counter circuits
38
JK FLIP-FLOP
• The JK flip-flop can also be derived from the basic D flip-flop such that
D=JQ’+K’Q
• The JK flip-flop combines aspects of the SR and the T flip-flop
– It behaves as the SR flip-flop (where J=S andK=R) for all values except J=K=1
– For J=K=1, it toggles like the T flip-flop
39
JK flip-flop timing diagram
40
REGISTERS
• A flip-flop stores one bit of information.
• When a set of n flip-flops is used to store n bits of data, we refer to
these flip-flops as a register
– Common register usages include
• Holding a data value output from an arithmetic circuit
• Holding a count value in a counter circuit
• A common clock signal is typically used for each flip-flop in a register
41
SHIFT REGISTER
• A register that provides the ability to shift its contents by a single bit
– May be to the right or left (or possibly both)
42
SHIFT RIGHT REGISTER
• Data is shifted to the right in a
serial fashion using the In input
• Positive edge triggered
– Contents of each flip-flop are
transferred to the next flip-flop at
each positive edge of the clock
• Level sensitive devices would
not be appropriate for this
circuit
43
PARALLEL-ACCESS SHIFT REGISTER
• Data transfer in computer systems is a common function
– If the transfer is n-bits at a time, the transfer is said to be in parallel
– If the transfer is 1-bit at a time, the transfer is said to be serial
• To transfer data serially, data is loaded into a register in parallel (in one clock
cycle) and then shifted out one bit at a time
– Parallel-to-serial data conversion
• If bits are received serially, after n clock cycles the contents of a register can
be accessed in parallel as an n-bit item
– Serial-to-parallel conversion
44
PARALLEL-ACCESS SHIFT REGISTER
45
COUNTERS
• Special purpose arithmetic circuits used for the purpose of counting
– Design circuits that can increment or decrement a count by 1
• Counter circuits server many purposes
– Count occurrences of certain events
– Generate timing intervals for controlling various tasks in a digital system
– Track elapsed time between events
• Often (but not always) built with T flip-flops because the toggle feature is
naturally suited for implementing the counting operation
46
UP-COUNTER WITH T FLIP-FLOPS
47
DOWN COUNTER WITH T FLIP-FLOPS
48
ASYNCHRONOUS COUNTERS
• The previous counters are examples of asynchronous counters. Also
called ripple counters.
– Input clock is only connected to one flip-flop
– Clocks for other flip-flops are (or are derived from) the outputs of the
previous flip-flops
• This form of counter is slow because the cascaded clocking scheme
– The clock source ripples from stage-to-stage
– The ripple effect is similar to that of a ripple carry adder circuit
49
SYNCHRONOUS COUNTERS
• Synchronous counters are built by
clocking all the flip-flops at the same time
(with a single clocking source)
– Faster response than
asynchronous counters
• Synchronous counters with T flip-flops
– Least significant bit, Q0, changes every
clock cycle
– Bit one, Q1, only changes when Q0=1
– Bit two, Q2, only changes when
Q0=Q1=1
50
T FLIP-FLOP SYNCHRONOUS COUNTER
51
ENABLE AND CLEAR CAPABILITY
• It may be desirable to disable counting or clear the counter
– Include an enable control signal
– Use a flip-flop with asynchronous clear capability
52
D FLIP-FLOP SYNCHRONOUS COUNTER
• A 4-bit up counter counts in the sequence 0,1,2,…,15,0,1…
• The count is given by the flip-flop outputs Q3Q2Q1Q0
• The D inputs are given by:
D0=Q0⊕Enable
D1=Q1⊕Q0⋅Enable
D2= Q2⊕Q1⋅Q0⋅Enable
D3= Q3⊕Q2⋅Q1⋅Q0⋅Enable
53
FOUR-BIT COUNTER (D FLIP-FLOPS)
54
COUNTERS WITH PARALLEL LOAD
• It is common for counters to begin a count with a zero value
– An asynchronous clear input can be used for his purpose
• It may be desirable for a counter to begin with a non-zero value
• Adding circuitry to provide parallel load capability is necessary
• A control input, load, is used to select a mode of operation
– Load=0, circuit counts
– Load=1, parallel load a new value into the counter
55
PARALLEL LOAD COUNTER
56
SYNCHRONOUS SEQUENTIAL CIRCUITS
• Circuits where a clock signal is used to control operation are called
synchronous sequential circuits
– The term active clock edge refers to the clock edge that causes a change
in state (positive or negative)
• Realized using combinational logic and one or more flip-flops
• Two models for synchronous sequential circuits
– Moore model: circuit outputs depend only on the present state of the
circuit
– Mealy model: circuit outputs depend on the present state of the circuit and
the primary inputs
• Sequential circuits are also called finite state
machines (FSM)
57
MOORE VERSUS MEALY MACHINES
58
BASIC DESIGN STEPS
• We will introduce techniques for sequential circuit design via a
simple example
• Design a circuit that meets the following specifications:
– The circuit has one input, w, and one output, z
– All changes in the circuit occur on the positive edge of the clock
signal
– Output z=1 if the input w was 1 during the two immediately
preceding clock cycles
• From this specification it is obvious that z cannot depend solely of
the value of w
59
SEQUENCES OF SIGNALS
• The example input and output sequence below aides in the description
of the circuit
STATE DIAGRAM
• The first step in designing an FSM is determining how many states are
needed and which transitions are possible from onestate to another
– No preset procedure for this
– The designer must think about what the circuit is to accomplish
• A good beginning is to define a reset state that the circuit should enter
when power is applied or when a reset signal is received
60
STATE DIAGRAM
• For our example, assume the starting state is called A
• As long as w=0, the circuit should do nothing and z=0
• When w=1, the circuit should ‘remember’ this
by transitioning to a new state (B)
• This transition should occur at the next
positive edge of the clock signal
61
STATE DIAGRAM
• When in state B and w=1, the circuit
should remember’ this by transitioning to
a new‘state (C)
COMPLETE STATE DIAGRAM
Moore model state diagram
62
STATE TABLE
• A state diagram describes circuit functionality, but does not describe
circuit implementation
• Translation to a tabular form is necessary
• The state table should contain
– All transitions from each present state to each next state for all
valuations of the input signals
– The output, z, is specified with respect to the present state
63
STATE ASSIGNMENT
• The states are defined in terms of variables (A, B, and C)
• Each state is represented by a particular valuation of state
variables
• Each state variable is implemented with a flip-flop
• Since three states have to be realized, it is sufficient to use two
state variables
– Use y2y1 for the present state (present state variables)
– Use Y2Y1 for the next state (next state variables)
64
STATE-ASSIGNED TABLE
Note the addition of the y2y1=11 state. Although it is not used, it is
needed for completeness.
65
NEXT-STATE AND OUTPUT MAPS
• K-maps are constructed from the state table for:
– Circuit outputs (z in this case)
– Inputs for the flip-flops (next-state K-maps)
• Constructing the next-state maps depends on the type of flip-flop (D,
T, JK) used for theimplementation
– D is the most straightforward: next-state mapsare constructed
directly from the state table since
• Q(t+1)=Q+=D
– T and JK implementations will be covered later
66
STATE TABLE AND NEXT-STATE MAPS
67
STATE TABLE AND OUTPUT MAP
68
CIRCUIT DIAGRAM
69
TIMING DIAGRAM
70
COUNTER DESIGN EXAMPLE
• Design a 2-bit counter that counts
– in the sequence 0,1,2,3,0,… if a given control signal U=1, or
– in the sequence 0,3,2,1,0,… if a given control signal U=0
• This represents a 2-bit binary up/down counter
– An input U to control to count direction
– A RESET input to reset the counter to the value zero
– Two outputs (Z1 Z0) representing the output (0-3)
– Counter counts on positive edge transitions of a common clock signal
• Design this counter as a synchronous sequential machine using
– D-type, T-type, JK-type flip-flops
71
COUNTER STATE DIAGRAM
COUNTER STATE TABLE
72
STATE-ASSIGNED STATE TABLE
• Choosing a state assignment of A=00, B=01, C=10 and D=11 makes
sense here because the outputs Z1Z0 become the outputs from the flipflops directly
73
D-TYPE FLIP-FLOP IMPLEMENTATION
• When D flip-flops are used to implement an FSM, the next-state entries
in the stateassigned state table correspond directly tothe signals that
must be applied to the D inputs
• Thus, K-maps for the D inputs can be derived directly from the stateassigned state table
• This will not be the case for the other types of flip-flops (T, JK)
74
STATE TABLE AND NEXT-STATE MAPS
75
CIRCUIT DIAGRAM (D FLIP-FLOP)
76
DESIGN USING OTHER FLIP-FLOP TYPES
• For the T- or JK-type flip-flops, we must derive the desired inputs
to the flip-flops
• Begin by constructing a transition table for the flip-flop type you
wish to use
– This table simply lists required inputs for a given change of state
• The transition table is used with the stateassigned state table to
construct an
excitation table
– The excitation table lists the required flip-flop
inputs that must be ‘excited’ to cause a transition
to the next state
77
TRANSITION TABLES
78
T-TYPE FLIP-FLOP IMPLEMENTATION
79
EXCITATION TABLE AND K-MAPS
80
CIRCUIT DIAGRAM (T FLIP-FLOP)
81
JK-TYPE FLIP-FLOP IMPLEMENTATION
• Use entries from the transition table to derive the flip-flop inputs
based on the state-assigned state table
– This must be done for each input (J and K) on each flip-flop
82
JK-TYPE FLIP-FLOP IMPLEMENTATION
83
EXCITATION TABLE AND K-MAPS
84
EXCITATION TABLE AND K-MAPS
85
CIRCUIT DIAGRAM (JK FLIP-FLOP)
86
STATE ASSIGNMENT GUIDELINES
1. States that have the same next
state for a given input should be
given adjacent assignments
2. States that are the next state of the
same state should be given adjacent
assignments.
• Keep the following in mind:
1. Assign the starting state to the ‘0’ cell on the map (i.e. the starting state has
all flip-flop outputs=0)
2. Satisfy guideline 1 and multiple occurrences of guideline 2 first
3. If the guidelines require that 3 or 4 states be adjacent, place these states
within a group of 4 adjacent squares on the map
4. Guideline 3 is less important than 1 or 2 unlessthe circuit is to have multiple
outputs
87
EXAMPLE MOORE STATE DIAGRAM
88
EXAMPLE STATE ASSIGNMENT
89
MEALY STATE MODEL
• Mealy model: circuit outputs depend on the present state of the circuit
and the primary inputs, giving additional flexibility in designing sequential
circuits
• Greater flexibility often leads to simpler circuits
90
MEALY STATE DIAGRAM
• For the Mealy model, outputs are no longer associated with a particular state
– Outputs are associated with transitions between states
• Typical Mealy model state diagram
– Detects w=11 sequence
91
MEALY MODEL STATE TABLE
• The state table for a Mealy model FSM differs from the Moore model FSM
only in how theoutputs are viewed
92
STATE-ASSIGNED STATE TABLE
Design example
• Construct a Mealy state diagram for a sequence detector that detects
the input sequence w=101
93
NOTAS DEL CURSO
94
Download