Sequential Logic - Module 5

Similar documents
DESCRIPTION OF DIGITAL CIRCUITS USING VHDL

Test Benches - Module 8

The University of Alabama in Huntsville ECE Department CPE Midterm Exam Solution March 2, 2006

The University of Alabama in Huntsville ECE Department CPE Midterm Exam Solution Spring 2016

The University of Alabama in Huntsville Electrical and Computer Engineering CPE/EE 422/522 Spring 2005 Homework #6 Solution

Timing in synchronous systems

VHDL And Synthesis Review

Sequential Statement

Verilog Sequential Logic. Verilog for Synthesis Rev C (module 3 and 4)

VHDL for Modeling - Module 10

Lecture 4: Modeling in VHDL (Continued ) EE 3610 Digital Systems

The University of Alabama in Huntsville ECE Department CPE Final Exam Solution Spring 2004

Part 4: VHDL for sequential circuits. Introduction to Modeling and Verification of Digital Systems. Memory elements. Sequential circuits

VHDL in 1h. Martin Schöberl

VHDL Modeling Behavior from Synthesis Perspective -Part B - EL 310 Erkay Savaş Sabancı University

[VARIABLE declaration] BEGIN. sequential statements

VHDL: RTL Synthesis Basics. 1 of 59

ECEU530. Homework 4 due Wednesday Oct 25. ECE U530 Digital Hardware Synthesis. VHDL for Synthesis with Xilinx. Schedule

Schedule. ECE U530 Digital Hardware Synthesis. Rest of Semester. Midterm Question 1a

Concurrent & Sequential Stmts. (Review)

COE 405, Term 062. Design & Modeling of Digital Systems. HW# 1 Solution. Due date: Wednesday, March. 14

!"#$%&&"'(')"*+"%,%-".#"'/"'.001$$"

COVER SHEET: Total: Regrade Info: 5 (14 points) 7 (15 points) Midterm 1 Spring 2012 VERSION 1 UFID:

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

Lecture 12 VHDL Synthesis

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

FSM Components. FSM Description. HDL Coding Methods. Chapter 7: HDL Coding Techniques

Introduction to VHDL #3

Inferring Storage Elements

8 Register, Multiplexer and

IT T35 Digital system desigm y - ii /s - iii

EL 310 Hardware Description Languages Midterm

ECE 448 Lecture 4. Sequential-Circuit Building Blocks. Mixing Description Styles

CSE 260 Introduction to Digital Logic and Computer Design. Exam 1. Your name 2/13/2014

EEL 4712 Digital Design Test 1 Spring Semester 2007

Sequential Circuit Design: Principle

Control Unit: Binary Multiplier. Arturo Díaz-Pérez Departamento de Computación Laboratorio de Tecnologías de Información CINVESTAV-IPN

ECE 545 Lecture 6. Behavioral Modeling of Sequential-Circuit Building Blocks. George Mason University

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 6 Combinational and sequential circuits

Synthesis from VHDL. Krzysztof Kuchcinski Department of Computer Science Lund Institute of Technology Sweden

Example 58: Traffic Lights

Problem Set 10 Solutions

EITF35: Introduction to Structured VLSI Design

Luleå University of Technology Kurskod SMD152 Datum Skrivtid

Two HDLs used today VHDL. Why VHDL? Introduction to Structured VLSI Design

DESIGN AND IMPLEMENTATION OF MOD-6 SYNCHRONOUS COUNTER USING VHDL

Nanosistemų programavimo kalbos 5 paskaita. Sekvencinių schemų projektavimas

Summary of FPGA & VHDL

VHDL. VHDL History. Why VHDL? Introduction to Structured VLSI Design. Very High Speed Integrated Circuit (VHSIC) Hardware Description Language

Field Programmable Gate Array

SEQUENTIAL STATEMENTS

ECE Digital Design Laboratory. Lecture 3 Finite State Machines!

CprE 583 Reconfigurable Computing

EITF35: Introduction to Structured VLSI Design

State Machine Descriptions

Department of Electronics & Communication Engineering Lab Manual E-CAD Lab

In our case Dr. Johnson is setting the best practices

Counters. Counter Types. Variations. Modulo Gray Code BCD (Decimal) Decade Ring Johnson (twisted ring) LFSR

Note: Closed book no notes or other material allowed, no calculators or other electronic devices.

Advanced Training Course on FPGA Design and VHDL for Hardware Simulation and Synthesis. 26 October - 20 November, 2009

Lab 3. Advanced VHDL

