有关conv_std_logic_vector和conv_integer
std_logic_arith
This is the library that defines some types and basic arithmetic operations for representing integers in standard ways. This is a Synopsys extention. The source code is instd_logic_arith.vhd and is freely redistributable.
The unsigned type
The signed type
The arithmetic functions: +, -, *
The comparison functions: <, <=, >, >=, =, /=
The shift functions: shl, shr
The conv_integer function
The conv_unsigned function
The conv_signed function
The conv_std_logic_vector function
-------------------------------------------------------------------------------------------------------------------------------
The conv_integer function
function conv_integer(arg: integer) return integer;
function conv_integer(arg: unsigned) return integer;
function conv_integer(arg: signed) return integer;
function conv_integer(arg: std_ulogic) return small_int;
These functions convert the arg argument to an integer. If the argument contains any undefined elements, a runtime warning is produced and 0 is returned.
The function provided by the std_logic_arith library can't convert a std_logic_vector to an integer because it is impossible to determine if it represents an unsigned or signed value.Functions that do this are included in the std_logic_unsigned and std_logic_signed libraries.
Examples
signal b : std_logic;
signal u1 : unsigned (3 downto 0);
signal s1 : signed (3 downto 0);
signal i1, i2, i3 : integer;
...
u1 <= "1001";
s1 <= "1001";
b <= 'X';
wait for 10 ns;
i1 <= conv_integer(u1); -- 9
i2 <= conv_integer(s1); -- -7
i3 <= conv_integer(b); -- warning produced in simulator
以上蓝字说明了一切
1.前一个包含在std_logic_arith.all程序包中
2.后一个在std_logic_unsigned 和std_logic_signed 中都有包含
计算机中的运算都是用2进制补码的,本人总结,在做算法时候,包含std_logic_signed 这个包比较好,这样conv_integer 就把需要转换的数据变成了带符号的整数,然而std_logic_unsigned就把需要转换的数据变成了无符号的整数。
3. conv_std_logic_vector 函数的转换结果是将被转换的数据先转换成2进制补码形式,然后取其低“位长”,作为输出。
如:a<=conv_std_logic_vector(-79,6)----(-79)2c=(10110001)
b<=conv_std_logic_vector(-2,6)-----(-2)2c=(11111110)
c<=conv_std_logic_vector(100,6)-----(100)2c=(01100100)
输出结果:a=110001,b=111110,c=100100
4.本人做了这样的转换conv_std_logic_vector (conv_integer (data),16),data是16范围内的有符号数,但是接口是32位的标准矢量形式(std_logic_vector(31 downto 0)刚开始包括的是std_logic_unsigned 包,发现数据变得面目全非了,想来想去,认为conv_integer (data)的原因,就该了下包,结果就正确了。
有关conv_std_logic_vector和conv_integer的更多相关文章
- VHDL学习之TEXTIO在仿真中的应用
TEXTIO 在VHDL 仿真与磁盘文件之间架起了桥梁,使用文本文件扩展VHDL 的仿真功能.本文介绍TEXTIO 程序包,以一个加法器实例说明TEXTIO 的使用方法,最后使用ModelSim 对设 ...
- VHDL数据类型转换
函 数 名 功 能 STD_LOGIC_1164包集合 TO_STDLOG ...
- VHDL 类型转换
STD_LOGIC_1164包集合 函 数 名 功 能 TO_STDLOGICVECTOR(A) 由BIT_VECTOR转换为STD_LOGIC_VECTOR TO_BITVECTOR(A) 由STD ...
- VHDL基础1
Description Structure 一个可综合的VHDL描述中一般由3部分组成:LIBRARY declarations.ENTITY.ARCHITECTURE Library(库)用来设计重 ...
- VHDL和verilog应该先学哪个?
网上有太多的VHDL和verilog比较的文章,基本上说的都是VHDL和verilog之间可以实现同一级别的描述,包括仿真级.寄存器传输级.电路级,所以可以认为两者是等同级别的语言.很多时候会了其中一 ...
- VHDL 数字时钟设计
序言 这个是我在做FPGA界的HelloWorld--数字钟设计时随手写下的,再现了数字钟设计的过程 目标分析 时钟具有时分秒的显示,需6个数码管.为了减小功耗采用扫描法显示 按键设置时间,需要对按键 ...
- 嵌入式CISC模型机设计
一. 课程设计的题目和内容 题目:设计一台嵌入式CISC模型计算机 采用定长CPU周期.联合控制方式,并运行能完成一定功能的机器语言源程序进行验证,机器语言源程序功能如下: 任意输入5个整数, ...
随机推荐
- Plotting trees from Random Forest models with ggraph
Today, I want to show how I use Thomas Lin Pederson's awesome ggraph package to plot decision trees ...
- VR全景智慧城市--2017年VR项目加盟将是一个机遇
全景智慧城市项目是河南艺境空间文化传播有限公司自主开发的国内第一家商业全景平台, 旨在构建全景城市,实现智慧生活,让人们随时随地身临其境拥有全世界,享受快捷.真实.趣味.优质生活. 以VR虚拟现实技术 ...
- JVM-2.Class文件结构
1.Class文件 (1)无关性:除了平台无关性,JVM还支持语言无关性:目前Clojure.Groovy.JRuby.Jyphon.Scala等语言可以在JVM上运行.实现语言无关性的原理仍然是字节 ...
- 设计模式二:MVC
先附上部分代码: /* *MVC 模式代表 Model-View-Controller(模型-视图-控制器) 模式.这种模式用于应用程序的分层开发. *Model(模型) - 模型代表一个存取数据的对 ...
- Javascript及Jquery获取元素节点以及添加和删除操作
用了javascript和jquery很久,把所有元素节点的操作总结了下,放在博客上作为记录. Javascript获取元素的主要方式有三种 1.document.getElementById('ma ...
- git clone https://github.com/istester/ido.git ,确提示“Failed to connect to 192.168.1.22 port 8080: Connection refused” 的解决办法 。
不知道是否有同学遇到如下的问题: p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo } span.s1 { } git clone ...
- 一些JQuery使用技巧
最近做项目,在使用JQuery中遇到一些问题记录下. 1.根据Id查询父级内容,或者父级的父级 之前会使用$("#id").parent().parent(): 这种使用有很大的弊 ...
- SQL中创建外键约束
alter table 表名 add constraint 外键约束名 foreign key(列名) references 引用外键表(列名)
- Caused by: java.lang.RuntimeException: by java.lang.OutOfMemoryError: PermGen space(tomcat 启动时提示内存溢出)
设置MaxPermSize大小TOMCAT_HOME/bin/catalina.bat 文件头加set JAVA_OPTS='-Xms512m -Xmx1024m -XX:MaxPermSize=51 ...
- Primeton BPS 6.7+MyEclipse_5.5.1GA_E3.2.2插件安装
准备 Primeton_BPS_6.7_Developer MyEclipse5.5插件版 BPS安装 MyEclipse插件安装 点击MyEclipse_5.5.1GA_E3.2.2_Install ...