zoukankan      html  css  js  c++  java
  • VHDL之package

      

    Pacakge

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

    1  Syntax

      Besides COMPONENTSFUNCTIONS, and PROCEDURES, it can also contain TYPE and CONSTANT definitions, 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

      It shows a PACKAGE called my_package. It contains only TYPE and 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 be compiled, becoming then part of our work LIBRARY (or any other). To make use of it in a VHDL code, we have to add a new USE clause to the main code (USE work.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_std defines numeric types and arithmetic functions for use with synthesis tools.

       - two numeric types are defined: UNSIGNEDSIGNED (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 on the SIGNED and UNSIGNED types.

       - contains useful type conversions functions.

  • 相关阅读:
    把VB.NET代码转换为C#代码的方法
    离散数学 第二章 谓词逻辑 26 前束范式
    离散数学 第二章 谓词逻辑 27 谓词演算的推理理论
    asp.net中怎样用Javascript控制RequiredFieldValidator控件什么时候启用,什么时候不启用验证?
    离散数学中的IFF标记
    BIRT Overview
    离散数学 第二章 谓词逻辑 25 谓词演算的等价式和蕴涵式
    getRemoteAddr()和getRemoteHost()的区别
    scp 不用密码
    利用spring实现javamail功能
  • 原文地址:https://www.cnblogs.com/mengdie/p/4433126.html
Copyright © 2011-2022 走看看