北邮数字逻辑课程设计实验报告可编辑.docx

上传人:b****5 文档编号:6060724 上传时间:2023-01-03 格式:DOCX 页数:10 大小:78.97KB
下载 相关 举报
北邮数字逻辑课程设计实验报告可编辑.docx_第1页
第1页 / 共10页
北邮数字逻辑课程设计实验报告可编辑.docx_第2页
第2页 / 共10页
北邮数字逻辑课程设计实验报告可编辑.docx_第3页
第3页 / 共10页
北邮数字逻辑课程设计实验报告可编辑.docx_第4页
第4页 / 共10页
北邮数字逻辑课程设计实验报告可编辑.docx_第5页
第5页 / 共10页
点击查看更多>>
下载资源
资源描述

北邮数字逻辑课程设计实验报告可编辑.docx

《北邮数字逻辑课程设计实验报告可编辑.docx》由会员分享,可在线阅读,更多相关《北邮数字逻辑课程设计实验报告可编辑.docx(10页珍藏版)》请在冰豆网上搜索。

北邮数字逻辑课程设计实验报告可编辑.docx

北邮数字逻辑课程设计实验报告可编辑

北邮数字逻辑课程设计实验报告(可编辑)

(文档可以直接使用,也可根据实际需要修改使用,可编辑推荐下载)

实验四:

电子钟显示

一、实验目的

(1)掌握较复杂的逻辑设计和调试。

(2)学习用原理图+VHDL语言设计逻辑电路。

(3)学习数字电路模块层次设计。

(4)掌握ispLEVER软件的使用方法。

(5)掌握ISP器件的使用。

二、实验所用器件和设备

在系统可编程逻辑器件ISP1032一片

示波器一台

万用表或逻辑笔一只

TEC-5实验系统,或TDS-2B数字电路实验系统一台

三、实验内容

数字显示电子钟

1、任务要求

(1)、时钟的“时”要求用两位显示;上、下午用发光管作为标志;

(2)、时钟的“分”、“秒”要求各用两位显示;

(3)、整个系统要有校时部分(可以手动,也可以自动),校时时不能产生进位;

(4)*、系统要有闹钟部分,声音要响5秒(可以是一声一声的响,也可以连续响)。

VHDL源代码:

LIBRARYieee;

----主体部分-

ENTITYclockis

port(clk,clr,put,clk1:

instd_logic;--clr为清零信号,put为置数脉冲,clk1为响铃控制时钟

choice:

instd_logic;--用来选择时钟状态的脉冲信号

lighthour:

outstd_logic_vector(10downto0);

lightmin:

outstd_logic_vector(7downto0);

lightsec:

outstd_logic_vector(7downto0);--输出显示

ring:

outstd_logic);--响铃信号

endclock;

--60进制计数器模块

ARCHITECTUREfuncofclockis

componentcounter_60

port(clock:

instd_logic;

clk_1s:

instd_logic;

putust:

instd_logic;

clr:

instd_logic;

load:

instd_logic;

s1:

outstd_logic_vector(3downto0)

;

s10:

outstd_logic_vector(3downto0)

;

co:

outstd_logic)

;

endcomponent;

--24进制计数器模块

componentcounter_24

port(clock:

instd_logic;

clk_1s:

instd_logic;

putust:

instd_logic;

clr:

instd_logic;

load:

instd_logic;

s1:

outstd_logic_vector(3downto0);

s10:

outstd_logic_vector(6downto0));

endcomponent;

signalsec,a:

std_logic;---2分频产生1s信号

signall1,l2,l3:

std_logic;---判定对时间三部分修改

signalc1,c2:

std_logic;---进位信号

signalload:

std_logic_vector(1downto0);

signaltemp:

integerrange0to2499;

signaltemp1:

integerrange0to95;--计数信号

signalsec_temp:

std_logic_vector(7downto0);

--总进程

begin

u1:

counter_60portmap(sec,sec,put,clr,l1,sec_temp(3downto0),sec_temp(7downto4),c1);

u2:

counter_60portmap(c1,sec,put,clr,l2,lightmin(3downto0),lightmin(7downto4),c2);

u3:

counter_24portmap(c2,sec,put,clr,l3,lighthour(3downto0),lighthour(10downto4));

lightsec(7downto0)<=sec_temp(7downto0);

--状态转换

process(choice)

begin

