数字电路课程设计《梁祝》乐曲 数字时钟 乒乓球游戏机 串并乘法(5)

2019-03-29 17:10

② 串并乘法器的结构非常有规律,由与门、D触发器和全加器构成。

二:系统组成以及系统各部分的设计

顶层文件(multiplier.vhd) library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; use work.mypackage.all;

entity multiplier is generic(n:integer:=8); port(

rst:in std_logic; --复位 clk:in std_logic; --时钟 a:in std_logic; --被乘数

b:in std_logic_vector(n-1 downto 0); --乘数 q:out std_logic--乘积 );

end multiplier;

architecture structural of multiplier is

signal and_out:std_logic_vector(n-1 downto 0); signal dff_out:std_logic_vector(n-1 downto 0); begin

g1:for i in 0 to n-1 generate andx:myand2 port map (

a=>a, b=>b(i),

c=>and_out(i) );

end generate;

g2:for i in 0 to n-2 generate pipex:pipe port map (

rst=>rst, --复位

clk=>clk, --时钟

a=>and_out(i), --输入

b=>dff_out(i+1), --输入

q=>dff_out(i) --输出 );

end generate;

dffx:mydff port map (

rst=>rst, --复位

clk=>clk, --时钟

d=>and_out(n-1), --输入

q=>dff_out(n-1) --输出 );

q<=dff_out(0); end structural;

全加器模块(full_adder.vhd)

library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all;

entity full_adder is port(

a:in std_logic; --被加数

b:in std_logic; --加数

cin:in std_logic; --进位输入

c:out std_logic; --和

cout:out std_logic--进位输出 );

end full_adder;

architecture behave of full_adder is begin

c<=a xor b xor cin;

cout<=(a and b)or(a and cin)or(b and cin); end behave;

流水线单元(pipe.vhd)

library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; use work.mypackage.all;

entity pipe is port(

rst:in std_logic; --复位

clk:in std_logic; --时钟

a:in std_logic; --输入

b:in std_logic;

q:out std_logic--输出 );

end pipe;

architecture structural of pipe is signal c:std_logic; signal cin:std_logic; signal cout:std_logic; begin

u1:component full_adder port map( a=>a, b=>b, cin=>cin, c=>c,

cout=>cout );

u2:component mydff port map( rst=>rst,

clk=>clk, d=>cout, q=>cin );

u3:component mydff port map( rst=>rst, clk=>clk, d=>c, q=>q );

end structural;

描述与门的模块(myand2.vhd)

library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; entity myand2 is port(

a:in std_logic; b:in std_logic; c:out std_logic );

end myand2;

architecture behave of myand2 is begin

c <=a and b; end behave;

D触发器(mydff.vhd)

library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all;

entity mydff is port(

rst:in std_logic; clk:in std_logic; d:in std_logic; q:out std_logic );

end mydff;

architecture behave of mydff is begin

process(rst,clk) begin

if rst='1' then q<='0';

elsif rising_edge(clk)then q<=d; end if;

end process; end behave;

程序包(mypackage.vhd)

library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all;

package mypackage is component myand2 is port(

a:in std_logic; b:in std_logic; c:out std_logic );

end component;

component full_adder is port(

a:in std_logic; b:in std_logic; cin:in std_logic; c:out std_logic; cout:out std_logic );

end component; component mydff is port(

rst:in std_logic; clk:in std_logic; d:in std_logic; q:out std_logic );

end component; component pipe is port(

a:in std_logic; b:in std_logic; clk:in std_logic; rst:in std_logic; q:out std_logic );

end component; end mypackage;

三:系统以及各个模块的仿真波形

顶层文件仿真波形

四:系统调试运行结果说明与分析

实验箱选择模式8 。乘数由并行输入,被乘数由串行输入。当被乘数还在串行输入时,就得到部分乘积结果是串并乘法器的一大特色,因此,特别适合用作流水线处理。

五:结论与体会

本次实验完成的是通用串并乘法器,通过调试可以完成预期功能,但是介于实验箱的范围问题有一定的局限性。经过这几次的数电实验,使我增强了对实验的兴趣以及动手能力,使理论的知识变为实际的东西…总之,我受益匪浅。


数字电路课程设计《梁祝》乐曲 数字时钟 乒乓球游戏机 串并乘法(5).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:等差数列教案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: