四位无符号数乘法器
一、设计分析:
四位无符号数乘法器:
两个输入信号:a_in,b_in
四位无符号数
一个输出信号:c_out
八位无符号数
运算:c_out = a_in × b_in
二、代码设计:
library
IEEE;
use
IEEE.std_logic_1164.all;
use
IEEE.std_logic_arith.all;
use
IEEE.std_logic_unsigned.all;
entity
mul_4
is
port(a_in,b_in:in
std_logic_vector(3
downto
0);
c_out:out
std_logic_vector( 7
downto
0));
end
entity
mul_4;
architecture behavior
of
mul_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(7 downto
0);
begin
temp1<=a_in
when b_in(0)='1'
else
"0000";
temp2<=a_in&'0'
when
b_in(1)='1'
else "00000";
temp3<=a_in&"00" when b_in(2)='1'
else "000000";
temp4<='0'&a_in&"000"
when
b_in(3)='1' else
"00000000";
c_out<=temp4+temp3+temp2+temp1 ;
end
architecture
behavior;
三、逻辑图
四位无符号乘法器逻辑图:
四、波形仿真
测试数据:
输入:a_in 输入:b_in
0000
0001
0010
0011
0000
0001
0010
0011
输出:c_out
0000 0000
0000 0001
0000 0100
0000 1001
四位全加器仿真波形图: