Packages and Use Clauses Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.

Slides:



Advertisements
Similar presentations
Sequential Statements
Advertisements

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.
Comprehensive VHDL Module 6 Types November Comprehensive VHDL: Types Copyright © 2000 Doulos Types Aim ©To understand the use and synthesis.
VHDL Data Types Module F3.1. VHDL Data Types Scalar Integer Enumerated Real (floating point)* Physical* Composite Array Record Access (pointers)* * Not.
ECE C03 Lecture 18ECE C03 Lecture 61 Lecture 18 VHDL Modeling of Sequential Machines Prith Banerjee ECE C03 Advanced Digital Design Spring 1998.
ELEN 468 Lecture 191 ELEN 468 Advanced Logic Design Lecture 19 VHDL.
Topics of Lecture Structural Model Procedures Functions Overloading.
VHDL And Synthesis Review. VHDL In Detail Things that we will look at: –Port and Types –Arithmetic Operators –Design styles for Synthesis.
Programming in VHDL Using Processes. How Processes Run A process is either in suspend mode or is running. For a process to run, there has to be a change.
ECE C03 Lecture 141 Lecture 14 VHDL Modeling of Sequential Machines Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
1 Lecture 11 Chap 13: Test Benches Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Lecture #6 Page 1 Lecture #6 Agenda 1.VHDL - Architecture 2.VHDL - Packages Announcements 1.HW #3 assigned ECE 4110– Sequential Logic Design.
Concordia University 1 Lecture #8 In this lecture we will cover the following material: The standard package, The std_logic_1164  Objects & data Types.
Resolved Signals Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Design Organization and Parameterization Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
1 Part I: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
A VHDL Tutorial ENG2410. ENG241/VHDL Tutorial2 Goals Introduce the students to the following: –VHDL as Hardware description language. –How to describe.
IAY 0600 Digital Systems Design
Lecture 3 Chap 4 Types Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Capt Michael Tanner Room 2F46A
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.
1 Introduction to VHDL Spring What is VHDL? VHDL can be uses to model and synthesise digital systems. VHDL = VHSIC Hardware Description Language.
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.
Lecture 5 Chap 6 Package std_logic_arith Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
VHDL Very High Speed Integrated Circuit Hardware Description Language Shiraz University of shiraz spring 2011.
Generate Statements Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Design Methodology Based on VHDL Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
INTRO TO VLSI DESIGN (CPE 448) (VHDL Tutorial ) Prof: Asuif Mahmood.
VHDL Basics. VHDL BASICS 2 OUTLINE –Component model –Code model –Entity –Architecture –Identifiers and objects –Operations for relations VHDL ET062G &
Introduction to VHDL Simulation … Synthesis …. The digital design process… Initial specification Block diagram Final product Circuit equations Logic design.
Lecture #7 Page 1 Lecture #7 Agenda 1.VHDL Data Types Announcements 1.n/a ECE 4110– Digital Logic Design.
Aliases Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Lecture 7 Chap 9: Registers Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
L19 – Resolved Signals. Resolved Signals  What are resolved signals In systems In VHDL Resolution – Isn’t that for resolving conflicts?  Ref: text Unit.
IAY 0600 Digital Systems Design
DATA TYPES 1.Pre-Defined Data Types 2. User-Defined Data Types.
Concordia University 1 Lecture #8 In this lecture we will cover the following material: The standard package, The std_logic_1164  Objects & data Types.
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.
8-Jan-16EE5141 Chapter 6 Subprograms & Packages Subprogram declaration Subprogram body Package declaration Package body Resolution function Subprogram.
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
ECOM 4311—Digital System Design with VHDL
BASIC VHDL LANGUAGE ELEMENTS Digital Design for Instrumentation with VHDL 1.
VHDL Discussion Subprograms IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
VHDL Programming Fundamentals Presented By Dr. Pradyut Kumar Biswal Department of Electronics, IIIT Bhubaneswar.
Advanced FPGA Based System Design Lecture-6 & 7 VHDL Data Types By: Dr Imtiaz Hussain 1.
Subprograms Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Signals & Data-typesVer 1.1, Copyright 1997, TS, Inc. VHDL S i g n a l s & D a t a T y p e s Page 1.
Case Study: Xilinx Synthesis Tool (XST). Arrays & Records 2.
Composite Data Types and Operations Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
EGRE 6311 LHO 04 - Subprograms, Packages, and Libraries EGRE 631 1/26/09.
1 Introduction to Engineering Spring 2007 Lecture 18: Digital Tools 2.
1 Introduction to Engineering Spring 2007 Lecture 19: Digital Tools 3.
IAY 0600 Digital Systems Design
Basic Language Concepts
Subject Name: FUNDAMENTALS OF HDL Subject Code: 10EC45
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
ECE 4110–5110 Digital System Design
CPE 528: Session #7 Department of Electrical and Computer Engineering University of Alabama in Huntsville.
ECE 434 Advanced Digital System L17
RTL Style در RTL مدار ترتيبي به دو بخش (تركيبي و عناصر حافظه) تقسيم مي شود. مي توان براي هر بخش يك پروسس نوشت يا براي هر دو فقط يك پروسس نوشت. مرتضي صاحب.
CPE/EE 422/522 Advanced Logic Design L11
IAS 0600 Digital Systems Design
CPE 528: Lecture #5 Department of Electrical and Computer Engineering University of Alabama in Huntsville.
CPE 528: Lecture #3 Department of Electrical and Computer Engineering University of Alabama in Huntsville.
IAS 0600 Digital Systems Design
VHDL Data Types Module F3.1.
EEL4712 Digital Design (VHDL Tutorial).
Presentation transcript:

