VHDL shift_right 数
VHDL shift_right number
我想将一个数字除以 512,这意味着我需要将它移动 9。例如,在我的代码中,我想将二进制形式的数字 26 乘以 100,然后除以 512。但是我需要做的不是除以 512,而是将数字 26*100 右移 9 次。但是当我执行 shift_right
命令时,出现以下错误:
Error (10511): VHDL Qualified Expression error at Multiplier_VHDL .vhd(34): SHIFT_RIGHT type specified in Qualified Expression must match std_logic_vector type that is implied for expression by context
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity Multiplier_VHDL is
GENERIC (
display_resolution : INTEGER := 23; -- counter to get to the lowest frequency
display_counter: INTEGER := 8); -- counter to get to 97KHz frequency
port (
Nibble1 : in std_logic_vector(display_counter downto 0) := "000011010"; -- 26 in binary form
Nibble2 : in std_logic_vector(display_counter downto 0);
Result: out std_logic_vector(17 downto 0));
end entity Multiplier_VHDL;
architecture Behavioral of Multiplier_VHDL is
signal number : unsigned(display_counter downto 0) := "001100100"; -- 100 in binary form
begin
Result <= std_logic_vector(unsigned(Nibble1) * unsigned(number));
Result <= (shift_right(unsigned(number), display_counter + 1));
end architecture Behavioral;
shift_right returns 未签名或已签名,取决于您提供的内容。因此,您正在尝试将无符号写入 std_logic_vector(结果类型为 std_logic_vector)。
此外,number
已经是 unsigned
类型,因此无需再次将其转换为 unsigned
。
但是我给你 +1 分使用 numeric_std 而不是 std_logic_arith。
我想将一个数字除以 512,这意味着我需要将它移动 9。例如,在我的代码中,我想将二进制形式的数字 26 乘以 100,然后除以 512。但是我需要做的不是除以 512,而是将数字 26*100 右移 9 次。但是当我执行 shift_right
命令时,出现以下错误:
Error (10511): VHDL Qualified Expression error at Multiplier_VHDL .vhd(34): SHIFT_RIGHT type specified in Qualified Expression must match std_logic_vector type that is implied for expression by context
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity Multiplier_VHDL is
GENERIC (
display_resolution : INTEGER := 23; -- counter to get to the lowest frequency
display_counter: INTEGER := 8); -- counter to get to 97KHz frequency
port (
Nibble1 : in std_logic_vector(display_counter downto 0) := "000011010"; -- 26 in binary form
Nibble2 : in std_logic_vector(display_counter downto 0);
Result: out std_logic_vector(17 downto 0));
end entity Multiplier_VHDL;
architecture Behavioral of Multiplier_VHDL is
signal number : unsigned(display_counter downto 0) := "001100100"; -- 100 in binary form
begin
Result <= std_logic_vector(unsigned(Nibble1) * unsigned(number));
Result <= (shift_right(unsigned(number), display_counter + 1));
end architecture Behavioral;
shift_right returns 未签名或已签名,取决于您提供的内容。因此,您正在尝试将无符号写入 std_logic_vector(结果类型为 std_logic_vector)。
此外,number
已经是 unsigned
类型,因此无需再次将其转换为 unsigned
。
但是我给你 +1 分使用 numeric_std 而不是 std_logic_arith。