用quartusII软件设计4位乘法器1.并行乘法的算法:下面根据乘法例题来分析这种算法,题中M4,M3,M2,M1是被乘数,用M表示。N4,N3,N2,N1是乘数,用N表示2.乘法模块Libraryieee;Useieee.std_logic_1164.all;Useieee.std_logic_unsigned.all;Entityand4aisPort(a:instd_logic_vector(3downto0);en:instd_logic;r:outstd_logic_vector(3downto0));Endand4a;Architecturebehaveofand4aisBeginProcess(en,a(3downto0))BeginIf(en='1')thenr=a;Elser=0000;Endif;Endprocess;Endbehave;3.加法模块Libraryieee;Useieee.std_logic_1164.all;Useieee.std_logic_unsigned.all;Entityls283isPort(o1,o2:instd_logic_vector(3downto0);res:outstd_logic_vector(4downto0));Endls283;Architecturebehaveofls283isBeginProcess(o1,o2)Beginres=('0'&o1)+('0'&o2);Endprocess;Endbehave;4.主程序Libraryieee;Useieee.std_logic_1164.all;Useieee.std_logic_unsigned.all;Entitymul4pisPort(op1,op2:instd_logic_vector(3downto0);result:outstd_logic_vector(7downto0));Endmul4p;Architecturecountofmul4piscomponentand4aport(a:instd_logic_vector(3downto0);en:instd_logic;r:outstd_logic_vector(3downto0));Endcomponent;Componentls283port(o1,o2:instd_logic_vector(3downto0);res:outstd_logic_vector(4downto0));Endcomponent;Signalsa:std_logic_vector(3downto0);Signalsb:std_logic_vector(4downto0);Signalsc:std_logic_vector(3downto0);Signalsd:std_logic_vector(4downto0);Signalse:std_logic_vector(3downto0);Signalsf:std_logic_vector(3downto0);Signalsg:std_logic_vector(3downto0);--signaltmp1:std_logic;Beginsg=('0'&sf(3downto1));--tmp1=op1(1);u0:and4aportmap(a=op2,en=op1(1),r=se);U1:and4aportmap(a=op2,en=op1(3),r=sa);U2:ls283portmap(o1=sb(4downto1),o2=sa,res=result(7downto3));U3:and4aportmap(a=op2,en=op1(2),r=sc);U4:ls283portmap(o1=sc,o2=sd(4downto1),res=sb);u5:ls283portmap(o1=sg,o2=se,res=sd);u6:and4aportmap(a=op2,en=op1(0),r=sf);result(0)=sf(0);result(1)=sd(0);result(2)=sb(0);--result(7downto0)=00000000;Endcount;5.仿真波形图6.引脚分配图7.硬件下载编程与硬件实现在实现硬件测试时,选择8个按键作为4个数据的输入信号,用8个LED灯作为运算结果数据输出指示,每4个数作为一个二进制数值,通过LED灯的亮灭来显示乘法的运算结果。加油哦!开心每一天!(*^__^*)……