Topics of Lecture Structural Model Procedures Functions Overloading.

Slides:



Advertisements
Similar presentations
COE 405 VHDL Basics Dr. Aiman H. El-Maleh Computer Engineering Department King Fahd University of Petroleum & Minerals Dr. Aiman H. El-Maleh Computer Engineering.
Advertisements

Discussed in class and on Fridays n FSMs (only synchronous, with asynchronous reset) –Moore –Mealy –Rabin-Scott n Generalized register: –With D FFs, –With.
VHDL Quick Start Peter J. Ashenden The University of Adelaide.
Data Types. Composite Date Types n Arrays –Single and multi-dimensional –Arrays are single Type n Records –Records are mixed types.
Sistemas Digitais I LESI - 2º ano Lesson 5 - VHDL U NIVERSIDADE DO M INHO E SCOLA DE E NGENHARIA Prof. João Miguel Fernandes Dept.
Why Behavioral Wait statement Signal Timing Examples of Behavioral Descriptions –ROM.
SubprogramsSubprograms. SubprogramsSubprograms ä Similar to subprograms found in other languages ä Allow repeatedly used code to be referenced multiple.
ELEN 468 Lecture 191 ELEN 468 Advanced Logic Design Lecture 19 VHDL.
Topics Entity DeclarationsEntity Declarations Port ClausePort Clause Component DeclarationComponent Declaration Configuration DeclarationConfiguration.
N Structural Modeling: n Entities n Ports n Architectures n Packages.
ECE C03 Lecture 141 Lecture 14 VHDL Modeling of Sequential Machines Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
VHDL. What is VHDL? VHDL: VHSIC Hardware Description Language  VHSIC: Very High Speed Integrated Circuit 7/2/ R.H.Khade.
Simple Testbenches Behavioral Modeling of Combinational Logic
Package with 4-valued logic Signal Attributes Assertion Data Flow description.
Introduction to VHDL (part 2)
1 H ardware D escription L anguages Basic Language Concepts.
1 Data Object Object Types A VHDL object consists of one of the following: –Signal, Which represents interconnection wires that connect component instantiation.
IAY 0600 Digitaalsüsteemide disain Event-Driven Simulation Alexander Sudnitson Tallinn University of Technology.
Introduction to VHDL Arab Academy for Science, Technology & Maritime Transport Computer Engineering Department Magdy Saeb, Ph.D.
VHDL IE- CSE. What do you understand by VHDL??  VHDL stands for VHSIC (Very High Speed Integrated Circuits) Hardware Description Language.
7/10/2007DSD,USIT,GGSIPU1 Basic concept of Sequential Design.
Slide: 1 Copyright © AdaCore Subprograms Presented by Quentin Ochem university.adacore.com.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Language Concepts Ver 1.1, Copyright 1997 TS, Inc. VHDL L a n g u a g e C o n c e p t s Page 1.
RTL Hardware Design by P. Chu Chapter Basic VHDL program 2. Lexical elements and program format 3. Objects 4. Data type and operators RTL Hardware.
CPS120: Introduction to Computer Science Decision Making in Programs.
29/10/58 1 Copyright  1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University.
2-Jun-16EE5141 Chapter 3 ä The concept of the signal ä Process concurrency ä Delta time ä Concurrent and sequential statements ä Process activation by.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHDL – Basic Language Elements  Identifiers: –basic identifier: composed of a sequence of one or more.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHSIC Hardware Description Language  Required Reading: –These Slides –VHDL Tutorial  Very High Speed.
VHDL Very High Speed Integrated Circuit Hardware Description Language Shiraz University of shiraz spring 2011.
IAY 0600 Digital Systems Design VHDL discussion Verification: Testbenches Alexander Sudnitson Tallinn University of Technology.
Electrical and Computer Engineering University of Cyprus LAB 1: VHDL.
Topics AliasesSubprograms Generics & Configurations.
(1) Basic Language Concepts © Sudhakar Yalamanchili, Georgia Institute of Technology, 2006.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
Chapter 5 Introduction to VHDL. 2 Hardware Description Language A computer language used to design circuits with text-based descriptions of the circuits.
George Mason University Simple Testbenches ECE 545 Lecture 4.
16/11/2006DSD,USIT,GGSIPU1 Packages The primary purpose of a package is to encapsulate elements that can be shared (globally) among two or more design.
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
VHDL Discussion Subprograms IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
Subprograms Lecture 6. Subprograms A subprogram defines a sequential algorithm that performs some computations. Subprograms can be: –1. functions –2.
Subprograms Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Relational Operators Result is boolean: greater than (>) less than (=) less than or equal to (
IAY 0600 Digital Systems Design Event-Driven Simulation VHDL Discussion Alexander Sudnitson Tallinn University of Technology.
55:032 - Intro. to Digital DesignPage 1 VHDL and Processes Defining Sequential Circuit Behavior.
IAY 0600 Digital Systems Design VHDL discussion Verification: Testbenches Alexander Sudnitson Tallinn University of Technology.
Case Study: Xilinx Synthesis Tool (XST). Arrays & Records 2.
Dataflow modelling Lecture 4. Dataflow modelling Specifies the functioning of a circuit without explicitly refer to its structure Functioning is described.
EGRE 6311 LHO 04 - Subprograms, Packages, and Libraries EGRE 631 1/26/09.
Introduction To VHDL 홍 원 의.
Basic Language Concepts
IAY 0600 Digitaalsüsteemide disain
Behavioral Style Combinational Design with VHDL
IAY 0600 Digital Systems Design
Timing Model Start Simulation Delay Update Signals Execute Processes
Behavioral Style Combinational Design with VHDL
IAY 0600 Digital Systems Design
ECE 434 Advanced Digital System L08
Peter J. Ashenden The University of Adelaide
IAS 0600 Digital Systems Design
ECE 434 Advanced Digital System L10
VHDL Discussion Subprograms
CPE 528: Lecture #3 Department of Electrical and Computer Engineering University of Alabama in Huntsville.
VHDL Discussion Subprograms
IAS 0600 Digital Systems Design
Data Object By E. Thirumeni Department of Electronics
Design units Lecture 2.
EEL4712 Digital Design (VHDL Tutorial).
(Simple Testbenches & Arithmetic Operations)
Presentation transcript:

Topics of Lecture Structural Model Procedures Functions Overloading

Subprograms

Structural Descriptions Port Mappings Can Be Specified Two Ways –Positional association Order is important –Named association For connecting some signals Easier to read which signals are connected to which internal signals Order is not important –Can only use one type of association at a time

Structural Descriptions Entity Ports Declared in an Architecture Body Are Signals –These signals are not available outside the architecture unless connected to one of the architectures ports

Structural Descriptions Subelement Association –Separate, actual signals can be associated with individual elements of the architecture port –All elements of the composite port must be associated –All associations for a particular port must be grouped together with no intervening ports among them. –Ranges can be associated

Design Processing Simulation and Synthesis Require –Analysis of model Performs syntax check Places entities and architectures in design library Dependency relations –primary units contain entity declarations –secondary units contain architecture bodies

Design Processing –Elaboration A collection of processes connected by nets Entity declarations replaced by architecture bodies

Execution Simulation Time Set to Zero Signals Assigned Initial Values Every Process Executed at Least Once Advance Simulation Clock to Next Scheduled Timeout Perform Transactions and Update Signals Resume Sensitive Processes

Subprograms Define Algorithms for Computing Values or Exhibiting Behavior –Type conversion –Define resolution functions for signals –Define portions of a process

Subprograms Two types –Procedure –Function Return Statements Allow for Different Exit Points –Function must always have a return statement –Procedure does not return a valueSubprograms

Subprograms Declared Variables, Constants and Files Are Local and Instantiated When Called. –No signals allowed Procedure declarations can be nested Procedures can call proceduresSubprograms

Value of Subprograms Write Once, Use Often Can Be Called Recursively Can Be Called Repeatedly From Within Scope

Procedure Subprograms Procedure –Encapsulates a collection of sequential statements into a single statement –Executed for their effect –May return zero or more values –May execute in zero or more simulation time –Can modify a calling parameter because it is a statement and doesn’t return a value

Function Subprograms Functions –Algorithmically generates and returns only one value May be on right hand side of expression –Must Alway returns a value –Executes in zero simulation time i.e., cannot contain a wait statement

Subprogram Declaration Names the Subprogram Specifies Required Parameters Contains the Sequential Statements Defining the Behavior of the Subprogram Defines the Return Type for Function Subprograms

Subprogram Declaration Local Declarations –Types –Subtypes –Constants and variables –Nested subprogram declarations

Procedure Syntax

Procedure Parameter List Specifies Class of Object(s) Passed –Constant (assumed if mode is in ) –Variable (assumed if mode is out ) –Signal (passed by reference, not value) If wait statement is executed inside a procedure, the value of a signal may change before the rest of the procedure is calculated If mode inout, reference to both signal and driver passed

Associates Identifier With Formal Parameter(s) –Allows reference to a parameter in procedure body –Formal parameters are replaced with actual values when called Procedure Parameter List

Specifies optional mode(s) –in assumed if not specified –out cannot use value for computations –inout both read & write Procedure Parameter List

Specifies Type(s) –Provides error checking for type mismatches –Unconstrained arrays are allowed (<>) Attributes of unconstrained arrays can be used to set local constants or variables within procedures such as looping parameters Procedure Parameter List

Specifies Optional Default Value(s) –Values to be used if a parameter is not specified –If default value is desired, use keyword open for parameter –If default value is at end of list, can omit actual value or use open Procedure Parameter List

Procedure Example* procedure do_arith_op ( op1, op2 : in integer ; op : in func_code ) is variable result : integer ; begin case op is when add => result := op1 + op2 ; when subtract => result := op1-op2 ; end case ; *Ashenden, p 197 Example of Procedure

Procedure Example* dest <= result after Tpd ; Z_flag <= (result = 0) after Tpd; end procedure do_arith_op ; *Ashenden, p 197

Procedure Calling Once a Procedure is Declared, It Can Be Called From Other Parts of Model A Procedure Is a Sequential Statement, So it Can Be Called From –Process –Other subprogram body

Procedure Calling Syntax

Procedure Calling

Concurrent Procedure Calling A Shorthand for A Procedure Call Where Only a Concurrent Statement Would Be Allowed Identical Syntax to Procedure Call Statement Sensitive to Non-constant Parameters Passed to It

Concurrent Procedure Example* procedure check_setup ( signal data, clock : in bit ; constant Tsu : in time ) is begin if (clock’event and clock = ‘1’) then assert data’last_event >= Tsu report “setup time violation” severity error ; end if ; end procedure check_setup ; *Ashenden, p 208

Concurrent Procedure Example* check_ready_setup : check_setup ( data => ready, clock => phi2, Tsu => Tsu_rdy_clk ) ; Formal Parameters –data, clock, Tsu Actual Parameters –ready, phi2, Tsu_rdy_clk –Procedure is sensitive to signals ready and phi2

Concurrent Procedures Advantages –Easier to read programs –Write once, use often –Check timing constraints

Concurrent Procedures If No in or inout Signals in Parameter List –No sensitivity list, hence no equivalent wait statement –If procedure returns, it suspends indefinitely –Desirable if want to execute procedure once at startup –If wait statements are included in procedure, then behaves like process

Concurrent Procedure Example* procedure generate_clock ( signal clk : out bit ; constant Tperiod, Tpulse, Tphase : in time ) is begin wait for Tphase ; loop clk <= ‘1’, ‘0’ after Tpulse ; wait for Tperiod ; end loop ; end procedure generate_clock ; *Ashenden, p 208

Concurrent Procedure Example* signal phi1, phi2 : std_ulogic := ‘0’ ;... gen_phi1:generate_clock(phi1, Tperiod => 50n, Tpulse => 20 ns, Tphase => 0 ns ) ; gen_phi2:generate_clock(phi2,Tperiod => 50 ns, Tpulse => 20 ns, Tphase => 25 ns ) ; 20 ns0 ns 95 ns45 ns

Function Subprograms

Function Syntax

Function Example* function byte_to_int ( byte : word_8 ) return integer is variable result : integer := 0 ; begin for index in 0 to 7 loop result := result*2 + bit'pos(byte (index) ) ; end loop ; return result ; end function byte_to_int ; *Ashenden, VHDL Cookbook

Function Parameter List Specifies Class of Object(s) Passed –Constant (assumed) –Variable class is NOT allowed since the result of operations could be different when different instantiations are executed –Signal (passed by reference, not value)

Function Parameter List Associates Identifier With Formal Parameter(s) –Allows reference to a parameter in procedure body –Formal parameters are replaced with actual values when called Specifies Type of Return Value

Function Parameter List Optionally Specifies mode –in is the ONLY allowed mode Specifies Type(s) –Provides error checking for type mismatches –Unconstrained arrays are allowed (<>) Attributes of unconstrained arrays can be used to set local constants or variables within procedures such as looping parameters

Function Parameter List Specifies Optional Default Value(s) –Values to be used if a parameter is not specified –If default value is desired, use keyword open for parameter –If default value is at end of list, omit actual value or open

Function Calling

Pure Functions Function Does Not Refer to Any Variables or Signals Declared by Parent Result of Function Only Depends on Parameters Passed to It Always Returns the Same Value for Same Passed Parameters If Not Stated Explicitly, a Function Is Assumed to Be Pure

Impure Functions Can State Explicitly and Hence Use Parents’ Variables and/or Signals for Function Computation May Not Always Return the Same Value e.g., Impure Function Now Return Delay_Length ;

Overloading Same Operation on Different Types More Than One Distinct Subprogram Can Be Defined With the Same Name Where Each Has: –Different parameter types –Different number of parameters Context and Parameter List Determine Which Subprogram Is Executed

Overloading Example* procedure increment ( a : inout integer ; n : in integer := 1 ) is... procedure increment (a : inout bit_vector ; n : in bit_vector := b”1” ) is... procedure increment (a : inout bit_vector ; n : in integer:= 1 ) is... *Ashenden, p 215

Overloading Symbols Predefined Arithmetic Symbols Can Also Be Overloaded One Could Define Mixed Type Arithmetic and Write a Function Overloaded Boolean Operators Are Not “Short- Circuit” Evaluated See next page

Overloading Symbols Predefined Arithmetic Symbol Is Quoted in Function Declaration, e.g., function “+” (left, right : in bit_vector ) return bit_vector...

Subprogram Declaration Visibility Visibility Follows Normal Scoping Rules All Variables Are Local and “directly visible” –Allows one to use function without insuring variable name has not been used before

Visibility of Non-Local Variables Explicit reference can be made to non-local variables –“visible by selection” –prepend variable with name of procedure, e.g., p1.v as opposed to directly visible local variable v

Sources Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University