9/15/09 - l23 more sequential circuits copyright 2009 - joanne degroat, ece, osu1 more sequential...

22
9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU 1 More Sequential Circuits

Upload: tiara-crittendon

Post on 01-Apr-2015

230 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 1

More Sequential Circuits

Page 2: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 2

Class 23-More Sequential Circuits An up/down counter A loadable down counter with signal

Material from section 5-5 of text

Page 3: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

Design of and up/down counter Problem Statement: Design a 3 bit binary

clocked counter that counts up when the input C = 1 and counts down when the input C = 0. When the counter gets to 111 (000) it rolls over to 000 (111).

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 3

Page 4: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

Problem Formulation Will use a state table for this problem

C=0 down C=1 up Present State Next State Next State 000 111 001 001 000 010 010 001 011 011 010 100 100 011 101 101 100 110 110 101 111 111 110 000

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 4

Page 5: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

State Assignment As this design involves a counter it already

has binary values assigned to the states. So we can move straight to creation of the

next state generation. The system will use D Flip-flops.

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 5

Page 6: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

Next State Generation In the table the Present State will be denoted

by the 3-bit binary value as seen in the state table. The binary value is Q2Q1Q0.

First the generation of Q0.

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 6

Page 7: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

Next State Generation D1

Generate the next state equation for D1

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 7

D1 = C’Q1’Q0’+C’Q1Q0+CQ1’Q0+CQ1Q0’ = C’(Q1’Q0’+Q1Q0) +C(Q1’Q0+Q1Q0’) = C’ (Q1Q0) + C (Q1Q0)

Page 8: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

Next State Generation D2

Generate the next state equation for D2

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 8

D2=C’Q2’Q1’Q0’+CQ2’Q1Q0+CQ2Q1’+ C’Q2Q0+Q2Q1Q0’

Page 9: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

Output Generation Output generation is easy as it just the current

state.

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 9

Page 10: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

Verification via HDL The models

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 10

ENTITY DFF IS PORT (D,CLK : IN BIT; Q,Q_bar : OUT BIT); END DFF; ARCHITECTURE beh OF DFF IS BEGIN PROCESS BEGIN Q <= D; Q_bar <= NOT D; WAIT UNTIL CLK='1' and CLK'EVENT; END PROCESS; END beh;

Page 11: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

The counter model Uses the D FF

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 11

ENTITY UDCNTR IS PORT (C,CLK : IN BIT; Q : OUT BIT_VECTOR(2 DOWNTO 0)); END UDCNTR; ARCHITECTURE one OF UDCNTR IS SIGNAL D0,D1,D2,Q0,Q1,Q2 : BIT; SIGNAL Q0_bar,Q1_bar,Q2_bar : BIT; COMPONENT DFF PORT (D,CLK : IN BIT; Q,Q_bar : OUT BIT); END COMPONENT; FOR ALL : DFF USE ENTITY work.dff(beh); BEGIN -- invoke FFs FF0 : DFF PORT MAP(D0,CLK,Q0,Q0_bar); FF1 : DFF PORT MAP(D1,CLK,Q1,Q1_bar); FF2 : DFF PORT MAP(D2,CLK,Q2,Q2_bar); -- set up next state logic D0 <= NOT Q0; D1 <= (NOT C and (Q1 xnor Q0)) OR (C and (Q1 xor Q0)); D2 <= (NOT C and NOT Q2 and NOT Q1 and NOT Q0) OR (C and NOT Q2 and Q1 and Q0) OR (C and Q2 and NOT Q1) OR (NOT C and Q2 and Q0) OR (Q2 and Q1 and NOT Q0); -- generate outputs Q(0) <= Q0; Q(1) <= Q1; Q(2) <= Q2; END one;

Page 12: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

The Testbench Need to apply stimulus and look at results.

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 12

ENTITY cntr_test IS END cntr_test; ARCHITECTURE one of cntr_test IS SIGNAL C,CLK : BIT; SIGNAL CNT : BIT_VECTOR(2 downto 0); COMPONENT UDCNTR PORT (C,CLK : IN BIT; Q : OUT BIT_VECTOR(2 downto 0)); END COMPONENT; FOR ALL : UDCNTR USE ENTITY work.UDCNTR(one); BEGIN -- set up the clock CLK <= not CLK after 5 ns; -- invoke the counter ctr0 : UDCNTR PORT MAP(C,CLK,CNT); -- set up the input C waveform PROCESS BEGIN C <= '1'; WAIT FOR 100 ns; C <= '0'; WAIT FOR 100 ns; C <= '1'; WAIT FOR 30 ns; C <= '0'; WAIT FOR 40 ns; WAIT; END PROCESS; END one;

Page 13: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

Simultion Results The waveform for counting up

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 13

Page 14: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

Simultion Results The waveform for counting down

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 14

Page 15: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

Simulation Results Waveform for up again and back to down

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 15

Page 16: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

Changing format to octal display For a more readable output

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 16

Page 17: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

A Loadable countdown timer Specification: Design a loadable 3-bit

countdown timer the after loading counts down to 0 and then generates a signal Z which will stay asserted as long as the countdown is enabled.

When the counter reaches 0 it remains there until a new count is loaded.

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 17

Page 18: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

The state table The state table showing both count enable and

load

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 18

Page 19: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

K-maps The K-maps for the circuit are.

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 19

Page 20: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

The output The output signal Z is

asserted when state 000 is reached. It stays asserted as long as C is asserted.

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 20

Page 21: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

The circuit Has 3 FFs

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 21

Page 22: 9/15/09 - L23 More Sequential Circuits Copyright 2009 - Joanne DeGroat, ECE, OSU1 More Sequential Circuits

Class 23 assignment Covered sections 5-5 Problems for hand in

Nothing new Problems for practice

Nothing new

Reading for next class: 5-6

9/15/09 - L23 More Sequential Circuits

Copyright 2009 - Joanne DeGroat, ECE, OSU 22