Computer-Aided Digital System Design VHDL

Similar documents
EEL 4783: Hardware/Software Co-design with FPGAs

Hardware Description Language VHDL (1) Introduction

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

Modeling Complex Behavior

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

Basic Language Concepts

VHDL And Synthesis Review

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

In our case Dr. Johnson is setting the best practices

Hardware Description Languages. Modeling Complex Systems

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

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

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

Review of Digital Design with VHDL

VHDL for FPGA Design. by : Mohamed Samy

Introduction to VHDL #1

Sequential Statement

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

C-Based Hardware Design

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

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

A bird s eye view on VHDL!

Digital Systems Design

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

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

Concurrent Signal Assignment Statements (CSAs)

Introduction to VHDL. Main language concepts

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

Introduction to VHDL #3

Lecture 12 VHDL Synthesis

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

VHDL Examples Mohamed Zaky

EITF35: Introduction to Structured VLSI Design

Control and Datapath 8

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

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

Summary of FPGA & VHDL

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

Sequential Logic - Module 5

[VARIABLE declaration] BEGIN. sequential statements

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

Subprograms, Packages, and Libraries

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

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

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

COE 405 Design Methodology Based on VHDL

ELCT 501: Digital System Design

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

VHDL: A Crash Course

Lecture 3 Introduction to VHDL

EE434 ASIC & Digital Systems

Mridula Allani Fall Fall

Getting Started with VHDL

Lattice VHDL Training

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

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

ECE U530 Digital Hardware Synthesis. Course Accounts and Tools

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

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

ECE4401 / CSE3350 ECE280 / CSE280 Digital Design Laboratory

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

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

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

Lecture 10 Subprograms & Overloading

ENGIN 241 Digital Systems with Lab

Digital Design with SystemVerilog

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

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

SEQUENTIAL STATEMENTS

VHDL simulation and synthesis

CprE 583 Reconfigurable Computing

VHDL: RTL Synthesis Basics. 1 of 59

Embedded Systems CS - ES

VHDL VS VERILOG.

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

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

Synthesis of Digital Systems CS 411N / CSL 719. Part 3: Hardware Description Languages - VHDL

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

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

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

ENGR 5865 DIGITAL SYSTEMS

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

VHDL for Modeling - Module 10

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

Very High Speed Integrated Circuit Har dware Description Language

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

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

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

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

Digital Design with FPGAs. By Neeraj Kulkarni

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

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

VHDL in 1h. Martin Schöberl

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

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

CCE 3202 Advanced Digital System Design

HDL. Hardware Description Languages extensively used for:

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

CprE 583 Reconfigurable Computing

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

Transcription:

بس م اهلل الر حم ن الر حی م Iran University of Science and Technology Department of Computer Engineering Computer-Aided Digital System Design VHDL Ramin Rajaei ramin_rajaei@ee.sharif.edu

Modeling Styles From the level of abstraction systems can be described in there types: 1. Behavioral 2. Dataflow 3. Structural VHDL Hierarchy 2

Modeling Styles Sequential vs. Concurrent Statements VHDL provides two different types of execution: sequential and concurrent. Different types of execution are useful for modeling of real hardware. Supports various levels of abstraction. Sequential statements view hardware from a programmer approach. Concurrent statements are order-independent and asynchronous. 3

Examples for Architecture Declaration Sequential (behavioral) Style Data flow Style Structural Style 4

Behavioral We can describe a system in terms of processing it performs on its input signals and the type of output it signals it produces. Example : LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY eq_comp4 is PORT( a,b : in std_logic_vector(3 downto 0); equals : out std_logic); END ; ARCHITECTURE behvioral OF eq_comp4 IS BEGIN comp: PROCESS (a,b) BEGIN IF (a=b) then equals <= '1'; Else equals <= '0'; END IF; END PROCESS comp; END behvioral; 5

Data Flow Dataflow architecture specifies how data will be transferred from signal to signal and input to input without the sequential statements. Primary difference is that behavioral uses processes while dataflow does not. The other main difference between dataflow and behavioral architectures is that the body of the process statement contains only sequential statements. Example: library ieee; use ieee.std_logic_1164.all; entity eq_comp4 is port ( end eq_comp4; a,b : in std_logic_vector(3 downto 0); equals : out std_logic); architecture bool of eq_comp4 is begin equals <= not (a(0) xor b(0)) and not (a(1) xor b(1)) and not (a(2) xor b(2)) and not (a(3) xor b(3)); end bool; 6

