VHDL中的位向量的否定意味着什么?例如,如果我有10100111这是一个叫temp的位矢量,我做了一些像temp:= not temp我的输出是什么?什么是VHDL中的位向量的否定(非)
4
A
回答
2
你可以使用“不”向量。用ModelSim或ISim运行下面的程序,反转/取反的位向量将被打印在控制台中。
LIBRARY ieee;
USE ieee.numeric_bit.ALL;
entity test is
end entity test;
architecture beh of test is
function vec_image(arg : bit_vector) return string is
-- original author Mike Treseler (http://mysite.ncnetwork.net/reszotzl/)
-- recursive function call turns ('1','0','1') into "101"
-------------------------------------------------------------------------------
constant arg_norm : bit_vector(1 to arg'length) := arg;
constant center : natural := 2; -- 123
variable bit_image : string(1 to 3); -- '0'
variable just_the_number : character;
begin
if (arg'length > 0) then
bit_image := bit'image(arg_norm(1)); -- 3 chars: '0'
just_the_number := bit_image(center); -- 1 char 0
return just_the_number -- first digit
& vec_image(arg_norm(2 to arg_norm'length)); -- rest the same way
else
return ""; -- until "the rest" is nothing
end if;
end function vec_image;
begin
demo:process is
variable bitvec : bit_vector (7 downto 0) := "10100111";
begin
report vec_image(bitvec);
report vec_image(not bitvec); -- not bit vector
wait;
end process demo;
end architecture beh;
7
按位反转。
一般在VHDL(LRM 7.2.1)中:“对于在一维数组类型上定义的一元操作not
,对操作数的每个元素执行操作,结果是具有相同索引的数组范围作为操作数“。
1
如果你真的想否定一个向量,你需要使用一个具有为它定义的某些属性的向量。具体做法是:
- 数值的一些概念(所以不能使用
bit_vector
或std_logic_vector
,它们只是位的集合) - “签到”
的一些概念从ieee.numeric_std
包,你应该使用signed
这个类型:
use ieee.numeric_std.all;
...
variable a,b:signed(8 downto 0);
...
a := "000000001";
b := -a;
相关问题
- 1. VHDL中的变量究竟是什么?
- 2. 使用VHDL中的向量
- 3. CSS绝对定位,什么是“非静态定位的祖先”?
- 4. VHDL - 将两个8位向量添加到一个9位向量中
- 5. VHDL向量传递
- 6. Haskell中的非确定性是什么?
- 7. NP中的非确定性是什么?
- 8. VHDL给定位数,是否有更清晰的方法来设置特定位?
- 9. 矢量中每个位的VHDL映射
- 10. 这是什么(非lambda?)“=>”C#中的变量定义?
- 11. 这个VHDL代码是做什么的?
- 12. C++中的位向量和位集之间有什么区别?
- 13. 在序言中,按位否定运算符(\)是做什么的?
- 14. 将非www重定向到www的最佳方法是什么?
- 15. 什么是量角器/ WebDriverJS中的by.js定位器?
- 16. 什么是m-ary向量?
- 17. 是什么字向量维
- 18. 什么是位矢量?
- 19. 带有32位向量的VHDL OR逻辑
- 20. VHDL - 与向量和位之间的操作
- 21. 什么是定量?
- 22. JavaScript中if(变量)的确切否定是什么?
- 23. addview的位置常量是什么
- 24. 为什么allocator在向量中是const?
- 25. 流星:重定向后的最终位置/网址是什么?
- 26. 什么是非破坏性的替代方法存在于类向量中c
- 27. 什么变量决定了环绕插件中非焦点元素的位置?
- 28. 如何比较VHDL中的整数?我的错误是什么?
- 29. 串联VHDL中的位
- 30. 无法在VHDL中拆分向量
感谢那正是我正在寻找。 – JC2 2011-02-03 13:13:38