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

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

Hardware Description Language VHDL (1) Introduction

Review of Digital Design with VHDL

ELCT 501: Digital System Design

COE 405 Design Methodology Based on VHDL

Digital Systems Design

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

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

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

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

Contents. Appendix D VHDL Summary Page 1 of 23

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

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

Outline. CPE/EE 422/522 Advanced Logic Design L07. Review: JK Flip-Flop Model. Review: VHDL Program Structure. Review: VHDL Models for a MUX

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

CPE/EE 422/522. Chapter 8 - Additional Topics in VHDL. Dr. Rhonda Kay Gaede UAH. 8.1 Attributes - Signal Attributes that return a value

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

BASIC VHDL LANGUAGE ELEMENTS AND SEMANTICS. Lecture 7 & 8 Dr. Tayab Din Memon

Outline CPE 626. Advanced VLSI Design. Lecture 4: VHDL Recapitulation (Part 2) Signals. Variables. Constants. Variables vs.

Logic and Computer Design Fundamentals VHDL. Part 1 Chapter 4 Basics and Constructs

Computer-Aided Digital System Design VHDL

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

C-Based Hardware Design

Getting Started with VHDL

VHDL BASIC ELEMENTS INTRODUCTION

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

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

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

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

Performance Engineering of Real-Time and Embedded Systems. Introduction to VHDL

VHDL Objects. Lecture 8: VHDL (2) Variables. VHDL Objects - Constant. Files. EE3109 Gopi K. Manne Fall 2007

VHDL Examples Mohamed Zaky

Building Blocks. Entity Declaration. Entity Declaration with Generics. Architecture Body. entity entity_name is. entity register8 is

VHDL And Synthesis Review

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

VHDL: A Crash Course

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

Outline CPE 626. Advanced VLSI Design. Lecture 3: VHDL Recapitulation. Intro to VHDL. Intro to VHDL. Entity-Architecture Pair

Mridula Allani Fall Fall

Inthis lecture we will cover the following material:

Concurrent Signal Assignment Statements (CSAs)

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

Design units can NOT be split across different files

Hardware Modeling. VHDL Syntax. Vienna University of Technology Department of Computer Engineering ECS Group

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

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

Digital Systems Design

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

-- Fill in values for each generic. -- Fill in values for each signal. SIGNAL load_start : std_ulogic := '1'; SIGNAL clock : std_ulogic := '0';

HDL. Hardware Description Languages extensively used for:

A bird s eye view on VHDL!

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

ECE 3401 Lecture 10. More on VHDL

VHDL 3 BASIC OPERATORS AND ARCHITECTURE BODY. Design descriptions & design constructions examples are taken from foundation series examples

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 4 Introduction to VHDL

Introduction to the VHDL language. VLSI Digital Design

Introduction to VHDL #1

Very High Speed Integrated Circuit Har dware Description Language

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

VHDL Part 2. What is on the agenda? Basic VHDL Constructs. Examples. Data types Objects Packages and libraries Attributes Predefined operators

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

VHDL Structural Modeling II

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

Lecture 10 Subprograms & Overloading

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

EEL 4783: Hardware/Software Co-design with FPGAs

Lecture 12 VHDL Synthesis

EEL 4712 Digital Design Test 1 Spring Semester 2007

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

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

ECE U530 Digital Hardware Synthesis. Course Accounts and Tools

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

The VHDL Hardware Description Language

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

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

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

Modeling Complex Behavior

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

Sequential Statement

EE261: Intro to Digital Design

Sequential Logic - Module 5

Basic Language Concepts

Lattice VHDL Training

VHDL for FPGA Design. by : Mohamed Samy

Chapter 6 Combinational-Circuit Building Blocks

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26)

Introduction to VHDL. Main language concepts

JUNE, JULY 2013 Fundamentals of HDL (10EC45) PART A

ECOM4311 Digital Systems Design

CprE 583 Reconfigurable Computing

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

Embedded Systems CS - ES

In our case Dr. Johnson is setting the best practices

ECE4401 / CSE3350 ECE280 / CSE280 Digital Design Laboratory

Writing VHDL for RTL Synthesis

ENGIN 241 Digital Systems with Lab

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

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 1

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

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

Transcription:

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

Design Flow 418_02 2

VHDL Modules 418_02 3

VHDL Libraries library IEEE; use IEEE.std_logic_1164.all; std_logic Single-bit signals std_logic_vector Multi-bit signals 418_02 4

