1
2의 보수로 std_logic_vector를 변환하려고합니다. 벡터에 -2 곱하기를 수행하려고합니다.std_logic_vector의 2의 보수
library ieee;
use ieee.std_logic_1164.all;
entity twoscomplement is
port (x : in std_logic_vector(15 downto 0);
y : out std_logic_vector(15 downto 0)
);
end entity;
architecture model of twoscomplement is
signal x_c : std_logic_vector (15 downto 0);
x_c <= (not(x) +'1')*2 ; -- x_c = -2*x
end model;
귀하의 특정 질문은 무엇입니까? 처리해야 할 오류가 있습니까? – user1155120
신호 x_c 선언 다음에'begin'이 없습니다. 'use ieee.numeric_std.all;','x_c <= std_logic_vector (shift_left (부호가없는 (x) + 1, 1)이 아님);)의 사용 조항이 추가 된 -2008 이전의 경우, x와 일치하는 결과 길이를가집니다. -2008의 경우 use useeeee.numeric_std_unsigned.all; 및 x_c <= shift_left ((x + 1)이 아닌), 1). "*"를 사용하면 결과 길이가 늘어납니다. 표준 패키지 사용 안내서를 참조하십시오 IEEE Std 1076-2008 G.3.5.1 나머지가있는 2의 제곱으로 곱하기 – user1155120
'std_logic_vector '의 2의 보수를 취하지 마십시오. 'numeric_std.signed'의 2의 보수를 취하십시오. –