对于全局时钟的管理,涉及到关于亚稳态的知识,大家可以上网搜索相关资料,这里不再赘述。亚稳态最简单的理解形式是无法判断是处于高电平状态还是处于低电平状态,这样会导致整个系统不稳定,会出现逻辑上的错误。

任何对时钟的管理形式,都是最大限度避免亚稳态情况的出现,从而提高MTBF(平均无故障时间)。

对于常用的异步复位形式(之前博客有提及到),如下:

always @(posedge clk or negedge rst_n)

    if(!rst_n) begin
......
......
end else begin
...........
...........
end

上述得异步复位结构,正常情况下,寄存器的更新会伴随clk的上升沿进行更新,但是rst_n何时结束就不一定了,若是在寄存器的   建立时间 + 保持时间之外,那么输出是稳定的,但是若是在这之内,那么会导致输出的数据不一定正确。

目前笔者搜索到的资料,较为合适的,能够最大限度降低亚稳态产生的逻辑电路,就是“异步复位,同步释放”。

module rstn_ (clk,rstn,rstn_out);
input clk ;
input rstn;
output rstn_out; //所要输出的复位信号
reg rst_out1,rst_out2;
always@(posedge clk or negedge rstn) begin
if(!rstn) begin
rst_out1 <= 'b0;
rst_out2 <= 'b0;
end
else begin
rst_out1 <= 'b1;
rst_out2 <= rst_out1;
end
assign rstn_out = rst_out2;
endmodule

RTL视图为:

通过两级缓存,使得rst_n也是伴随clk时钟下的使能信号。

  实际应用电路

那么在实际应用中,由于电源等芯片转换需要一定的时间,FPGA稳定启动需要一定的时间,外围电路启动也需要一定的时间,人为的添加50ms的延时电路,使整个系统稳定。

  有PLL参与的时钟电路

  RTL视图

  Verilog 代码

  延时模块:

