Sequential Statement

Similar documents
Sequential Logic - Module 5

[VARIABLE declaration] BEGIN. sequential statements

VHDL And Synthesis Review

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

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

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

Timing in synchronous systems

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

In our case Dr. Johnson is setting the best practices

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

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

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

VHDL Examples Mohamed Zaky

Computer-Aided Digital System Design VHDL

DESCRIPTION OF DIGITAL CIRCUITS USING VHDL

SEQUENTIAL STATEMENTS

VHDL Testbench. Test Bench Syntax. VHDL Testbench Tutorial 1. Contents

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

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

Field Programmable Gate Array

EITF35: Introduction to Structured VLSI Design

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

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

Lecture 12 VHDL Synthesis

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

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

CSE 260 Introduction to Digital Logic and Computer Design. Exam 1 Solutions

CS211 Digital Systems/Lab. Introduction to VHDL. Hyotaek Shim, Computer Architecture Laboratory

VHDL in 1h. Martin Schöberl

VHDL: Code Structure. 1

Lab # 5. Subprograms. Introduction

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

EITF35: Introduction to Structured VLSI Design

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

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

Concurrent & Sequential Stmts. (Review)

CS/EE Homework 7 Solutions

Lattice VHDL Training

Inferring Storage Elements

VHDL for Modeling - Module 10

EEL 4712 Digital Design Test 1 Spring Semester 2007

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

EL 310 Hardware Description Languages Midterm

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

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

VHDL simulation and synthesis

VHDL for FPGA Design. by : Mohamed Samy

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

Summary of FPGA & VHDL

Problem Set 10 Solutions

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

ECOM 4311 Digital Systems Design

Hardware Description Language VHDL (1) Introduction

Test Benches - Module 8

Control and Datapath 8

Contents. Chapter 9 Datapaths Page 1 of 28

8 Register, Multiplexer and

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

5. 0 VHDL OPERATORS. The above classes are arranged in increasing priority when parentheses are not used.

CSE 260 Digital Computers: Organization and Logical Design. Exam 2. Jon Turner 3/28/2012

VHDL. ELEC 418 Advanced Digital Systems Dr. Ron Hayne. Images Courtesy of Cengage Learning

ECE 459/559 Secure & Trustworthy Computer Hardware Design

CprE 583 Reconfigurable Computing

ELCT 501: Digital System Design

13/06/56 8 ก ก. 08-Case Study

Hardware Description Languages. Modeling Complex Systems

University of Technology

The CPU Bus : Structure 0

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

HDL. Hardware Description Languages extensively used for:

Abi Farsoni, Department of Nuclear Engineering and Radiation Health Physics, Oregon State University

Design Problem 5 Solutions

1 ST SUMMER SCHOOL: VHDL BOOTCAMP PISA, JULY 2013

Lab 3. Advanced VHDL

entity priority is Port ( a,b,c,d : in STD_LOGIC; encoded : out STD_LOGIC_VECTOR(2 downto 0)); end priority;

Luleå University of Technology Kurskod SMD152 Datum Skrivtid

CMPT 250: Computer Architecture. Using LogicWorks 5. Tutorial Part 1. Somsubhra Sharangi

Quartus Counter Example. Last updated 9/6/18

COE Design Process Tutorial

Pollard s Tutorial on Clocked Stuff in VHDL

Date Performed: Marks Obtained: /10. Group Members (ID):. Experiment # 11. Introduction to Verilog II Sequential Circuits

3 Designing Digital Systems with Algorithmic State Machine Charts

ACS College of Engineering. Department of Biomedical Engineering. Logic Design Lab pre lab questions ( ) Cycle-1

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

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

COVER SHEET: Total: Regrade Info: 2 (6 points) 3 (8 points) 4 (10 points) 8 (12 points) 6 (6 points) 7 (6 points) 9 (30 points) 10 (4 points)

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

Counters and Simple Design Example

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs

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

Example 58: Traffic Lights

EENG 2910 Project III: Digital System Design. Due: 04/30/2014. Team Members: University of North Texas Department of Electrical Engineering

VHDL HIERARCHICAL MODELING

VHDL VS VERILOG.

ELE432. ADVANCED DIGITAL DESIGN HACETTEPE UNIVERSITY Designing with VHDL

DESIGN AND IMPLEMENTATION OF MOD-6 SYNCHRONOUS COUNTER USING VHDL

