Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ......

37
Chapter 3 Counters & Shift Registers Chapter 8 of R.P Jain

Transcript of Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ......

Page 1: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Chapter 3

Counters & Shift Registers

Chapter 8 of R.P Jain

Page 2: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Syllabus Counters & Shift Registers Ripple

Counters, Design of Modulo-N ripple counter, Up-Down counter, design of synchronous counters with and without lockout conditions, design of shift registers with shift-left, shift-right & parallel load facilities, Universal

shift Registers.

Page 3: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Counters

Page 4: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

• Counters are sequential circuits which "count" through a specific sequence.

• They can count up, count down, or count through other fixed sequences.

• modulus of a counter = no. of states in the cycle • A counter with m states is called a modulus-m counter or a divide-by-m counter • Types of counters: 1. Ripple Counters or Asynchronous Counter

– flip-flops connected in cascade – clock connected to LSB bit flip-flop – Output of this flip flop is clock to next flip flop – Output change is delayed more for each bit toward the MSB.

2. Synchronous Counters – Clock is connected directly to all the flip-flop – Hence output of all flip flops changes simultaneously

Counters

Page 5: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

5

3 bit ripple counter using T flip flops • This is called as a ripple counter due to the way the FFs respond one after another in a kind of rippling effect.

Page 6: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Note 1.Here T ff is used and is connected to logic ‘1’ as this will toggle at clock

edge 2.JK flip flop can be used with J=K=‘1’ 3.To count from 000111, 3 flip flops are required i.e

– no of flip flops = no of bits 4.Here counter counts from decimal 0 to 8, i.e 8 states (modulo 8) and 3 ff

are used i.e – 2no of flip flops = no of states

5.For modulo n counter, N ff are required – Where n=2N

6. If clock period is T, then clock period of 1st ff is 2T, next has 4T and so on.

7. Q’ is connected to +ve clock of next ff 8. Propagation delay adds up from LSB-ff to MSB-ff

Page 7: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Up-Down counter

• UP COUNTER: counts from 000111 – Q’ is connected to +ve clock of next ff (as in

previous slide) – Or, Q is connected to -ve clock of next ff

• DOWN COUNTER: counts from 111000 – Q is connected to +ve clock of next ff (as in

previous slide) – Or, Q’ is connected to -ve clock of next ff

Page 8: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Design problems

1. Design a modulo 16 (00001111) counter using JK flip flops.

2. Design a modulo 4 down counter – It will count 4 states i.e 3,2,1,0

3. Design ripple decade counter (mod-10) -Here at count decimal 10 i.e at 1010, OR the

output of all the four flip flops and put this ORed output to clear of all flip flops. This will make next output as 0000.

Page 9: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Synchronous Counter

• Clock is connected directly to all the flip-flop • Hence all outputs change simultaneously • So, Propagation delay of all flip flops is same

Page 10: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

2-bit Synchronous Counter

Page 11: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Steps : Design of synchronous counter

• Design a 3 bit synchronous counter • Step1 : Draw the State Table

Page 12: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

• Step 2. Prepare State Table

• Step 3. Choose the flip flops – As it is 3 bit, so 3 flip flops are used. – We can use either T ff or JK ff only

Page 13: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

• Step 4: Write the excitation table for the flip flop

QnQn+1 T

00 0

01 1

10 1

11 0

QnQn+1 D

00 0

01 1

10 0

11 1

QnQn+1 J K

00 0 X

01 1 x

10 x 1

11 x 0

Page 14: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

• Step 5: From the excitation table of chosen flip flop, make excitation table for the state table

Present State Nxt state J2 K2

J1 K1 J0 K0

Q2 Q1 Q0 Q2 Q1 Q0

0 0 0 0 0 1 0 X 0 X 1 x

0 0 1 0 1 0 0 X 0 x x 1

0 1 0 0 1 1 0 X x 0 1 x

0 1 1 1 0 0 0 x x 1 x 1

1 0 0 1 0 1 x 0 0 X 1 x

1 0 1 1 1 0 x 0 0 x x 1

1 1 0 1 1 1 x 0 x 0 1 x

1 1 1 0 0 0 x 1 x 1 x 1

