why latches are considered bad?
A "latch" is different from a "Flip-Flop" in that a FF only changes its output in response to a clock edge. A latch can change its output in response to something other than a clock. For example, an SR-Latch has a set and a reset input and if either of them are active then the output can change. Where as an SR-FF only responds to a set or reset when there is also a clock edge.
In an FPGA, you want your logic to be fully synchronous. Meaning that all storage elements (like FF's) are all clocked from a single clock source. Anything that is asynchronous to that clock needs to be treated very carefully otherwise timing errors will occur.
A latch is basically an asynchronous storage element. It has no clock input, and thus cannot be synchronized with any clock. I should note that there are FF's with asynchronous reset and reset inputs, and these should be treated with the same care as normal latches.
Going into all of the timing issues that latches can cause is way beyond what can be covered here, but let me give you one example:
Let's say that you have an SR-Latch, and you want it to be set every time an 8-bit counter reaches a certain value. I'm not sure what the Verilog code would be, but in VHDL the code is: set <= '1' when count="11010010" else '0'; That set signal goes to the set input on our SR-Latch.
The logic that is generates is purely combinatorial; a mix of and-gates, or-gates, and inverters (Or LUTs). But the signal paths through that combinatorial logic is not always perfect and the "set" signal could have glitches on it. The signal path through a particular group of gates could take longer than another group, causing the set output to go active for a brief moment before the output settles down into the final state.
This output glitch could cause our SR-Latch to be set, even though it wasn't supposed to. If we switch from an SR-Latch to an SR-FF, clocked off the same clock that the counter is, then the SR-FF will wait for one whole clock cycle before changing state. In essence it will wait for the set signal to settle before looking at it.
If the paths through combinatorial logic for the set signal is just routed differently (causing different delays), then the glitch behavior will change too. The logic might work fine, but then because you changed something entirely unrelated this logic is routed differently and so the bug pops up. Temperature and voltage will also change the signal timing, and thus can change the glitch behavior.
This uncertainly in the timing is why you should avoid latches in your logic. FF's are much safer to use. This is why your compiler is warning you about latches, since it is easy to mistakenly make a latch and you probably don't want it there anyway.
Of course, sometimes latches are required. You just have to use them very rarely, only when absolutely required, and then you must design the logic right so there are no glitches possible.
why latches are considered bad?的更多相关文章
- What makes an inferred latch? how To avoid creating inferred latches? when do you know you need latches?
What makes an inferred latch?For combinatorial logic, the output of the circuit is a function of inp ...
- BAYESIAN STATISTICS AND CLINICAL TRIAL CONCLUSIONS: WHY THE OPTIMSE STUDY SHOULD BE CONSIDERED POSITIVE(转)
Statistical approaches to randomised controlled trial analysis The statistical approach used in the ...
- [20190214]11g Query Result Cache RC Latches补充.txt
[20190214]11g Query Result Cache RC Latches补充.txt --//上午测试链接:http://blog.itpub.net/267265/viewspace- ...
- [20190214]11g Query Result Cache RC Latches.txt
[20190214]11g Query Result Cache RC Latches.txt --//昨天我重复链接http://www.pythian.com/blog/oracle-11g-qu ...
- Oracle Shared Pool机制之——Latches, Locks, Pins and Mutexes
本文中,我们将讨论共享池(Shared Pool)中的各种内存保护结构,即Latches,Locks,Pins和Mutexes. 1. Lathes 当在库缓冲(Libraray Cache)中创建 ...
- [DEPRECATION] Encountered positional parameter near xxx Positional parameter are considered deprecated; use named parameters or JPA-style positional parameters instead.
WARN:30 20:55:45,340ms- [HqlSqlWalker]1009行-[DEPRECATION] Encountered positional parameter near line ...
- oracle(enquences & latches )lock (oracle 锁大全)
资料来自官方文档: https://docs.oracle.com/database/121/CNCPT/consist.htm#CNCPT1333 https://docs.oracle.com/d ...
- Exception Handling Considered Harmful
异常处理被认为存在缺陷 Do, or do not. There is no try. - Yoda, The Empire Strikes Back (George Lucas) by Jason ...
- Which ports are considered unsafe on Chrome
1, // tcpmux 7, // echo 9, // discard 11, // systat 13, // daytime 15, // netstat 17, // qotd 19, // ...
随机推荐
- SOA 面向服务架构 阅读笔记(二)
SOA并不能保证企业的员工更加轻松,企业的收益更加客观. 6.软件组件 6.1 组件和组件的作用 通过可重用的软件代码-组件,可以构建灵活的软件. 6.2 软件组件又称为应用程序,程序,函数,模 ...
- vue引入bootstrap.min.css报错:Cannot find module "./assets/css/bootstrap.min.css"
问题如下图: 明明文件就在那里,就是报错说找不到模板,然后我就用了网上的方法,重新建立了一个项目,请参考如下: http://blog.csdn.net/ansu2009/article/detail ...
- Python 时间日历类型
# 时间日历 # time模块 # 提供了处理时间和表示之间转换的功能 # 获取当前时间戳 # 概念 # 从0时区的1970年1月1日0时0分0秒, 到所给定日期时间的秒数 # 浮点数 # 获取方式 ...
- DBUtiles中的简单使用(QueryRunner和ResultSetHandler的手动实现)
DBUtiles是一个很好的处理JDBC的工具类.(DbUtils is a small set of classes designed to make working with JDBC easie ...
- python统计代码行数
以前写了一个java的统计代码行数的小程序,最近在看python,于是就参考前辈的代码,写了一个统计文件夹下面各种程序的代码的小程序,这里贴出来供大家参考 参考链接: https://gist.git ...
- 经典的MapReduce1中的失败
经典的MapReduce1中的失败在MapReduce1运行时,主要考虑三种失败的模式,运行任务失败.tasktracker失败以及jobtracker失败1. 任务运行失败首先考虑子任务失败的情况. ...
- HIVE HSQL 基本操作命令
创建表: hive>create table tablename(id int,name string,password string); 创建一个名字为tablename的表,表的属性有int ...
- Apache Phoenix的Array类型
Apache Phoenix支持JDBC ARRAY类型,任何原生的数据类型就可以在ARRAY中使用.下面我介绍一下在创建的表中使用ARRAY类型. 先看一下创建表的SQL语句: CREATE TAB ...
- 初探MyBatis之HelloWorld(三)
三.用SQL映射语句用注解,dataSource用xml(不推荐). 综合上面两节(一个用xml,一个用annotation),发现一个好玩儿的,SQL映射用注解方式,然后还是得有两个xml配置文件. ...
- JMeter常用的调试工具
JMeter常用的调试工具有如下五种: 1.View Tree:查看结果树.含请求信息.响应信息等,请求头信息中的cookie信息一般默认不会显示,可通过修改JMeter配置参数进行显示.日常大家用的 ...