在VHDL中对位向量进行否定是什么意思?例如,如果我有10100111这是一个名为temp的位向量,我会做一些像temp:= not temp我的输出是什么?
您可以在向量上使用“not”。只需使用 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;
Run Code Online (Sandbox Code Playgroud)