Class 06 Sequential Logic: Flip-Flop

Similar documents
Class 19 Sequential Logic: Flip-Flop

HDL & High Level Synthesize (EEET 2035) Laboratory II Sequential Circuits with VHDL: DFF, Counter, TFF and Timer

Flip-flop and Registers

ACS College of Engineering. Department of Biomedical Engineering. HDL pre lab questions ( ) Cycle-1

Flip-Flops and Registers

Feedback Sequential Circuits

download instant at

Eng. Mohammed Samara. Fall The Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department

VHDL 4 BUILDING BLOCKS OF A COMPUTER.

ECE 263 Digital Systems, Fall 2015

Other Flip-Flops. Lecture 27 1

Chapter 6. Flip-Flops and Simple Flip-Flop Applications

Sequential circuits. Same input can produce different output. Logic circuit. William Sandqvist

Design Problem 4 Solutions

RS flip-flop using NOR gate

Chapter 8 Registers & Counters

Unit 11. Latches and Flip-Flops

(CSC-3501) Lecture 7 (07 Feb 2008) Seung-Jong Park (Jay) CSC S.J. Park. Announcement

Lecture 8: Sequential Logic

Figure 1 Block diagram of a 4-bit binary counter

STATIC RANDOM-ACCESS MEMORY

EMT 125 Digital Electronic Principles I CHAPTER 6 : FLIP-FLOP

Logic Gates, Timers, Flip-Flops & Counters. Subhasish Chandra Assistant Professor Department of Physics Institute of Forensic Science, Nagpur

10.1 Sequential logic circuits are a type of logic circuit where the output of the circuit depends not only on

Sequential Logic. E&CE 223 Digital Circuits and Systems (A. Kennings) Page 1

EE292: Fundamentals of ECE

Laboratory Exercise 7

Ryerson University Department of Electrical and Computer Engineering EES508 Digital Systems

Digital Logic Design Sequential Circuits. Dr. Basem ElHalawany

RS flip-flop using NOR gate

Universidad Carlos III de Madrid Digital Electronics Exercises

Sequential Digital Design. Laboratory Manual. Experiment #3. Flip Flop Storage Elements

ECE 3401 Lecture 12. Sequential Circuits (II)

ECE 3401 Lecture 11. Sequential Circuits

Synchronous Sequential Logic

ELCT201: DIGITAL LOGIC DESIGN

COMP2611: Computer Organization Building Sequential Logics with Logisim

Flip-Flops and Sequential Circuit Design

library IEEE; use IEEE.STD_LOGIC_1164.ALL;

California State University, Bakersfield Computer & Electrical Engineering & Computer Science ECE 3220: Digital Design with VHDL Laboratory 7

YEDITEPE UNIVERSITY DEPARTMENT OF COMPUTER ENGINEERING. EXPERIMENT VIII: FLIP-FLOPS, COUNTERS 2014 Fall

LATCHES & FLIP-FLOP. Chapter 7

Slide 1. Flip-Flops. Cross-NOR SR flip-flop S R Q Q. hold reset set not used. Cross-NAND SR flip-flop S R Q Q. not used reset set hold 1 Q.

ELCT201: DIGITAL LOGIC DESIGN

Laboratory Exercise 7

Chapter 11 State Machine Design

Chapter 2. Digital Circuits

Lab 3: VGA Bouncing Ball I

CSE Latches and Flip-flops Dr. Izadi. NOR gate property: A B Z Cross coupled NOR gates: S M S R Q M

Asynchronous (Ripple) Counters

Digital Fundamentals: A Systems Approach

CHAPTER 1 LATCHES & FLIP-FLOPS

Introduction to Sequential Circuits

COE758 Xilinx ISE 9.2 Tutorial 2. Integrating ChipScope Pro into a project

CHAPTER 4: Logic Circuits

Introduction. NAND Gate Latch. Digital Logic Design 1 FLIP-FLOP. Digital Logic Design 1

