数字逻辑与数字系统
数字逻辑与数字系统
课程设计
班级:计131
学号: [1**********]4
姓名:吴传文
指导教师:沙丽杰
2014年12月27~29日
目录
第一章功能简介 ....................................................................................................................... 2
正常计时: ........................................................................................................................... 2
整点报时: ........................................................................................................................... 2
校时: ................................................................................................................................... 2
暂停: ................................................................................................................................... 2
清零: ................................................................................................................................... 2
第二章总体结构框图 ............................................................................................................... 2
第三章各模块框图 ................................................................................................................... 2
第四章各模块VHDL 程序 ........................................................................................................ 3
第五章仿真图 ........................................................................................................................... 9
第六章下载检验 ..................................................................................................................... 10
第七章心得体会 ..................................................................................................................... 10
第一章功能简介
正常计时:秒(16)、分(16)、小时(12)计数;秒计时的频率为1Hz ,数码管用动态扫描实时显示计时的秒、分、小时。
整点报时:逢整点蜂鸣器在“15”分钟的第11、13、秒发频率为512Hz 的低音,在“15”分钟的第15秒发频率为1024Hz 的高音。
校时:校小时(K1=1),显示小时数码管以4Hz 的频率递增计数。 暂停:保持当前时间,暂态显示。
清零:清零当前时间,从零开始重新计时。
第二章总体结构框图
第三章各模块框图
1. 12和16进制框图
2. 动显及蜂鸣器
1
第四章各模块VHDL 程序 libraryieee;
use ieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entity fenpin1 is
port(clk:instd_logic;
clr:instd_logic;
y:out std_logic_vector(1 downto 0);
co:outstd_logic);
end fenpin1;
architecture fp1 of fenpin1 is
signal q: std_logic_vector(1 downto 0);
begin
process(clk)
begin
if(clr='0') then
q
co
elsif(clk'event and clk='1') then
if(q="01") then
q
co
else
q
co
end if;
end if;
y
2
end fp1;
libraryieee;
use ieee.std_logic_1164.all;
entity mux2 is
port(min,hz,kg:instd_logic;
h:out std_logic);
end mux2;
architecture m2 of mux2 is
begin
process(kg)
begin
if(kg='1') then
h
else
h
end if;
end process;
end m2;
libraryieee;
use ieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityfenpin is
port(clk:instd_logic;
clr:instd_logic;
y:out std_logic_vector(1 downto 0);
co:outstd_logic);
endfenpin;
architecturefp of fenpin is
signal q: std_logic_vector(1 downto 0);
begin
process(clk)
begin
if(clr='0') then
q
co
elsif(clk'event and clk='1') then
if(q="11") then
q
co
else
co
end if;
end if;
y
end process;
endfp;
libraryieee;
use ieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entity count_12 is
port(clk:instd_logic;
clr:instd_logic;
msh:outstd_logic_vector(7 downto 4);
msl:outstd_logic_vector(3 downto 0);
co:outstd_logic);
end count_12;
architecture c12 of count_12 is
signalqh:std_logic_vector(7 downto 4);
signalql:std_logic_vector(3 downto 0);
begin
process(clk)
begin
if(clr='0') then
qh
ql
co
elsif(clk'event and clk='1') then
if(qh="0001" and ql="0001") then
qh
ql
co
elsif(ql="1001") then
qh
ql
co
else
qh
ql
co
end if;
end if;
msh
msl
end process;
end c12;
libraryieee;
use ieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entity count_16 is
port(clk:instd_logic;
clr:instd_logic;
msh:outstd_logic_vector(7 downto 4);
msl:outstd_logic_vector(3 downto 0);
co:outstd_logic);
end count_16;
architecture c16 of count_16 is
signalqh:std_logic_vector(7 downto 4);
signalql:std_logic_vector(3 downto 0);
begin
process(clk)
begin
if(clr='0') then
qh
ql
co
elsif(clk'event and clk='1') then
if(qh="0001" and ql="0101") then
qh
ql
co
elsif(ql="1001") then
qh
ql
co
else
qh
ql
co
end if;
end if;
msh
msl
end process;
end c16;
libraryieee;
use ieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entity alarm1 is
port (min2,min1,sce2,sce1:in std_logic_vector(3 downto 0); clk1,clk2: in std_logic;
q:out std_logic);
end alarm1;
architecture a1 of alarm1 is
begin
process(sce1,sce2,clk1,clk2)
begin
if(min2="0001" and min1="0101") then
if ( sce2="0001"and sce1="0001") then
q
elsif(sce2="0001" and sce1="0011") then
q
elsif(sce2="0001" and sce1="0101") then
q
else
q
end if;
else
q
end if;
end process;
end a1;
libraryieee;
use ieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entity count_8 is
port(clk:instd_logic;
clr:instd_logic;
y:out std_logic_vector(2 downto 0);
co:outstd_logic);
end count_8;
architecture c8 of count_8 is
signal q:std_logic_vector(2 downto 0);
begin
process(clk)
begin
ifclr='0' then
q
elsif(clk'event and clk='1') then
if(q="111") then
q
else
q
end if;
end if;
y
end process;
end c8;
libraryieee;
use ieee.std_logic_1164.all;
entity mux8_1 is
port(h1,h0,m1,m0:in std_logic_vector(3 downto 0); s1,s0,k1,k2:instd_logic_vector(3 downto 0);
sel:instd_logic_vector(2 downto 0);
y:out std_logic_vector(3 downto 0));
end mux8_1;
architecture m8 of mux8_1 is
begin
process(sel)
begin
if(sel="000") then
y
elsif(sel="001") then
y
elsif(sel="010") then
y
elsif(sel="011") then
y
elsif(sel="100") then
y
elsif(sel="101") then
y
elsif(sel="110") then
y
elsif(sel="111") then
y
end if;
end process;
end m8;
libraryieee;
use ieee.std_logic_1164.all;
entity duan7 is
port(
cin :in std_logic_vector(3 downto 0); en : in std_logic;
cout :out std_logic_vector(6 downto 0)); end duan7;
architecturertl of duan7 is
begin
process(cin,en)
begin
if(en='1')then
casecin is
when"0000"=>coutcoutcoutcoutcoutcoutcoutcoutcoutcoutcout
end if;
end process;
endrtl;
第五章仿真图 12进制
数字逻辑与数字系统
第六章下载检验
本实验涉及到两个输入1024hz 和4hz 分别作为蜂鸣器和秒位进制。一共有三个开关。开关s1具有校时功能,s2具有清零功能,s3具有暂停功能。这些功能均在输入低电平时作用。实验成功。
第七章心得体会
选择题目后,在经过多次修改与编译后,终于做出了数字多功能电子表,包含计数器、分频器、蜂鸣器、显示器等模块,并成功运行。
刚开始设计时,找不到方法,总是存在一些小错误,经过不断调试和老师的指导。不断的修正和编译才得到正确的程序。并在老师指导要求下加了暂停功能模块。
在这次的课程设计中,不仅检验了我所学习的知识,更加使我了解了VHDL 语言的编程思想。通过这次课程设计,我们所学的专业知识也运用到了实践中去,懂得了学以致用,积累了一定经验,也从中发现了自己存在的不足。
感谢老师在这次课程设计中对我们的指导,正是由于老师的督促和耐心指点,我才能够成功的制作出数字多功能电子表,从而完成这次课程设计。谢谢老师!
10