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.

  • 相关阅读:
    JAVA中重写equals()方法为什么要重写hashcode()方法说明
    深入浅出UML类图
    UML解惑:图说UML中的六大关系
    maven自动打包上传nexus仓库配置
    vi查找替换命令详解
    Maven运行JUnit测试(http://www.360doc.com/content/13/0927/15/7304817_317455642.shtml)
    Maven 排除依赖jar包
    2、【Spark】Spark环境搭建(集群方式)
    1、【Spark】Spark安装
    Centos7 执行firewall-cmd –permanent –add-service=mysql报错“ModuleNotFoundError: No module named 'gi'”
  • 原文地址:https://www.cnblogs.com/mengdie/p/4433126.html
Copyright © 2011-2022 走看看