SubprogramsSubprograms. SubprogramsSubprograms ä Similar to subprograms found in other languages ä Allow repeatedly used code to be referenced multiple.

Slides:



Advertisements
Similar presentations
Chapter 11 Verilog HDL Application-Specific Integrated Circuits Michael John Sebastian Smith Addison Wesley, 1997.
Advertisements

Blocks Resolved Signals Signal GUARDs Tri-State Buses.
1 Lecture 13 VHDL 3/16/09. 2 VHDL VHDL is a hardware description language. The behavior of a digital system can be described (specified) by writing a.
Introduction to VHDL (Lecture #5) ECE 331 – Digital System Design The slides included herein were taken from the materials accompanying Fundamentals of.
VHDL Data Types Module F3.1. VHDL Data Types Scalar Integer Enumerated Real (floating point)* Physical* Composite Array Record Access (pointers)* * Not.
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.
ELEN 468 Lecture 191 ELEN 468 Advanced Logic Design Lecture 19 VHDL.
Topics of Lecture Structural Model Procedures Functions Overloading.
Topics Entity DeclarationsEntity Declarations Port ClausePort Clause Component DeclarationComponent Declaration Configuration DeclarationConfiguration.
HDL-Based Digital Design Part I: Introduction to VHDL (I) Dr. Yingtao Jiang Department Electrical and Computer Engineering University of Nevada Las Vegas.
N Objects n Constants n Variables n Types and Type Declarations n Numbers n Physical Types n Enumeration Types n Subtypes n Operators.
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.
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.
VHDL Training ©1995 Cypress Semiconductor 1 Introduction  VHDL is used to:  document circuits  simulate circuits  synthesize design descriptions 
Resolved Signals Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
ECE 332 Digital Electronics and Logic Design Lab Lab 5 VHDL Design Styles Testbenches.
IAY 0600 Digitaalsüsteemide disain Event-Driven Simulation Alexander Sudnitson Tallinn University of Technology.
A VHDL Tutorial ENG2410. ENG241/VHDL Tutorial2 Goals Introduce the students to the following: –VHDL as Hardware description language. –How to describe.
Dataflow Descriptions Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
VHDL Introduction. V- VHSIC Very High Speed Integrated Circuit H- Hardware D- Description L- Language.
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.
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.
IAY 0600 Digital Systems Design VHDL discussion Dataflow&Behavioral Styles Combinational Design Alexander Sudnitson Tallinn University of Technology.
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.
Introduction to VHDL Spring EENG 2920 Digital Systems Design Introduction VHDL – VHSIC (Very high speed integrated circuit) Hardware Description.
Copyright(c) 1996 W. B. Ligon III1 Getting Started with VHDL VHDL code is composed of a number of entities Entities describe the interface of the component.
VHDL Very High Speed Integrated Circuit Hardware Description Language Shiraz University of shiraz spring 2011.
Topics AliasesSubprograms Generics & Configurations.
(1) Basic Language Concepts © Sudhakar Yalamanchili, Georgia Institute of Technology, 2006.
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.
VHDL Programming Fundamentals Presented By Dr. Pradyut Kumar Biswal Department of Electronics, IIIT Bhubaneswar.
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.
VHDL Tutorial.
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.
1 Introduction to Engineering Spring 2007 Lecture 18: Digital Tools 2.
Introduction To VHDL 홍 원 의.
Basic Language Concepts
Subject Name: FUNDAMENTALS OF HDL Subject Code: 10EC45
IAY 0600 Digitaalsüsteemide disain
Behavioral Style Combinational Design with VHDL
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
Dataflow Style Combinational Design with VHDL
Timing Model Start Simulation Delay Update Signals Execute Processes
Behavioral Style Combinational Design with VHDL
IAY 0600 Digital Systems Design
IAS 0600 Digital Systems Design
ECE 434 Advanced Digital System L08
ECE 434 Advanced Digital System L9
CPE/EE 422/522 Advanced Logic Design L11
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
VHDL Data Types Module F3.1.
EEL4712 Digital Design (VHDL Tutorial).
Presentation transcript:

SubprogramsSubprograms

SubprogramsSubprograms ä Similar to subprograms found in other languages ä Allow repeatedly used code to be referenced multiple times without rewriting ä Break down large blocks of code into small, more manageable parts ä VHDL provides functions and procedures

Subprograms (cont’d) ä Contain sequential statements similar to processes ä May declare local variables, constants ä Executed when called from a sequential statement. ä Local Variables are re-initialized every time a subprogram is called. ä Parameters of calling routine are known as actuals, while the parameters of the declared subprogram are known as formals. ä Up level referencing to higher level variables and signals is allowed. ä Recursive calls by functions and procedures are allowed ä Attributes of signals cannot be accessed within subprograms

FunctionsFunctions ä Produce a single return value ä Called by expressions ä Cannot modify the parameters passed to them ä Require a RETURN statement FUNCTION add_bits2 (a, b : IN BIT) RETURN BIT IS VARIABLE result : BIT; -- variable is local to function BEGIN result := (a XOR b); RETURN result; -- the two functions are equivalent END add_bits2; FUNCTION add_bits2 (a, b : IN BIT) RETURN BIT IS VARIABLE result : BIT; -- variable is local to function BEGIN result := (a XOR b); RETURN result; -- the two functions are equivalent END add_bits2; FUNCTION add_bits (a, b : IN BIT) RETURN BIT IS BEGIN -- functions cannot return multiple values RETURN (a XOR b); END add_bits; FUNCTION add_bits (a, b : IN BIT) RETURN BIT IS BEGIN -- functions cannot return multiple values RETURN (a XOR b); END add_bits;

FunctionsFunctions x

FunctionsFunctions

FunctionsFunctions

FunctionsFunctions

FunctionsFunctions

Example of a Function

Example of a Function (cont)

FunctionsFunctions ä Functions must be called by other statements ä Parameters use positional association ARCHITECTURE behavior OF adder IS BEGIN PROCESS (enable, x, y) BEGIN IF (enable = '1') THEN result <= add_bits(x, y); carry <= x AND y; ELSE carry, result <= '0'; END PROCESS; END behavior; FUNCTION add_bits (a, b : IN BIT)

ProceduresProcedures

Procedures (cont)

Example of a Procedure

Another Example of a Procedure

Summary on Sequential Statements

ProceduresProcedures ä May produce multiple output values ä Are invoked by statements ä May modify the parameters PROCEDURE add_bits3 (SIGNAL a, b, en : IN BIT; SIGNAL temp_result, temp_carry : OUT BIT) IS BEGIN -- procedures can return multiple values temp_result <= (a XOR b) AND en; temp_carry <= a AND b AND en; END add_bits3; PROCEDURE add_bits3 (SIGNAL a, b, en : IN BIT; SIGNAL temp_result, temp_carry : OUT BIT) IS BEGIN -- procedures can return multiple values temp_result <= (a XOR b) AND en; temp_carry <= a AND b AND en; END add_bits3; l Do not require a RETURN statement

Procedures (Cont.) ä With parameter passing, it is possible to further simplify the architecture ARCHITECTURE behavior OF adder IS BEGIN PROCESS (enable, x, y) BEGIN add_bits3(x, y, enable, result, carry); END PROCESS; END behavior; PROCEDURE add_bits3 (SIGNAL a, b, en : IN BIT; SIGNAL temp_result, temp_carry : OUT BIT) l The parameters must be compatible in terms of data flow and data type

Signal Resolution and Buses Bus Resolution Function OR AND Execution phaseSignal update phase Resolved signal Transaction queue

Bus Resolution Smoke Generator ä VHDL does not allow multiple concurrent signal assignments to the same signal ä Multiple sequential signal assignments are allowed LIBRARY attlib; USE attlib.att_mvl.ALL; -- this code will generate an error ENTITY bus IS PORT (a, b, c : IN MVL; z : OUT MVL); END bus; ARCHITECTURE smoke_generator OF bus IS SIGNAL circuit_node : MVL; BEGIN circuit_node <= a; circuit_node <= b; circuit_node <= c; z <= circuit_node; END smoke_generator; LIBRARY attlib; USE attlib.att_mvl.ALL; -- this code will generate an error ENTITY bus IS PORT (a, b, c : IN MVL; z : OUT MVL); END bus; ARCHITECTURE smoke_generator OF bus IS SIGNAL circuit_node : MVL; BEGIN circuit_node <= a; circuit_node <= b; circuit_node <= c; z <= circuit_node; END smoke_generator;

Bus Resolution Functions ä Are used to determine the assigned value when there are multiple signal drivers to the same signal FUNCTION wired_and (drivers : MVL_VECTOR) RETURN MVL IS VARIABLE accumulate : MVL := '1'; BEGIN FOR i IN drivers'RANGE LOOP accumulate := accumulate AND drivers(i); END LOOP; RETURN accumulate; END wired_and; FUNCTION wired_and (drivers : MVL_VECTOR) RETURN MVL IS VARIABLE accumulate : MVL := '1'; BEGIN FOR i IN drivers'RANGE LOOP accumulate := accumulate AND drivers(i); END LOOP; RETURN accumulate; END wired_and; l Bus resolution functions may be user defined or called from a package

Bus Resolution Smoke Generator Fixed ä A signal which has a bus resolution function associated with it may have multiple drivers LIBRARY attlib; USE attlib.att_mvl.ALL; USE WORK.bus_resolution.ALL; ENTITY bus IS PORT (a, b, c : IN MVL; z : OUT MVL); END bus; ARCHITECTURE fixed OF bus IS SIGNAL circuit_node : wired_and MVL; BEGIN circuit_node <= a; circuit_node <= b; circuit_node <= c; z <= circuit_node; END fixed;

Null Transactions ä How can a driver be disconnected (i.e. not influence the output at all)? ä Use the null waveform element ä Example bus_out <= NULL AFTER 17 ns; ä What happens if all drivers of a resolved signal are disconnected? ä Use register kind in signal declaration to keep most recently determined value ä Use bus kind in signal declaration if resolution function will determine the value ä Example signal t : wired_bus BUS; signal u : BIT REGISTER;

Concurrent Statement ä Exists outside of a process but in an architecture ä The process is itself a concurrent statement all processes scheduled to run concurrently ä Concurrent signal assignment is a short hand form for a single statement process -- equivalent to process containing one statement, sensitive to changes on the right hand side. ä Used frequently in DATAFLOW style descriptions

The Process

Concurrent Signal Assignment

Concurrent Assignment Statements

Concurrent Signal Sensitivity ä Concurrent Statements are sensitive to all signals on the input side ä If a signal appears on both sides, the statement is sensitive to changes in its own output. ä A <= A+B; will be evaluated when B changes. This will change A and the statement will be evaluated again. ä Time will not be able to advance because the statement keeps executing.

Conditional Signal Statement

Example of Conditional Signal Statement

Selected Signal Statement

Example of Selected Signal Assignment

Concurrent Procedure Call ä IN, OUT and INOUT parameter modes ä Allows return of more than 1 value (unlike function call) ä Considered a statement ä Equivalent to a process containing the single procedure call followed by a wait on parameters of mode in or inout

Example of Concurrent Procedure Call

Sequential vs. Concurrent Statement in Simulation Cycle ä VHDL is inherently a concurrent language ä All VHDL processes execute concurrently ä Concurrent signal assignment statements are actually oneline processes ä VHDL statements execute sequentially within a process ä Concurrent processes with sequential execution within a process offers maximum flexibility ä Supports various levels of abstraction ä Supports modeling of concurrent and sequential events as observed in real systems

BlocksBlocks

BlocksBlocks ä Blocks are concurrent statements and provide a mechanism to partition an architecture description ä Items declared in declarative region of block are visible only inside the block, e.g. : ä signals, subprograms ä Blocks may be nested to define a hierarchical partitioning of the architectural description ä Blocks may contain Guards for disabling drives.

BlocksBlocks

Nested Blocks

ä End of this file

Modeling Styles ä Behavioral Modeling ä Explicit definition of mathematical relationship between the input and output ä No implementation information ä Structural Modeling ä Implicit definition of I/O relationship through particular structure ä Interconnection of components

Behavioral Modeling ä All VHDL processes execute concurrently ä Non-procedural ä Data-flow ä Concurrent execution ä Procedural ä Algorithmic ä Sequential execution of statements ä Equivalent to a single concurrent statement

Data Flow Model ä Concurrent Statements ä Execute in arbitrary order ä Execute only when any of input variables changes Local_Sig_1 <= In_1 AND In_2 ; Local_Sig_2 <= In_1 OR Local_Sig_1;

Signal Assignment Statements ä Two Types ä Conditional concurrent signal assignment statement ä Selected concurrent signal assignment statement ä Each of These Has a Sequential Process Equivalent ä Either Form Can Be Used and Are Equivalent

BIT or BOOLEAN? ä Logical Types Are Not Equal  BIT for signals ä ‘0’ or ‘1’ ä Character type  BOOLEAN for conditions ä TRUE or FALSE

Conditional Concurrent Syntax signal_identifier <= options conditional_waveforms ; conditional_waveforms ; options <= [ guarded ] [ delay_mechanisms ] [ guarded ] [ delay_mechanisms ] conditional_waveforms <= { waveform when condition else } { waveform when condition else } waveform [ when condition ] waveform [ when condition ]

Waveform Syntax waveform <= ( value_expression [ after time_expression ] ) {,... }

Operator Precedence ä Highest to Lowest ä Unary operator: NOT ä Relational operators: =, /=,, >= ä Boolean (bitwise): AND, OR, NAND, NOR, XOR, XNOR ä Parentheses Can Be Used to ä Force particular order of evaluation ä Improve readability of expressions

Type Declaration/Definition type identifier is type_definition ; type_definition <= scalar_type_definition | scalar_type_definition | composite_type_definition | composite_type_definition | access_type_definition | access_type_definition | file_type_definition file_type_definition

Scalar Type scalar_type_definition <= enumeration_type_definition | enumeration_type_definition | integer_type_definition | integer_type_definition | floating_type_definition | floating_type_definition | physical_type_definition physical_type_definition

Predefined Enumerated Types ä type severity_level is ( note, warning, error, failure ); ä type Boolean is ( false, true ); ä Used to model abstract conditions ä type bit is ( '0', '1' ); ä Used to model hardware logic levels

Bit-Vector Type ä Useful Composite Type Since It Groups Bits Together Which Can Represent Register Contents or Binary Numbers. signal Out_Port_Adx: Bit_Vector ( 15 downto 0 ); ( 15 downto 0 );

Specifying Values with String Literal Out_Port_Adx <= B ”0110_1001”; Out_Port_Adx <= X ”69” ; Out_Port_Adx <= O ”151” ;

HW 2-11 LIBRARY ieee ; USE ieee.std_logic_1164.all ; PACKAGE Clock_2_11_pkg IS COMPONENT Clock_2_11 COMPONENT Clock_2_11 --GENERIC ( ) ; --GENERIC ( ) ; PORT ( ClockOut : out bit := '0' ); PORT ( ClockOut : out bit := '0' ); END COMPONENT ; END COMPONENT ; END Clock_2_11_pkg ;

HW 2-11 ENTITY Clock_2_11 IS -- GENERIC ( ); -- GENERIC ( ); PORT ( ClockOut : out bit := '0' ); PORT ( ClockOut : out bit := '0' ); END Clock_2_11 ;

HW 2-11 ARCHITECTURE KJH_Clock OF Clock_2_11 IS BEGIN clock_gen : PROCESS BEGIN BEGIN ClockOut <= '1'; WAIT FOR 10 ns ; ClockOut <= '1'; WAIT FOR 10 ns ; Clockout <= '0'; WAIT FOR 10 ns ; Clockout <= '0'; WAIT FOR 10 ns ; END PROCESS clock_gen ; END PROCESS clock_gen ; END KJH_Clock ;

SourcesSources ä VLSI, Ohio University, Prof. Starzyk ä Professor K.J. Hintz. ä California State University Northridge ä Prof. Krzysztof Kuchcinski