Tutorial 4 HDL. Outline VHDL PROCESS. Modeling Combinational Logic. Structural Description Instantiation and Interconnection Hierarchy

Design Problem 3 Solutions

EEL 4712 Digital Design Test 1 Spring Semester 2008

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

Transcription:

Sequential Statement

Sequential Logic Output depends not only on current input values but also on previous input values. Are building blocks of; Counters Shift registers Memories Flip flops are basic sequential logic devices. Sequential logic can be Synchronous or are asynchronous inputs Combinational Circuit Memory outputs

Sequential Logic Synchronous Sequential Logic Change in output due to current input values and current system state (history) to next state only takes place when a clock pulse is applied. Asynchronous Change in output due to current input values and current system state (history) to next state is triggered by completion of previous stage without reference to clock pulse.

VHDL Sequential Statement Statements that are executed one after the other like in software languages. Must be enclosed within PROCESS statement Four types of sequential statements IF statement CASE statement WAIT statement LOOP statement

IF statement Similar to Conditional Signal Assignment Assigns higher priority to statements that are at the top within the if statement Syntax IF conditions THEN assignments; ELSIF conditions THEN assignments; assignments; ELSIF conditions THEN assignments;... ELSE assignments;

IF... Statement Examples: IF (X = '1') THEN Q <= D; -------------------------------IF (k = 0) THEN X1 <= D; ELSE X1 <= Q; IF (a = 1) THEN Q <= D; ELSIF (a = 2) THEN Q <= NOT(D); ELSIF (a = 3) THEN Q <= '1'; ELSE Q <= '0';

