VHDL in 1h. Martin Schöberl

Similar documents
Sequential Logic - Module 5

In our case Dr. Johnson is setting the best practices

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

Lecture 12 VHDL Synthesis

Luleå University of Technology Kurskod SMD152 Datum Skrivtid

SEQUENTIAL STATEMENTS

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

VHDL And Synthesis Review

Timing in synchronous systems

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

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

[VARIABLE declaration] BEGIN. sequential statements

Sequential Statement

VHDL for FPGA Design. by : Mohamed Samy

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

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

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

Sign here to give permission to return your test in class, where other students might see your score:

VHDL simulation and synthesis

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

Hardware Description Languages. Modeling Complex Systems

Introduction to VHDL #3

Concurrent & Sequential Stmts. (Review)

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

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

ELCT 501: Digital System Design

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

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

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

EITF35: Introduction to Structured VLSI Design

EITF35: Introduction to Structured VLSI Design

Summary of FPGA & VHDL

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

Programmable Logic. Simple Programmable Logic Devices

EITF35: Introduction to Structured VLSI Design

Control and Datapath 8

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

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

Lecture 38 VHDL Description: Addition of Two [5 5] Matrices

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

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

DESCRIPTION OF DIGITAL CIRCUITS USING VHDL

Computer-Aided Digital System Design VHDL

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

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

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

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

Hardware Description Language VHDL (1) Introduction

Modeling Complex Behavior

Lattice VHDL Training

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

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.

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

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

VHDL: RTL Synthesis Basics. 1 of 59

VHDL par Ahcène Bounceur VHDL

Advanced Digital Design Spring 2011 Final Examination Time Limit: 2 Hours

INTRODUCTION TO VHDL ADVANCED COMPUTER ARCHITECTURES. Slides by: Pedro Tomás. Additional reading: - ARQUITECTURAS AVANÇADAS DE COMPUTADORES (AAC)

EL 310 Hardware Description Languages Midterm

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

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

Today. Comments about assignment Max 1/T (skew = 0) Max clock skew? Comments about assignment 3 ASICs and Programmable logic Others courses

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

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

Quartus Counter Example. Last updated 9/6/18

VHDL Sequential Statements. Cristian Sisterna

6.111 Lecture # 8. Topics for Today: (as time permits)

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

Chapter 2 Basic Logic Circuits and VHDL Description

Digital Systems Design

Altera s Avalon Communication Fabric

EEL 4712 Digital Design Test 1 Spring Semester 2008

Lab 3. Advanced VHDL

CprE 583 Reconfigurable Computing

The Virtex FPGA and Introduction to design techniques

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

A bird s eye view on VHDL!

Problem Set 5 Solutions

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

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

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

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

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

CPE 626 Advanced VLSI Design Lecture 6: VHDL Synthesis. Register File: An Example. Register File: An Example (cont d) Aleksandar Milenkovic

Writing VHDL for RTL Synthesis

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 3

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

HDL. Hardware Description Languages extensively used for:

3 Designing Digital Systems with Algorithmic State Machine Charts

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

EEL 4712 Digital Design Test 1 Spring Semester 2007

VHDL Examples Mohamed Zaky

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

VHDL: Code Structure. 1

Codec. WM8731 Audio Codec

Introduction to VHDL #1

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

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

VHDL. Chapter 7. Behavioral Modeling. Outline. Behavioral Modeling. Process Statement

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

Transcription:

VHDL in 1h Martin Schöberl

VHDL /= C, Java, Think in hardware All constructs run concurrent Different from software programming Forget the simulation explanation VHDL is complex We use only a small subset AK: JVMHW VHDL 2

Signals are Wires Use std_logic std_logic_vector (n downto 0) unsigned Variables Elegant for some constructs Easy to produce too much logic Avoid them AK: JVMHW VHDL 3

Synchronous Design Register Clock, reset Combinatorial logic And, or, +, - =, /=, >, AK: JVMHW VHDL 4

Register Changes the value on the clock edge process(clk) if rising_edge(clk) then reg <= data; AK: JVMHW VHDL 5

Register with Reset Usually has an asynchronous reset process(clk, reset) if (reset='1') then reg <= "00000000"; elsif rising_edge(clk) then reg <= data; AK: JVMHW VHDL 6

Combinational Logic Simple expressions as signal assignment Concurrent statement a <= b; c <= a and b; AK: JVMHW VHDL 7

Combinational Logic Complex expressions in a process Sequential statement Input signals in the sensitivity list Assign a value to the output for each case process(a, b) if a=b then equal <= '1'; gt <= '0'; else equal <= '0'; if a>b then gt <= '1'; else gt <= '0'; AK: JVMHW VHDL 8

Defaults for Combinational process(a, b) equal <= '0'; gt <= '0'; if a=b then equal <= '1'; if a>b then gt <= '1'; AK: JVMHW VHDL 9

Constants Single bit 0 and 1 Use for std_logic Bit arrays 0011 Use for std_logic_vector and unsigned Integer: 1, 2, 3 Use for integer, unsigned AK: JVMHW VHDL 10

Example: Counter signal reg : std_logic_vector(7 downto 0); signal count : std_logic_vector(7 downto 0); -- the adder process process(reg) count <= std_logic_vector(unsigned(reg) + 1); -- the register process process(clk, reset) if reset='1' then reg <= (others => '0'); elsif rising_edge(clk) then reg <= count; -- assign the counter to the out port dout <= reg; AK: JVMHW VHDL 11