Computer-Aided Digital System Design VHDL

Finite State Machines (FSM) Description in VHDL. Review and Synthesis

3 Designing Digital Systems with Algorithmic State Machine Charts

310/ ICTP-INFN Advanced Tranining Course on FPGA and VHDL for Hardware Simulation and Synthesis 27 November - 22 December 2006

Sequential Circuit Design: Principle

VHDL: Modeling RAM and Register Files. Textbook Chapters: 6.6.1, 8.7, 8.8, 9.5.2, 11.2

Writing VHDL for RTL Synthesis

The University of Alabama in Huntsville ECE Department CPE Midterm Exam February 26, 2003

Sign here to give permission for your test to be returned in class, where others might see your score:

Hardware Description Languages. Modeling Complex Systems


Digital Design with SystemVerilog

VHDL for Logic Synthesis

Midterm Exam Thursday, October 24, :00--2:15PM (75 minutes)

Lecture 7. Standard ICs FPGA (Field Programmable Gate Array) VHDL (Very-high-speed integrated circuits. Hardware Description Language)

A bird s eye view on VHDL!

Assignment. Last time. Last time. ECE 4514 Digital Design II. Back to the big picture. Back to the big picture

ECE 574: Modeling and Synthesis of Digital Systems using Verilog and VHDL. Fall 2017 Final Exam (6.00 to 8.30pm) Verilog SOLUTIONS

COVER SHEET: Total: Regrade Info: 1 (8 points) 2 ( 8 points) 3 (16 points) 4 (16 points) 5 (16 points) 6 (16 points) 7 (16 points) 8 (8 points)

CprE 583 Reconfigurable Computing

Hardware Description Language VHDL (1) Introduction

ECE 545 Lecture 6. Behavioral Modeling of Sequential-Circuit Building Blocks. Behavioral Design Style: Registers & Counters.

VHDL 2 Combinational Logic Circuits. Reference: Roth/John Text: Chapter 2

VHDL for Logic Synthesis

ECE 545 Lecture 12. Datapath vs. Controller. Structure of a Typical Digital System Data Inputs. Required reading. Design of Controllers

Latch Based Design (1A) Young Won Lim 2/18/15

HDL Design Cube. Synthesis and VHDL

ELCT 501: Digital System Design

Creating Safe State Machines

ECE 551: Digital System *

Modeling Complex Behavior

8-1. Fig. 8-1 ASM Chart Elements 2001 Prentice Hall, Inc. M. Morris Mano & Charles R. Kime LOGIC AND COMPUTER DESIGN FUNDAMENTALS, 2e, Updated.

1 ST SUMMER SCHOOL: VHDL BOOTCAMP PISA, JULY 2013

Outline. CPE/EE 422/522 Advanced Logic Design L05. Review: General Model of Moore Sequential Machine. Review: Mealy Sequential Networks.

Verilog Module 1 Introduction and Combinational Logic

Lecture 5: State Machines, Arrays, Loops. EE 3610 Digital Systems

Programable Logic Devices

The VHDL Hardware Description Language

ECEU530. Schedule. ECE U530 Digital Hardware Synthesis. Datapath for the Calculator (HW 5) HW 5 Datapath Entity

Transcription:

Sequential Logic Module 5 Jim Duckworth, WPI 1

Latches and Flip-Flops Implemented by using signals in IF statements that are not completely specified Necessary latches or registers are inferred by the synthesis tool. Transparent Latch Edge-triggered flip-flop Reset Asynchronous Synchronous Counters Shift Registers Finite State Machines Jim Duckworth, WPI 2

Combinational Logic - review All input signals specified in sensitivity list All conditions evaluated PROCESS (a, b, sel) IF sel = 1 THEN y <= a ; ELSE y <= b ; END PROCESS; a b sel y Jim Duckworth, WPI 3

Transparent (Flow-Through) Latch IF statement not completely specified - missing ELSE part Output follows input when enable high but stores old value when enable goes low PROCESS (enable, d) IF enable = 1 THEN q <= d; END PROCESS; d enable q enable d q Jim Duckworth, WPI 4

Edge-Triggered Flip-Flop Positive edge-triggered flip flop PROCESS (clk) IF clk EVENT AND clk = 1 THEN q <= d; END PROCESS; d clk q d clk q Jim Duckworth, WPI 5

Flip-flop (cont d) clk EVENT is an example of a function signal attribute returns TRUE if event (change in value) occurred on signal can be used to detect an edge when combined with a further test (AND clk = 1 ) we can determine that it was a rising edge Note: not strictly necessary in this example but good practice makes VHDL description easier to read may be required if additional signals added later Jim Duckworth, WPI 6