Full Adder (Dataflow) library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity FullAdder is port(x, Y, Cin: in std_logic; Cout, Sum: out std_logic); end FullAdder; --Inputs --Outputs architecture Dataflow of FullAdder is begin -- concurrent assignment statements Sum <= X xor Y xor Cin after 2 ns; Cout <= (X and Y) or (X and Cin) or (Y and Cin) after 2 ns; end Dataflow; 418_02 5

4-bit Ripple-Carry Adder entity Adder4 is port(a, B: in std_logic_vector(3 downto 0); Ci: in std_logic; S: out std_logic_vector(3 downto 0); Co: out std_logic); end Adder4; 418_02 6

4-bit Adder (Structural) architecture Structure of Adder4 is component FullAdder port(x, Y, Cin: in std_logic; -- Inputs Cout, Sum: out std_logic); -- Outputs end component; signal C: std_logic_vector(3 downto 1); -- internal begin --instantiate four copies of the FullAdder FA0: FullAdder port map(a(0),b(0),ci,c(1),s(0)); FA1: FullAdder port map(a(1),b(1),c(1),c(2),s(1)); FA2: FullAdder port map(a(2),b(2),c(2),c(3),s(2)); FA3: FullAdder port map(a(3),b(3),c(3),co,s(3)); end Structure; 418_02 7

VHDL Test Bench constant PERIOD: time := 10 ns; BEGIN stim_proc: process begin wait for PERIOD; A <= "0011"; B <= "0010"; Ci <= '0'; wait for PERIOD; B <= "1110"; wait; end process; END; 418_02 8

VHDL Simulation 418_02 9

VHDL Processes (Behavioral) D Flip-Flop with Asyncronous Clear 418_02 10

VHDL Data Types Bit '0' or '1' Bit_Vector "00", "01", "10",... Boolean FALSE or TRUE Time integer with units fs, ps, ns, us, ms,... Integer Real Character 'a', 'b', '1', '2',... Enumeration Type User defined 418_02 11

IEEE 1164 Standard Logic 9-Valued Logic System 'U' Uninitialized 'X' Forcing Unknown '0' Forcing 0 '1' Forcing 1 'Z' High Impedance 'W' Weak Unknown 'L' Weak 0 'H' Weak 1 '-' Don't Care 418_08 12

VHDL Operators Logical and, or, nand, nor, xor Relational =, /=, <, <=, >, >= Shift sll, srl, sla, sra, rol, ror Addition +, - Concatenation & Unary Sign +, - Multiplication *, /, mod, rem Miscellaneous not, abs, ** 418_02 13

VHDL Synthesis Example entity Q3 is port(a, B, F, CLK: in std_logic; G: out std_logic); end Q3; architecture circuit of Q3 is signal C: std_logic; begin process(clk) begin if rising_edge(clk) then C <= A and B; -- statement 1 G <= C or F; -- statement 2 end if; end process; end circuit; 418_02 14

Multiplexers entity MUX2to1 is port(i1, I0, S: in std_logic; F: out std_logic); end MUX2to1; S architecture Dataflow of MUX2to1 is begin F <= I0 when S = '0' else I1; end Dataflow; 418_02 15

Multiplexers entity MUX4to1 is port(i: in std_logic_vector(3 downto 0); S: in std_logic_vector(1 downto 0); F: out std_logic); end MUX4to1; architecture Dataflow of MUX4to1 is begin with S select F <= I(0) when "00", I(1) when "01", I(2) when "10", I(3) when "11"; end Dataflow; 418_02 16

VHDL Libraries library IEEE; use IEEE.std_logic_1164.all; Types std_logic and std_logic_vector use IEEE.std_logic_unsigned.all; Overloaded operators Conversion functions 418_02 17

4-bit Adder (Overload) library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; entity Adder4 is port(a, B: in std_logic_vector(3 downto 0); Ci: in std_logic; S: out std_logic_vector(3 downto 0); Co: out std_logic); end Adder4; 418_02 18

4-bit Adder (Overload) architecture Overload of Adder4 is signal Sum5: std_logic_vector(4 downto 0); begin Sum5 <= ('0' & A) + ( 0 & B) + ( 0000 & Ci); S <= Sum5(3 downto 0); Co <= Sum5(4); end Overload; 418_02 19

Shift Register Left Shift Register Synchronous Clear and Load 418_02 20

74163 Binary Counter (clear) (parallel load) (no change) (increment count) 418_02 21

