基于FPGA的数字跑表设计报告姓名:学号:指导老师:***摘要:本文详细介绍了数字秒表的设计指标,设计思路,设计方案,系统电路设计,系统单元模块设计,系统硬件实现与测试的结果。
一 引言 科技高度发展的今天,集成电路和计算机应用得到了高速发展。
尤其是计算机应用的发展。
它在人们日常生活已逐渐崭露头角。
大多数电子产品多是由计算机电路组成,如:手机、mp3等。
而且将来的不久他们的身影将会更频繁的出现在我们身边。
各种家用电器多会实现微电脑技术。
电脑各部分在工作时多是一时间为基准的。
本文就是基于计算机电路的时钟脉冲信号、状态控制等原理设计出的数字秒表。
秒表在很多领域充当一个重要的角色。
在各种比赛中对秒表的精确度要求很高,尤其是一些科学实验。
他们对时间精确度达到了几纳秒级别。
二 项目任务与设计思路 本项目的任务是掌握使用VHDL 语言的设计思想;熟悉ise 软件的使用;了解XILINX 学生EDA 实验板。
了解 EDA 技术,对计算机系统中时钟控制系统进一步了解,掌握状态机工作原理,同时了解计算机时钟脉冲是怎么产生和工作的。
在掌握所学的计算机组成与结构课程理论知识时。
通过对数字秒表的设计,进行理论与实际的结合,提高与计算机有关设计能力,提高分析、解决 计算机技术实际问题的能力。
通过课程设计深入理解计算机结构与控制实现的技术,达到课程设计的目标。
项目任务与设计思路本项目的指标:1、跑表精度为0.01秒2、跑表计时范围为:1小时3、设置开始计时/停止计时、复位两个按钮4、显示工作方式:用六位BCD 七段数码管显示读数。
显示格式:三 基于VHDL 方法设计方案 VHDL 的设计流程主要包括以下几个步骤:1.文本编辑:用任何文本编辑器都可以进行,也可以用专用的HDL 编辑环境。
通常VHDL 文件保存为.vhd文件2.功能仿真:将文件调入HDL 仿真软件进行功能仿真,检查逻辑功能是否正确。
3.逻辑综合:将源文件调入逻辑综合软件进行综合,即把语言综合成最简的布尔表达式。
逻辑综合软件会生成.edf 或.edif 的 EDA 工业标准文件。
4.布局布线:将.edf 文件调入PLD 厂家提供的软件中进行布线,即把设 分 秒 0.01秒计好的逻辑安放PLD/FPGA 内。
5.时序仿真:需要利用在布局布线中获得的精确参数,用仿真软件验证电路的时序。
(也叫后仿真)通常以上过程可以都在 PLD/FPGA 厂家提供的开发工具。
6.器件编程。
四系统电路设计五系统单元模块设计一分频器代码实现:Freq:process(clk)variable fcount1,fcount2:integer;beginif clk'event and clk='1' thenif fcount1=24000 thenfcount1<=1;clk_1k<= not clk_1k;else fcount1<=fcount1+1; end if;if fcount2=240000 then fcount2<=1;clk_100<=not clk_100; else fcount2<=fcount2+1;end if;end if;end process;二计数器代码实现: Count:process(rst,clk_100,pause)beginif rst='1' thencount_1<="0000";count_2<="0000";count_3<="0000";count_4<="0000";count_5<="0000";count_6<="0000";elsif pause='1' thenNULL;elseif clk_100'event and clk_100='1' then if count_1="1001" thencount_1<="0000";if count_2="1001" thencount_2<="0000";if count_3="0101" thencount_3<="0000";if count_4="1001" thencount_4<="0000";if count_5="1001" thencount_5<="0000";if count_6="0101" thencount_6<="0000";else count_6<=count_6+1;end if;else count_5<=count_5+1;end if;else count_4<=count_4+1;end if;else count_3<=count_3+1;end if;else count_2<=count_2+1;end if;else count_1<=count_1+1;end if;end if;end if;end process;三译码显示控制代码实现:Countscan:process(clk1)beginif clk_1k'event and clk_1k='1' thenif count_s="101" thencount_s<="000";else count_s<=count_s+1;end if;end if;end process;choose<=count_s;scan:process(count_s,count_1,count_2,count_3,count_4,count_5,count_6) begincase count_s iswhen "000" => data<=count_1;when "001" => data<=count_2;when "010" => data<=count_3;when "011" => data<=count_4;when "100" => data<=count_5;when "101" => data<=count_6;when others=>NULL;end case;end process;shuma:process(data)begincase data iswhen "0000"=> light <= "0000001";when "0001"=> light <= "1001111";when "0010"=> light <= "0010010";when "0011"=> light <= "0000110";when "0100"=> light <= "1001100";when "0101"=> light <= "0100100";when "0110"=> light <= "0100000";when "0111"=> light <= "0001111";when "1000"=> light <= "0000000";when "1001"=> light <= "0000100";when others => NULL;end case;end process;六系统硬件实现与测试一程序代码:entity szpb isport(clk:in std_logic;allout:out std_logic_vector(6 downto 0);rst:in std_logic;choose:out std_logic_vector(2 downto 0);inen:in std_logic;outen:out std_logic;pause:in std_logic);end szpb;architecture of szpb issignal clk1,clk2:std_logic:=’0’;signalcount_1,count_2,count_3,count_4,count_5,count_6:std_logic_vector(3 downto 0):=”0000”;signal count_s:std_logic_vector(2 downto 0):=”000”;signal data:std_logic_vector(3 downto 0):=”0000”;beginFreq:process(clk)variable con1,con2:integer;beginif clk'event and clk='1' thenif con1=23999 thencon1:=0;clk1<= not clk1;else con1:=con1+1;end if;if con2=239999 thencon2:=0;clk2<=not clk2;else con2:=con2+1;end if;end if;end process;Count:process(rst,clk2,pause)beginif rst='1' thencount_1<="0000";count_2<="0000";count_3<="0000";count_4<="0000";count_5<="0000";count_6<="0000";elsif pause='1' thenNULL;elseif clk2'event and clk2='1' then if count_1="1001" thencount_1<="0000";if count_2="1001" thencount_2<="0000";if count_3="0101" thencount_3<="0000";if count_4="1001" thencount_4<="0000";if count_5="1001" thencount_5<="0000";if count_6="0101" thencount_6<="0000";else count_6<=count_6+1;end if;else count_5<=count_5+1;end if;else count_4<=count_4+1;end if;else count_3<=count_3+1;end if;else count_2<=count_2+1;end if;else count_1<=count_1+1;end if;end if;end if;end process;Countscan:process(clk1)beginif clk1'event and clk1='1' thenif count_s="101" thencount_s<="000";else count_s<=count_s+1;end if;end if;end process;choose<=count_s;scan:process(count_s,count_1,count_2,count_3,count_4,count_5,count_6) begincase count_s iswhen "000" => data<=count_1;when "001" => data<=count_2;when "010" => data<=count_3;when "011" => data<=count_4;when "100" => data<=count_5;when "101" => data<=count_6;when others=>NULL;end case;end process;shuma:process(data)begincase data iswhen "0000"=> light <= "0000001";-----when "0001"=> light <= "1001111";when "0010"=> allout <= "0010010";when "0011"=> allout <= "0000110";when "0100"=> allout <= "1001100";when "0101"=> allout <= "0100100";when "0110"=> allout <= "0100000";when "0111"=> allout <= "0001111";when "1000"=> allout <= "0000000";when "1001"=> allout <= "0000100";when others => NULL;end case;end process;outen<=inen;end szpb;二仿真实现三下载过程:光标移至【Generate Programing File】后单击鼠标右键,然后单击【Properties】在打开的对话框的左侧栏选中【Configuration Options】将右侧的Unused IOB Pins这一项改为Pull Up,单击OK。