Counters as State Machines Lecture L9.1 Handout Section 9.1.

Slides:



Advertisements
Similar presentations
Counters Discussion D8.3.
Advertisements

Modulo-N Counters Module M10.4 Section 7.2.
Encoders Module M9.3 Section 6.3. Encoders Priority Encoders TTL Encoders.
Demultiplexers Module M6.4 Section 6.4. Demultiplexers YIN 1 x 4 DeMUX d0d1 Y0 Y1 Y2 Y3 Y0 Y1 Y2 Y3 d1d0 0 0 YIN YIN YIN
Shift Registers Module M11.1 Section 7.3.
7-Segment Displays Lecture L6.1 Section 6.3. Turning on an LED.
Counters. In class excercise How to implement a “counter”, which will count as 0,3,1,4,5,7,0,3,1,…… Q2Q1Q0D2D1D
Asynchronous Counter with MSI Gates
Latches and Flip-Flops Discussion D8.1 Section 13-9.
1 EE121 John Wakerly Lecture #10 Some shift-register stuff Sequential-circuit analysis.
Digital Logic Circuit Analysis & Design 王 军 王 军 王晓东.
Binary Counters Module M10.3 Section 7.2. Counters 3-Bit Up Counter 3-Bit Down Counter Up-Down Counter.
7-Segment Displays Lecture L6.7 Section 6.5. Turning on an LED.
Binary-to-BCD Converter Lecture L6.2 Section 6.5 pp
CMPUT Computer Organization and Architecture II1 CMPUT329 - Fall 2003 TopicJ: Counters José Nelson Amaral.
Using State Machines as Control Circuits Lecture L9.4.
Multiplier Lecture L7.3 Section 10.4 (p.276) Section 7.3 (Handout)
1 Sequential logic networks I. Motivation & Examples  Output depends on current input and past history of inputs.  “State” embodies all the information.
Multiplexers Lecture L6.4 Section 6.4.
Subtractors Module M8.2 Section 6.2. Subtractors Half Subtractor Full Subtractor Adder/Subtractor - 1 Adder/Subtractor - 2.
Designing State Machines Lecture L9.2 Handout Section 9.2.
Datapaths Lecture L10.2 Sections 10.2, ALU (Sect. 7.5 and Lab 6)
Arbitrary Waveforms Lecture L8.5 Section 7.2. CLK DQ !Q CLK DQ !Q CLK DQ !Q Q0Q0.D Q1 Q2 Q1.D Q2.D s s s s3 0 1.
Designing State Machines SQRT controller Lecture L9.2a Section 9.2.
Flip-Flops Module M10.2 Section 7.1. D Latch Q !Q CLK D !S !R S R X 0 Q 0 !Q 0 D CLK Q !Q Note that Q follows D when the clock in high, and.
Counters Mano & Kime Sections 5-4, 5-5. Counters Ripple Counter Synchronous Binary Counters –Design with D Flip-Flops –Design with J-K Flip-Flops Counters.
Binary Counters Lecture L8.3 Section 8.2. Counters 3-Bit Up Counter 3-Bit Down Counter Up-Down Counter.
Modulo-N Counters Lecture L8.4 Section 7.2. Counters Modulo-5 Counter 3-Bit Down Counter with Load and Timeout Modulo-N Down Counter.
Codes and Code Converters
Code Converters Module M7.1 Section 6.5. Code Converters Binary-to-BCD Converters ABEL TRUTH_TABLE Command.
Arbitrary Waveforms Module M10.5 Section 7.2. CLK DQ !Q CLK DQ !Q CLK DQ !Q Q0Q0.D Q1 Q2 Q1.D Q2.D s s s s3 0 1.
Arithmetic Logic Unit (ALU) Lecture L7.5 Section 7.5.
Sequential Logic Design
Pulse-Width Modulated DAC Lecture 11.3 Section 11.5.
Multiplexers Module M6.1 Section 6.4. Multiplexers A 4-to-1 MUX TTL Multiplexer A 2-to-1 MUX.
Adders Lecture L7.1 Section 6.2 Section 10.4 (pp )
Arbitrary Waveform Discussion 12.2 Example 34. Recall Divide-by-8 Counter Use q2, q1, q0 as inputs to a combinational circuit to produce an arbitrary.
Flip-Flops Lecture L8.2 Section 8.1. Recall the !S-!R Latch !S !R Q !Q !S !R Q !Q X Y nand 1 0 Set 1 0.
Counters Discussion 12.1 Example 33. Counters 3-Bit, Divide-by-8 Counter 3-Bit Behavioral Counter in Verilog Modulo-5 Counter An N-Bit Counter.
Arithmetic Logic Unit (ALU) Lecture L9.3 Lab 10. ALU CB = carry_borrow flag Z = zero flag (Z = 1 if Y = 0)
Shift Registers Lecture L6.6 Section Bit Shift Register.
7-Segment Displays Module M7.2 Section 6.5. Turning on an LED Common Anode.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Senior Design I Lecture 4 - Verilog 2 (Sequential.
Flip-Flops Lecture L8.2 Section 7.1 – Book Sect. 8.1– Handout.
ELEN 468 Advanced Logic Design
Chapter 9 Counters.
Introduction to Counter in VHDL
Synchronous Counters with SSI Gates
Counters Dr. Rebhi S. Baraka Logic Design (CSCI 2301) Department of Computer Science Faculty of Information Technology The Islamic University.
2017/4/24 CHAPTER 6 Counters Chapter 5 (Sections )
Counters. In class excercise How to implement a “counter”, which will count as 0,3,1,4,5,7,0,3,1,…… Q2Q1Q0D2D1D
Computer Organization & Programming Chapter 5 Synchronous Components.
Traffic Lights Discussion D8.3a. Recall Divide-by-8 Counter Use Q2, Q1, Q0 as inputs to a combinational circuit to produce an arbitrary waveform. s0 0.
EE121 John Wakerly Lecture #11
A Greatest Common Divisor (GCD) Processor Lecture L10.3 Sections 10.4, 10.5.
Decade Counter (BCD Counter). Introduction A counter which is reset at the 10 th clock pulse is called decade counter. The decade counter is otherwise.
Digital Electronics.
EE121 John Wakerly Lecture #9
Electronics Merit Badge Class 3 3/13/2016Electronics Merit Badge Class 31.
State Machine Design State Machine Design Digital Electronics
Digital Logic & Design Dr. Waseem Ikram Lecture No. 35.
Digital Logic & Design Dr. Waseem Ikram Lecture 37.
Counters as State Machines
Shift Registers Lecture L8.6 Section 8.3.
Designing Digital Circuits Using Hardware Description Languages (HDLs)
Digital Logic & Design Dr. Waseem Ikram Lecture No. 31.
Analog-to-Digital Converters
Finite State Machines.
Digital Logic & Design Dr. Waseem Ikram Lecture No. 36.
Counters.
Presentation transcript:

Counters as State Machines Lecture L9.1 Handout Section 9.1

Counters as State Machines Divide by 8 Counter A Divide-by-16 Counter with Count Enable

CLK DQ !Q CLK DQ !Q CLK DQ !Q Q0Q0.D Q1 Q2 Q1.D Q2.D s s s s s s s s State Q2 Q1 Q0 Q2.D Q1.D Q0.D Divide-by-8 Counter

s s s s s s s s State Q2 Q1 Q0 Q2.D Q1.D Q0.D Divide-by-8 Counter Q2 Q1 Q Q2.D Q2.D = !Q2 & Q1 & Q0 # Q2 & !Q1 # Q2 & !Q0

s s s s s s s s State Q2 Q1 Q0 Q2.D Q1.D Q0.D Divide-by-8 Counter Q2 Q1 Q Q1.D Q1.D = !Q1 & Q0 # Q1 & !Q0

s s s s s s s s State Q2 Q1 Q0 Q2.D Q1.D Q0.D Divide-by-8 Counter Q2 Q1 Q Q0.D Q0.D = ! Q0

Divide-by-8 Counter A state machine for a divide by 8 counter

Divide-by-8 Counter A state-transition table s s s s s s s s State Q2 Q1 Q0 Q2.D Q1.D Q0.D

Divide-by-8 Counter A Divide by 8 counter Circuit using D Flip-flops

MODULE div8cnts TITLE 'Divide by 8 Counter using State Machine' DECLARATIONS hex7seg interface([D3..D0] -> [a,b,c,d,e,f,g]); d7R FUNCTIONAL_BLOCK hex7seg; " INPUT PINS " CLK PIN 12; " 1 Hz clock (jumper) clear PIN 11;" switch 1 " OUTPUT PINS " Q2..Q0 PIN 41,43,44 ISTYPE 'reg'; " LED Q = [Q2..Q0]; " 3-bit output vector [a,b,c,d,e,f,g] PIN 15,18,23,21,19,14,17 ISTYPE 'com'; " Rightmost (units) 7-segment LED display div8cnts.abl

" Definitions QSTATE = [Q2,Q1,Q0]; s0 = [0,0,0]; s1 = [0,0,1]; s2 = [0,1,0]; s3 = [0,1,1]; s4 = [1,0,0]; s5 = [1,0,1]; s6 = [1,1,0]; s7 = [1,1,1]; state_diagram QSTATE state s0: GOTO s1; state s1: GOTO s2; state s2: GOTO s3; state s3: GOTO s4; state s4: GOTO s5; state s5: GOTO s6; state s6: GOTO s7; state s7: GOTO s0; Define the states; Associate a variable name With a numerical representation Define the transitions between the states div8cnts.abl (cont.)

EQUATIONS Q.AR = clear; Q.C = CLK; [a,b,c,d,e,f,g] = d7R.[a,b,c,d,e,f,g]; d7R.[D2..D0] = Q; d7R.D3 = 0; Connect the clock Connect the 7-segment display div8cnts.abl (cont.)

test_vectors([CLK, clear] -> Q) [.C.,1] -> 0; [.C.,0] -> 1; [.C.,0] -> 2; [.C.,0] -> 3; [.C.,0] -> 4; [.C.,0] -> 5; [.C.,0] -> 6; [.C.,0] -> 7; [.C.,0] -> 0; [.C.,0] -> 1; [.C.,0] -> 2; [.C.,0] -> 3; [.C.,0] -> 4; END div8cnts

Counters as State Machines Divide by 8 Counter A Divide-by-16 Counter with Count Enable

count = 1 Counter counts count = 0 Counter stops counting Cout = 1 if [Q3..Q0] = [1,1,1,1]

State Diagram for a Divide-by-16 Counter with Count Enable

div16cnt.abl MODULE div16cnt interface ([CLK,clear,count] -> [Q3,Q2,Q1,Q0,Cout]); TITLE 'Divide by 16 (4-bit) Counter using State Machine' DECLARATIONS " INPUT PINS " CLK PIN ; " clock input clear PIN ;" asynchronous clear count PIN ;" count enable " OUTPUT PINS " Q3..Q0 PIN ISTYPE 'reg'; Q = [Q3..Q0]; " 3-bit output vector CoutPIN ISTYPE 'com';" Carry out

" Definitions QSTATE = [Q3,Q2,Q1,Q0]; s0 = [0,0,0,0]; s1 = [0,0,0,1]; s2 = [0,0,1,0]; s3 = [0,0,1,1]; s4 = [0,1,0,0]; s5 = [0,1,0,1]; s6 = [0,1,1,0]; s7 = [0,1,1,1]; s8 = [1,0,0,0]; s9 = [1,0,0,1]; s10 = [1,0,1,0]; s11 = [1,0,1,1]; s12 = [1,1,0,0]; s13 = [1,1,0,1]; s14 = [1,1,1,0]; s15 = [1,1,1,1]; div16cnt.abl (cont.)

state_diagram QSTATE state s0: if count then s1 else s0; state s1: if count then s2; else s1; state s2: if count then s3; else s2; state s3: if count then s4; else s3; state s4: if count then s5; else s4; state s5: if count then s6; else s5; state s6: if count then s7; else s6; state s7: if count then s8; else s7; Use If..Then statements to implement the count div16cnt.abl (cont.)

state s8: if count then s9 else s8; state s9: if count then s10; else s9; state s10: if count then s11; else s10; state s11: if count then s12; else s11; state s12: if count then s13; else s12; state s13: if count then s14; else s13; state s14: if count then s15; else s14; state s15: if count then s0; else s15;

div16cnt.abl (cont.) EQUATIONS Q.C = CLK; Q.AR = clear; Cout = Q3 & Q2 & Q1 & Q0; END div16cnt

8-Bit Counter