Page 15: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

• Step 6: Using K map, find equations for J0, K0, J1, K1,J2, K2

• We get: • J0 = K0 =1 • J1 = K1 =Q0

• J2 = K2 =Q0Q1

Page 16: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

3 bit synchronous counter • Step 7: Draw circuit diagram

Page 17: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Design Problem

1.Design 4-bit synchronous up-counter 2.Design 4-bit synchronous down-counter using

T-ff

Page 18: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Design Problem 3.Design synchronous decade counter (mod-10)

(counts from 09 and resets to 0) 4. Design a synchronous counter which counts as 02 4 6 8 10 12 14 0 2 and so on

5. Design Mod 7 counter. 6. Design a 3bit up-down counter Hint: Include a direction control bit M. If M=0, it acts as

up counter and when M=1, it acts as down counter . For 3 bit we have 8 states, but because of M, we will have 16 states {eg 8.10 R.P Jain Pg 260}

Page 19: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

• 7.Design sync counter for state diagram using D ff

Page 20: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

• Soln

Page 21: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

8. 7.Design sync counter for state diagram

Page 22: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

9.Design sync counter for state diagram

Page 23: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Lockout condition 10.Design a synchronous counter for 46 7 3

1 4 6 using JK flip flop. Avoid lockout condition Here, state 5, 2, 0 are forced to some specified state.

This is called avoiding lock-out condition. If next states of 5,2,0 is not specified, then foe example next state of 5 was 2 then the counter would have been locked.

Page 24: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Shift Registers

Page 25: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Last Lecture

• flip flops hold data bit • A data input value is loaded

into the register on the rise of the clock edge.

• Some circuits have additional ~clear or ~reset inputs.

D

C

Q

Q

Positive edge- triggered flip-flop

C D Q 0 0 1 1 ? Qn

Page 26: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Four bit Register

D

C

Q

D

C

Q

D

C

Q

D

C

Q

D0

D1

D2

D3

Q0

Q1

Q2

Q3

clk

D0

D1

D2

D3

Q0

Q1

Q2

Q3 clk

Symbol Circuit

Page 27: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Shift Registers – Allow stored data to be moved from one bit

position to another

D

C

Q D

C

Q D

C

Q D

C

Q Da

Qa Qb Qc Qd

A B C D

Qa Qb Qc Qd 0 0 1 0 1 0 0 1 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1

Da =1: Initial Values after clock 1 after clock 2

Da = 0: after clock 3 after clock 4 after clock 5

Page 28: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Shift Registers

• Points to note: – At every clock pulse, the first flip flop is loaded

with the value of the data in stream – The data that was in this flip flop is then loaded

into the second and so on. – The data can be taken out of the last flip flop in

serial form or it can be taken from all outputs at the same time – parallel form.

Page 29: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Shift Left/Right Registers • Multi-bit register that moves stored data bits

left/right • ( 1 bit position per clock cycle)

Page 30: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Types of Shift Registers • Shift registers can be loaded using parallel/serial

input lines.Therefore inputs can be parallel or serial • Outputs can be parallel or serial • Functions that shift registers can carry out include:

– Serial in, serial out shift register – Serial in, parallel out shift register – Parallel in, serial out shift register – Parallel in, parallel out shift register

Page 31: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Serial-In Serial-Out shift register

Page 32: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Serial-In Parallel-Out shift register

Page 33: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Parallel-In Serial-Out shift register

Page 34: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Parallel-In Parallel-Out shift register

Page 35: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.
Page 36: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.
Page 37: Counters & Shift Registers - Amazon S3 · PDF fileChapter 3 Counters & Shift Registers ... – It will count 4 states i.e 3,2,1,0 3. Design ... (counts from 0 9 and resets to 0) 4.

Ring Counter • Ring counter: is a shift register (a cascade connection

of flip-flops) with the output of the last one connected to the input of the first, that is, in a ring. Typically a pattern consisting of a single 1 bit is circulated, so the state repeats every N clock cycles if N flip-flops are used. It can be used as a cycle counter of N states.

• Johnson counter: is a modified ring counter, where the output from the last stage is inverted and fed back as input to the first stage..