DESCRIPTION OF DIGITAL CIRCUITS USING VHDL

Similar documents
Sequential Logic - Module 5

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

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

Lecture 12 VHDL Synthesis

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

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

[VARIABLE declaration] BEGIN. sequential statements

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

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

VHDL: RTL Synthesis Basics. 1 of 59

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

Sequential Statement

Timing in synchronous systems

Control and Datapath 8

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

ELCT 501: Digital System Design

CprE 583 Reconfigurable Computing

Introduction to VHDL #3

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

Concurrent & Sequential Stmts. (Review)

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

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

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

Hardware Description Language VHDL (1) Introduction

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

EEL 4712 Digital Design Test 1 Spring Semester 2007

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

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

8 Register, Multiplexer and

VHDL for Synthesis. Course Description. Course Duration. Goals

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

VHDL And Synthesis Review

VHDL Examples Mohamed Zaky

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

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

EL 310 Hardware Description Languages Midterm

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

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 Modeling Behavior from Synthesis Perspective -Part B - EL 310 Erkay Savaş Sabancı University

Digital Systems Design

10 Writing Circuit Descriptions

CCE 3202 Advanced Digital System Design

Writing VHDL for RTL Synthesis

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

Summary of FPGA & VHDL

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

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

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

ECE Digital Design Laboratory. Lecture 3 Finite State Machines!

Inferring Storage Elements

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

VHDL in 1h. Martin Schöberl

CprE 583 Reconfigurable Computing

SRI SUKHMANI INSTITUTE OF ENGINEERING AND TECHNOLOGY, DERA BASSI (MOHALI)

Programable Logic Devices

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

Problem Set 10 Solutions

Writing Circuit Descriptions 8

Digital Design with SystemVerilog

Verilog for High Performance

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

SEQUENTIAL STATEMENTS

קורס VHDL for High Performance. VHDL

EITF35: Introduction to Structured VLSI Design

The VHDL Hardware Description Language

EITF35: Introduction to Structured VLSI Design

EITF35: Introduction to Structured VLSI Design

Sequential Logic Design

Test Benches - Module 8

State Machine Descriptions

Computer-Aided Digital System Design VHDL

Lattice VHDL Training

Verilog for Synthesis Ing. Pullini Antonio

UNIT I Introduction to VHDL VHDL: - V -VHSIC, H - Hardware, D - Description, L Language Fundamental section of a basic VHDL code Library :

Hardware Description Languages. Modeling Complex Systems

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs

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

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

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

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

ECE 551: Digital System *

Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA

Used to perform operations many times. See previous Parallel to Serial Example

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

LANGUAGE VHDL FUNDAMENTALS

EEL 4712 Digital Design Test 1 Spring Semester 2008

Using ModelSim to Simulate Logic Circuits in VHDL Designs. 1 Introduction. For Quartus II 13.0

Blocking(=) vs Nonblocking (<=) Assignment. Lecture 3: Modeling Sequential Logic in Verilog HDL. Procedural assignments

The block diagram representation is given below: The output equation of a 2x1 multiplexer is given below:

Example 58: Traffic Lights

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 3

Lecture 3. Behavioral Modeling Sequential Circuits. Registers Counters Finite State Machines

3 Designing Digital Systems with Algorithmic State Machine Charts

Written Re-exam with solutions for IE1204/5 Digital Design Friday 10/

The process. Sensitivity lists

Sequential Circuit Design: Principle

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

ECE 341 Midterm Exam