DIGITAL ELECTRONICS MCQs

Experiment 8 Introduction to Latches and Flip-Flops and registers

Electrical and Telecommunications Engineering Technology_TCET3122/TC520. NEW YORK CITY COLLEGE OF TECHNOLOGY The City University of New York

Sequential Logic and Clocked Circuits

Outputs Combinational circuit. Next state. Fig. 4-1 Block Diagram of a Sequential Circuit

Sequential Logic Circuits

Level and edge-sensitive behaviour

Registers and Counters

Rangkaian Sekuensial. Flip-flop

CHAPTER 4: Logic Circuits

Serial In/Serial Left/Serial Out Operation

hochschule fu r angewandte wissenschaften hamburg Prof. Dr. B. Schwarz FB Elektrotechnik/Informatik

Sequential Digital Design. Laboratory Manual. Experiment #7. Counters

ECE 341. Lecture # 2

CMSC 313 Preview Slides

LAB #4 SEQUENTIAL LOGIC CIRCUIT

Chapter 6. sequential logic design. This is the beginning of the second part of this course, sequential logic.

Debugging of VHDL Hardware Designs on Altera s DE2 Boards

ECE 448 Lecture 10. VGA Display Part 1 VGA Synchronization

SEQUENTIAL LOGIC. Satish Chandra Assistant Professor Department of Physics P P N College, Kanpur

CS/EE Homework 6

Chapter. Synchronous Sequential Circuits

Clocks. Sequential Logic. A clock is a free-running signal with a cycle time.

ME 515 Mechatronics. Introduction to Digital Electronics

Department of Electrical and Computer Engineering Mid-Term Examination Winter 2012

Digital Circuits ECS 371

CprE 281: Digital Logic

Sequential Design Basics

Microprocessor Design

EKT 121/4 ELEKTRONIK DIGIT 1

Chapter 5 Synchronous Sequential Logic

Digital Fundamentals. Lab 5 Latches & Flip-Flops CETT Name: Date:

DALHOUSIE UNIVERSITY Department of Electrical & Computer Engineering Digital Circuits - ECED 220. Experiment 4 - Latches and Flip-Flops

COSC 243. Sequential Logic. COSC 243 (Computer Architecture) Lecture 5 - Sequential Logic 1

LAB 7. Latches & Flip Flops

Digital Circuit And Logic Design I. Lecture 8

Outline. CPE/EE 422/522 Advanced Logic Design L04. Review: 8421 BCD to Excess3 BCD Code Converter. Review: Mealy Sequential Networks

Digital Circuit And Logic Design I

Sequential Logic Basics

VU Mobile Powered by S NO Group

Chapter 4. Logic Design

DIGITAL CIRCUIT LOGIC UNIT 11: SEQUENTIAL CIRCUITS (LATCHES AND FLIP-FLOPS)

Chapter 8 Sequential Circuits

INTRODUCTION TO SEQUENTIAL CIRCUITS

Transcription:

Class 06 Sequential Logic: Flip-Flop June 16, 2017 2 Differences between Latch and Flip-Flop D latch Level trigger D flip-flop Edge trigger 1

June 16, 2017 3 Function Table of D Flip-Flop DFF D flip-flop Edge trigger CLK D Q t+1 nq t+1 Function 0 0 1 Reset 1 1 0 Set 0 X Q t nq t Inhibited 1 X Q t nq t Inhibited X Q t nq t Inhibited Function table of D flip-flop June 16, 2017 4 JK Flip-Flop JKFF SR NAND Latch Gated SR NAND Latch JK flip-flop CLK J K Q t+1 nq t+1 Function 0 0 Q t nq t No Change 0 1 0 1 Reset 1 0 1 0 Set 1 1 nq t Q t Toggle 0 X X Q t nq t Inhibited 1 X X Q t nq t Inhibited X X Q t nq t Inhibited Function table of JK flip-flop 2

