马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
乘法器代码如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity multi_4 is
port(x,y:in std_logic_vector(3 downto 0);
put std_logic_vector(7 downto 0));
end multi_4;
architecture ach of multi_4 is
signal temp1: std_logic_vector(3 downto 0);
signal temp2: std_logic_vector(4 downto 0);
signal temp3: std_logic_vector(5 downto 0);
signal temp4: std_logic_vector(6 downto 0);
begin
--process(x,y)
--begin
temp1<= x when y(0)='1' else "0000";
temp2<= (x(3 downto 0)&'0') when y(1)='1' else "00000";
temp3<= (x(3 downto 0)&"00") when y(2)='1' else "000000";
temp4<= (x(3 downto 0)&"000") when y(3)='1' else "0000000";
p<=temp1+temp2+temp3+('0'&temp4);
--end process;
end ach;
为什么当x*y值大于32家计算不正确了?总是和正确积相差32
譬如x=3,y=11,
应该计算结果p=33;
而仿真结果p=1, |