Multi-valued Logic. Standard Logic IEEE 1164 Type std_ulogic is ( U, uninitialized

Transcription:

DESCRIPTION OF DIGITAL CIRCUITS USING VHDL Combinatinal circuits Sequential circuits Design organization. Generic design Iterative operations Authors: Luis Entrena Arrontes, Celia López, Mario García, Enrique San Millán, Marta Portela, Almudena Lindoso 1

Outline Condicional sentences Rules for design of combinational circuits Examples and exercises 2

Conditional sentences Sequential sentences IF...THEN...ELSE CASE...IS...WHEN Concurrent sequences... WHEN... (conditional assignment) WITH... SELECT (selection assingment) 3

Multiplexer 2:1 -- Sequential description PROCESS (a, b, s) IF s = '0' THEN z <= a; ELSE z <= b; -- Concurrent description z <= a WHEN s = '0' ELSE b; a MUX b s z 4

Multiplexer 4:1 -- Sequential description PROCESS (a, b, c, d, s) CASE s IS WHEN "00" => z <= a; WHEN "01" => z <= b; WHEN "10" => z <= c; WHEN OTHERS => z <= d; END CASE; -- Concurrent description WITH s SELECT z <= a WHEN "00", b WHEN "01", c WHEN "10", d WHEN OTHERS; a b MUX c d z s 5

Diferences between IF and CASE IF...THEN...ELSE imposes priority in the selection inputs IF s0 = '0' THEN z <= a; ELSIF s1 = '0' THEN a b 0 0 1 z z <= b; ELSE z <= c; c 1 s0 s1 6

Diferences between IF and CASE CASE does not impose priority in the selection inputs PROCESS (a, b, c, d, s) CASE s IS WHEN "00" "10" => z <= a; WHEN "01" => z <= b; WHEN OTHERS => z <= d; a b d MUX z END CASE; s 7

Truth tables PROCESS (a, b, c) VARIABLE inputs: STD_LOGIC_VECTOR (2 DOWNTO 0); inputs := a & b & c; CASE inputs IS WHEN "000" => f <= '1'; WHEN "001" => f <= 'X'; WHEN "010" => f <= '0'; WHEN "011" => f <= '1'; WHEN "100" => f <= '0'; WHEN "101" => f <= '1'; WHEN OTHERS => f <= 'X'; END CASE; 8

Rules for design of combinational circuits Condicions that are necessary for a process to infere a correct combinational circuit: If a signal is assigned in a conditional process o conditional concurrent sentence, then it needs to have assigned a value for all the possible branches or conditions. The sensitivity list of a process must contain all the signal that are read in the process, i.e. all the signal which value is used in the process, and therefore are inputs in the synthesized circuit. Variables used in processes have to be used as intermediate values, i.e. they have to be written before being read. 9

Rules for design of combinational circuits Some consequences of the previous rules: To cover all the possible cases, it is convenient that every IF sentence or conditional assignment is followed by an ELSE clause, and every CASE or selection assignment is followed by an WHEN OTHERS clause. Loop references should not be created, i.e. outputs that depend on themselves, because those loops are asynchronous. Use of signals is recommended over variables whenever it is possible. 10

Examples (mistakes and correct solution) PROCESS( s, a) IF s = 0 THEN z <= a; PROCESS( s, a) IF s = 0 THEN z <= a; ELSE z <= b; PROCESS( s, a) IF s = 0 THEN z <= a; ELSE z <= z; PROCESS( s, a, b) IF s = 0 THEN z <= a; ELSE z <= b; 11

Effect of the sensitivity list in simulation Incorrect sensitivity list (s, a) Correct sensitivity list (s, a, b) 12

Exercise Design a 2:4 decoder Using sequential sentences Using concurrent sentences Declaration of the entity: ENTITY decodificador IS PORT ( a: IN STD_LOGIC_VECTOR (1 DOWNTO 0); END decodificador; z: OUT STD_LOGIC_VECTOR (3 DOWNTO 0)); 13

Exercise Design a 4-bit comparator Using sequential sentences Using concurrent sentences Declaration of the entity: ENTITY comparator IS PORT ( a, b: IN STD_LOGIC_VECTOR (3 DOWNTO 0); END comparator; less_than, greater_than, equal: OUT STD_LOGIC); 14

Exercise Design a 2-bit encoder with priority Using sequential sentences Using concurrent sentences Declaration of the entity: ENTITY codificador IS PORT ( a: IN STD_LOGIC_VECTOR (3 DOWNTO 0); END decodificador; z: OUT STD_LOGIC_VECTOR (1 DOWNTO 0); gs: OUT STD_LOGIC); 15

Solution: decoder 16

Solution: comparator 17

Solution: encoder 18

DESCRIPTION OF DIGITAL CIRCUITS USING VHDL Combinatinal circuits Sequential circuits Design organization. Generic design Iterative operations 19

Outline Registers and flip-flops Rules for design of sequential circuits Counters Finite state machines 20

Bistables -- D flip-flop -- rising edge triggered PROCESS (clk) IF clk EVENT AND clk = 1 THEN q <= d; -- D latch -- level triggered(latch) PROCESS (enable, d) IF enable = 1 THEN q <= d; d q d q clk enable ONLY SYNCHRONOUS DESIGN 21

A register If q is a vector, then it is created a register with as many flipflops as the vector dimension specifies. -- Registro de 8 bits SIGNAL q, d: STD_LOGIC_VECTOR (7 DOWNTO 0);... PROCESS (clk) IF clk EVENT AND clk = 1 THEN q <= d; 22

Flip-flop with asynchronous inputs Asynchronous inputs must be included in the sensitivity list Note: Control signals priority is given by the IF... ELSIF... ELSIF... order PROCESS (preset, clr, clk) IF preset = 1 THEN q <= 1 ; ELSIF clr = 1 THEN q <= 0 ; ELSIF clk EVENT AND clk = 1 THEN q <= d; preset has priority over clr 23

Flip-flop with synchronous control inputs Synchronous inputs are not included in the sensitivity list (changes in these inputs depend on the clock signal) PROCESS (reset, clk) IF reset = 1 THEN q <= 0 ; ELSIF clk EVENT AND clk = 1 THEN IF enable = 1 THEN q <= d; } } Synchronous Asynchronous part part 24

