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 input only and should not contain any memory or internal state (latch).
In Verilog, a variable will keep its previous value if it is not assigned a value in an always block. A latch must be created to store this present value.
An incomplete if-else statement will generate latches. An if-else statement is considered "incomplete" if the output state is not defined for all possible input conditions. The same goes for an incomplete case statement, or a case statement that does not have a default: item.
Why are inferred latches bad?
Inferred latches can serve as a 'warning sign' that the logic design might not be implemented as intended. A crucial if-else or case statement might be missing from the design.
Latches can lead to timing issues and race conditions. They may lead to combinatorial feedback - routing of the output back to the input - which can be unpredictable.
To avoid creating inferred latches:
Include all the branches of an if or case statement
Assign a value to every output signal in every branch
Use default assignments at the start of the procedure, so every signal will be assigned.
Some parts paraphrased from "FPGA Prototyping by Verilog Examples" by P. Chu
when do you know you need latches?
Which, as you implied, is a subjective question. Expect more opinion than fact as answers. That being said, here is my opinion:
I, like you, often find better ways to use flip-flops thus avoiding latches. The resulting logic is often more elegant and robust. But there are times where I don't have enough control over the logic to avoid latches. For example, I might be interfacing to a processor bus that requires latches to meet the desired specifications. Since I can't redesign the CPU or the bus, I'm stuck with the latch.
In the past 13+ years, that is the only time I have needed latches.
最新文章
- 2012 Multi-University Training Contest 9 / hdu4389
- Bootstrap CSS概览代码文字标注篇
- viewport ——视区概念,为 自适应网页设计
- Codeforces Round #352 (Div. 2) A	 Summer Camp
- Qt 学习资料
- OpenStack介绍
- 用NOPI将图片二进制流导出到Excel
- jquery中判断是否按下回车enter键
- 【原创】Kmeans算法 优缺点分析
- 如何在python脚本里面连续执行adb shell后面的各种命令
- 结束《Java编程思想》(Thinking in Java)自学的读后感(2017.10.15)
- python 类的介绍
- Python设计模式 - UML - 用例图(Use Case Diagram)
- apache geode 试用
- 用python写web一定要去破解的异步请求问题.经历web.py和tornado,完破!
- django关系类型字段
- Jsp基础语法(由简入杂)
- 在EF中使用MySQL的方法及常见问题
- C++加速程序的全局执行函数
- TopJUI | easyui HTML Dialog页面间GET方式数据传递