Structural One way to describe a system is to describe component chips and the interconnections assuming that the user is familiar with it. This kind of definition is the structural definition. Example: library ieee; use ieee.std_logic_1164.all; entity full_adder is port( a,b,ci : in std_logic; sum,co : out std_logic); What circuit this architecture means? end full_adder; architecture bool of full_adder is signal s1,s2,s3 : std_ulogic; begin u0: s1 <= (a xor b); u1: s2 <= (ci and s1); u2: s3 <= (a and b); u3: sum <= (s1 xor ci); u4 : co <= (s2 or s3); end bool; 7

Standard VHDL operators Logical - defined for type BIT AND, NAND OR, NOR XOR, XNOR NOT Relational - defined for types BIT, BIT_VECTOR, INTEGER = (equal to) =/ (not equal to) < (less than) = < (less than or equal to) > (greater than) = > (greater than or equal to) 8

Standard VHDL operators Unary Arithmetic - defined for type INTEGER - (arithmetic negate) Arithmetic - defined for type INTEGER + (addition) - (subtraction) Concatenation - defined for types STRING, BIT, BIT_VECTOR & 9

Concurrency 10

Sequential Style Syntax Assignments are executed sequentially inside processes. 11

A D-Flip Flop D CLEAR CLK DFF Q 12

Sequential Statements {Signal, Variable} assignments Flow control if <condition> then <statments> [elsif <condition> then <statments>] else <statements> end if; for <range> loop <statments> end loop; while <condition> loop <statments> end loop; case <condition> is when <value> => <statements>; when <value> => <statements>; when others => <statements>; Wait on <signal> until <expression> for <time>; 13

Data Objects There are three types of data objects: Signals Can be considered as wires in a schematic. Can have current value and future values. Variables and Constants Used to model the behavior of a circuit. Used in processes, procedures and functions. 14

Signal Declaration and Assignment Signals are used for communication between components. Signals are declared outside the process. Signals can be seen as real, physical signals. Some delay must be incurred in a signal assignment. A key difference between variables and signals is the assignment delay. 15

Variable Declaration and Assignment Variables are used for local storage of data. Variables are generally not available to multiple components or processes. All variable assignments take place immediately. Variables are more convenient than signals for the storage of (temporary) data. 16

Constant Declaration A constant can have a single value of a given type. A constant s value cannot be changed during the simulation. Constants declared at the start of an architecture can be used anywhere in the architecture. Constants declared in a process can only be used inside the specific process. CONSTANT constant_name : type_name [ : = value]; CONSTANT rise_fall_time : TIME : = 2 ns; CONSTANT data_bus : INTEGER : = 16; 17

Signals vs. Variables Variable is used when you want to create a serialized code, unlike the normal parallel code. A variable, can exist only inside a process, and the assignment of values is not parallel. For example, the fallowing code: 18

Signals vs. Variables entity sig_var is port (In1: in std_logic; In2: in std_logic; out1: out std_logic); end sig_var; architecture Behavioral of sig_var is begin process(in1, In2) variable a, b: std_logic; begin a := In1 and In2; b := a and In2; out1 <= b and In2; end process; end Behavioral; 19

Signals vs. Variables entity sig_var is port (In1: in std_logic; In2: in std_logic; out1: out std_logic); end sig_var; architecture Behavioral of sig_var is signal a, b: std_logic; begin process(in1, In2) begin a <= In1 and In2; b <= a and In2; out1 <= b and In2; end process; end Behavioral; 20

Signals vs. Variables entity sig_var is port (In1: in std_logic; In2: in std_logic; out1: out std_logic); end sig_var; architecture Behavioral of sig_var is signal a, b: std_logic; begin a <= In1 and In2; b <= a and In2; out1 <= b and In2; end Behavioral; 21

Signal vs Variable: synthesis entity sig_var is port (clk: in std_logic; Din: in std_logic_vector (3 downto 0); out1: out std_logic_vector (3 downto 0)); end sig_var; architecture Behavioral of sig_var is signal a, b: std_logic_vector (3 downto 0); begin process(clk) begin if (rising_edge(clk)) then a <= Din; b <= a; end if; end process; out1 <= b; end Behavioral; 22

Signal vs Variable: synthesis entity sig_var is port (clk: in std_logic; Din: in std_logic_vector (3 downto 0); out1: out std_logic_vector (3 downto 0)); end sig_var; architecture Behavioral of sig_var is signal a, b: std_logic_vector (3 downto 0); begin process(clk) begin if (rising_edge(clk)) then a <= Din; b <= a; out1 <= b; end if; end process; end Behavioral; 23

IF vs. CASE statement Syntax 24