June 16, 2017 5 Frequency Divider or Counter Clock Q 2 Q 1 Q 0 Pulse 0 0 0 0 1 0 0 1 2 0 1 0 3 0 1 1 4 1 0 0 5 1 0 1 6 1 1 0 7 1 1 1 8 0 0 0 June 16, 2017 6 JK Flip-Flop with Asynchronous Inputs Second priority npre nclr CLK J K Q t+1 nq t+1 Function Sync 1 1 0 0 Q t nq t No Change 1 1 0 1 0 1 Reset 1 1 1 0 1 0 Set 1 1 1 1 nq t Q t Toggle Async 0 1 X X X 1 0 Preset 1 0 X X X 0 1 Clear 0 0 X X X 1 1 Forbidden 1 1 0 X X Q t nq t Inhibited First 1 1 1 X X Q t nq t Inhibited priority 1 1 X X Q t nq t Inhibited 3

June 16, 2017 7 T Flip-Flop D flip-flop with an XOR at the input T flip-flop: the output Q toggles on each clock pulse when T is high CLK T Q t+1 Function 0 Q t No change 1 nq t Toggle 0 X Q t Inhibited 1 X Q t Inhibited X Q t Inhibited Function table of T flip-flop June 16, 2017 8 Integer vs. Unsigned STD_LOGIC USE ieee.std_logic_1164.all; ENTITY compare4 IS PORT( a, b : IN INTEGER RANGE 0 TO 15; agtb, aeqb, altb : OUT STD_LOGIC); END compare4; ARCHITECTURE a OF compare4 IS SIGNAL compare : STD_LOGIC_VECTOR(2 downto 0); PROCESS (a,b) IF a<b THEN compare <= "110"; ELSIF a=b THEN compare <= "101"; ELSIF a>b THEN compare <= "011"; ELSE compare <= "111"; agtb <= compare(2); aeqb <= compare(1); altb <= compare(0); END PROCESS; END a; USE ieee.std_logic_1164.all; USE ieee.std_logic_unsigned.all; ENTITY compare4 IS PORT( a, b : IN STD_LOGIC_VECTOR (3 downto 0); agtb, aeqb, altb : OUT STD_LOGIC); END compare4; ARCHITECTURE a OF compare4 IS SIGNAL compare : STD_LOGIC_VECTOR(2 downto 0); PROCESS (a,b) IF a<b THEN compare <= "110"; ELSIF a=b THEN compare <= "101"; ELSIF a>b THEN compare <= "011"; ELSE compare <= "111"; agtb <= compare(2); aeqb <= compare(1); altb <= compare(0); END PROCESS; END a; 4

June 16, 2017 9 Signal Attributes and Edges Attribues of Signal p[0..7] Attribute Description Value p HIGH Upper bound of p 7 p LOW Lower bound of p 0 p LEFT Left bound of p 0 p RIGHT Right bound of p 7 p LENGTH Length of p 8 Q EVENT and Q= 0 ) FALLING_EDGE(Q) Q Q Q EVENT and Q= 1 ) RISING_EDGE(Q) June 16, 2017 10 Signal Attributes and Constant with Default Value USE ieee.std_logic_1164.all; ENTITY parity_genx IS PORT( pe: OUT STD_LOGIC); END parity_genx; ARCHITECTURE parity OF parity_genx IS CONSTANT width: INTEGER := 8; SIGNAL d: STD_LOGIC_VECTOR(0 to width-1); SIGNAL p : STD_LOGIC_VECTOR(d'LOW+1 to d'high); p(1) <= d(0) xor d(1); parity_generate: FOR i IN d'left+2 to d'right GENERATE p(i) <= p(i-1) xor d(i); END GENERATE; pe <= p(d LENGTH-1); END parity; Constant value 0+2=2 8-1=7 7 1 Default value 7 8-1=7 5