Clocked Process - general format ARCHITECTURE behav OF flip-flop IS PROCESS (clock signal, [asynchronous signals]) IF asynchronous conditions THEN sequential statements for reset or preset; ELSIF clock_edge THEN sequential statements for clock_edge; END PROCESS; END behav; Sensitivity list includes clk and asynchronous signals All signal assignments in process result in flip-flops Jim Duckworth, WPI 8

Adding asynchronous clear and preset signals ENTITY dtype IS PORT(clk, d, clr, pre : IN std_logic; q, n_q : OUT std_logic); END dtype; ARCHITECTURE behav OF dtype IS SIGNAL temp_q : std_logic; -- internal signal PROCESS (clk, clr, pre) IF clr = 1 THEN -- clear operation temp_q <= 0 ; ELSIF pre = 1 THEN -- preset operation temp_q <= 1 ; ELSIF clk EVENT AND clk = 1 THEN -- clock temp_q <= d; END PROCESS; q <= temp_q; n_q <= NOT temp_q; END behav; Jim Duckworth, WPI 9

Flip-flop (cont d) Variations can be easily achieved negative-triggered clock synchronous clear ARCHITECTURE behav OF flip-flop IS PROCESS (clk) IF clk EVENT AND clk = 0 THEN IF n_clr = 0 THEN q <= 0 ELSE q <= d; END PROCESS; END behav; Jim Duckworth, WPI 12

Counter Five-bit counter with asynchronous reset Using integer type (could also use std_logic_vector with unsigned library) LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY count17 IS PORT(clk, reset : IN std_logic; q : OUT integer RANGE 0 TO 17); END count17; Jim Duckworth, WPI 13

Counter (cont d) ARCHITECTURE behav OF count17 is SIGNAL count : integer RANGE 0 TO 17; PROCESS(clk, reset) IF reset = 1 THEN count <= 0; ELSIF clk EVENT AND clk = 1 THEN IF count = 17 THEN count <= 0; ELSE count <= count + 1; END PROCESS; q <= count; -- concurrent statement END behav; -- internal signal -- sensitivity list -- asynch reset -- positive edge -- terminal count Jim Duckworth, WPI 14

5-bit Counter Synthesis Jim Duckworth, WPI 15

5-Bit Counter Schematic Jim Duckworth, WPI 16

Counter with Preset (Synchronous Clear) ENTITY cnt4pre IS PORT(clk, pre, n_clr : IN std_logic; d : IN integer RANGE 0 TO 12; q : OUT integer RANGE 0 TO 12); END cnt4pre; ARCHITECTURE behav OF cnt4pre IS SIGNAL count : integer RANGE 0 TO 12; PROCESS (clk) IF clk EVENT AND clk = 1 THEN IF n_clr = 0 THEN -- synchronous clear count <= 0; ELSIF pre = 1 THEN count <= d; ELSE IF count = 12 THEN count <= 0; ELSE count <= count + 1; END PROCESS; q <= count; END behav; Jim Duckworth, WPI 17

Schematic Jim Duckworth, WPI 19

Behavioral Simulation Results (ISE) Jim Duckworth, WPI 22

Shift Registers Example of 4-bit shift register with parallel load shift left and shift right capability LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY shift IS PORT(load, clk, left_right : IN std_logic; d : IN std_logic_vector(3 DOWNTO 0); q : OUT std_logic_vector(3 DOWNTO 0)); END shift; Jim Duckworth, WPI 25

Shift Register (cont d) ARCHITECTURE behav OF shift IS SIGNAL temp : std_logic_vector(3 DOWNTO 0); PROCESS(clk) -- all operations synchronous IF clk'event AND clk = '1' THEN IF load = '1' THEN temp <= d; ELSIF left_right = '0' THEN -- shift left; temp <= temp(2 DOWNTO 0) & '0'; ELSE temp <= '0' & temp(3 DOWNTO 1); -- right END PROCESS; q <= temp; END behav; Jim Duckworth, WPI 26

Synthesis Results Jim Duckworth, WPI 27

Shift Register - Behavioral Simulation Jim Duckworth, WPI 29

State Machines Module 6 Jim Duckworth, WPI 1 State Machines - Module 6

State Machines Block Diagram - Moore Machine Outputs determined by current state Inputs Next State Logic State Memory Output Logic Outputs Clock Reset Current State Jim Duckworth, WPI 3 State Machines - Module 6