FOR vs. WHILE statement Syntax For is considered to be a combinational circuit by some synthesis tools. Thus, it cannot have a wait statement to be synthesized. While is considered to be an FSM by some synthesis tools. Thus, it needs a wait statement to be synthesized. 25

WAIT statement Syntax The wait statement causes the suspension of a process statement or a procedure. wait [sensitivity_clause] [condition_clause] [timeout_clause]; Sensitivity_clause ::= on signal_name wait on CLOCK; Condition_clause ::= until boolean_expression wait until Clock = 1 ; Timeout_clause ::= for time_expression wait for 150 ns; wait until clk event and clk= 1 ; wait until rising_edge(clk); 26

Sensitivity-lists vs Wait-on - statement 27

Example entity process_example is Port ( clk : in STD_LOGIC; D1, D2: in std_logic; reset: in std_logic; out1 : out STD_LOGIC; out2 : out STD_LOGIC); end process_example; architecture Behavioral of process_example is begin process begin if reset = '1' then out1 <= '0'; else out1 <= D1; end if; if rising_edge(clk) then out2 <= D2; end if; end process; end Behavioral; 28

Example (cont.) entity process_example is Port ( clk : in STD_LOGIC; D1, D2: in std_logic; reset: in std_logic; out1 : out STD_LOGIC; out2 : out STD_LOGIC); end process_example; architecture Behavioral of process_example is begin process begin wait until rising_edge (clk); if reset = '1' then out1 <= '0'; else out1 <= D1; end if; out2 <= D2; end process; end Behavioral; 29

Example (cont.) Error message: line 36: Bad condition in wait statement, or only one clock per process. 30

Concurrent Process Equivalents All concurrent statements correspond to a process equivalent. U0: q <= a xor b after 5 ns; is short hand notation for U0: process begin q <= a xor b after 5 ns; wait on a, b; end process; 31

Structural Statements The component instantiation is one of the building blocks of structural descriptions. The component instantiation process requires component declarations and component instantiation statements. Component instantiation declares the interface of the components used in the architecture. At instantiation, only the interface is visible. The internals of the component are hidden. 32

Component Declaration and Instantiation The component declaration declares the interface of the component to the architecture. Necessary if the component interface is not declared elsewhere (package, library). The instantiation statement maps the interface of the component to other objects in the architecture. 33

Component Instantiation Syntax The instantiation has 3 key parts Name Component type Port map 34

Examples: architecture first of add4 is begin s <= a + b; -- works with std_logic_vector or integer end; architecture second of add4 is signal c: std_logic_vector(2 downto 0); begin s(0) <= a(0) XOR b(0); c(0) <= a(0) AND b(0); s(1) <= a(1) XOR (b(1) XOR c(0)); c(1) <=.. end add4; 35

Example: n-bit Comparator library ieee; use ieee.std_logic_1164.all entity Comparator is port( A: in std_logic_vector(1 downto 0); B: in std_logic_vector(1 downto 0); less: out std_logic; equal: out std_logic; greater: out std_logic ); end Comparator; architecture behv of Comparator is Begin process(a,b) Begin if (A<B) then less <= '1'; equal <= '0'; greater <= '0'; elsif (A=B) then less <= '0'; equal <= '1'; greater <= '0'; else less <= '0'; equal <= '0'; greater <= '1'; end if; end process; end behv; 36

More Examples for Review 37

Example: 38

Synthesis Result 39

Example: entity reg4 is port (clk, clr : in bit; d : in bit_vector(0 to 3); q : out bit_vector(0 to 3); end entity reg4; architecture struct of reg4 is component flipflop is generic (Tprop, Tsetup, Thold : delay_length); port ( clk, clr, d : in bit; q : out bit); end component flipflop; begin bit0: component flipflop generic map ( Tprop => 2 ns, Tsetup => 2ns, Thold => 1ns) port map ( clk => clk, clr => clr, d => d(0), q => q(0) ); bit1: component flipflop generic map ( Tprop => 2 ns, Tsetup => 2ns, Thold => 1ns) port map ( clk => clk, clr => clr, d => d(1), q => q(1) ); bit2: component flipflop generic map ( Tprop => 2 ns, Tsetup => 2ns, Thold => 1ns) port map ( clk => clk, clr => clr, d => d(2), q => q(2) ); bit3: component flipflop generic map ( Tprop => 2 ns, Tsetup => 2ns, Thold => 1ns) port map ( clk => clk, clr => clr, d => d(3), q => q(3) ); end architecture struct; 40

Example: Array of AND-gates 41

Next Sessions: In Lec-5, we will have a tutorial for Modelsim. And also Exercise 2 42