1
Unit 11 Latches and Flip-Flops 1
Latches and Flip-Flops
11.1 Introduction 11.2 Set-Reset Latch 11.3 Gated D Latch
11.4 Edge-Triggered D Flip-Flop 11.5 S-R Flip-Flop
11.6 J-K Flip-Flop 11.7 T Flip-Flop
11.8 Flip-Flops with additional Inputs
Unit 11 Latches and Flip-Flops 2
Edge-Triggered D Flip-Flop 邊緣觸發D型正反器
D型正反器有2個輸入:
D(資料)和
Ck(時脈)。
正反器的輸出只對時脈有反應,與D的變化無關。
Unit 11 Latches and Flip-Flops 3
Edge-Triggered
active edge(作用邊緣):
指觸發正反器讓狀態改變的時脈邊緣
rising edge(上緣)或
falling edge(下緣)。
Rising Edge-Triggered上升邊緣(正緣)觸發:
如果輸出變化對時脈輸入從0到1轉換有反應,稱此 正反器被時脈的上升邊緣觸發。
Falling Edge-Triggered下降邊緣(負緣)觸發:
如果輸出變化只對時脈輸入從1到0的轉換有反應,
稱此正反器被時脈的下降邊緣觸發。
Timing for D Flip-Flop (Falling-Edge Trigger)
D型正反器的時序:
3
Unit 11 Latches and Flip-Flops 5
D Flip-Flop
(Rising-Edge Trigger)
上升邊緣觸發D型正反器:
用2個gated D latches和一個inverter組成。
Unit 11 Latches and Flip-Flops 6
當 CLK = 0,G
1=1,
第1個latch直接穿透,所以輸出
P
緊跟著D
輸入。 因為G2=0,第2個latch維持
Q
目前的值。 當 CLK 變成1,
G1變成0,
D
目前的值儲存在第1個latch中。 因為G2=1,
P
的值流經第2個latch到達輸出Q
。 當 CLK 變回成0,
第2個latch取得
P
的值並保存該值, 接著第1個latch開始再次跟隨
D
的輸入。 如果第1個latch在第2個latch取得P的值之前跟隨
D
的輸入,則正反器的功能不正確。
Unit 11 Latches and Flip-Flops 7
Review Question
【習題11.5】 (page 311):
What change must be made to Figure 11-15(a) to implement a falling-edge triggered D flip-flop?
Complete the following timing diagram for the modified flip-flop
.Setup and Hold Times
正反器只在時脈觸發邊緣改變狀態,
正反器的傳播延遲是時脈觸發邊緣到輸出改變之間的時間。
為了能正常動作,邊緣觸發正反器的
D
輸入在時脈作用邊緣前後一段時間內必須維持定值。
setup time ( t su ) :在觸發邊緣之前 D 必須穩定的時間。
hold time ( t h ):在觸發邊緣之後 D 必須維持的時間。
5
Unit 11 Latches and Flip-Flops 9
Determination of Minimum Clock Period
不違反時序限制的最小時脈週期。
EX:假設
inverter的傳播延遲為2
ns
, 同時假設flip-flop的傳播延遲為5
ns
, setup time為3
ns
(hold time不影響計算)。
若時脈週期為9
ns
, 則flip-flop也許無法取得 正確的值。Unit 11 Latches and Flip-Flops 10
Determination of Minimum Clock Period (Cont’d)
若時脈週期為15 ns ,則 flip-flop 能正常動作。
10 ns 是電路能動作的最小時脈週期。
Unit 11 Latches and Flip-Flops 11
Latches and Flip-Flops
11.1 Introduction 11.2 Set-Reset Latch 11.3 Gated D Latch
11.4 Edge-Triggered D Flip-Flop 11.5 S-R Flip-Flop
11.6 J-K Flip-Flop 11.7 T Flip-Flop
11.8 Flip-Flops with additional Inputs
S-R Flip-Flop
S-R正反器:
7
Unit 11 Latches and Flip-Flops 13
S-R Flip-Flop implementation
2個 S-R latch和邏輯閘組成的 S-R flip-flop (主從式正 反器):
當
CLK = 0, S
和R
輸入將master的輸出設成適當的值,而 slave維持之前的Q
值。 當時脈從0變成1,
P
的值保留在master ,且此值轉送到 slave 。 當
CLK = 1,
master維持P
的值,也因此Q
不會改變。 當時脈從1變成0,
Q
的值被鎖在slave ,讓master可以處理 新的輸入。master slave
Unit 11 Latches and Flip-Flops 14
Timing for S-R Flip-Flop
主從式正反器之時序:
Unit 11 Latches and Flip-Flops 15
Review Question
【習題11.6】 (page 311):
A reset-dominant flip-flop behaves like an S-R flip- flop, except that the input S=R=1 is allowed, and the flip-flop is reset when S=R=1.
Derive the characteristic equation for a reset-dominant flip- flop
Show how a reset-dominant flip-flop can be constructed by adding gate(s) to an S-R flip-flop.
Latches and Flip-Flops
11.1 Introduction 11.2 Set-Reset Latch 11.3 Gated D Latch
11.4 Edge-Triggered D Flip-Flop 11.5 S-R Flip-Flop
11.6 J-K Flip-Flop 11.7 T Flip-Flop
11.8 Flip-Flops with additional Inputs
9
Unit 11 Latches and Flip-Flops 17
J-K Flip-Flop
J-K正反器:
J-K正反器有三個輸入,J、K和時脈(CK)。
J輸入對應到S,K對應到R。
Unit 11 Latches and Flip-Flops 18
J-K Flip-Flop Timing
J-K正反器的時序:
Q changes on
the rising edge
Unit 11 Latches and Flip-Flops 19
Master-Slave J-K Flip-flop
利用2個 S-R latch 聯結成圖11-21所示的主-從 ( master-slave )式架構,實現 J-K flip-flop 。
master
slave
Review Question
【習題11.7】 (page 311):
Complete the following timing diagram for the flip-
flop of Figure 11-20(a).
11
Unit 11 Latches and Flip-Flops 21
Latches and Flip-Flops
11.1 Introduction 11.2 Set-Reset Latch 11.3 Gated D Latch
11.4 Edge-Triggered D Flip-Flop 11.5 S-R Flip-Flop
11.6 J-K Flip-Flop 11.7 T Flip-Flop
11.8 Flip-Flops with additional Inputs
Unit 11 Latches and Flip-Flops 22
T Flip-Flop
T型正反器(切換( toggle )正反器):
有1個 T 輸入和1個時脈輸入。
當 T = 1時,正反器在時脈觸發邊緣之後改變狀態。
當 T = 0時,不會發生狀態改變。
Unit 11 Latches and Flip-Flops 23
Timing Diagram for T Flip-flop
T型正反器的時序: falling edge trigger
Implementation of T Flip-flop
利用
1) J-K正反器、
2) D型正反器和XOR閘 實現 T flip-flop 。
13
Unit 11 Latches and Flip-Flops 25
Latches and Flip-Flops
11.1 Introduction 11.2 Set-Reset Latch 11.3 Gated D Latch
11.4 Edge-Triggered D Flip-Flop 11.5 S-R Flip-Flop
11.6 J-K Flip-Flop 11.7 T Flip-Flop
11.8 Flip-Flops with additional Inputs
Unit 11 Latches and Flip-Flops 26
Flip-Flops with additional Inputs 具有額外輸入的正反器
正反器通常具有額外的輸入,可以用來設置與 時脈無關的正反器初始狀態。
clear (ClrN) and preset (PreN)
Unit 11 Latches and Flip-Flops 27
Timing Diagram for D Flip-Flop with Asynchronous Clear and Preset
具有非同步清除和預置輸入動作的D型正反器 時序圖。
Review Question
【習題11.9】 (page 312):
a)
Complete the following timing diagram for a J-K flip-flop with a falling-edge trigger and asynchronous ClrNandPreN
inputs.15
Unit 11 Latches and Flip-Flops 29
Review Question
【習題11.9】 (page 312):
b)
Complete the timing diagram for the following circuit. Note that the Ck inputs on the two flip-flops are different.Unit 11 Latches and Flip-Flops 30
D Flip-Flop with Clock Enable
欲設計同步數位系統(synchronous) 當即使正反器的資料輸入有變化,
我們仍希望某些正反器能維持現在的資料 --利用閘控時脈(gating the clock)。
當 En = 0時,正反器的時脈輸入為0, Q 不會改變。
Unit 11 Latches and Flip-Flops 31
Two Potential Problems
使用閘控時脈的缺點:
首先,閘控延遲會讓時脈在不同的時間抵達不同的 正反器,造成同步性的缺失。
其次,若 En 在錯誤的時間點改變,正反器也許會因 En 改變而被觸發,而非因時脈的改變,再一次導致 同步性的缺失。
改善方式:
採用具有 時脈致能( CE )的正反器。
D Flip-flop with Clock Enable
D-CE flip-flop :具有時脈致能的D型正反器
當 CE = 0時,時脈被禁能,不會發生狀態變化,所
以Q + =Q。
當 CE = 1時,正反器的動作像一般的 D 正反器,所 以Q + =D。
因此特性方程式為Q + = Q•CE’ + D•CE。
17
Unit 11 Latches and Flip-Flops 33
Review Question
【習題11.8】 (page 312):
Complete the following diagrams for the falling- edge triggered D-CE flip-flop of Figure 11-27(c).
Assume Q begins at 1.
a)
First draw Q based on your understanding of the behavior of a D flip-flop with clock enable.b)
Now draw the internal signal D from Figure 11-27(c), and confirm that this gives the same Q as in a).Unit 11 Latches and Flip-Flops 34
Summary (總結)
正反器的特性( next state )方程式可以推導如下:
首先,製作一個真值表,
表中
next state
(Q+)為current state
(Q)和輸入之函數, 任何不合規定的輸入組合則用不理會項來處理。
接著繪出Q+的圖,從圖中導出特性方程式。
特性方程式適用於閂和正反器,但是兩者的解釋方式 不同。
例如,對
gated D latch
而言,Q+代表latch
在某個輸入改變短暫時間之後的狀態。
但是對
D flip-flop
而言,Q+代表flip-flop
在時脈觸發邊緣短暫時間之後的狀態。
Unit 11 Latches and Flip-Flops 35