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

任何对时钟的管理形式,都是最大限度避免亚稳态情况的出现,从而提高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. 使用android-resource-remover优化资源使用率和lint-result.xml如果导出

    安装教程:http://blog.csdn.net/mlj1668956679/article/details/38643145   按照上面教程中.下载了 get-pip.py.后一运行出现这个问题 ...

  2. (转载)220v交流接触器自锁接线图另接热继电器

    220v交流接触器自锁接线图另接热继电器 时间:2015-06-26 20:36:56编辑:电工栏目:接触器 导读:求一个220v交流接触器自锁接线图,外加个热继电器怎么接,接线图中两根粉色的线接的就 ...

  3. vue.js $refs和$emit 父子组件交互

    父调子 $refs (把父组件的数据传给子组件)  <template> <div id="app"> <input type="butto ...

  4. 并发编程 – Concurrent 用户指南--转

    1. java.util.concurrent – Java 并发工具包 Java 5 添加了一个新的包到 Java 平台,java.util.concurrent 包.这个包包含有一系列能够让 Ja ...

  5. [Windows Azure] How to Scale an Application

    How to Scale an Application To use this feature and other new Windows Azure capabilities, sign up fo ...

  6. Recommender Systems中Yehuda Koren 和 Ma Hao的paper

    以前读了Yehuda Koren和Ma Hao的论文,感觉非常不错,这里分享一下.如果想着具体了解他们近期发的论文,可以去DBLP去看看. Yehuda Koren也是Netflix Prize的冠军 ...

  7. python将列表元素按指定数目分组

    比如,有时候,我们需要将列表中的元素,按照每5个分组,分成好几个组时,可以采用下面的代码 a = [1,2,3,4,5,6,7,8,9,10,11] step = 5 b = [a[i:i+step] ...

  8. JS操作MongoDB

    JavaScript处理MongoDB,更新数据: #!/bin/bash mongo=/home/zhangzhenghai/cluster/mongodb/bin/mongo if true; t ...

  9. C#对DataTable里数据筛选排序的方法

    在日常开发过程中,有一个DataTable集合,里面有很多字段,现在要求针对某一列进行排序,如果该列为数字的话,进行ASC即可实现,但是该字段类型为string,此时排序就有点不正确了 protect ...

  10. Leetcode:Longest Substring Without Repeating Characters 解题报告

    Longest Substring Without Repeating Characters Given a string, find the length of the longest substr ...