2016年北邮数电实验报告 (1)

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

数字电路与逻辑设计
实验报告
学院:电子工程学院
班级:
姓名:
学号:
班内序号:
目录
(一)实验名称及实验任务要求 (1)
(二)模块端口说明及连接图 (2)
1.1实验三(3)模块端口说明 (2)
1.2实验三(3)连接图 (2)
2.1实验四模块端口说明 (2)
2.2实验四连接图 (2)
(三)原理图或VHDL代码 (3)
1.实验一(2)原理图 (3)
2.实验三(3)VHDL代码 (4)
3.实验四VHDL代码 (7)
(四)仿真波形 (10)
1.实验一(2)仿真波形 (10)
2.实验三(3)仿真波形 (11)
3.实验四仿真波形 (11)
(五)仿真波形分析 (11)
1.实验一(2)仿真波形分析 (11)
2.实验三(3)仿真波形分析 (11)
3.实验四仿真波形分析 (11)
(六)故障及问题分析 (12)
(七)总结和结论 (13)
(一)实验名称及实验任务要求
实验一
名称:QuartusII原理图输入法设计与实现
实验任务要求:EDA基础实验1(1)、(2)、(3)必做,选做VHDL 实现加法器。

实验二
名称:用VHDL设计与实现组合逻辑电路
实验任务要求:四人表决器、8421码转格雷码、数码管译码器(下载测试)。

实验三
名称:用VHDL设计与实现时序逻辑电路
实验任务要求:分频器、8421十进制计数器、将分频器/8421十进制计数器/数码管译码器3个电路进行连接并下载。

实验四
名称:用VHDL设计与实现相关电路
实验任务要求:数码管动态扫描控制器、点阵扫描控制器。

(二)模块端口说明及连接图
1.1实验三(3)模块端口说明
cp:时钟信号输入;
rst:8421十进制计数器异步置位;
c[6...0]:七段二极管数码管显示;
cat[7...0]:数码管显示。

1.2实验三(3)连接图
2.1实验四模块端口说明
cp:时钟信号输入;
rst:8421计数器异步复位;
lgt[6...0]:七段二极管数码管显示;
cat[7...0]:数码管显示。

