最近用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. hive与依赖环境的交互
  2. php隐藏api,PHP 在 Laravel 中动态隐藏 API 字段
  3. java nio底层实现_Java NIO 底层原理
  4. 2019-07-18
  5. SignalR---DOTNET客户端
  6. MySQL主从同步(四)——M-M架构配置实战
  7. [转]win7添加xp的快速启动栏
  8. 【bzoj2806】[Ctsc2012]Cheat 广义后缀自动机+二分+单调队列优化dp
  9. 从nginx访问日志中的400错误说起
  10. 【Unity实战100例】技能伤害区域判定(矩形,圆,三角形,扇形)(三)
  11. 【题目精刷】2022诺瓦-数字IC设计
  12. Beyond Compare不能打开*.te文件解决方案
  13. Android--图片轮播(banner)
  14. matlab幼苗识别,基于MATLAB的植物幼苗识别
  15. 7-5 华氏度转摄氏度(四舍五入) (5分) java
  16. 算法设计 - 01背包问题
  17. Zabbix Server trapper命令注入漏洞(CVE-2020-11800)
  18. 一心多用多线程-Thread的api探险
  19. 2021年网络系统管理网络模块show
  20. LeetCode Weekly Contest 25 之 545.Boundary of Binary Tree

热门文章

  1. 监测你的SQL SERVER--让瓶颈暴露
  2. 古剑奇谭二服务器维护,《古剑奇谭二》10月4日例行维护更新公告
  3. 斯坦德机器人收购_斯坦德机器人合伙人兼CMO王茂林:人是公司发展根本,多数企业都死于合伙人...
  4. idea java编译报错_intellij-idea,java_idea 编译报错,intellij-idea,java - phpStudy
  5. java异常_聊聊Java中的异常及处理
  6. js里父页面与子页面的相互调用
  7. ecshop affiche.php,affiche.php
  8. flutter图标按钮_Flutter开发第一个项目android studio 开发工具的使用说明
  9. python文本数据增强_CVPR2020场景文字数据增强(纯python实现)
  10. 用python随机生成数字_如何实现python随机生成数字?