VHDL Counter (Behavioral) -- 74163 FULLY SYNCHRONOUS COUNTER library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; entity Counter74163 is port(ldn, ClrN, P, T, Clk: in std_logic; D: in std_logic_vector(3 downto 0); Cout: out std_logic; Qout: out std_logic_vector(3 downto 0)); end Counter74163; 418_02 22

VHDL Counter (Behavioral) architecture Behave of Counter74163 is signal Q: std_logic_vector(3 downto 0) := "0000"; begin process(clk) begin if rising_edge(clk) then if ClrN = '0' then Q <= "0000"; elsif LdN = '0' then Q <= D; elsif (P and T) = '1' then Q <= Q + 1; end if; end if; end process; Qout <= Q; Cout <= '1' when Q = "1111" and T = '1' else '0'; end Behave; 418_02 23

8-bit Counter 418_02 24

VHDL Counter (Structural) library IEEE; use IEEE.std_logic_1164.all; entity Eight_Bit_Counter is port(clrn, LdN, P, T1, Clk: in std_logic; Din1, Din2: in std_logic_vector(3 downto 0); Qout: out std_logic_vector(7 downto 0); Carry2: out std_logic); end Eight_Bit_Counter; 418_02 25

VHDL Counter (Structural) architecture Structure of Eight_Bit_Counter is component Counter74163 is port(ldn, ClrN, P, T, Clk: in std_logic; D: in std_logic_vector(3 downto 0); Cout: out std_logic; Qout: out std_logic_vector(3 downto 0)); end component; signal Carry1: std_logic; signal Qout1, Qout2: std_logic_vector(3 downto 0); 418_02 26

VHDL Counter (Structural) begin ct1: Counter74163 port map(ldn,clrn,p,t1,clk, Din1,Carry1,Qout1); ct2: Counter74163 port map(ldn,clrn,p,carry1,clk, Din2, Carry2, Qout2); Qout <= Qout2 & Qout1; end Structure; 418_02 27

Sequential Machine 418_02 28

Sequential Machine 418_02 29

Behavioral Model entity Sequence_Detector is port(x, CLK: in std_logic; Z: out std_logic); end Sequence_Detector; architecture Behave of Sequence_Detector is signal State: integer range 0 to 2 := 0; begin process(clk) begin if rising_edge(clk) then 418_02 30

Behavioral Model case State is when 0 => if X = '0' then State <= 0; else State <= 1; end if; when 1 => if X = '0' then State <= 2; else State <= 1; end if; 418_02 31

Behavioral Model when 2 => if X = '0' then State <= 0; else State <= 1; end if; end case; end if; end process; Z <= '1' when (State = 2 and X = '1') else '0'; end Behave; 418_02 32

Additional VHDL Variables, Signals and Constants Arrays Loops Assert and Report Statements 418_02 33

Look-Up Tables 418_02 34

Look-Up Tables library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; entity Parity_Gen is Port(X: in std_logic_vector(3 downto 0); Y: out std_logic_vector(4 downto 0)); end Parity_Gen; 418_02 35

Look-Up Tables architecture Table of Parity_Gen is type OutTable is array(0 to 15) of std_logic; signal ParityBit: std_logic; constant OT: OutTable := ('1','0','0','1','0','1','1','0', begin '0','1','1','0','1','0','0','1'); ParityBit <= OT(conv_integer(X)); Y <= X & ParityBit; end Table; 418_02 36

4-bit Adder Test Bench constant PERIOD: time := 10 ns; -- Test vector arrays constant N: integer := 4; type arr1 is array(1 to N) of std_logic; type arr2 is array(1 to N) of std_logic_vector(3 downto 0); constant A_array: arr2:= ( "0011", "0011", "0011", "1101"); constant B_array: arr2 := ( "0010", "1110", "1101", "0010"); constant Ci_array: arr1 := ( '0', '0', '1', '0'); constant Co_array: arr1:= ('0', '1', '1', '0' ); constant S_array: arr2 := ( "0101", "0001", "0001", "1111"); 418_02 37

4-bit Adder Test Bench -- Stimulus process stim_proc: process begin for i in 1 to N loop A <= A_array(i); B <= B_array(i); Ci <= Ci_array(i); wait for PERIOD; assert (S = S_array(i) and Co = Co_array(i)) report "Wrong Answer" severity error; end loop; report "Test Finished"; end process; 418_02 38

VHDL Simulation 418_02 39

VHDL Summary Entity Architecture Dataflow Structural Behavioral Data Types and Operators Synthesis Libraries Simulation Test Benches 418_02 40