IF statement Example:DFF with Asynchronous Reset LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY dff IS PORT ( d, clk, rst: IN STD_LOGIC; q: OUT STD_LOGIC); END dff; ARCHITECTURE behavior OF dff IS PROCESS (clk, rst) IF (rst='1') THEN q <= '0'; ELSIF (clk'event AND clk='1') THEN q <= d; END PROCESS; END behavior;

Signals and Variables Signal and variable types can be used in Process statement Signal represents actual signal path in circuit Variable is a temporary storage for keeping data Signals are updated only at the end of the Process statement Variable is updated immediately after statement is evaluated ARCHITECTURE rtl OF reg IS SIGNAL a, b : std_logic; PROCESS (clk) IF(clk'event and clk = 1) THEN a <= d; b <= a; q <= b; END PROCESS; ARCHITECTURE rtl OF reg IS PROCESS (clk) VARIABLE a, b : std_logic; IF(clk'event and clk = 1) THEN a <= d; b <= a; q <= b; END PROCESS;

Signals and Variables SIGNALS Declared in declarative of Entity, Package or architecture SIGNAL mysig:datatype := intialvalue Can be local or global VARIABLES Declared only in a piece of sequential logic e.g. PROCESS VARABLE: varname:= initialvalue; Can only be local to the declarative process Cannot be passed of the process directly: assign to a signal first. Uses <= as an assignment operator Uses = as an assignment operator Value of a signal in a PROCESS is not updated at assignment but at the end of process execution. Value of VARABLE in a process is updated immediately after its assignment.

PROCESS Statement (revisited) ARCHITECTURE behavior OF dff IS PROCESS (clk, rst) either clk or rst signal changes, IF (rst='1') THEN IF statement will be executed. q <= '0'; ELSIF (clk'event AND clk='1') THEN q <= d; END PROCESS; END behavior;

PROCESS Statement Using signal attribute as a condition IF(clk'EVENT AND clk = '1') Rising Edge Falling Edge

WAIT Statement Wait statement can be used in PROCESS statement It works similarly to sensitivity list in PROCESS statement Syntax : WAIT UNTIL signal condition Example: ARCHITECTURE behavior OF dff IS PROCESS WAIT UNTIL (rising_edge(clk) OR rst = '1'); IF (rst='1') THEN q <= '0'; ELSIF (clk'event AND clk='1') THEN q <= d; END PROCESS; END behavior; rising_edge( ) and falling_edge( ) functions are implemented in std_logic_1164 library:

FOR...LOOP Statement When pieces of code need to be repeated several times, we put them in a loop Use FOR...LOOP when certain number of repetition is known Syntax: Example: FOR identifier IN range LOOP (sequential statements) END LOOP; FOR j IN 0 TO 3 LOOP qt(j+1) <= qt(j); END LOOP; -- OR -FOR k IN 3 DOWNTO 0 LOOP qt(k+1) <= qt(k); END LOOP

WHILE...LOOP Statement Use when number of repetition depends on certain condition Syntax: WHILE condition LOOP (sequential statements) END LOOP; Example: j = 0; WHILE j <= 3 LOOP qt(j+1) <= qt(j); j = j + 1; END LOOP;

CASE Statement Use for selecting assignment based on value of identifier Syntax: CASE identifier IS WHEN value => assignments; [assignments;] WHEN value => assignments; [assignments;]... END CASE; Example: CASE control IS WHEN "00" => x<=a; y<=b; WHEN "01" => x<=b; y<=c; WHEN OTHERS => x<="0000"; y<="zzzz"; END CASE;

Flip-Flop Modeling D Flip-Flop LIBRARY IEEE; USE IEEE.std_logic_1164.all; ENTITY D_FF IS PORT(d, clk: IN std_logic; q: OUT std_logic); END D_FF; ARCHITECTURE behavior OF D_FF IS PROCESS (clk) IF(clk'EVENT AND clk = '1') THEN q <= d; [Image taken from: Floyd, Digital Fundamentals, 10th Ed.] END PROCESS; END behavior;

Flip-Flop Modeling ENTITY JK_FF IS PORT (J, K, clk,: IN std_logic; Q: OUT std_logic); END JK_FF; ARCHITECTURE behavior OF JK_FF IS SIGNAL T: std_logic; -- Temporary signal PROCESS(clk) IF(clk'EVENT AND clk = '1') THEN IF(J = '0' AND K = '0') THEN T <= T; -- NO CHANGE ELSIF(J = '0' AND K = '1') THEN T <= '0'; -- RESET ELSIF(J = '1' AND K = '0') THEN T <= '1'; -- SET ELSIF(J = '1' AND K = '1') THEN T <= NOT(T); -- TOGGLE END PROCESS; Q <= T; -- Update output signal END behavior; [Image taken from: Floyd, Digital Fundamentals, 10th Ed.]

Flip-Flop Applications ENTITY JKCounter IS PORT(clk : in std_logic; Q0, Q1 : out std_logic); END JKCounter; Asynchronous Counter ARCHITECTURE Counter OF JKCounter IS SIGNAL J0, K0, J1, K1: std_logic := '1'; -- J&K are connected to '1 SIGNAL T0, T1: std_logic; JKFF0: PROCESS(clk) IF(clk'EVENT AND clk = '1') THEN IF(J0 = '0' AND K0 = '0') THEN T0 <= T0; -- NO CHANGE ELSIF(J0 = '0' AND K0 = '1') THEN T0 <= '0'; -- RESET ELSIF(J0 = '1' AND K0 = '0') THEN T0 <= '1'; -- SET ELSIF(J0 = '1' AND K0 = '1') THEN T0 <= NOT(T0); -- TOGGLE END PROCESS JKFF0; Q0 <= T0; (continue next page) [Image taken from: Floyd, Digital Fundamentals, 10th Ed.]

Flip-Flop Applications (cont'd) JKFF1: PROCESS(T0) IF(T0'EVENT and T0 = '1') THEN IF(J1 = '0' AND K1 = '0') THEN T1 <= T1; -- NO CHANGE ELSIF(J1 = '0' AND K1 = '1') THEN T1 <= '0'; -- RESET ELSIF(J1 = '1' AND K1 = '0') THEN T1 <= '1'; -- SET ELSIF(J1 = '1' AND K1 = '1') THEN T1 <= NOT(T1); -- TOGGLE END PROCESS JKFF1; Q1 <= T1; END Counter;

Flip-Flop Applications Counter revisited The previous counter example is not practical way of implementation We can generate circuit from its behavior without knowing what are the actual components that we need to use. For example, we can describe the behavior of counter using pseudo code as follows Counter_Output = 0 DO IF Clock = rising_edge THEN Increment Counter_Output by 1 LOOP forever

Type Conversion VHDL provide a standard package called "Unsigned Logic" This package allows us to do data type conversion i.e., from logic vector to integer Now we are able to do basic arithmetic operation on logic vector Example: We can write VHDL description of our asynchronous counter as follows:

Type Conversion library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; entity sync_counter is port(clk : in std_logic; output : out std_logic_vector(3 downto 0)); end sync_counter; architecture behavior of sync_counter is signal T: std_logic_vector(3 downto 0) := "0000"; begin process(clk) begin if(clk'event AND clk = '1') then T <= T+1; end if; end process; output <= T; end behavior;