if(choice'eventandchoice='1')then

caseloadis

when"00"=>l1<='0';--非修改状态

l2<='0';

l3<='0';

load<="01";

when"01"=>l1<='0';--此状态下对小时进行修改

l2<='0'

;

l3<='1'

;

load<="10"

;

when"10"=>l1<='0';--此状态下对分钟进行修改

l2<='1';

l3<='0';

load<="11";

whenothers=>l1<='1';--此状态下对秒进行修改

l2<='0';

l3<='0';

load<="00"

;

endcase;

endif;

endprocess;

--计数进程

process(clk)

begin

if(clk'eventandclk='1')then--分频

if(temp=2499)then

temp<=0;

sec<=notsec;

else

temp<=temp+1;

endif;

endif;

endprocess;

--响铃进程

process(clk1)

begin

if(clk1'eventandclk1='1')then

if(temp1=95)then

temp1<=0;

a<=nota;

else

temp1<=temp1+1;

endif;

endif;

endprocess;

ring<=awhen(c2='1'andsec_temp<5andsec='1')else--5s整点响铃

'0';

endfunc;

libraryIEEE;

entitycounter_60is

port(clock:

instd_logic;--计数信号,即低位的进位信号或时钟脉冲信号

clk_1s:

instd_logic;--周期1s的时钟信号

putust:

instd_logic;--调表置数信号

clr:

instd_logic;--清零

load:

instd_logic;--判定信号

s1:

outstd_logic_vector(3downto0);--计数器的个位s10:

outstd_logic_vector(3downto0);--计数器的十位

co:

outstd_logic);

endcounter_60;

if(load=1)--防止脉冲产生进位

co_temp<=’0’;

architecturefuncofcounter_60is

signals1_temp:

std_logic_vector(3downto0);

signals10_temp:

std_logic_vector(3downto0);

signalclk,co_temp:

std_logic;

begin

clk<=clockwhenload='0'else

putust;

process(clk,clr)

begin

if(clr='1')then

s1_temp<="0000"

;

s10_temp<="0000"

;

elsif(clk'eventandclk='1')then--进位判断

if(s1_temp=9)then

s1_temp<="0000"

;

if(s10_temp=5)then

s10_temp<="0000";

co_temp<='1';

else

co_temp<='0'

;

s10_temp<=s10_temp+1;

endif;

else

co_temp<='0'

;

s1_temp<=s1_temp+1;

endif;

endif;

endprocess;

s1<=s1_tempwhen(clk_1s='1'orload='0')else

"1111"

;

s10<=s10_tempwhen(clk_1s='1'orload='0')else

"1111"

;

co<=co_tempwhen(load='0')else

'0'

;

endfunc;

libraryIEEE;

--24进制计数器

entitycounter_24is

port(clock:

instd_logic;--计数信号

clk_1s:

instd_logic;--周期1s的时钟信号

putust:

instd_logic;

clr:

instd_logic;--清零信号

load:

instd_logic;--判定信号

s1:

outstd_logic_vector(3downto0);--计数器的个位

s10:

outstd_logic_vector(6downto0));--计数器的十位

endcounter_24;

architecturefuncofcounter_24is

signals1_temp:

std_logic_vector(3downto0);

signals10_temp:

std_logic_vector(1downto0);

signalclk:

std_logic;

begin

clk<=clockwhenload='0'else

putust;

process(clk,clr)

begin

if(clr='1')then

s1_temp<="0000"

;

s10_temp<="00"

;

elsif(clk'eventandclk='1')then

if(s1_temp=3ands10_temp=2)then

s1_temp<="0000"

;

s10_temp<="00"

;

elsif(s1_temp=9)then

s1_temp<="0000"

;

s10_temp<=s10_temp+1;

else

s1_temp<=s1_temp+1;

endif;

endif;

endprocess;

--显示进程

process(s10_temp)

begin

if(clk_1s='1'orload='0')then

cases10_tempis

when"00"=>s10<="1111110";

when"01"=>s10<="0110000";

when"10"=>s10<="1101101";

whenothers=>null;

endcase;

else

s10<="0000000";

endif;

endprocess;

s1<=s1_tempwhen(clk_1s='1'orload='0')else

"1111";

endfunc;

四、实验小结:

注意当时钟处于被修改状态时,即对时、分、秒的值进行修改时,不应产生进位,产生很多莫名其妙的错误,如修改后有进位(分钟为00)时,或者自行到整点响铃后,再次给脉冲会进位的情况。

最终修改了很多语句,实际就是在修改给脉冲时强制使进位信号为0.

注意计数器60,,2进制的实现,加入响铃后需要把进位信号放到计数过程中才能使响铃正常。

调整非秒针时,秒针依旧走动,通过1s计数器实现闪烁,符合实际情况。

此次试验模块多且杂,需要更加细化的了解程序实质,也对代码的执行方式和顺序有了更加深刻的认识

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1