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.

 ------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.all;
------------------------------------------------
PACKAGE my_package IS
TYPE state IS (st1, st2, st3, st4);
TYPE color IS (red, green, blue);
CONSTANT vec: STD_LOGIC_VECTOR( DOWNTO ) := "";
END my_package;
------------------------------------------------

  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.

 ------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE work.my_package.all;
------------------------------------
ENTITY...
...
ARCHITECTURE...
...
------------------------------------

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.

VHDL之package的更多相关文章

  1. 第二章:systemverilog声明的位置

    1.package 定义及从package中导入定义(***) verilog中,对于变量.线网.task.function的声明必须在module和endmodule之间.如果task被多个modu ...

  2. VHDL学习札记:library and Package

     参考:http://www.cnblogs.com/garylee/archive/2012/11/16/2773596.htmlhttp:// http://forums.xilinx.com ...

  3. 让WPS支持VHDL的关键词加粗

    WPS的VBA在这里下载:http://bbs.wps.cn/forum.php?mod=viewthread&tid=22347925 语法高亮是参考Word的,这篇文章:http://bl ...

  4. VHDL学习之TEXTIO在仿真中的应用

    TEXTIO 在VHDL 仿真与磁盘文件之间架起了桥梁,使用文本文件扩展VHDL 的仿真功能.本文介绍TEXTIO 程序包,以一个加法器实例说明TEXTIO 的使用方法,最后使用ModelSim 对设 ...

  5. VHDL基础2

    Signals & Variables VHDL 提供了 signal 和 variable 两种对象来处理非静态数据:提供了 constant 和 generic 来处理静态数据. cons ...

  6. VHDL基础1

    Description Structure 一个可综合的VHDL描述中一般由3部分组成:LIBRARY declarations.ENTITY.ARCHITECTURE Library(库)用来设计重 ...

  7. 基于VHDL利用PS2键盘控制的电子密码锁设计

    基于VHDL利用PS2键盘控制的密码锁设计 附件:下载地址 中文摘要 摘 要:现代社会,人们的安全意识正在不断提升.按键密码锁由于其具有方便性.低成本等特征,还是大有用武之地的.但是通常的按键密码锁开 ...

  8. 毕业设计预习:VHDL入门知识学习(一) VHDL程序基本结构

    VHDL入门知识学习(一) VHDL程序基本结构 简介 VHDL程序基本结构 简介 概念: HDL-Hardware Description Language-硬件描述语言-描述硬件电路的功能.信号连 ...

  9. VHDL入门学习-程序组成

    1. VHDL程序的组成 一个完整的VHDL程序是以下五部分组成的: 2. 库(LIBRARY):比较好理解,调用系统已有的库,WORK库就是用户当前编辑文件所在的文件夹, IEEE库:由IEEE(美 ...

随机推荐

  1. PAT_A1125#Chain the Ropes

    Source: PAT A1125 Chain the Ropes (25 分) Description: Given some segments of rope, you are supposed ...

  2. 【剑指Offer】43、左旋转字符串

      题目描述:   汇编语言中有一种移位指令叫做循环左移(ROL),现在有个简单的任务,就是用字符串模拟这个指令的运算结果.对于一个给定的字符序列S,请你把其循环左移K位后的序列输出.例如,字符序列S ...

  3. HTTP 状态码 301 和 302 详解及区别——辛酸的探索之路

    转自:http://blog.csdn.net/grandpang/article/details/47448395 一直对http状态码301和302的理解比较模糊,在遇到实际的问题和翻阅各种资料了 ...

  4. [luogu2054 AHOI2005] 洗牌 (数论)

    传送门 Solution 我们考虑每一步牌的变化: 前半部分的牌位置*2 后半部分的牌位置*2-n-1 那么我们可以看做是\(x\times 2^m\equiv l \pmod n\) 于是求个逆元就 ...

  5. 【习题 4-5 Uva1590】 IP Networks

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 假设从第i位开始有不一样的. 那么就把i+1..32位全都置0. 掩码的话类似.前i为全为1,后面32-i位全0. 尽量让后面的连续 ...

  6. Locally managed (LMT) vs. Dictionary managed (DMT) tablespace

    The LMT is implemented by adding the extent management local clause to the tablespace definition syn ...

  7. hdu 2897简单博弈

    #include<stdio.h> int main() {     int n,p,q,k;    while(scanf("%d%d%d",&n,& ...

  8. CodeForces - 445A - DZY Loves Chessboard

    先上题目: A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input ...

  9. 【ACM】hdu_zs1_1001_水仙花数_201307271504

    水仙花数 Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)Total Submissio ...

  10. 这篇文章关于两阶段提交和Paxos讲的很好

    http://blog.chinaunix.net/uid-16723279-id-3803058.html <两阶段提交协议与paxos投票算法> 点评:2PC绝对是CP的死党,是分布式 ...