Rules for desing of synchronous sequential circuits Must be described using processes There must be a clock edge condition IF clk EVENT AND clk = 1 THEN IF clk EVENT AND clk = 0 THEN After that condition the ELSE clause cannot be used If a signal is assigned, it is not needed to cover all the cases (in non-covered cases the signal maintains its value) Sensitivity list: clock + asynchronous inputs (reset) Data inputs and synchronous inputs do not appear in the sensitivity list. 25

Rules for design of synchronous sequential circuits Template for design of synchronous sequential circuits PROCESS( <clock + asynchronous inputs>) IF <asynchronous initialization condition> THEN < asynchronous initialization > ELSIF <active clock edge> THEN -- synchronous behavior 26

Examples PROCESS (reset, clk) IF reset = 0 THEN q <= 0101 ; ELSIF clk EVENT AND clk = 1 AND enable = 1 THEN q <= d; 27

Examples PROCESS (reset, clk) IF reset = 0 THEN q <= 0101 ; ELSIF enable = 1 THEN IF clk EVENT AND clk = 1 THEN q <= d; 28

Examples PROCESS (reset, clk) IF reset = 1 THEN IF clk EVENT AND clk = 1 THEN IF enable = 1 THEN q <= d; ELSE q <= 0101 ; 29

Inference of registers and flip-flops Every signal that is assigned between IF clk EVENT... and END IF infiere a flip-flop/register Every variable that is read between IF clk EVENT... and END IF, before being written, infere a flip-flop/register 30

Examples -- Example 1 (inferes 1 flip-flop) PROCESS (clk) VARIABLE v: STD_LOGIC; IF clk EVENT AND clk = 1 THEN v := d; q <= v; -- Example 2 (inferes 2 flip-flops) -- Shift register, but NOT recommended PROCESS (clk) VARIABLE v: STD_LOGIC; IF clk EVENT AND clk = 1 THEN q <= v; v := d; 31

Examples -- Example 3 (inferes 2 flip-flops) -- Shift register (recommended) SIGNAL v: STD_LOGIC; PROCESS (clk) IF clk EVENT AND clk = 1 THEN v <= d; q <= v; 32

Examples -- Example 4 (inferes 2 flip-flops) PROCESS (clk) VARIABLE a: STD_LOGIC; IF clk EVENT AND clk = 1 THEN a := a +1; q <= a; -- Example 5 (inferes 1 flip-flop) PROCESS (clk) VARIABLE a: STD_LOGIC; IF clk EVENT AND clk = 1 THEN a := a +1; q <= a; But use of signals instead of variables is recommended 33

Examples -- Combinational adder PROCESS (a, b) s <= a + b; -- Adder followed by a register PROCESS (clk) IF clk EVENT AND clk = 1 THEN s <= a + b; 34

Examples -- Adder with registered inputs and outputs PROCESS (clk) IF clk EVENT AND clk = 1 THEN a1 <= a; b1 <= b; s <= a1 + b1; -- Adder with registered inputs and outputs -- Input and output registers with reset input PROCESS (reset, clk) IF reset = 1 THEN a1 <= (OTHERS => 0 ); b1 <= (OTHERS => 0 ); s <= (OTHERS => 0 ); ELSIF clk EVENT AND clk = 1 THEN a1 <= a; b1 <= b; s <= a1 + b1; 35

