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, // ...
随机推荐
- [GUI] Linux中的图形管理
转:http://www.cnblogs.com/yongpenghan/p/4555619.html 做了一段时间linux下与QT事件相关的工作,经常会遇到X11,总是苦于无法完全理解其与linu ...
- MongoDB 使用Limit和Skip完成分页 和游标(二)
//$slice操作符返回文档中指定数组的内部值 //查询出Jim书架中第2~4本书 db.persons.find({name:"jim"},{books:{"$sli ...
- 4.2《深入理解计算机系统》笔记(五)并发、多进程和多线程【Final】
该书中第11章是写web服务器的搭建,无奈对web还比较陌生.还没有搞明白. 这些所谓的并发,其实都是操作系统做的事情,比如,多进程是操作系统fork函数实现的.I/O多路复用需要内核挂起进程.多线程 ...
- ZooKeeper服务-操作(API、集合更新、观察者、ACL)
操作 create:创建一个znode(必须要有父节点)delete:删除一个znode(该znode不能有任何子节点)exists:测试一个znode是否存在并且查询它的元数据getACL,setA ...
- 解决fasterxml中string字符串转对象json格式错误问题
软件152 尹以操 springboot中jackson使用的包是fasterxml的.可以通过如下代码,将一个形如json格式string转为一个java对象: com.fasterxml.jack ...
- tyvj 1884 [NOIP2000T4]方格取数 || codevs 1043 dp
P1884 [NOIP2000T4]方格取数 时间: 1000ms / 空间: 131072KiB / Java类名: Main 背景 [noip2000T4]方格取数 描述 设有N*N的方格图(N& ...
- 一个最简单的JMeter测试流程
环境: JMeter 3.3 JDK 1.8 首先下载JMeter安装包 可以去官网下载. http://jmeter.apache.org/ 然后选择Download Windows系 ...
- JMeter-Window10系统下设置环境变量
首先我们右击此电脑(我的电脑),点击属性 接下来我们就可以进入到控制面板主页,点击[高级系统设置] 在系统属性里面,点击[环境变量]按钮 在环境变量里面,点击[新建]按钮 接下来我们输 ...
- sqlserver设置具体的访问权限
为具体的用户设置具体的访问权限 收藏 use 你的库名 go --新增用户 exec sp_addlogin 'test' --添加登录 exec sp_grantdbaccess N'test' - ...
- 批量反编译class文件
首先得进入jad的路径中,一般都放在jdk的安装目录的bin中 进入到该目录中,否则无法使用jad命令. jad -o -r -d F:\src -s java F:\classes\**\*.cla ...