收藏 分销(赏)

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

上传人:精**** 文档编号:10006083 上传时间:2025-04-17 格式:DOCX 页数:10 大小:645.23KB 下载积分:8 金币
下载 相关 举报
北邮数字逻辑课程设计实验报告.docx_第1页
第1页 / 共10页
北邮数字逻辑课程设计实验报告.docx_第2页
第2页 / 共10页


点击查看更多>>
资源描述
北邮数字逻辑课程设计实验报告(可编辑) (文档可以直接使用,也可根据实际需要修改使用,可编辑推荐下载) 实验四:电子钟显示 一、 实验目的 (1)掌握较复杂的逻辑设计和调试。 (2)学习用原理图+VHDL语言设计逻辑电路。 (3)学习数字电路模块层次设计。 (4)掌握ispLEVER 软件的使用方法。 (5)掌握ISP 器件的使用。 二、实验所用器件和设备 在系统可编程逻辑器件ISP1032 一片 示波器 一台 万用表或逻辑笔 一只 TEC-5实验系统,或TDS-2B 数字电路实验系统 一台 三、 实验内容 数字显示电子钟 1、任务要求 (1)、时钟的“时”要求用两位显示;上、下午用发光管作为标志; (2)、时钟的“分”、“秒”要求各用两位显示; (3)、整个系统要有校时部分(可以手动,也可以自动),校时时不能产生进位; (4)*、系统要有闹钟部分,声音要响5秒(可以是一声一声的响,也可以连续响)。 VHDL源代码: LIBRARY ieee; ----主体部分- ENTITY clock is port(clk,clr,put,clk1 : in std_logic; -- clr 为清零信号,put 为置数脉冲,clk1 为响铃控制时钟 choice : in std_logic; --用来选择时钟状态的脉冲信号 lighthour : out std_logic_vector(10 downto 0); lightmin : out std_logic_vector(7 downto 0); lightsec : out std_logic_vector(7 downto 0); --输出显示 ring : out std_logic); --响铃信号 end clock; --60进制计数器模块 ARCHITECTURE func of clock is component counter_60 port(clock : in std_logic; clk_1s : in std_logic; putust : in std_logic; clr : in std_logic; load : in std_logic; s1 : out std_logic_vector(3 downto 0) ; s10 : out std_logic_vector(3 downto 0) ; co : out std_logic) ; end component; --24进制计数器模块 component counter_24 port(clock : in std_logic; clk_1s : in std_logic; putust : in std_logic; clr : in std_logic; load : in std_logic; s1 : out std_logic_vector(3 downto 0); s10 : out std_logic_vector(6 downto 0)); end component; signal sec,a:std_logic; --- 2 分频产生1s信号 signal l1,l2,l3:std_logic; ---判定对时间三部分修改 signal c1,c2:std_logic; ---进位信号 signal load:std_logic_vector(1 downto 0); signal temp:integer range 0 to 2499; signal temp1:integer range 0 to 95; --计数信号 signal sec_temp:std_logic_vector(7 downto 0); --总进程 begin u1 : counter_60 port map (sec,sec,put,clr,l1,sec_temp(3 downto 0),sec_temp(7 downto 4),c1); u2 : counter_60 port map (c1,sec,put,clr,l2,lightmin(3 downto 0),lightmin(7 downto 4),c2); u3 : counter_24 port map (c2,sec,put,clr,l3,lighthour(3 downto 0),lighthour(10 downto 4)); lightsec(7 downto 0)<=sec_temp(7 downto 0); --状态转换 process (choice) begin if (choice'event and choice='1') then case load is 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"; when others => l1<='1'; --此状态下对秒进行修改 l2<='0'; l3<='0'; load<="00" ; end case; end if; end process; --计数进程 process(clk) begin if (clk'event and clk='1') then --分频 if (temp=2499) then temp <= 0; sec<=not sec; else temp <= temp+1; end if; end if; end process; --响铃进程 process(clk1) begin if(clk1'event and clk1='1') then if (temp1=95) then temp1<=0; a<=not a; else temp1<=temp1+1; end if; end if; end process; ring<=a when (c2='1' and sec_temp<5 and sec='1') else --5s整点响铃 '0'; end func; library IEEE; entity counter_60 is port (clock : in std_logic; --计数信号,即低位的进位信号或时钟脉冲信号 clk_1s : in std_logic; --周期1s 的时钟信号 putust : in std_logic; --调表置数信号 clr : in std_logic; --清零 load : in std_logic; --判定信号 s1 : out std_logic_vector(3 downto 0); --计数器的个位s10 : out std_logic_vector(3 downto 0); --计数器的十位 co : out std_logic ); end counter_60; if(load=1 ) --防止脉冲产生进位 co_ temp<=’0’; architecture func of counter_60 is signal s1_temp: std_logic_vector(3 downto 0); signal s10_temp : std_logic_vector(3 downto 0); signal clk,co_temp : std_logic; begin clk<=clock when load='0' else putust; process (clk,clr) begin if (clr='1') then s1_temp <= "0000" ; s10_temp <= "0000" ; elsif (clk'event and clk='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; end if; else co_temp<='0' ; s1_temp <= s1_temp+1; end if; end if; end process; s1 <= s1_temp when (clk_1s='1'or load='0') else "1111" ; s10 <= s10_temp when (clk_1s='1' or load='0') else "1111" ; co <= co_temp when (load='0') else '0' ; end func; library IEEE; --24进制计数器 entity counter_24 is port(clock : in std_logic; --计数信号 clk_1s : in std_logic; --周期1s 的时钟信号 putust : in std_logic; clr : in std_logic; --清零信号 load : in std_logic; --判定信号 s1 : out std_logic_vector(3 downto 0); --计数器的个位 s10 : out std_logic_vector(6 downto 0)); --计数器的十位 end counter_24; architecture func of counter_24 is signal s1_temp : std_logic_vector(3 downto 0); signal s10_temp : std_logic_vector(1 downto 0); signal clk : std_logic; begin clk<=clock when load='0' else putust; process (clk,clr) begin if (clr='1') then s1_temp <= "0000" ; s10_temp <= "00" ; elsif (clk'event and clk='1') then if (s1_temp=3 and s10_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; end if; end if; end process; --显示进程 process(s10_temp) begin if (clk_1s='1' or load='0') then case s10_temp is when "00" => s10<="1111110"; when "01" => s10<="0110000"; when "10" => s10<="1101101"; when others => null; end case; else s10<="0000000"; end if; end process; s1 <= s1_temp when (clk_1s='1' or load='0') else "1111"; end func; 四、 实验小结: 注意当时钟处于被修改状态时,即对时、分、秒的值进行修改时,不应产生进位,产生很多莫名其妙的错误,如修改后有进位(分钟为00)时,或者自行到整点响铃后,再次给脉冲会进位的情况。最终修改了很多语句,实际就是在修改给脉冲时强制使进位信号为0. 注意计数器60,,2进制的实现,加入响铃后需要把进位信号放到计数过程中才能使响铃正常。 调整非秒针时,秒针依旧走动,通过1s计数器实现闪烁,符合实际情况。 此次试验模块多且杂,需要更加细化的了解程序实质,也对代码的执行方式和顺序有了更加深刻的认识
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 学术论文 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4009-655-100  投诉/维权电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服