Examples A register may not have reset, but a reset signal needs always an associated register! -- Adder followed by register -- Incorrect initialization! PROCESS (clk) IF reset = 1 THEN a <= (OTHERS => 0 ); b <= (OTHERS => 0 ); s <= (OTHERS => 0 ); ELSIF clk EVENT AND clk = 1 THEN s <= a + b; 36

Exercises Design a JK flip-flop falling-edge triggered ENTITY jk_flipflop IS PORT ( reset: END k_flipflop; clk: Design a shift register IN STD_LOGIC; IN STD_LOGIC; j, k: IN STD_LOGIC; q: OUT STD_LOGIC); ENTITY shift_reg IS PORT ( reset: IN STD_LOGIC; clk: IN STD_LOGIC; es: IN STD_LOGIC; q: OUT STD_LOGIC_VECTOR (0 to 3)); END shift_reg; 37

Solution: JK flip-flop 38

Solution: Shift register 39

Counters PROCESS (reset, clk) IF reset = 1 THEN q <= 00000000 ; ELSIF clk EVENT AND clk = 1 THEN IF enable = 1 THEN q <= q + 1; 40

Counters PROCESS (reset, clk) VARIABLE c: INTEGER RANGE 0 TO 255; IF reset = 1 THEN c := 0; Necessary to avoid overflow in simulation ELSIF clk EVENT AND clk = 1 THEN IF enable = 1 THEN IF c = 255 THEN c := 0; ELSE c := c + 1; q <= c; q declared as integer If q is std_logic_vector, then q <= CONV_STD_LOGIC_VECTOR(c, 8); 41

Exercise Design a 4-bit up-counter with carry output ENTITY cont4 IS PORT ( reset: IN STD_LOGIC; clk: IN STD_LOGIC; q: OUT STD_LOGIC_VECTOR(7 DOWNTO 0); carry_out: OUT STD_LOGIC); END cont4 ; 42

Exercise Design a up/down counter with enable and load inputs ENTITY cont_up_down IS PORT ( reset: IN STD_LOGIC; clk: IN STD_LOGIC; load: IN STD_LOGIC; d: IN STD_LOGIC_VECTOR(7 DOWNTO 0); ud: IN STD_LOGIC; enable: IN STD_LOGIC; q: OUT STD_LOGIC_VECTOR(7 DOWNTO 0)); END cont_up_down; 43

Solution: 4-bit up-counter 44

Solution: up/down counter with enable and load inputs 45

Finite state machines Inputs Outputs Combinational part Current state Next state Flip-flops clk 46

Example: Moore s machine 0 0 s0 / 0 1 1 s1 / 0 1 s11 / 1 ENTITY machine is PORT( clk: in std_logic; reset: in std_logic; a: in std_logic; z : out std_logic); END machine; 0 47

Example: Moore s machine ARCHITECTURE moore OF machine IS TYPE state IS (s0, s1, s11); SIGNAL current_state, next_state: state; PROCESS (clk, reset) IF reset = '1' THEN current_state <= s0; ELSIF clk'event AND clk = '1' THEN current_state <= next_state;... PROCESS (current_state, a) CASE current_state IS WHEN s0 => z <= '0'; IF a = '0' THEN next_state <= s0; ELSE next_state <= s1; WHEN s1 => z <= '0'; IF a = '0' THEN next_state <= s1; ELSE next_state <= s11; WHEN s11 =>...... END CASE; END moore; 48

Example: Mealy s machine 0 / 0 0 / 0 s0 1 / 0 s1 1 / 1 ENTITY machine is PORT( clk: in std_logic; reset: in std_logic; a: in std_logic; z : out std_logic); END machine; 49

Example: Mealy s machine ARCHITECTURE mealy OF machine IS TYPE state IS (s0, s1); SIGNAL current_state, next_state: state; PROCESS (clk, reset) IF reset = '1' THEN current_state <= s0; ELSIF clk'event AND clk = '1' THEN current_state <= next_state;... PROCESS (current_state, a) CASE current_state IS WHEN s0 => z <= '0'; IF a = '0' THEN next_state <= s0; ELSE next_state <= s1; WHEN s1 => IF a = '0' THEN z <= '0'; next_state <= s1; ELSE z <= '1'; next_state <= s11; END CASE;... 50