A latch is a binary storage device,composed of two or more gates,with feedback.
A flip flop is a clocked binary storage device,that is ,a device that stores either a 0 or a 1.The value will only change on the appropriate transition of the clock.
锁存器一般为电平触发,而触发器则由边沿(clock、置位、复位等)触发。
锁存器的缺点:
1、对毛刺敏感,毛刺信号在控制信号无效时会一直传递下去,影响系统稳定。并且没有异步复位,不能在芯片上电时处在一个稳定状态。
2、会使静态分析变的复杂,可测性不好,不利于设计的可重用性。所以在ASIC中高速CPU才会用到锁存器,一般很少用到。
3、FPGA中有大量的D触发器结构而没有锁存器结构,所以会浪费资源。
锁存器的优点就是消耗的资源比flip flop要少,所以在高集成度的ASIC中用的会比较多。
如何避免锁存器的出现:
1、分支条件中尽量覆盖全部条件,尤其是if…else…,case等。
具体的给大家推荐一下无双大哥的博文:
http://www.cnblogs.com/oomusou/archive/2008/08/09/1264292.html;
http://www.cnblogs.com/oomusou/archive/2012/01/29/verilog_else.html#2323314;
写的都是相当好的!!