VHDL Examples Mohamed Zaky

Similar documents
Hardware Description Language VHDL (1) Introduction

Mridula Allani Fall Fall

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

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

Basic Language Concepts

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

Review. LIBRARY list of library names; USE library.package.object; ENTITY entity_name IS generic declarations PORT ( signal_name(s): mode signal_type;

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

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

ELCT 501: Digital System Design

EE6301 DIGITAL LOGIC CIRCUITS UNIT V VHDL PART A

Field Programmable Gate Array

Digital Design Using VHDL Using Xilinx s Tool for Synthesis and ModelSim for Verification

Digital Systems Design

2/14/2016. Hardware Synthesis. Midia Reshadi. CE Department. Entities, Architectures, and Coding.

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

Sequential Statement

Concurrent Signal Assignment Statements (CSAs)

Hardware Description Languages. Modeling Complex Systems

Modeling Complex Behavior

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

VHDL for FPGA Design. by : Mohamed Samy

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

Arithmetic Circuits. Nurul Hazlina Adder 2. Multiplier 3. Arithmetic Logic Unit (ALU) 4. HDL for Arithmetic Circuit

Computer-Aided Digital System Design VHDL

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

1. What is y-chart? ans: The y- chart consists of three domains:- behavioral, structural and geometrical.

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

Timing in synchronous systems

VHDL VS VERILOG.

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

Federal Urdu University of Arts, Science and Technology, Islamabad VLSI SYSTEM DESIGN. Prepared By: Engr. Yousaf Hameed.

CCE 3202 Advanced Digital System Design

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

COE 405 Design Methodology Based on VHDL

DESCRIPTION OF DIGITAL CIRCUITS USING VHDL

QUESTION BANK FOR TEST

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

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

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

Written exam for IE1204/5 Digital Design Thursday 29/

EXPERIMENT #8: BINARY ARITHMETIC OPERATIONS

VHDL And Synthesis Review

COVER SHEET: Total: Regrade Info: 5 (5 points) 2 (8 points) 6 (10 points) 7b (13 points) 7c (13 points) 7d (13 points)

What Is VHDL? VHSIC (Very High Speed Integrated Circuit) Hardware Description Language IEEE 1076 standard (1987, 1993)

Test Benches - Module 8

Declarations of Components and Entities are similar Components are virtual design entities entity OR_3 is

Advanced Electronics Lab.

Digital Design with FPGAs. By Neeraj Kulkarni

11.1. Unit 11. Adders & Arithmetic Circuits

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

Lattice VHDL Training

LABORATORY MANUAL VLSI DESIGN LAB EE-330-F

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

DIGITAL SYSTEM DESIGN

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

Lecture 12 VHDL Synthesis

HDL PROGRAMING AND EDA TOOLS LABORATORY MANUAL FOR I / II M.TECH VLSI DESIGN (ECE) I - SEMESTER

EEL 4712 Digital Design Test 1 Spring Semester 2007

DOD, VHSIC ~1986, IEEE stnd 1987 Widely used (competition Verilog) Commercial VHDL Simulators, Synthesizers, Analyzers,etc Student texts with CDROMs

Experiment 8 Introduction to VHDL

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

EECE-4740/5740 Advanced VHDL and FPGA Design. Lecture 3 Concurrent and sequential statements

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

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

Introduction to VHDL. Yvonne Avilés Colaboration: Irvin Ortiz Flores Rapid System Prototyping Laboratory (RASP) University of Puerto Rico at Mayaguez

EEL 4712 Digital Design Test 1 Spring Semester 2008

EITF35: Introduction to Structured VLSI Design

CSCI Lab 3. VHDL Syntax. Due: Tuesday, week6 Submit to: \\fs2\csci250\lab-3\

Chapter 6 Combinational-Circuit Building Blocks

DIGITAL SYSTEM DESIGN

Control and Datapath 8

Sequential Logic - Module 5

Lecture 1: VHDL Quick Start. Digital Systems Design. Fall 10, Dec 17 Lecture 1 1

EE261: Intro to Digital Design

[VARIABLE declaration] BEGIN. sequential statements

6.111 Lecture # 5. Entity section describes input and output. VHDL: Very High speed integrated circuit Description Language:

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

ECE 448 Lecture 3. Combinational-Circuit Building Blocks. Data Flow Modeling of Combinational Logic

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

ECE 448 Lecture 3. Combinational-Circuit Building Blocks. Data Flow Modeling of Combinational Logic

Digital Circuit Design and Language. Datapath Design. Chang, Ik Joon Kyunghee University

Contents. Appendix D VHDL Summary Page 1 of 23

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

Question Total Possible Test Score Total 100

1. Defining and capturing the design of a system. 2. Cost Limitations (low profit margin must sell millions)

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

Digital Fundamentals. Lab 6 2 s Complement / Digital Calculator

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

PACKAGE. Package syntax: PACKAGE identifier IS...item declaration... END PACKAGE [identifier]

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

Architecture des Ordinateurs I

ECE 545 Lecture 8. Data Flow Description of Combinational-Circuit Building Blocks. George Mason University

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

VHDL. Official Definition: VHSIC Hardware Description Language VHISC Very High Speed Integrated Circuit

EE434 ASIC & Digital Systems

ECE 545 Lecture 5. Data Flow Modeling in VHDL. George Mason University

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

EITF35: Introduction to Structured VLSI Design

SEQUENTIAL STATEMENTS

Transcription:

VHDL Examples By Mohamed Zaky (mz_rasmy@yahoo.co.uk) 1

Half Adder The Half Adder simply adds 2 input bits, to produce a sum & carry output. Here we want to add A + B to produce Sum (S) and carry (C). A B HALF ADDER Sum (S) Carry (C) Truth Table A B S C 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 Designing Logic Circuit S = AB + AB (XOR) C = AB (AND) VHDL code HALF ADDER Entity entity HALFADD is port ( A,B : in bit; S,C : out bit ); end HALFADD; Architecture architecture struct of HALFADD is begin S <= A xor B; C <= A and B; end struct; MZ 2

Full Adder (1 bit) The Full Adder operates on 3 inputs to produce a sum & carry output. C IN A B FULL ADDER Sum (S) C OUT We can design the Full Adder by using truth table and get its logic expression; but it s better to use the Half Adder we just designed to build the Full Adder. Since the Half Adder adds only 2 inputs while the Full Adder adds 3 inputs; then we can use 2 Half Adders to construct Full Adder. A B HALF ADDER 1 I2 I1 HALF ADDER 2 I3 Sum (S) C IN I2 OR C OUT Full Adder using 2 Half Adders & 1 OR gate To add a an already designed component to a new design First, add it as follows: 3

Syntax component ENTITYNAME (of the desired component) port (INPUTS : DATATYPE; OUTPUTS : DATATYPE); end component; Second, use the added component as a ready, functioning block (don t write its VHDL code again) Just use it as a block, having inputs & outputs. This is done using Port map, as follows: Syntax Label: ENTITYNAME (of the desired component) port map (INPUTS & OUTPUTS) It s that simple!! VHDL code FULL ADDER (1 bit) Entity entity FULLADD is port ( A,B,CIN : in bit; COUT,S: out bit); end FULLADD; Architecture architecture struct of FULLADD is Signals signal I1,I2,I3 : bit; use HALF ADDER component HALFADD port (A,B : in bit; S,C : out bit ); end component; Begin!! begin HA1:HALFADD port map (A,B,I1,I2); HA2:HALFADD port map (I1,CIN,S,I3); COUT <= I3 or I2; end struct; 4

MZ Full Adder (2 bit) We first made 2 bit Full Adder to make the idea of n-bit Full Adder clear. We made the 2 bit Full Adder using 2 (1 bit) Full Adders. Here is a simple block diagram of 2 bit Full Adder (In the case of 8 bit Full Adder we will have 8 Full Adder (FA#0 to FA#7)) a0 a1 co FA #0 c1 s0 FA #1 c2 s1 b0 b1 VHDL code 2 bit FULL ADDER Entity entity FULLADD2 is port (a0,b0,a1,b1,c0 :in bit; c2,s0,s1 :out bit); end FULLADD2; Architecture architecture struct of FULLADD2 is Signals signal c1:bit; use 1 bit FULL ADDER component FULLADD port ( A,B,CIN :in bit ; S,COUT : out bit); end component; Begin!! begin FA1:FULLADD port map(a0,b0,c0,s0,c1); FA2:FULLADD port map(a1,b1,c1,s1,c2); end struct; 5

MZ 4 bit Full Adder To understand this code, just draw its Block diagram exactly like 2 bit Full Adder (of course you will use 4 Full Adders) You can extend this code to any N bit Full Adders See Digital Electronics Reference of second year (Tocci) page 289. VHDL code 4 bit FULL ADDER Entity entity FULLADD4 is port (a0,b0,a1,b1,a2,b2,a3,b3,c0 :in bit; c4,s0,s1,s2,s3 :out bit); end FULLADD4; Architecture architecture struct of FULLADD4 is Signals signal c1,c2,c3 :bit; use 1 bit FULL ADDER component FULLADD port ( A,B,CIN :in bit ; S,COUT : out bit); end component; Begin!! begin FA1:FULLADD port map(a0,b0,c0,s0,c1); FA2:FULLADD port map(a1,b1,c1,s1,c2); FA3:FULLADD port map(a2,b2,c2,s2,c3); FA4:FULLADD port map(a3,b3,c3,s3,c4); end struct; MZ 6

DFF (flip flop) The new thing in this code is that we use CLK input. In VHDL, if you want to use CLK input then put it in a Process. Syntax PROCESS(clk) IF ( clk = '1') AND ( clk'event ) THEN here we work on positive going transition q <= d; END IF; END PROCESS; In the beginning of the code we wrote LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; The IEEE introduced many new Data Types, Here we used (std_logic_1164) which has a main benefit; that is its values are (1or High, 0 or Low & Don t Care). Here we might not want Don t Care condition; frankly I m not sure if we need this declaration or not. Any way it s better to call IEEE library (just as you call header files in C). 7

VHDL code D Flip-Flop LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; Entity ENTITY dff IS PORT( d, clk : IN std_logic; q : OUT std_logic); END dff; Architecture ARCHITECTURE structdff OF dff IS Begin!! PROCESS(clk) IF ( clk = '1') AND ( clk'event ) THEN q <= d; END IF; END PROCESS; END structdff; MZ 8

Shift Register (4 bit) A shift register is a group of Flip Flops (FFs) arranged so that the binary numbers stored in the FFs are shifted from one FF to the next for every clock pulse. We made a 4-bit Shift Register using DFFs. 4-bit Shift Register Block Diagram 9

VHDL code Shift Register LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; Entity ENTITY shiftreg IS PORT( a, clk : IN std_logic; b : OUT std_logic); END shiftreg; Architecture ARCHITECTURE structshift OF shiftreg IS COMPONENT dff PORT( d, clk : IN std_logic; q : OUT std_logic); END COMPONENT; SIGNAL z : std_logic_vector( 0 TO 4 ); z(0) <= a; dff1: dff PORT MAP( z(0), clk, z(1) ); dff2: dff PORT MAP( z(1), clk, z(2) ); dff3: dff PORT MAP( z(2), clk, z(3) ); dff4: dff PORT MAP( z(3), clk, z(4) ); b <= z(4); END structshift; 10

Multiplexer ( 4 in ; 2 select ; 1 out!! ) MUX VHDL code Multiplexer ( 4 in ; 2 select ; 1 out!! ) Entity ENTITY mux1 IS PORT ( a, b, c, d : IN BIT; s0, s1 : IN BIT; x : OUT BIT); END mux1; Architecture ARCHITECTURE seqmux OF mux1 IS Begin!! process (a, b, c, d, s0, s1 ) IF s0 = '0' and s1 = '0' THEN x <= a; ELSIF s0 = '1' and s1 = '0' THEN x <= b; ELSIF s0 = '0' and s1 = '1' THEN x <= c; ELSE x <= d; END IF; END process; END seqmux; MZ 11