2.2实验四连接图
(三)原理图或VHDL代码
1.实验一(2)原理图
半加器:
全加器:
2.实验三(3)VHDL代码
//分频器部分
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity div_12 is
port
(
cp: in std_logic;
clk1: out std_logic
);
end div_12;
architecture a of div_12 is
signal tmp: integer range 0 to 11;
begin
process (cp)
begin
if (cp'event and cp='1') then
if tmp=11 then tmp<=0;
else tmp<=tmp+1;
end if;
if tmp<=5 then clk1<='0';
else clk1<='1';
end if;
end if;
end process;
end a;
//8421十进制加法器部分library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity jisuqi8421 is
port
(
clk2,rst: in std_logic;
q : out std_logic_vector(3 downto 0)
);
end jisuqi8421;
architecture a of jisuqi8421 is
signal q_temp:std_logic_vector (3 downto 0); begin
process(clk2,rst)
begin
if (rst='1') then
q_temp<="0000";
elsif (clk2'event and clk2='1') then
if q_temp>="1001" then q_temp<="0000";
else
q_temp<=q_temp+1;
end if;
end if;
end process;
q<=q_temp;
end a;
//译码管部分
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY yimaguan IS
PORT(
a: IN STD_LOGIC_VECTOR (3 downto 0);
b: OUT STD_LOGIC_VECTOR (6 downto 0);
cat: out std_logic_vector(7 downto 0)
);
end yimaguan;
ARCHITECTURE seg7_1_arch OF yimaguan IS
BEGIN
PROCESS(a)
BEGIN
CASE a IS
WHEN"0000" => b <="1111110"; --0
WHEN"0001" => b <="0110000"; --1
WHEN"0010" => b <="1101101"; --2
WHEN"0011" => b <="1111001"; --3
WHEN"0100" => b <="0110011"; --4
WHEN"0101" => b <="1011011"; --5
WHEN"0110" => b <="1011111"; --6
WHEN"0111" => b <="1110000"; --7
WHEN"1000" => b <="1111111"; --8
WHEN"1001" => b <="1111011"; --9
WHEN OTHERS => b <="0000000";
END CASE;
END PROCESS;
cat<="11101111";
END;
//整体显示
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity display is
port
(
cp,rst: in std_logic;
c:out std_logic_vector(6 downto 0);
cat: out std_logic_vector(7 downto 0)
);
end display;
architecture r of display is
component div_12
port
(
cp:in std_logic;
clk1:out std_logic
);
end component;
component jisuqi8421
port
(
clk2,rst:in std_logic;
q:out std_logic_vector(3 downto 0)
);
end component;
component yimaguan
port
(
a:in std_logic_vector(3 downto 0);
b:out std_logic_vector(6 downto 0);
cat: out std_logic_vector(7 downto 0)
);
end component;
signal x:std_logic;
signal y:std_logic_vector(3 downto 0);
begin
u1:div_12 port map(cp=>cp,clk1=>x);
u2:jisuqi8421 port map(clk2=>x,rst=>rst,q=>y); u3:yimaguan port map(a=>y,b=>c,cat=>cat);
end r;
3.实验四VHDL代码
//分频器分频部分
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity div is
port
(
cp: in std_logic;
clk1: out std_logic
);
end div;
architecture a of div is
signal tmp: integer range 0 to 49; begin
process (cp)
begin
if (cp'event and cp='1') then
if tmp=49 then tmp<=0;
else tmp<=tmp+1;
end if;
if tmp<=25 then clk1<='0';
else clk1<='1';
end if;
end if;
end process;
end a;
//计数器计数部分
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity count is
port
(
clk,rst: in std_logic;
q : out std_logic_vector(3 downto 0)
);
end count;
architecture a of count is
signal temp:std_logic_vector (3 downto 0); begin
process(clk,rst)
begin
if (rst='1') then
temp<="0000";
elsif (clk'event and clk='1') then
if temp>="0101" then temp<="0000";
else
temp<=temp+1;
end if;
end if;
end process;
q<=temp;
end a;
//译码管显示部分
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity yimaqi is
port
(
a:in std_logic_vector(3 downto 0);
led:out std_logic_vector(6 downto 0);
cat:out std_logic_vector(7 downto 0)
);
end entity;
architecture rtl of yimaqi is
begin
process(a)
begin
case a is
when "0000"=>led<="1111110"; cat<="11111110"; --0
when "0001"=>led<="0110000"; cat<="11111101"; --1
when "0010"=>led<="1101101"; cat<="11111011"; --2
when "0011"=>led<="1111001"; cat<="11110111"; --3
when "0100"=>led<="0110011"; cat<="11101111"; --4
when "0101"=>led<="1011011"; cat<="11011111"; --5
when others=>led<="0000000"; cat<="11111111";
end case;
end process;
end;
//合成数码管显示
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity show is
port
(
cp:in std_logic;
rst:in std_logic;
lgt:out std_logic_vector(6 downto 0);
cat:out std_logic_vector(7 downto 0)
);
end entity;
architecture rtl of show is
component div
port
(
cp : in std_logic;
clk1: out std_logic
);
end component;
signal x:std_logic;
component count
port
(
clk,rst: in std_logic;
q : out std_logic_vector(3 downto 0)
);
end component;
signal y:std_logic_vector(3 downto 0);
component yimaqi
port
(
a :in std_logic_vector(3 downto 0);
led:out std_logic_vector(6 downto 0);
cat:out std_logic_vector(7 downto 0)
);
end component;
begin
u0:div port map (cp=>cp,clk1=>x);
u1:count port map(clk=>x,rst=>rst,q=>y);
u2:yimaqi port map(a=>y,cat=>cat,led=>lgt); end rtl;
(四)仿真波形
1.实验一(2)仿真波形
2.实验三(3)仿真波形
3.实验四仿真波形
(五)仿真波形分析
1.实验一(2)仿真波形分析
a,b,ci均为输入信号,s,co为输出信号
其逻辑功能为:s=a xor b xor ci
co=( ( a xor b ) and ci ) or (a and b ) 2.实验三(3)仿真波形分析
rst,cp均为输入信号,c,cat为输出信号。

当rst为1时,输出信号c 置零;
当rst为0时,信号c以八为周期,周期性输出,从该波形看出下载后显示的结果应为第四个数码管连续性显示输出0~8。

3.实验四仿真波形分析
r st,cp均为输入信号,lgt,cat为输出信号。

当rst为1 时,输出信号lgt置零;
当rst为0时,信号lgt以六为周期,周期性输出,从该波形可以看出,下载后现实的结果应为cat[0]~cat[5]六个数码管分别显示
输出0、1、2、3、4、5。

(六)故障及问题分析
1.电路连接问题:如为连接错误;
2.管脚名问题:
2.1原理图连接的时候如果没有将管脚名修改的话,也可能报错,
不过个人没有遇到过;
2.2如果不慎将两个管脚的名称写成了一样的,则会有报错Error:
Illegal name"管脚名" -- pin name already exists
3.存储问题:
3.1老师说工程得全英文路径,可是个人试了一下发现存储工程
的文件夹名称为中文的运行也能成功,可能是有某些案例显
示中文路径会报错吧;
3.2 编写的VHDL代码或原理图文件都应该存储到与工程的同一
路径下,否则将报错Error: Top-level design entity "工程名" is
undefined;
3.3需要引用到新建的工程或元件时该工程应与新建的工程或元
件存储到同一路径下,否则报错Error: Node instance "某管脚"
instantiates undefined entity "新建工程名称",或者显示unknown 3.4如果存储的工程名称与VHDL代码中的工程名称不一致则会
报错Error: Top-level design entity "工程名" is undefined;
4. VHDL代码问题:
4.1在port的“)”前多加了个“,”,如Error (10500): VHDL syntax
error at count.vhd(12) near text ")"; expecting an identifier, or
"constant", or "file", or "signal", or "variable";
4.2赋值语句没写“<”,如Error (10500): VHDL syntax error at
div_12.vhd(22) near text "="; expecting "(", or "'", or ".";
4.3类型使用错误,如Error (10517): VHDL type mismatch error at
div_12.vhd(24): std_logic_vector type does not match integer
literal;
4.4元件与元件之间的连接缺少signal,如Error (10482): VHDL error
at show.vhd(50): object "clk" is used but not declared
5.下载
5.1管脚的adress没有填对,比如数码管的a~f七段二极管应分别
对应AA~AF,而经常会犯错将其分别对应AF~AA,这样数码管
也将会显示错误;
5.2填完管脚后没有从新编译,则下载完成后得不到所需结果(七)总结和结论
通过这几周的数字电路与逻辑设计实验,个人受益匪浅。

首先是养成了一个实验课前预习的好习惯,而刚开始实验的时
候没有提前预习,等到老师讲的时候感觉思路跟不上,错过很多要点,并且不能很好的操作QuartusII软件;
接着是对EDA有了初步的了解,知道了通过vhdl里的那短短的代码就能实现数字可编程器件的各种功能。

这几周的实验是以数码管的显示为主的,个人从中也了解到了挺多的,比如计数器的实现,分频器的实现等;
然后是通过这几周的实验,个人对数字电与逻辑设计这门课有了不同以往的兴趣,在未来的日子里也将会更加努力的去学习这门课程;
最后,感谢老师的谆谆教导。

相关文档
最新文档