最近用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. (chap6 Http首部) 响应首部字段 Accept-RangeAge Etag
  2. Samsung Pay体验札记:或推支付新浪潮
  3. MySQL数据库:查看数据库性能常用命令
  4. ocelot简单入门
  5. python中静态方法存在的意义
  6. Linux 大文件拷贝失败,linux – Rsync失败,“文件太大”
  7. 正则表达式去除括号的问题
  8. 图片随意命名可能被广告拦截插件拦截
  9. 360浏览器保存网页html5,360浏览器怎么保存整个网页为图片?
  10. Java扫码登录原理
  11. 把电脑做成服务器系统,把电脑做成云盘服务器
  12. 计算机怎么看事件管理,win7系统事件查看器怎么打开
  13. 计算机管理系统功能模块,设备管理系统功能模块
  14. CCID 设备通讯 (Windows 平台)
  15. Android 模仿淘宝历史记录,记录存在手机内
  16. C++:亲戚(relation)
  17. 【Unity3D】AudioSource组件
  18. 【Python】关键字
  19. html5与cs6,【CS6新功能介绍】EPUB 和 HTML5
  20. 智慧交通、智能交通有啥区别

热门文章

  1. Java多线程协作(wait、notify、 notifyAll)
  2. Oracle其他函数
  3. android fersco 框架,Android Fresco框架的简单使用
  4. ylinux系统找到软件_电脑用了段时间发现多处一些软件该怎么办?
  5. windows查看python安装的库_Python第三方库face_recognition在windows上的安装过程
  6. 【web前端】可筛选[输入搜索]的select(重写)
  7. java线程饥饿死锁_java并发-线程饥饿死锁测试
  8. android webview gettitle,Android-webview加载网页去除标题
  9. 计算机教育的发展,计算机教育发展方向研究
  10. oracle 11.2.0.3 asm非rac双机,oracle11.2.0.4 rac asm启动故障