Counter in a Single Process -- we now use unsigned for the counter signal reg : unsigned(7 downto 0); -- a single process: process(clk, reset) if reset='1' then reg <= (others => '0'); elsif rising_edge(clk) then reg <= reg + 1; -- assign the counter to the out port dout <= std_logic_vector(reg); AK: JVMHW VHDL 12

Quiz 1 process(a, b, sel) if sel='0' then data <= a; else data <= b; A 2:1 Multiplexer AK: JVMHW VHDL 13

Quiz 2 process(sel, a, b, c, d) case sel is when "00" => data <= a; when "01" => data <= b; when "10" => data <= c; when others => data <= d; end case; 4:1 Multiplexer (Mux) AK: JVMHW VHDL 14

Quiz 3 process(sel) case sel is when "00" => z <= "0001"; when "01" => z <= "0010"; when "10" => z <= "0100"; when "11" => z <= "1000"; when others => z <= "XXXX"; end case; 2 to 4 decoder AK: JVMHW VHDL 15

Quiz 4 process(clk, reset) if reset='1' then reg <= (others => '0'); elsif rising_edge(clk) then if en='1' then reg <= data; Register with enable AK: JVMHW VHDL 16

Quiz 5 process(data, en) if en='1' then reg <= data; A Latch! VERY bad AK: JVMHW VHDL 17

User defined types State machine states Operation type type rgb_type is (red, green, blue); signal color : rgb_type; color <= red; AK: JVMHW VHDL 18

A simple ALU type op_type is (op_add, op_sub, op_or, op_and); signal op : op_type; process(op, a, b) case op is when op_add => result <= a + b; when op_sub => result <= a - b; when op_or => result <= a or b; when others => result <= a and b; end case; AK: JVMHW VHDL 19

File structure library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity alu is port ( clk, reset : in std_logic; a_in, b_in : in std_logic_vector(7 downto 0); dout : out std_logic_vector(7 downto 0) ); end alu; architecture rtl of alu is signal a, b : unsigned(7 downto 0);... a <= unsigned(a_in); dout <= std_logic_vector(result); process(op, a, b)... end rtl; AK: JVMHW VHDL 20

Adder as Component library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity add is port ( a, b : in std_logic_vector(7 downto 0); dout : out std_logic_vector(7 downto 0) ); end add; architecture rtl of add is signal result : unsigned(7 downto 0); signal au, bu : unsigned(7 downto 0); au <= unsigned(a); bu <= unsigned(b); result <= au + bu; dout <= std_logic_vector(result); end rtl; AK: JVMHW VHDL 21

Component Use Declaration component add is port ( a : in std_logic_vector(7 downto 0); b : in std_logic_vector(7 downto 0); dout : out std_logic_vector(7 downto 0) ); end component add; Instantiation cmp_add: add port map (a_in, b_in, sum); AK: JVMHW VHDL 22

Component library ieee; entity alu is end alu; architecture rtl of alu is component add is port ( a, b : in std_logic_vector(7 downto 0); dout : out std_logic_vector(7 downto 0) ); end component add; signal a, b : unsigned(7 downto 0); signal sum : std_logic_vector(7 downto 0); a <= unsigned(a_in); cmp_add : add port map (a_in, b_in, sum);... end rtl; AK: JVMHW VHDL 23

State Machine architecture rtl of sm1 is type state_type signal state_reg signal next_state -- state register process(clk, reset) if reset='1' then state_reg <= green; elsif rising_edge(clk) then state_reg <= next_state; -- output of state machine process(state_reg) if state_reg=red then ring_bell <= '1'; else ring_bell <= '0'; is (green, orange, red); : state_type; : state_type; -- next state logic process(state_reg, bad_event, clear) next_state <= state_reg; case state_reg is when green => if bad_event = '1' then next_state <= orange; when orange => if bad_event = '1' then next_state <= red; when red => if clear = '1' then next_state <= green; end case; end rtl; AK: JVMHW VHDL 24

State Machine architecture rtl of sm2 is type state_type signal state_reg signal next_state -- state register process(clk, reset) if reset='1' then state_reg <= green; elsif rising_edge(clk) then state_reg <= next_state; is (green, orange, red); : state_type; : state_type; -- next state logic and output process(state_reg, bad_event, clear) next_state <= state_reg; ring_bell <= '0'; case state_reg is when green => if bad_event = '1' then next_state <= orange; when orange => if bad_event = '1' then next_state <= red; when red => ring_bell <= '1'; if clear = '1' then next_state <= green; end case; end rtl; AK: JVMHW VHDL 25

State Machine in one Process architecture rtl of sm3 is type state_type is (green, orange, red); signal state : state_type; -- single process process(clk, reset) if reset='1' then state <= green; ring_bell <= '0'; elsif rising_edge(clk) then case state is when green => if bad_event = '1' then state <= orange; when orange => if bad_event = '1' then state <= red; ring_bell <= '1'; when red => ring_bell <= '1'; if clear = '1' then state <= green; ring_bell <= 0'; end case; end rtl; AK: JVMHW VHDL 26

Summary Think in hardware! Beware of unassigned pathes (latch!) Use simple types Use simple statements AK: JVMHW VHDL 27

More Information FAQ comp.lang.vhdl Mark Zwolinski, Digital System Design with VHDL. AK: JVMHW VHDL 28