FPGA实验报告 - 图文 联系客服

发布时间 : 星期三 文章FPGA实验报告 - 图文更新完毕开始阅读

3. 系统组成

3.29 测频法的基本原理

图3.30 系统组成原理

如图6.2 所示,输入信号包括20M 的基准时钟和1Hz~~40MHz 的被测时钟,闸门时间模块的作用是对基准时钟进行分频,得到一个1 秒的闸门信号,作为8 位十进制计数器的计数标志,点阵模块显示Hz,8 位数码管模块显示分频信号的频率。

六、实验连线

图3.31

输入信号:

时钟SysClk 接20MHz 频率下载板上系统时钟;P28

时钟Clkin 接可调时钟SW7,选择输入(1Hz~40MHz)被测时钟;P152 输出信号:

Seg7(7 downto 0)接七段数码管O50-O57(数码管区短路夹连接JP1);P73、74、75、76、77、78、79 82

ctr(7 downto 0)接七段数码管选择信号SO58-SO65。P83、84、85、86、87、88、93、94 Clockout :P178

七、实验步骤

下载程序 ,拨动SW7 到不同的段位,此时会在数码管上显示出对应段位的频率值。

八、实验程序

1. VHDL 程序 library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;

entity Cymometer is

port(SysClk, Clkin: in std_logic;

SEG7, SCAN:out std_logic_vector(7 downto 0) ); end entity;

architecture Cymometer of Cymometer is signal cnt:std_logic_vector(24 downto 0); signal Clk_Cnt:std_logic;

signal cntp1,cntp2,cntp3,cntp4,cntp5,cntp6,cntp7,cntp8,Dat:std_logic_vector(3 downto 0); signal cntq1,cntq2,cntq3,cntq4,cntq5,cntq6,cntq7,cntq8:std_logic_vector(3 downto 0); begin

process( SysClk) begin

if SysClk'event and SysClk='1' then --if rising_edge(SysClk) then if cnt=19999999 then

Clk_Cnt<=not Clk_Cnt;

cnt<=\ else

cnt<=cnt+1; end if; end if; end process;

process(Clkin) begin

if Clkin'event and Clkin='1' then if Clk_Cnt='0' then

if cntp1=\ cntp1<=\ if cntp2=\ cntp2<=\ if cntp3=\ cntp3<=\ if cntp4=\ cntp4<=\ if cntp5=\ cntp5<=\ if cntp6=\ cntp6<=\ if cntp7=\ cntp7<=\

if cntp8=\ cntp8<=\ else

cntp8<=cntp8+1; end if; else

cntp7<=cntp7+1; end if; else

cntp6<=cntp6+1; end if; else

cntp5<=cntp5+1; end if; else

cntp4<=cntp4+1; end if; else

cntp3<=cntp3+1; end if; else

cntp2<=cntp2+1; end if; else

cntp1<=cntp1+1; end if; else

if cntp1/=\

cntp2/=\ or cntp6/=\ cntq1<=cntp1; cntq2<=cntp2; cntq3<=cntp3; cntq4<=cntp4; cntq5<=cntp5; cntq6<=cntp6; cntq7<=cntp7; cntq8<=cntp8; cntp1<=\ cntp2<=\ cntp3<=\ cntp4<=\ cntp5<=\ cntp6<=\