什么是VHDL中的位向量的否定(非)

JC2*_*JC2 5 vector vhdl bit

在VHDL中对位向量进行否定是什么意思?例如,如果我有10100111这是一个名为temp的位向量,我会做一些像temp:= not temp我的输出是什么?

Jan*_*uwe 9

有点反转.

通常在VHDL(LRM 7.2.1)中:"对于在一not维数组类型上定义的一元运算,对操作数的每个元素执行操作,结果是与操作数具有相同索引范围的数组. "


Hen*_*rik 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;
Run Code Online (Sandbox Code Playgroud)