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 COMPONENTS, FUNCTIONS, 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: 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 on the SIGNED and UNSIGNED types.
- contains useful type conversions functions.
VHDL之package的更多相关文章
- 第二章:systemverilog声明的位置
1.package 定义及从package中导入定义(***) verilog中,对于变量.线网.task.function的声明必须在module和endmodule之间.如果task被多个modu ...
- VHDL学习札记:library and Package
参考:http://www.cnblogs.com/garylee/archive/2012/11/16/2773596.htmlhttp:// http://forums.xilinx.com ...
- 让WPS支持VHDL的关键词加粗
WPS的VBA在这里下载:http://bbs.wps.cn/forum.php?mod=viewthread&tid=22347925 语法高亮是参考Word的,这篇文章:http://bl ...
- VHDL学习之TEXTIO在仿真中的应用
TEXTIO 在VHDL 仿真与磁盘文件之间架起了桥梁,使用文本文件扩展VHDL 的仿真功能.本文介绍TEXTIO 程序包,以一个加法器实例说明TEXTIO 的使用方法,最后使用ModelSim 对设 ...
- VHDL基础2
Signals & Variables VHDL 提供了 signal 和 variable 两种对象来处理非静态数据:提供了 constant 和 generic 来处理静态数据. cons ...
- VHDL基础1
Description Structure 一个可综合的VHDL描述中一般由3部分组成:LIBRARY declarations.ENTITY.ARCHITECTURE Library(库)用来设计重 ...
- 基于VHDL利用PS2键盘控制的电子密码锁设计
基于VHDL利用PS2键盘控制的密码锁设计 附件:下载地址 中文摘要 摘 要:现代社会,人们的安全意识正在不断提升.按键密码锁由于其具有方便性.低成本等特征,还是大有用武之地的.但是通常的按键密码锁开 ...
- 毕业设计预习:VHDL入门知识学习(一) VHDL程序基本结构
VHDL入门知识学习(一) VHDL程序基本结构 简介 VHDL程序基本结构 简介 概念: HDL-Hardware Description Language-硬件描述语言-描述硬件电路的功能.信号连 ...
- VHDL入门学习-程序组成
1. VHDL程序的组成 一个完整的VHDL程序是以下五部分组成的: 2. 库(LIBRARY):比较好理解,调用系统已有的库,WORK库就是用户当前编辑文件所在的文件夹, IEEE库:由IEEE(美 ...
随机推荐
- Coloring Flame Graphs: Code Hues
转自:http://www.brendangregg.com/blog/2017-07-30/coloring-flamegraphs-code-type.html I recently improv ...
- SSL/TLS 加密新纪元 - Let's Encrypt
转自: https://linux.cn/article-6565-1.html SSL/TLS 加密新纪元 - Let's Encrypt 根据 Let's Encrypt 官方博客消息,Let's ...
- webpack学习笔记(1)--webpack.config.js
主要的信息都是来自于下方所示的网站 https://webpack.docschina.org/configuration 从 webpack 4.0.0 版本开始,可以不用通过引入一个配置文件打包项 ...
- UVA1339 - Ancient Cipher 【字符串+排序】【紫书例题4.1】
题意:给定两个字符串,你可以替换或者置换,替换是指可以将相同的字母替换为任意一个字母,而置换是指将字母替换为下一个,如A替换B,B替换为C,,,Z替换为A.你需要判断是否可以通过一系列操作使两个字符串 ...
- openc下cv::Mat和IplImage的相互转换
opencv2.0的类CV::Mat和opencv1.0的IplImage之间烦人转换: cv::Mat matimg = cv::imread ("girl.jpg"); Ipl ...
- 关于git修改和查看用户名邮箱
git 查看/修改用户名.密码 查看用户名和邮箱地址: $ git config user.name $ git config user.email 修改用户名和邮箱地址: $ git config ...
- Class 找出一个整形数组中的元素的最大值
目的:找出一个整形数组中的元素的最大值 以下,我们用类和对象的方法来做. #include<iostream> using namespace std; class Array_m ...
- iOS 加入粘贴板的功能(复制功能)
1. UIPasteboard *board = [UIPasteboard generalPasteboard]; board.string = @" 须要粘贴的问题字符串" ...
- MongoDB 索引的使用, 管理 和优化
MongoDB 索引的使用, 管理 和优化 2014-03-25 17:12 6479人阅读 评论(0) 收藏 举报 分类: MongoDB(9) [使用explain和hint] 前面讲高级查询 ...
- 1-1restful简介及资源介绍