vhdl - vhdl 中的时钟分频器从 100MHz 到 1Hz 代码
问题描述
我写了这个代码来划分时钟一个nexys4 fpga,默认情况下它的集成时钟频率为100Mhz,我需要将它划分为1hz。有人可以告诉我它是否正确或者是否需要更改?
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
entity digi_clk is
port (clk1 : in std_logic;
clk : out std_logic
);
end digi_clk;
architecture Behavioral of digi_clk is
signal count : integer :=0;
signal b : std_logic :='0';
begin
--clk generation.For 100 MHz clock this generates 1 Hz clock.
process(clk1)
begin
if(rising_edge(clk1)) then
count <=count+1;
if(count = 50000000) then
b <= not b;
count <=0;
end if;
end if;
clk<=b;
end process;
end;
解决方案
代码看起来不错。然而,现有代码将产生一个略低于 1 Hz 的输出频率。要获得精确的 100000000:1 比率,您需要将条件语句从以下位置更改:
if(count = 50000000) then
... 至:
if(count = 50000000-1) then
推荐阅读
- hadoop - 如何防止hadoop以安全模式启动?
- html - 如何确保长文本在圆形内水平和垂直居中
- reactjs - React Native 错误 - 未定义不是函数(评估“(0 _reactnavigation.switchnavigator)”)
- ios - 隐藏在表格视图中的自定义范围滑块
- javascript - 使用 Javascript 函数进行时间转换
- sql - 在 Bigquery 中的 sum() 之后将科学记数法转换为浮点数
- php - 从具有相同值的两个表中选择数据后结果重复
- flutter - Flutter:如何在 ListView 中均匀分布 ListTiles
- r - r 在 dplyr 累积函数上添加一个组
- kubernetes - Kubernetes - 使用 Configmap 设置环境变量组