State Machine (cont d) Current state determined by state memory (flip-flops) Outputs are decoded from the value of the current state combinational logic Next state is determined by current state and inputs at time of next triggering clock edge. Jim Duckworth, WPI 4 State Machines - Module 6

Simple State Machine Example RESET=1 EN=0 EN=1 S0 C=0 EN=1 S3 C=1 S1 C=0 EN=0 EN=0 EN=1 S2 C=0 EN=1 EN=0 Jim Duckworth, WPI 5 State Machines - Module 6

State Machine Coding Style ENTITY sm1 IS PORT(clk, reset, en c END sm1; : IN std_logic; : OUT std_logic); ARCHITECTURE behav OF sm1 IS TYPE state_type IS (s0, s1, s2, s3); -- enumerated type SIGNAL current_state, next_state : state_type; state_memory: PROCESS(clk, reset) -- see next slides for detail END PROCESS state_memory; next_state_logic: PROCESS(en, current_state) END PROCESS next_state_logic; END behav; Jim Duckworth, WPI 7 State Machines - Module 6

state_memory Process state_memory: PROCESS(clk, reset) IF reset = '1' THEN current_state <= s0; ELSIF clk'event AND clk = '1' THEN -- triggering edge current_state <= next_state; END PROCESS state_memory; Jim Duckworth, WPI 8 State Machines - Module 6

next_state Process next_state_logic: PROCESS(en, current_state) CASE current_state IS WHEN s0 => IF en = '1' THEN next_state <= s1; ELSE next_state <= s0; c <= 0 ; WHEN s1 => IF en = '1' THEN next_state <= s2; ELSE next_state <= s1; c <= 0 ; WHEN s2 => IF en = '1' THEN next_state <= s3; ELSE next_state <= s2; c <= 0 ; WHEN s3 => IF en = '1' THEN next_state <= s0; ELSE next_state <= s3; c <= 1 ; END CASE; END PROCESS next_state_logic; Jim Duckworth, WPI 9 State Machines - Module 6

SM1 VHDL Code Jim Duckworth, WPI 10 State Machines - Module 6

SM1- Schematic Jim Duckworth, WPI 13 State Machines - Module 6

Behavioral Simulation Jim Duckworth, WPI 14 State Machines - Module 6

State Machine - alternative coding style -- one process with one state signal ARCHITECTURE behav OF sm2 IS TYPE state_type IS (s0, s1, s2, s3); -- enumerated type SIGNAL state : state_type; PROCESS(clk, reset) IF reset = '1' THEN state <= s0; ELSIF clk'event AND clk = '1' THEN -- triggering edge CASE state IS WHEN s0 => IF en = '1' THEN state <= s1; ELSE state <= s0; c <= '0'; WHEN s1 => IF en = '1' THEN state <= s2; Jim Duckworth, WPI 28 State Machines - Module 6

State Machine (cont d) END PROCESS; END behav; END CASE; ELSE state <= s1; c <= '0'; WHEN s2 => IF en = '1' THEN state <= s3; ELSE state <= s2; c <= '0'; WHEN s3 => IF en = '1' THEN state <= s0; ELSE state <= s3; c <= '1'; Jim Duckworth, WPI 29 State Machines - Module 6

SM2 - Synthesis Results Jim Duckworth, WPI 30 State Machines - Module 6

Registered Outputs Output signal assignments within state machine process No glitches on registered outputs Outputs are registered in parallel with state registers Register introduces a one cycle delay Jim Duckworth, WPI 31 State Machines - Module 6

Block Diagram (registered outputs) Inputs Next State Logic State Memory Current State Clock Output Logic Output Register Outputs Jim Duckworth, WPI 32 State Machines - Module 6

Functional Simulation Jim Duckworth, WPI 33 State Machines - Module 6

Block Diagram (using next state logic) Inputs Next State Logic State Memory Current State Clock Output Logic Output Register Outputs Jim Duckworth, WPI 34 State Machines - Module 6

Three processes: Registered Outputs (no delay) state_memory PROCESS (clk, reset) ELSIF clk EVENT AND clk = 1 THEN current_state <= next_state; next_state_logic PROCESS (en, current_state) CASE current_state IS WHEN s0 => next_state <= s1; registered_output_logic (uses next state to determine outputs) PROCESS (clk, reset) ELSIF clk EVENT AND clk = 1 THEN CASE next_state IS WHEN s3 => c <= 1 ; WHEN OTHERS => c <= 0 ; Jim Duckworth, WPI 35 State Machines - Module 6