/*********************************************************

//description : this module will complete function of system init delay when power on
//author : raymon
//address : GDUT university of technology
//e-mail : 770811496@qq.com
//contact : 770811496
//time : 2015-1-31 **********************************************************/
`timescale 1ns/1ns
module system_init_delay
#(
parameter SYS_DELAY_TOP = 'd2500000 //50ms system init delay
)
(
//-------------------------------------------
//global clock input clk, //50MHz
input rst_n, //system interface
output delay_done
); //------------------------------------------
//Delay 50ms for steady state when power on reg [:] delay_cnt = 'd0;
always@(posedge clk or negedge rst_n)
begin
if(!rst_n)
delay_cnt <= ;
else if(delay_cnt < SYS_DELAY_TOP - 'b1)
delay_cnt <= delay_cnt + 'b1;
else
delay_cnt <= SYS_DELAY_TOP - 'b1;
end
assign delay_done = (delay_cnt == SYS_DELAY_TOP - 'b1)? 1'b1 : 'b0; endmodule

  PLL

此模块是正常的利用quartus II生成的IP核PLL,这里不再讲解。

  顶层模块:

/*********************************************************

//description : this module will complete function of system init delay when power on
//author : raymon
//address : GDUT university of technology
//e-mail : 770811496@qq.com
//contact : 770811496
//time : 2015-1-31 **********************************************************/
`timescale 1ns/1ns
module sys_control(clk, rst_n, clk_ref, sys_rst_n); //----------------------------------------------
//globol clock
input clk; //50MHz
input rst_n; //reset //----------------------------------------------
//synced signal
output clk_ref; //clock output
output sys_rst_n; //system reset //----------------------------------
//component instantiation for system_delay
wire delay_done; //system init delay has done
system_init_delay
#(
.SYS_DELAY_TOP ('d2500000)
)
u_system_init_delay
(
//global clock
.clk (clk),
.rst_n ('b1), //It don't depend on rst_n when power up
//system interface
.delay_done (delay_done)
); //注意这里因为PLL的areset复位信号是高电平复位,和平常使用的rst_n信号正好相反
wire pll_reset = ~delay_done; //pll of ip needs high level to reset

//----------------------------------
//using IP
wire locked; sys_pll U1(
.areset(pll_reset),
.inclk0(clk),
.c0(clk_ref), //output 100MHz
.locked(locked)
); //----------------------------------------------
//rst_n sync, only controlled by the main clk
reg rst_nr1, rst_nr2;
always @(posedge clk_ref)
begin
if(!rst_n)
begin
rst_nr1 <= 'b0;
rst_nr2 <= 'b0;
end
else
begin
rst_nr1 <= 'b1;
rst_nr2 <= rst_nr1;
end
end
assign sys_rst_n = rst_nr2 & locked; //active low endmodule

  无PLL参与的时钟电路

  RTL视图

  Verilog 代码

/*********************************************************

//description : this module will complete function of system init delay when power on
//author : raymon
//address : GDUT university of technology
//e-mail : 770811496@qq.com
//contact : 770811496
//time : 2015-1-31 **********************************************************/
`timescale 1ns/1ns
module system_init_delay
#(
parameter SYS_DELAY_TOP = 'd2500000 //50ms system init delay
)
(
//-------------------------------------------
//global clock input clk, //50MHz
input rst_n, //system interface
output delay_done
); //------------------------------------------
//Delay 50ms for steady state when power on reg [:] delay_cnt = 'd0;
always@(posedge clk or negedge rst_n)
begin
if(!rst_n)
delay_cnt <= ;
else if(delay_cnt < SYS_DELAY_TOP - 'b1)
delay_cnt <= delay_cnt + 'b1;
else
delay_cnt <= SYS_DELAY_TOP - 'b1;
end
assign delay_done = (delay_cnt == SYS_DELAY_TOP - 'b1)? 1'b1 : 'b0; endmodule

  上述是延时部分的代码。

/*********************************************************

//description :this module will complete function of system init delay when power on
//author : raymon
//address : GDUT university of technology
//e-mail : 770811496@qq.com
//contact : 770811496
//time : 2015-1-31 **********************************************************/
`timescale 1ns/1ns
module system_ctrl(clk, rst_n, clk_ref, sys_rst_n); //----------------------------------------------
//globol clock
input clk;
input rst_n; //----------------------------------------------
//synced signal
output clk_ref; //clock output
output sys_rst_n; //system reset //----------------------------------------------
//rst_n sync, only controlled by the main clk
reg rst_nr1, rst_nr2;
always @(posedge clk)
begin
if(!rst_n)
begin
rst_nr1 <= 'b0;
rst_nr2 <= 'b0;
end
else
begin
rst_nr1 <= 'b1;
rst_nr2 <= rst_nr1;
end
end //----------------------------------
//component instantiation for system_delay
wire delay_done; //system init delay has done
system_init_delay
#(
.SYS_DELAY_TOP ('d2500000)
)
u_system_init_delay
(
//global clock
.clk (clk),
.rst_n ('b1), //It don't depend on rst_n when power up
//system interface
.delay_done (delay_done)
); assign clk_ref = clk;
assign sys_rst_n = rst_nr2 & delay_done; //active High endmodule

上述是实现整个模块,可以查看RTL视图。

上面提到的最大限度降低亚稳态复位电路,在应用时,直接可以调用。目前已在多个工程中使用。

//=======================================================================

更多详细的资料下载可以登录笔者百度网盘:

网址:http://pan.baidu.com/s/1bnwLaqF

密码:fgtb

//=======================================================================

FPGA内部动态可重置PLL讲解(二)的更多相关文章

  1. FPGA内部动态可重置PLL讲解(一)

    SDRAM驱动需要两个时钟,一个是控制时钟,一个是驱动时钟,这两个时钟有一个相位差,如何产生高精度的时钟是SDRAM能够正常工作的关键,采用FPGA内部动态可重置PLL生成SDRAM所需要的时钟频率. ...

  2. FPGA 内部详细架构你明白了吗?

    FPGA 芯片整体架构如下所示,大体按照时钟域划分的,即根据不同的工艺.器件速度和对应的时钟进行划分: FPGA 内部详细架构又细分为如下六大模块: 1.可编程输入输出单元(IOB)(Input Ou ...

  3. FPGA内部硬件结构简介

    我们知道FPGA内部有很多可供用户任意配置的资源,其中包括:可编程逻辑.可编程I/O.互连线.IP核等资源,很多学过数字电路的人都知道与或非门可以构成几乎所有的数字电路,但是FPGA内部最基本的主要单 ...

  4. 关于 FPGA 内部信号扇入扇出

    扇入.扇出系数 扇入系数是指门电路允许的输入端数目.一般门电路的扇入系数为1—5,最多不超过8.扇出系数是指一个门的输出端所驱动同类型门的个数,或称负载能力.一般门电路的扇出系数为8,驱动器的扇出系数 ...

  5. 【转】FPGA内部小数计算

    FPGA内部计算小数  [转载] 谓定点小数,就是小数点的位置是固定的.我们是要用整数来表示定点小数,由于小数点的位置是固定的,所以就没有必要储存它(如果储存了小数点的位置,那就是浮点数了).既然没有 ...

  6. FPGA内部信号避免高阻态

    RT,否则警告Warning: Tri-state node(s) do not directly drive top-level pin(s),会利用或门代替中间的扇出fan-out. 原因:在进行 ...

  7. C# 动态创建SQL数据库(二) 在.net core web项目中生成二维码 后台Post/Get 请求接口 方式 WebForm 页面ajax 请求后台页面 方法 实现输入框小数多 自动进位展示,编辑时实际值不变 快速掌握Gif动态图实现代码 C#处理和对接HTTP接口请求

    C# 动态创建SQL数据库(二) 使用Entity Framework  创建数据库与表 前面文章有说到使用SQL语句动态创建数据库与数据表,这次直接使用Entriy Framwork 的ORM对象关 ...

  8. FPGA内部IP核DDS

    项目当中需要正弦信号与余弦信号,首先想到了DDS芯片,例如AD9833.AD9834.由于还需要用FPGA   做一些数据处理,后来干脆直接用FPGA 内部的DDSIP核,同时根据IP核内部的相位累加 ...

  9. 风炫安全web安全学习第三十七节课 15种上传漏洞讲解(二)

    风炫安全web安全学习第三十七节课 15种上传漏洞讲解(二) 05后缀名黑名单校验之上传.htaccess绕过 还是使用黑名单,禁止上传所有web容器能解析的脚本文件的后缀 $is_upload = ...

随机推荐

  1. [svc]linux文件权限

    linux中,每个文件拥有三种权限 f dir权限位最佳实战 权限 对文件的影响 对文件夹的影响 r 可读取/阅读文件的内容 可以列出目录内容,无法cd,ls -l看到文件名,属性是乱码. w 可修改 ...

  2. Python使用读写excel文件

    Python使用openpyxl读写excel文件 这是一个第三方库,可以处理xlsx格式的Excel文件.pip install openpyxl安装.如果使用Aanconda,应该自带了. 读取E ...

  3. express中的路径区别

    请求的url:http://localhost:3000/api/article/upload?q=1000&n=tom请求方法:postconsole.log('hostname==='+r ...

  4. analysis-what-blockchain-technology-means-for-artificial-intelligence-cm888540

    http://m.nasdaq.com/article/analysis-what-blockchain-technology-means-for-artificial-intelligence-cm ...

  5. MYSQL performance

    https://www.mysql.com/why-mysql/performance/ https://www.slideshare.net/oysteing/how-to-analyze-and- ...

  6. Spring Boot中扩展XML请求和响应的支持

    在Spring Boot中,我们大多时候都只提到和用到了针对HTML和JSON格式的请求与响应处理.那么对于XML格式的请求要如何快速的在Controller中包装成对象,以及如何以XML的格式返回一 ...

  7. c++map的用法

    Map是c++的一个标准容器,她提供了很好一对一的关系,在一些程序中建立一个map可以起到事半功倍的效果,总结了一些map基本简单实用的操作!1. map最基本的构造函数:   map<stri ...

  8. STL之std::set、std::map的lower_bound和upper_bound函数使用说明

    由于在使用std::map时感觉lower_bound和upper_bound函数了解不多,这里整理并记录下相关用法及功能. STL的map.multimap.set.multiset都有三个比较特殊 ...

  9. How to disable SSL certificate checking with Spring RestTemplate?(使用resttemplate访问https时禁用证书检查)

    How to disable SSL certificate checking with Spring RestTemplate?(使用resttemplate访问https时禁用证书检查) **** ...

  10. 【机器学习】DBSCAN Algorithms基于密度的聚类算法

    一.算法思想: DBSCAN(Density-Based Spatial Clustering of Applications with Noise)是一个比较有代表性的基于密度的聚类算法.与划分和层 ...