8位乘法器的程序设计

来源:百度知道 编辑:UC知道 时间:2024/06/16 21:32:50
1、 能设置输入的两个乘数(十进制),按操作键后以十进制的方式显示积。
2' VHDL语言

有符号数的还是无符号数的?
可以直接使用2进制乘法器
至于2进制转10进制,10转2就很简单了
我给你一个2进制有符号数的乘法器源程吧
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity mp is
Port ( ai : in std_logic_vector(7 downto 0);
bi : in std_logic_vector(7 downto 0)
done : out std_logic;
clk : in std_logic;
op : out std_logic_vector(15 downto 0));
end mp;
architecture Behavioral of mp is
begin

process(ai,bi,clk)
variable a,b,m : std_logic_vector( 7 downto 0);
variable cp: std_logic_vector( 1 downto 0);
variable t: std_logic ;
variable counter: integer;
begin
if clk'event and clk='1' then
counter:=0;
t:='0';
a:=ai;