June 16, 2017 11 Frequency Divider K Map to external 50MHz USE ieee.std_logic_1164.all; ENTITY FrequencyDivider IS clock PORT ( CLK: IN STD_LOGIC; LED: OUT STD_LOGIC); END FrequencyDivider; ARCHITECTURE a OF FrequencyDivider IS Imported from COMPONENT jkff_primitive jkff_primitive.bdf PORT ( of the same project CLK: IN STD_LOGIC; Q: OUT STD_LOGIC); END COMPONENT; SIGNAL Q: STD_LOGIC_VECTOR(25 downto 0); JKFF PRN J INPUT OUTPUT VCC J Q Q CLK INPUT VCC INPUT VCC K CLRN inst The procedure to import a.bdf design into a VHDL file: 1. Create a jkff_primitive.bdf file, and add a JKFF component into this file. 2. Create input and output pins for this JKFF component. 3. In the VHDL file, declare the jkff_primitive as its component with only the in/out pins that it wants to use. 4. Generate this component in this VHDL file. -- Frequency Divider Q(Q'LOW) <= CLK; 1 2 5 divider: FOR i IN Q'LOW+1 to Q'HIGH GENERATE divider_unit: jkff_primitive PORT MAP(CLK=>Q(i-1), Q=>Q(i)); END GENERATE; LED <= not Q(Q'HIGH); END a; Turn the LED on/off every 0.67s 1s / (50MHz / 2 25 ) Generate 25 JK flip-flops June 16, 2017 12 FOR Loop and Array USE ieee.std_logic_1164.all; ENTITY FrequencyDivider IS PORT (Hex0, Hex1, Hex2, Hex3: OUT STD_LOGIC_VECTOR(0 to 7)); END FrequencyDivider; ARCHITECTURE a OF FrequencyDivider IS CONSTANT DigitValue: INTEGER := 16; TYPE MMSS is array (0 to 3) of INTEGER RANGE 0 to DigitValue; SIGNAL digits: MMSS; TYPE SEVENSEGMENT is array (0 to 3) of STD_LOGIC_VECTOR(0 to 7); SIGNAL segments: SEVENSEGMENT; -- show 7-segment Hex0 <= segments(0); Hex1 <= segments(1); Hex2 <= segments(2); Hex3 <= segments(3); Define an STD_LOGIC_VECTOR array Map signal to port Constant with default value 16 Define an integer array Light on dot of HEX2 hexadecimal Note: 101000011000 = x A18 = o 5030 = b 101000011000 binary octal PROCESS(all) FOR i IN 0 to 3 LOOP CASE digits(i) IS WHEN 0=> segments(i)<="00000011"; -- 0 WHEN 1=> segments(i)<="10011111"; -- 1 WHEN 2=> segments(i)<="00100101 ; -- 2 WHEN 3=> segments(i)<="00001101"; -- 3 WHEN 4=> segments(i)<="10011001"; -- 4 WHEN 5=> segments(i)<="01001001"; -- 5 WHEN 6=> segments(i)<="11000001"; -- 6 WHEN 7=> segments(i)<="00011111"; -- 7 WHEN 8=> segments(i)<="00000001"; -- 8 WHEN 9=> segments(i)<="00011001"; -- 9 WHEN others =>segments(i)<="11111111"; END CASE; END LOOP; segments(2)(7) <= '0'; -- display "dot" END PROCESS; END a; 6

Hint: digits(0) <= digit mod 10; digits(1) <= (digit/10) mod 10; digits(2) <= (digit/100) mod 10; digits(3) <= (digit/1000) mod 10; PROCESS(CLK) IF(RISING_EDGE(CLK)) THEN Ticks <= Ticks + 1; Function IF(Ticks >= TenMiniSecondTicks-1) THEN Ticks <= 0; digit <= digit + 1; USE ieee.std_logic_1164.all; END PROCESS; ENTITY FrequencyDivider IS PORT (CLK: IN STD_LOGIC; Hex0, Hex1, Hex2, Hex3: OUT STD_LOGIC_VECTOR(0 to 7)); END FrequencyDivider; ARCHITECTURE a OF FrequencyDivider IS SIGNAL Ticks : INTEGER; TYPE MMSS is array (0 to 3) of INTEGER RANGE 0 to 16; SIGNAL TenMiniSecondTicks: INTEGER := 500000; SIGNAL digits: MMSS; Function name SIGNAL digit; FUNCTION PlusOne (a:integer RANGE 0 to 16) RETURN INTEGER IS VARIABLE result : INTEGER RANGE 0 to 16; result := a + 1; RETURN (result); END; Return value Parameters (separated by ;) Variable (SIGNAL is not allowed in functions) Value assignment to variable should use := Return value type -- Stopwatch PROCESS(CLK) IF(RISING_EDGE(CLK)) THEN Ticks <= Ticks + 1; IF(Ticks >= TenMiniSecondTicks-1) THEN Ticks <= 0; digits(0) <= PlusOne(digits(0)); IF(digits(0)>=9) THEN digits(1) <= PlusOne(digits(1)); digits(0) <= 0; IF(digits(1)>=9) THEN digits(2) <= PlusOne(digits(2)); digits(1) <= 0; IF(digits(2)>=9) THEN digits(3) <= PlusOne(digits(3)); digits(2) <= 0; IF(digits(3)>=9) THEN digits(3) <= 0; Function call END PROCESS; END a; June 16, 2017 13 Remember to USE ieee_std_logic_arith.all; Exercise: Try to use one integer instead of an integer array (i.e., 4 intergers). June 16, 2017 14 DE2 External Clock 7

June 16, 2017 15 Lab 06 Part 1: Frequency Divider with JK flip-flops or T flipflops Design a flashing light array with the 50MHz clock - LEDG[0..9] is toggled every 2 [25..34] clock ticks, respectively. - E.g., LEDG0 is toggled with 1.49Hz, LEDG1 is toggled with 0.745Hz, and so on. Part 2: Design a clock Design a clock with four digits. - HEX[3210] represents MM.SS (MM: minutes, SS: seconds), where the dot between MM and SS should be always on. - Set the initial time to 34.56. June 16, 2017 16 DE2 External Clock 8

June 16, 2017 17 Pushbutton and Slide Switches Pin number Pin number 4 Pushbutton switches: Not pressed Logic High Pressed Logic Low BUTTON(KEY) DE2-115 0 M23 1 M21 2 N21 3 R24 17 Slide switches (Sliders): Up Logic High Down Logic Switch DE2-115 0 AB28 1 AC28 2 AC27 3 AD27 4 AB27 5 AC26 6 AD26 7 AB26 8 AC25 9 AB25 10 AC24 11 AB24 12 AB23 13 AA24 14 AA23 15 AA22 16 Y24 17 Y23 June 16, 2017 18 LEDs Pin number 9 LEDs Output high LED on Output low LED off LEDG DE2-115 0 E21 1 E22 2 E25 3 E24 4 H21 5 G20 6 G22 7 G21 8 F17 9

June 16, 2017 19 7-Segment Displays DE2-115 Pin NO Pin NO Pin NO Pin NO HEX0[0] G18 HEX1[0] M24 HEX2[0] AA25 HEX3[0] V21 HEX0[1] F22 HEX1[1] Y22 HEX2[1] AA26 HEX3[1] U21 HEX0[2] E17 HEX1[2] W21 HEX2[2] Y25 HEX3[2] AB20 HEX0[3] L26 HEX1[3] W22 HEX2[3] W26 HEX3[3] AA21 HEX0[4] L25 HEX1[4] W25 HEX2[4] Y26 HEX3[4] AD24 HEX0[5] J22 HEX1[5] U23 HEX2[5] W27 HEX3[5] AF23 HEX0[6] H22 HEX1[6] U24 HEX2[6] W28 HEX3[6] Y19 10