最近用Verilog HDL设计了一个小电路,一个3分频的电路,用的是我刚接触FPGA时,别人告诉我的思路,没想到今天才发现有大问题?

如下:

module Freq_divide(input clk,input rst_n,output reg clk_divide);wire clk_reverse;assign clk_reverse = ~clk;reg [3:0] count;always @ (posedge clk or posedge clk_reverse or negedge rst_n) beginif(!rst_n) begincount <= 0;endelse if(count < 2) begincount <= count + 1;endelse begincount <= 0;endendalways @ (posedge clk or posedge clk_reverse or negedge rst_n) beginif(!rst_n) beginclk_divide <= 0;endelse if(count == 2) beginclk_divide <= ~clk_divide;endelse beginclk_divide <= clk_divide;endendendmodule

这段代码确实是一个反面教材呀,为了偷懒,只是仿真了一下,觉得功能没有问题,还很满意,但是今天偶然的一次机会,我突然想看下RTL电路图,Vivado却报错了?

报错如下:

意思就是我的这句代码有问题:

always @ (posedge clk or posedge clk_reverse or negedge rst_n)

通过这种方式来实现双时钟采样是不对的。

这是问大神的聊天记录:

由对话可以得出信息,我博文标题中的两种方式都是不对的,一种是:

always@(posedge clk or negedge clk)

另一种是:

always@(posedge clk or posedge clk_reverse)

甚至这种也是不对的:

always@(posedge clk or negedge rst_n) begin

a <= 1'b0;

end

因为你没有用rst_n,Verilog会认为你的rst_n也是一个时钟,这又变成和上面两种情况一样的问题了。

这是在Xilinx官网上找到的解答:

[Synth 8-91] ambiguous clock in event control

https://forums.xilinx.com/t5/Welcome-Join/synth-8-91-ambiguous-clk-in-event-control/m-p/724225#M40235

解读的非常漂亮:

Re: [Synth 8-91] ambiguous clock in event control

You have to always remember that you are using Register Transfer Language (RTL) to have the synthesis infer hardware.

您必须始终记住您正在使用寄存器传输语言(RTL)来合成推断硬件。

Verilog HDL can do pretty much anything - the syntax of the always @(<whatever>) is very flexible. However, when you go to synthesize the design, the code has to map to an available piece of hardware on the FPGA.

Verilog HDL几乎可以做任何事情 -  always @(<whatever>)的语法非常灵活。 但是,当您进行综合设计时,代码必须映射到FPGA上的可用硬件。

On the FPGA we have combinatorial logic (LUTs, MUXes, etc...). These are inferred a variety of ways, including the always @(*) construct.

在FPGA上我们有组合逻辑(LUT,MUX等)。 这些是通过各种方式推断出来的,包括always @(*)构造。

In addition we have flip-flops. A flip-flop on an FPGA (and pretty much anywhere else) is a device that has one clock and is sensitive to only one edge of that clock. So, the synthesis tool can only map to this device when the sensitivity list is always @(posedge clk). We have variants of the flip-flop that can do asynchronous preset/clear, so will map to always @(posedge clk or <posedge/negedge> rst), but that's it.

另外我们有触发器。 FPGA(以及其他任何地方)上的触发器是一个具有一个时钟且仅对该时钟的一个边缘敏感的器件。 因此,当灵敏度列表始终为@(posedge clk)时,综合工具只能映射到此设备。 我们有触发器的变种,可以进行异步预置/清除,因此将映射到始终@(posedge clk或<posedge / negedge> rst),但就是这样。

There is no real hardware device that can do the equivalent of what you are describing - always @(posedge clk or negedge clk).

没有真正的硬件设备可以完成与你所描述的相同的东西 - 总是@(posedge clk or negedge clk)。

The only exception (sort of) are the IDDR and ODDR, and these need to be instantiated - they cannot be inferred from an HDL description.

唯一的例外(种类)是IDDR和ODDR,这些需要实例化 - 它们不能从HDL描述中推断出来。

So, no, this is not synthesizable Verilog.

因此,这不是可以综合的Verilog。


What exactly do you want to do? You want to clock your design at twice the rate of the incoming clock? If so, then use an MMCM to double your clock, and use that new high speed clock to clock your logic....

