EDA实验报告

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
验一:译码器及计数器设计实验
1、实验目的
1)复习二进制译码器的功能。
2)学习VHDL语言源程序输入方法。
3)学习VHDL语言源程序检查和修改。
4)掌握用VHDL语言设计一个3线-8线译码器和六十进制计数器的方法。
5)掌握VHDL语言编辑器的基本操作。
2、实验内容
1)本实验给出了有错误的3线—8线译码器的VHDL程序,请采用VHDL编辑器,修改调试程序。
2)采用VHDL设计方法,设计一个60进制计数器,采用BCD码输出。
3、实验步骤
(一)、3—8译码器
1、分析3—8译码器原理,设计相应端口以及信号输入输出变量等。
2、其中A、B、C为三位二进制代码输人端。Y0-Y7是八个输出端,G1、G2A、G2B为三个输入控制端。只有当G1=1,G2A=0,G2B=0时,译译码器才处于工作状态。否则、译码器将处在禁止状态,所有输出端全为高电平。
when"011"=>Y<="00001000";
when"100"=>Y<="00010000";
when"101"=>Y<="00100000";
when"110"=>Y<="01000000";
when"111"=>Y<=;
whenothers=>null;
endcase;
elseY<=;
endif;
q(0)<=qh(0);
qd(3)<=ql(3);
qd(2)<=ql(2);
qd(1)<=ql(1);
qd(0)<=ql(0);
P1:process(clk,en,clr)
begin
if (clr='1') then
ql<="0000";
elsif (clk'event and clk='1') then
endprocess;
endBehavioral;
仿真结果:
2. 60进制计数器
实验程序:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following lines to use the declarations that are
-- provided for instantiating Xilinx primitive components.
--library UNISIM;
entity jishuqi is
port(clk:in std_logic;
en,clr:in std_logic;
q,qd:out std_logic_vector(3 downto 0));
if (en='1') then
if (ql="1001") then
ql<="0000";
else
ql<=ql+'1';
end if;
end if;
end if;
end process P1;
co<=ql(3) and ql(0);
P2:process(clk,clr)
begin
if (clr='1')then
U3: quanjia port map(a(3),b(3),carry(2),sum(3),carry(3));
U4: quanjia port map(a(4),b(4),carry(3),sum(4),cout);
end Behavioral;
实验截图:
2.用VHDL语言设计一个8位双向可控移位寄存器。
architecture Behavioral of quanjia is
signal int: std_logic;
begin
int <= a xor b ;
cout <=(a and b) or (int and cin) ;
sum <= int xor cin;
end Behavioral;
四位加法器:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following lines to use the declarations that are
3)用VHDL语言设计一个双向可控移位寄存器
3、wk.baidu.com验步骤
1)4位二进制加法器可以由4个一位全加器通过级联的方式构成。
全加器:完成加数、被加数、低位的进位数三个1位数相加,并产生本位“和”及向高位“进位”。
2)移位寄存器是由D-型触发器构成的,将前一个触发器的输出作为下一个触发器的输入,每个触发器的时钟连接成同步方式。常用的移位寄存器有并行输入串行输出移位寄存器和串行输入并行输出移位寄存器。这些移位寄存器经常用作串并转换电路。
if(S='1') then
qtemp<=qtemp(6 downto 0)&Dim;
else qtemp<=Dim&qtemp(7 downto 1);
end if;
end if;
end process;
Q<=qtemp;
end Behavioral;
实验截图:
仿真结果:
实验二、四位全加器和8位移位寄存器设计实验
1、实验目的
1)学习了解加法器工作原理。
2)学习用VHDL语言设计全加器的设计方法。
3)学习使用元件例化的方法设计多位加法器。
4)了解移位寄存器的工作原理
5)学习移位寄存器设计方法
2、实验内容
1)用VHDL语言设计全加器。
2)用元件例化方法设计一个四位二进制加法器。
qh<="0000";
elsif
(clk'event and clk='1') then
if (co='1') then
if (qh="0101") then
qh<="0000";
else
qh<=qh+'1';
end if;
end if;
end if;
end process P2;
end Behavioral;
试验程序:
1.用元件例化方法设计一个四位二进制加法器。
全加器:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following lines to use the declarations that are
end yiwei;
architecture Behavioral of yiwei is
signal qtemp:std_logic_vector(7 downto 0):="00000000";
begin
process(clk,S)
begin
if(clk'event and clk='1') then
sum,cout:out std_logic);
end component;
signal carry: std_logic_vector(n downto 1);
begin
U1: quanjia port map(a(1),b(1),cin,sum(1),carry(1));
U2: quanjia port map(a(2),b(2),carry(1),sum(2),carry(2));
--library UNISIM;
entityT138is
port(A,B,C,G1,G2A,G2B:instd_logic;
Y:outstd_logic_vector(7downto0));
endT138;
architectureBehavioralofT138is
signalD_IN:std_logic_vector(2downto0);
3、
(二)、设计一个60进制计数器,采用BCD码输出。
1)BCD码:用4位二进制数编码表示1位十进制数
2)一个十进制计数器即为一个4位二进制计数器,若将两个4位二进制计数器连接起来就可构成100进制以内的计数器。
实验程序
1、3-8译码器
libraryIEEE;
useIEEE.STD_LOGIC_1164.ALL;
begin
D_IN<=C&B&A;
process(D_IN,G1,G2A,G2B)
begin
if(G1='1'andG2A='0'andG2B='0')then
caseD_INis
when"000"=>Y<="00000001";
when"001"=>Y<="00000010";
when"010"=>Y<="00000100";
-- provided for instantiating Xilinx primitive components.
--library UNISIM;
entity quanjia is
port (a,b,cin:in std_logic;
cout,sum:out std_logic);
end quanjia;
程序代码:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following lines to use the declarations that are
-- provided for instantiating Xilinx primitive components.
--library UNISIM;
entity yiwei is
port(Dim:in std_logic;
S:in std_logic;
clk:in std_logic;
Q:out std_logic_vector(7 downto 0));
end jishuqi;
architecture Behavioral of jishuqi is
signal co:std_logic;
signal ql,qh:std_logic_vector(3 downto 0);
begin
q(3)<=qh(3);
q(2)<=qh(2);
q(1)<=qh(1);
useIEEE.STD_LOGIC_ARITH.ALL;
useIEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following lines to use the declarations that are
-- provided for instantiating Xilinx primitive components.
cin: in std_logic;
sum: out std_logic_vector(n downto 1);
cout: out std_logic
);
end siwei;
architecture Behavioral of siwei is
component quanjia
port (a,b,cin:in std_logic;
-- provided for instantiating Xilinx primitive components.
--library UNISIM;
entity siwei is
generic (n:integer:= 4 );
port (a,b:in std_logic_vector(n downto 1);
相关文档
最新文档