VHDLでビットベクトルの否定を行うとはどういう意味ですか?たとえば、tempと呼ばれるビットベクトルである10100111があり、temp:= not tempのようなことをした場合、出力はどうなりますか?
57661 次
3 に答える
10
ビット単位の反転。
一般に、VHDL(LRM 7.2.1)では次のようになります。「1次元配列型で定義された単項演算の場合、演算not
はオペランドの各要素で実行され、結果はオペランドと同じインデックス範囲の配列になります。 「」
于 2011-02-03T09:20:23.330 に答える
3
ベクトルには「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;
于 2011-02-03T08:44:58.050 に答える
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;
于 2011-02-03T12:01:05.923 に答える