As for the GTX example design (and I don't know exactly what you are referring to), you have to realize that a whole bunch of different things are written in Verilog

- synthesizable RTL - this must use only the synthesizable portion of Verilog

- testbench code - this can use the entier Verilog HDL language

- models for library cells (see below)

If you are seeing something like always @(posedge clk or negedge clk) it is pretty much guaranteed that it is going to be in one of the last two (testbench code or library cell models) - these are not synthesizable and hence can use the entire Verilog language.

So, what is a library cell model... When we synthesize an RTL design, we end up with a netlist of Xilinx primitive devices. These primitive devices are really the set of transistors that physically exist on the Xilinx die. However, for simulation purposes, we must have simulation models for these cells.

For some cells (like the LUTs), these are pretty simple - the simulation model of the LUT has to perform the same Boolean operations that will end up happening in the LUT on the die (which is a purely digital thing).

For other cells, like the GTX, the silicon is very highly complex sets of analog and digital functionality. To simulate this, Xilinx provides a GTX simulation model that (at least grossly) describes the functionality of the GTX from a digital point of view - things like the PLLs and clock recovery and other stuff is abstracted so that the result mimics the digital functionality of the underlying silicon. In this model, again, the entire Verilog HDL language can be (and is used) to describe the functionality. However, this description is not (and doesn't need to be/shouldn't be) synthesizable...

归根结底,针对原问题,出问题的原因是FPGA中没有响应的硬件与之对应。

【 Verilog 】always@()的敏感源中为什么不能双边沿触发?为什么不能双时钟触发?相关推荐

  1. 敏感词汇检测及返回敏感源词汇

    import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;/* ...

  2. 在Python源中使用UTF-8编码[重复]

    本文翻译自:Working with UTF-8 encoding in Python source [duplicate] This question already has an answer h ...

  3. boost::regex模块实现以编程方式生成代码片段,以便剪切并粘贴到正则表达式源中测试程序

    boost::regex模块实现以编程方式生成代码片段,以便剪切并粘贴到正则表达式源中测试程序 实现功能 C++实现代码 实现功能 boost::regex模块实现以编程方式生成代码片段,以便剪切并粘 ...

  4. 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include quot;StdAfx.hquot;”?

    错误 16 error C1010: 在查找预编译头时遇到意外的文件结尾.是否忘记了向源中添加"#include "StdAfx.h""? c:\gsoap\g ...

  5. IntelliJ IDEA 如何知道项目中的模块数据_如何从项目源中选择模块加入当前项目中(添加模块)_如何移除项目中的模块(移除模块/删除模块)

    文章目录 IDEA 如何获取项目的模块数据 从项目源中选择模块加入当前项目中 如何移除项目中的模块 方式一,选择模块的根目录(Content Root),鼠标右键 Remove 方式二,打开[项目结构 ...

  6. python-演练-数据排除-从学生得分中去除题目源中并不存在的题

    需求与情况说明 需要删掉学生得分数据中,不存在的题目 当前有两个数据 题目源数据 学生得分数据 假设 题目源数据 = [a题目,b题目,c题目] 学生得分数据 = [a题目得分,b题目得分,e题目得分 ...

  7. (57)FPGA面试题-我们是否应该在敏感列表中包含组合电路的所有输入?

    1.1 FPGA面试题-我们是否应该在敏感列表中包含组合电路的所有输入? 1.1.1 本节目录 1)本节目录: 2)本节引言: 3)FPGA简介: 4)FPGA面试题-我们是否应该在敏感列表中包含组合 ...

  8. 三相交流电源中相电压电流符号表示

    三相交流电源中相电压符号表示: 相电压的表示方法是用U表示电压,右下角的角标表示相别;如UA.daoUB.版Uc.Ua.Ub.Uc.Uu.Uv.Uw. 相电流的表示符号是用权I表示电压,右下角的角标表 ...

  9. 区块链是什么意思?源中瑞开发BaaS平台促进企业数字转型升级

    现在许多商业区块链案例中,我们经常能看到BaaS这个词,所谓区块链BaaS是Blockchain as a Service的缩写,中文译为"区块链即服务",那么区块链BaaS究竟是 ...

最新文章

  1. 前端不哭!最新优化性能经验分享来啦 | 技术头条
  2. 夏日炎炎,请照顾好你的电脑
  3. TPAMI 2020 | 无监督多类域适应:理论,算法与实践
  4. 以太网数据帧的报尾封装字段是什么_16、90秒快速“读懂”数据包的封装、解封装...
  5. C++ STL 遍历 map 的时候如何删除其中的 element
  6. C\C++不经意间留下的知识空白------宏
  7. 理解 PHP output buffer
  8. checking build system type... ./config.guess: unable to guess system type/you must specify one
  9. 关于java实习报告周记_2019年度热门关于java实习报告周记优秀七篇
  10. 中国有多少家银行 最全名单统计
  11. .net接入微信二维码支付(模式二)
  12. Oracle中根据日期范围进行查询,查询大于某一天的数据,查询小于某一天的数据
  13. 智力题——1红蓝墨水
  14. matlab我方指挥,【单选题】机场指挥塔位置:北纬30度35.343分,东经104度2.441分,在MATLAB中用变量...
  15. Android最完整的仿QQ表情聊天图文展示代码示例
  16. xd导出标注html,Adobe XD免费交付神器 标记狮MarkLion 一键导出离线标注网页
  17. RHEL8.0快速入门系列笔记--理论知识储备(一)
  18. [力扣c语言实现]207. 课程表(拓扑排序)
  19. opengauss、GaussDB数据库安装-详细教程
  20. web2.0 时代我们需要什么样的阅读---转载

热门文章

  1. 用Unison+inotify实现数据的双向实时同步
  2. Amy Mcdonald - This is the Life
  3. winsock I/O模型
  4. 组装计算机的游戏,如何组装一台游戏电脑
  5. 测试MindMotion 的 ISP功能 - 无法进入ISP功能
  6. 走火入魔 | 暑期电子设计课程学生们的作品
  7. 斩草除根-修复被剪断的鼠标引线
  8. 半导体制冷片中的N,P半导体测试
  9. 第十五届全国大学生智能车竞赛浙江赛区隆重开幕
  10. 如何配置Keil 外部编辑器?