Binary 16位数字乘法
在这段代码中,我尝试将16位数字相乘,得到32位输出。代码有一个错误。排队Binary 16位数字乘法,binary,logic,vhdl,Binary,Logic,Vhdl,在这段代码中,我尝试将16位数字相乘,得到32位输出。代码有一个错误。排队 c<=c+a; c这个错误正是编译器告诉您的 无法读取模式输出的端口“c” 您无法读取输出。当您在第c行使用Max plus II编写c时,您正在阅读c,但cI没有注意到,它只是从OP的代码中剪切和粘贴的。我会修正的。还要注意的是,这段代码不能作为乘法器工作。这只是修复编译器错误的原始代码。虽然使用VHDL2008,输出端口现在可以读取。。。为较新的标准设置编译器。如果它不支持,记录一个bug!
c<=c+a;
c这个错误正是编译器告诉您的
无法读取模式输出的端口“c”
您无法读取输出。当您在第c行使用Max plus II编写c时,您正在阅读c
,但cI没有注意到,它只是从OP的代码中剪切和粘贴的。我会修正的。还要注意的是,这段代码不能作为乘法器工作。这只是修复编译器错误的原始代码。虽然使用VHDL2008,输出端口现在可以读取。。。为较新的标准设置编译器。如果它不支持,记录一个bug!
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity circ is
port ( a :in std_logic_vector (15 downto 0);
b :in std_logic_vector (15 downto 0);
c :out std_logic_vector (31 downto 0)
);
end entity;
architecture data of circ is
begin
process(a,b)
begin
c<= '0';
for i in 15 to 0 loop
if (b(i) = '1') then
c<=c+a;
end if;
END LOOP;
end process;
end data;
signal s : std_logic_vector(31 downto 0);
process(a,b)
begin
s <= (others => '0');
for i in 15 to 0 loop
if (b(i) = '1') then
s <= s + a; -- Use a local signal that we can read and write
end if;
end loop;
c <= s; -- Assign the output to the local signal.
end process;