新濠天地 > 新濠编程网 > 新濠天地VHDL之package

原标题:新濠天地VHDL之package

浏览次数:132 时间:2019-09-23

  

Pacakge

  Frequently used pieces of VHDL code are usually written in theform of COMPONENTS, FUNCTIONS, or PROCEDURES. Such codes are thenplaced inside a PACKAGE and compiled into the destination LIBRARY.

新濠天地 1

1  Syntax

  Besides COMPONENTS,FUNCTIONS, and PROCEDURES新濠天地,, it can also contain TYPE and CONSTANTdefinitions, among others. Its syntax is presented below.

PACKAGE package_name IS    (declarations)END package_name;[PACKAGE BODY package_name IS    (FUNCTION and PROCEDURE descriptions)END package_name;]

2  Simple Package

  Itshows a PACKAGE called my_package. It contains only TYPEand CONSTANT declarations, so a PACKAGE BODY is not necessary.

 1 ------------------------------------------------ 2 LIBRARY ieee; 3 USE ieee.std_logic_1164.all; 4 ------------------------------------------------ 5 PACKAGE my_package IS 6 TYPE state IS (st1, st2, st3, st4); 7 TYPE color IS (red, green, blue); 8 CONSTANT vec: STD_LOGIC_VECTOR(7 DOWNTO 0) := "11111111"; 9 END my_package;10 ------------------------------------------------

  The PACKAGE above can now becompiled, becoming then part of our work LIBRARY (or any other). To make useof it in a VHDL code, we have to add a new USE clause to the main code (USEwork.my_package.all), as shown below.

 1 ------------------------------------ 2 LIBRARY ieee; 3 USE ieee.std_logic_1164.all; 4 USE work.my_package.all; 5 ------------------------------------ 6 ENTITY... 7 ... 8 ARCHITECTURE... 9 ...10 ------------------------------------

3  Package in ASIC

  In ASIC design, use ieee.std_logic_1164, and ieee.numeric_std, NEVER use ieee.std_logic_arith

  numeric_stddefines numeric types and arithmetic functionsfor use with synthesis tools.

   - two numeric types are defined:UNSIGNED,SIGNED (represents a SIGNED number in vector form)

   - base element type is type STD_LOGIC.The leftmost bit is treated as the most significant bit.

   - signed vectors are represented in two's complement form.

   - contains overloaded arithmetic operators onthe SIGNED and UNSIGNED types.

   - containsuseful type conversions functions.

本文由新濠天地发布于新濠编程网,转载请注明出处:新濠天地VHDL之package

关键词:

上一篇:在符号表中归入常量,const将兼具全局生命周期的

下一篇:切入hello.js所在文件夹