FPGA数字跑表程序设计与防仿真.doc

上传人:人*** 文档编号:552694522 上传时间:2023-10-28 格式:DOC 页数:12 大小:190.50KB
返回 下载 相关 举报
FPGA数字跑表程序设计与防仿真.doc_第1页
第1页 / 共12页
FPGA数字跑表程序设计与防仿真.doc_第2页
第2页 / 共12页
FPGA数字跑表程序设计与防仿真.doc_第3页
第3页 / 共12页
FPGA数字跑表程序设计与防仿真.doc_第4页
第4页 / 共12页
FPGA数字跑表程序设计与防仿真.doc_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《FPGA数字跑表程序设计与防仿真.doc》由会员分享,可在线阅读,更多相关《FPGA数字跑表程序设计与防仿真.doc(12页珍藏版)》请在金锄头文库上搜索。

1、一、 设计名称:基于FPGA的数字系统设计(数字跑表)二、 设计指标:1、跑表精度为0.01秒2、跑表计时范围为:1小时3、设置开始计时/停止计时、复位两个按钮4、显示工作方式:用六位BCD七段数码管显示读数。显示格式为xx分xx秒xx0.01秒三、 设计要求:1、设计出符合设计要求的解决方案2、设计出单元电路3、利用EDA软件对各单元电路及整体电路进行仿真4、利用EDA软件在实验板上实现设计四、 方案设计:1、由石英振荡器产生正弦信号,然后通过分频器分频产生需要的分频信号2、由开关通过使能控制对计数器的工作状态进行控制3、分频信号控制计数器计数4、将计数器结果输入显示模块,完成在七段数码管上

2、的显示五、 系统设计框图:六、 单元电路划分1 分频器 (1)设计思路:由于显示最末位为0.01秒故需给计数器提供100Hz的时钟信号;显示部分由于一次只能显示单只数码管,为满足设计要求一次显示六位则需提高显示模块时钟信号频率,利用视觉效应使人一次看到六位显示,故分频器需要提供100Hz和1KHz两个输出信号。分频器通过计数的方法实现分频功能。 (2)元件符号: (3)源程序:library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity c

3、lock is Port ( clk : in STD_LOGIC; clk1 : out STD_LOGIC; clk2 :out STD_LOGIC);end clock;architecture Behavioral of clock issignal fcount1:integer range 1 to 24000:=1;signal fcount2:integer range 1 to 5:=1;signal clk1_tmp:STD_LOGIC:=0;signal clk2_tmp:STD_LOGIC:=0;begin process (clk,fcount1,clk1_tmp)

4、begin if clkevent and clk = 1 then if fcount1= 24000 then fcount1 = 1; clk1_tmp= not clk1_tmp; else fcount1 = fcount1 + 1; end if; end if;end process;clk1= clk1_tmp;process (clk1_tmp,clk1_tmp,fcount2,clk2_tmp) begin if clk1_tmpevent and clk1_tmp = 1 then if fcount2= 5 then fcount2 = 1; clk2_tmp= not

5、 clk2_tmp; else fcount2 = fcount2 + 1; end if; end if;end process;clk2=clk2_tmp;end Behavioral;(4)仿真结果: (5)结果分析:仿真结果显示分频程序正确的产出了实验所需频率信号.2 十进制计数器 (1)源程序:library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity counter10 is Port ( rst : in STD_LOGIC

6、; clk : in STD_LOGIC; carry_in : in STD_LOGIC; carry_out : out STD_LOGIC; count_out : out STD_LOGIC_VECTOR (3 downto 0);end counter10;architecture Behavioral of counter10 issignal count_tmp:STD_LOGIC_VECTOR (3 downto 0):=0000;signal pause : STD_LOGIC:=1;beginprocess(clk,rst,carry_in,count_tmp)begini

7、f rising_edge(carry_in) thenpause = not pause;end if;if rst=0 then count_tmp=0000; carry_out=0; elsif clkevent and clk=1 then if pause=1 then if count_tmp=1001 then count_tmp=0000; carry_out=1; ELSE count_tmp=count_tmp+1; carry_out=0; end if; end if;end if;count_out=count_tmp;end process; end Behavi

8、oral;(2) 仿真结果: (3)结果分析: 仿真结果显示当无reset信号输入时计数器正常计数并在记满时自动清零并产生进位信号,当有reset输入时会清零,程序符合设计要求.3 六进制计数器 (1)源程序:library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity counter6 is Port ( rst : in STD_LOGIC; clk : in STD_LOGIC; carry_in : in STD_LOGIC; ca

9、rry_out : out STD_LOGIC; count_out : out STD_LOGIC_VECTOR (3 downto 0);end counter6;architecture Behavioral of counter6 issignal count_tmp:STD_LOGIC_VECTOR (3 downto 0):=0000;beginprocess(clk,rst,carry_in,count_tmp)beginif rst=0 then count_tmp=0000; carry_out=0; elsif clkevent and clk=1 then if carr

10、y_in=1 then if count_tmp=0101 then count_tmp=0000; carry_out=1;ELSE count_tmp=count_tmp+1; carry_out=0; end if; end if;end if;count_out=count_tmp;end process;end Behavioral;(2)仿真结果:4 显示模块(1)设计思路:数码管显示需要对应位置显示对应位数的时间,故需要一个信号同时选择六个地址输入的一个和其所对应的数码管,因此需要一个六位计数器产生这个选择信号。前级计数器的地址输入为4位地址输入而数码管段选信号为7位信号,因而需

11、要对输入的地址信号进行七段译码。由于硬件要求还需输出一低电平信号使数码管能正常工作。 (2)元件符号:(3)源程序:library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;- Uncomment the following library declaration if instantiating- any Xilinx primitives in this code.-library UNISIM;-use UNISIM.VComponents.a

12、ll;entity xiansi is PORT(count_out1 : in STD_LOGIC_VECTOR (3 downto 0); count_out2 : in STD_LOGIC_VECTOR (3 downto 0); count_out3 : in STD_LOGIC_VECTOR (3 downto 0); count_out4 : in STD_LOGIC_VECTOR (3 downto 0); count_out5 : in STD_LOGIC_VECTOR (3 downto 0); count_out6 : in STD_LOGIC_VECTOR (3 down

13、to 0); clk : in STD_LOGIC; led : out STD_LOGIC_VECTOR (6 downto 0); sel:out STD_LOGIC_VECTOR (2 downto 0 ); led_en: out STD_LOGIC);end xiansi ;architecture Behavioral of xiansi issignal sel_tmp: STD_LOGIC_VECTOR (2 downto 0);signal y_tmp : STD_LOGIC_VECTOR (3 downto 0);beginprocess(clk)beginif clkevent and clk = 1 then if sel_tmp=101 then sel_tmp=000; else sel_tmp=sel_tmp+1; end if;end if;end process;process(sel_tmp,count_out1,count_out2,count_

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 高等教育 > 理学

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号