Packages and Use Clauses Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University

Outline Package Declarations Package bodies Use Clauses Standard Packages

Package Declarations Packages in VHDL provide an important way of organizing the data and subprograms declared in a model, for example a package may be – A set of subprograms that provide operations on a particular type of data – Set of declarations needed to model a particular design Related info. can be collected into a design unit (i.e. package)

Package Declarations Packages separate the external view of the items they declare from the implementation of those items (information hiding). – External view: package declaration – Implementation: package body

Package Declarations EBNF: see page 232 Example (Figure 8.1): package cpu_types is constant word_size : positive := 16; constant address_size : positive := 24; subtype word is bit_vector(word_size - 1 downto 0); subtype address is bit_vector(address_size - 1 downto 0); type status_value is ( halted, idle, fetch, mem_read, mem_write, io_read, io_write, int_ack ); end package cpu_types;

Package Declarations Package declarative item – Type – Subtype – Constant – Signal – Subprograms – Alias – …

Package Declarations A package is another form of design unit A package is analyzed and placed into the working directory as a library unit Selected name of an item in a package – Library_Name.Package_Name.item – Ex. Work.cpu_type.status_value – Ex. Fig 8.2 Packages can be shared among models – Ex. Fig 8.3, 8.4 and 8.5

entity address_decoder is port ( addr : in work.cpu_types.address; status : in work.cpu_types.status_value; mem_sel, int_sel, io_sel : out bit ); end entity address_decoder; architecture functional of address_decoder is constant mem_low : work.cpu_types.address := X"000000"; constant mem_high : work.cpu_types.address := X"EFFFFF"; constant io_low : work.cpu_types.address := X"F00000"; constant io_high : work.cpu_types.address := X"FFFFFF"; begin mem_decoder : mem_sel <= '1' when ( work.cpu_types."="(status, …. end architecture functional; Fig 8.2

library ieee; use ieee.std_logic_1164.all; package clock_pkg is constant Tpw : delay_length := 4 ns; signal clock_phase1, clock_phase2 : std_ulogic; end package clock_pkg; Fig 8.3 library ieee; use ieee.std_logic_1164.all; entity io_controller is port ( ref_clock : in std_ulogic; ); end entity io_controller; architecture top_level of io_controller is begin internal_clock_gen : entity work.phase_locked_clock_gen(std_cell) port map ( reference => ref_clock, phi1 => work.clock_pkg.clock_phase1, phi2 => work.clock_pkg.clock_phase2 ); end architecture top_level; Fig 8.4

architecture fsm of bus_sequencer is -- NOTE: it uses the clock signals from clock_pkg to synchronize the fsm. signal next_state_vector : --...; begin bus_sequencer_state_register : entity work.state_register(std_cell) port map ( phi1 => work.clock_pkg.clock_phase1, phi2 => work.clock_pkg.clock_phase2, next_state => next_state_vector, ); end architecture fsm; Fig 8.5

Package Declarations Note different VHDL suites provide different ways of specifying the library into which a library unit is placed. Global signals can be declared in packages. – A global signal can affect overall behavior of a system (not by port but by global signal) – Global signals should be used sparingly. – Ex Fig 8.3

Subprograms, constants in Package Declaration Constants, Procedures and functions can be declared in a package Example: subtype word32 is bit_vector(31 downto 0); procedure add ( a, b : in word32; result : out word32; overflow : out boolean ); function "<" ( a, b : in word32 ) return boolean; constant max_buffer_size : positive ;

package cpu_types is -- a revised version of Fig 8.1 constant word_size : positive := 16; constant address_size : positive := 24; subtype word is bit_vector(word_size - 1 downto 0); subtype address is bit_vector(address_size - 1 downto 0); type status_value is ( halted, idle, fetch, mem_read, mem_write, io_read, io_write, int_ack ); subtype opcode is bit_vector(5 downto 0); function extract_opcode ( instr_word : word ) return opcode; constant op_nop : opcode := "000000"; constant op_breq : opcode := "000001"; constant op_brne : opcode := "000010"; constant op_add : opcode := "000011"; end package cpu_types; Fig 8.6

architecture behavioral of cpu is begin interpreter : process is variable instr_reg : work.cpu_types.word; variable instr_opcode : work.cpu_types.opcode; begin initialize loop fetch instruction instr_opcode := work.cpu_types.extract_opcode( instr_reg ); case instr_opcode is when work.cpu_types.op_nop => null; when work.cpu_types.op_breq =>... … end case; end loop; end process interpreter; end architecture behavioral; Fig 8.7

Package Body Package declarations provide external views (interfaces) and package bodies provide the implementation (information hiding) If a package declaration only includes types, signals, constants, then there is no need to have package body EBNF: see page 239 The package_body_declarative_item must include the full declarations (implementation) of all subprograms defined in the corresponding package declaration.

package bit_vector_signed_arithmetic is function "+" ( bv1, bv2 : bit_vector ) return bit_vector; function "-" ( bv : bit_vector ) return bit_vector; function "*" ( bv1, bv2 : bit_vector ) return bit_vector; end package bit_vector_signed_arithmetic; Fig 8.8

package body bit_vector_signed_arithmetic is function "+" ( bv1, bv2 : bit_vector ) return bit_vector is function "-" ( bv : bit_vector ) return bit_vector is function mult_unsigned ( bv1, bv2 : bit_vector ) return bit_vector is return bit_vector( "*"(unsigned(bv1), unsigned(bv2)) ); end function mult_unsigned; function "*" ( bv1, bv2 : bit_vector ) return bit_vector is begin if bv1(bv1'left) = '0' and bv2(bv2'left) = '0' then return mult_unsigned(bv1, bv2); elsif bv1(bv1'left) = '0' and bv2(bv2'left) = '1' then return -mult_unsigned(bv1, -bv2); elsif bv1(bv1'left) = '1' and bv2(bv2'left) = '0' then return -mult_unsigned(-bv1, bv2); else return mult_unsigned(-bv1, -bv2); end if; end function "*"; end package body bit_vector_signed_arithmetic; Fig 8.8

Package Body A package declaration is a primary design unit A package body is a secondary design unit Package declarations and package bodies are analyzed separately – Package declarations must be analyzed before the declaration bodies – Package declarations must be analyzed before any other design units refer to them.

Use Clauses Use clause can make a library unit directly visible in a model, allowing us to omit the library name when referring to the library unit. Library clause makes the contents of the library accessible to the model and the use clause import the type names. EBNF: see page 241 Example: use work.cpu_types; variable data_word : cpu_types.word; variable next_address : cpu_types.address;

Use Clauses Another Example: use work.cpu_types.word, work.cpu_types.address; variable data_word : word; variable next_address : address; Importing all of the names defined in a package: library.package.ALL – Example: use ieee.std_logic_1164.all;

architecture behavioral of cpu is begin interpreter : process is use work.cpu_types.all; variable instr_reg : word; variable instr_opcode : opcode; begin initialize loop fetch instruction instr_opcode := extract_opcode ( instr_reg ); case instr_opcode is when op_nop => null; when op_breq => end case; end loop; end process interpreter; end architecture behavioral; Fig 8.9

Predefined Package Standard Standard package defines some contents that will be used for all designs (Appendix B) – TYPE: boolean, bit, character, sensitive_level, integer, time, bit_vector – SUBTYPE: natural, positive, delay_length – Function: now, (>,<,… for integer, bit_vector,..) VHDL includes an implicit context clause library std, work, use std.standard.all at the beginning of each design unit.

function "<" ( a, b : bit_vector ) return boolean is variable tmp1 : bit_vector(a'range) := a; variable tmp2 : bit_vector(b'range) := b; begin tmp1(tmp1'left) := not tmp1(tmp1'left); -- negate signed bit tmp2(tmp2'left) := not tmp2(tmp2'left); return std.standard."<" ( tmp1, tmp2 ); end function "<"; Fig 8.10

IEEE Standard Packages IEEE has published standards for packages that define commonly used data types and operations. – Using these standards can save us development time – Many tool vendors provide optimized implementations of these IEEE standard packages – Packages: std_logic_1164, numeric_bit and numeric_std, math_real, math_complex,

IEEE std_logic_1164 IEEE standard package std_logic_1164 defines types and operations for models that need to deal with strong, weak and high- impedance strength and with unknown values – Multi-value logic systems Check types and functions in your CAD tools

Standard VHDL Synthesis Package IEEE standard packages numeric_bit and numeric_std define arithmetic operations on integers represented using vectors of bit and std_logic element respectively Most synthesis tools accept models using these types and operations for numeric computations IEEE standard for synthesizable models specifies that these are the only types that can be used

Standard VHDL Synthesis Package Appendix A describes the topics of synthesis of VHDL model in more detail. Appendix C lists numeric_bit and numeric_std packages See Fig 8.11 on page 247

Standard VHDL Math Packages IEEE standard packages math_real and math_complex define constants and mathematical functions on real and complex numbers, respectively See appendix C.

Multi-value Logic (std_logic) Value Representing ==================== '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 std_logic satisfies most hardware design needs

AND table for std_logic type