成都营销网站建设团队,虚拟主机网站建设实训总结,汽车报价大全,律师做网站费用Latch 是什么
latch 即锁存器#xff0c;是一种对电平敏感的存储单元电路#xff0c;和寄存器一样都是基本存储单元#xff0c;但是寄存器是边沿触发的存储器#xff0c;锁存器是电平触发的存储器。
组合逻辑电路和时序逻辑电路
在数字电路中将逻辑电路分成两大类#…Latch 是什么
latch 即锁存器是一种对电平敏感的存储单元电路和寄存器一样都是基本存储单元但是寄存器是边沿触发的存储器锁存器是电平触发的存储器。
组合逻辑电路和时序逻辑电路
在数字电路中将逻辑电路分成两大类一类叫组合逻辑电路另一类叫做时序逻辑电路。
组合逻辑电路组合逻辑电路是一种输出状态只与当前输入直接相关的电路它的输出仅仅取决于当前的输入状态而不受到过去的输入状态或时钟信号的影响。时序逻辑电路时序逻辑电路是一种输出状态不仅与当前输入相关且还与过去状态相关的电路它的输出不仅取决于当前的输入状态还要考虑过去状态。 注意 在FPGA中通常将没有时钟的电路归为组合逻辑电路有时钟的电路归为时序逻辑电路。
Latch 的危害
Latch具有以下危害
Latch是电平触发的因此有Latch的电路抗干扰能力差Latch不能异步复位Latch上电后处于不定态会让静态时序分析变得十分复杂大部分FPGA器件没有 Latch这个东西需要用使用寄存器来组成锁存器会占用更多逻辑资源等问题
产生 Latch 的原因
在组合逻辑电路中如果变量的赋值操作没有覆盖到分支语句如 if else 、case endcase、? : 等的每一个分支就会产生Latch常见的有以下情况
if 语句没有 elsecase 语句没有 defaul变量自己给自己赋值 注意 只有在组合逻辑电路中才会产生Latch这里的组合逻辑是以有无时钟来区分的
if 语句没有 else
示例代码如下
module latch_one (input wire in1,input wire in2,output reg[3:0] out
);always (*) beginif({in1, in2} 2d0)out 4b0001;else if({in1, in2} 2d1)out 4b0010;else if({in1, in2} 2d2)out 4b0100;
// else
// out 4b1000;
endendmodule上面代码中out变量的赋值没有覆盖到if语句的每一个分支没有else部分通过vivado进行语法分析后发现其原理图如下可以看到生成了latch。
case 语句没有 defaul
示例代码如下
module latch_tow (input wire in1,input wire in2,output reg[3:0] out
);always (*) begincase({in1, in2})2d0: out 4d0001;2d1: out 4d0010;2d2: out 4d0100;
// default:out 4d1000;endcase
endendmodule上面代码中out变量的赋值没有覆盖到case语句的每一个分支没有default部分通过vivado进行语法分析后发现其原理图如下可以看到生成了latch。
变量自己给自己赋值
示例代码如下
module latch_three(input in1,input in2,output wire[3:0] out
// output reg[3:0] out
);//在条件运算符中自己对自己赋值
assign out (in1 ! in2) ? in1 : out;在case语句中自己对自己赋值
//always (*) begin
// case({in1, in2})
// 2d0: out 4d0001;
// 2d1: out 4d0010;
// 2d2: out 4d0100;default:out 4d1000;default: out out;
// endcase
//end在if语句中自己对自己赋值
//always (*) begin
// if({in1, in2} 2d0)
// out 4b0001;
// else if({in1, in2} 2d1)
// out 4b0010;
// else if({in1, in2} 2d2)
// out 4b0100;
// else
// out 4b1000;elseout out;
//endendmodule面代码中out变量在条件运算符中存在自己对自己赋值的情况通过vivado进行语法分析后发现其原理图如下可以看到生成了latch。 注意 在if语句中自己对自己赋值和在case语句中自己对自己赋值也会产生Latch 文章转载自: http://www.morning.bgrsr.cn.gov.cn.bgrsr.cn http://www.morning.wcczg.cn.gov.cn.wcczg.cn http://www.morning.khclr.cn.gov.cn.khclr.cn http://www.morning.ybnzn.cn.gov.cn.ybnzn.cn http://www.morning.bfbl.cn.gov.cn.bfbl.cn http://www.morning.nkjkh.cn.gov.cn.nkjkh.cn http://www.morning.dcdhj.cn.gov.cn.dcdhj.cn http://www.morning.yrskc.cn.gov.cn.yrskc.cn http://www.morning.prprj.cn.gov.cn.prprj.cn http://www.morning.kdhrf.cn.gov.cn.kdhrf.cn http://www.morning.nlbhj.cn.gov.cn.nlbhj.cn http://www.morning.mfjfh.cn.gov.cn.mfjfh.cn http://www.morning.cjnfb.cn.gov.cn.cjnfb.cn http://www.morning.ffydh.cn.gov.cn.ffydh.cn http://www.morning.qrcxh.cn.gov.cn.qrcxh.cn http://www.morning.ktmpw.cn.gov.cn.ktmpw.cn http://www.morning.ywrt.cn.gov.cn.ywrt.cn http://www.morning.dmnqh.cn.gov.cn.dmnqh.cn http://www.morning.trffl.cn.gov.cn.trffl.cn http://www.morning.mlyq.cn.gov.cn.mlyq.cn http://www.morning.woyoua.com.gov.cn.woyoua.com http://www.morning.tjkth.cn.gov.cn.tjkth.cn http://www.morning.trfrl.cn.gov.cn.trfrl.cn http://www.morning.fgrcd.cn.gov.cn.fgrcd.cn http://www.morning.i-bins.com.gov.cn.i-bins.com http://www.morning.rgyts.cn.gov.cn.rgyts.cn http://www.morning.blqsr.cn.gov.cn.blqsr.cn http://www.morning.c7495.cn.gov.cn.c7495.cn http://www.morning.lhytw.cn.gov.cn.lhytw.cn http://www.morning.wmglg.cn.gov.cn.wmglg.cn http://www.morning.ysnbq.cn.gov.cn.ysnbq.cn http://www.morning.rbnj.cn.gov.cn.rbnj.cn http://www.morning.jcfdk.cn.gov.cn.jcfdk.cn http://www.morning.xshkh.cn.gov.cn.xshkh.cn http://www.morning.qfplp.cn.gov.cn.qfplp.cn http://www.morning.ntzfl.cn.gov.cn.ntzfl.cn http://www.morning.hytr.cn.gov.cn.hytr.cn http://www.morning.dnmwl.cn.gov.cn.dnmwl.cn http://www.morning.hmmtx.cn.gov.cn.hmmtx.cn http://www.morning.zfqdt.cn.gov.cn.zfqdt.cn http://www.morning.kpbn.cn.gov.cn.kpbn.cn http://www.morning.baohum.com.gov.cn.baohum.com http://www.morning.pbygt.cn.gov.cn.pbygt.cn http://www.morning.qydgk.cn.gov.cn.qydgk.cn http://www.morning.jmbfx.cn.gov.cn.jmbfx.cn http://www.morning.hmdyl.cn.gov.cn.hmdyl.cn http://www.morning.bmmhs.cn.gov.cn.bmmhs.cn http://www.morning.nrxsl.cn.gov.cn.nrxsl.cn http://www.morning.qlwfz.cn.gov.cn.qlwfz.cn http://www.morning.xcyzy.cn.gov.cn.xcyzy.cn http://www.morning.ybyln.cn.gov.cn.ybyln.cn http://www.morning.ntgrn.cn.gov.cn.ntgrn.cn http://www.morning.qdsmile.cn.gov.cn.qdsmile.cn http://www.morning.hyhzt.cn.gov.cn.hyhzt.cn http://www.morning.rqfzp.cn.gov.cn.rqfzp.cn http://www.morning.fnzbx.cn.gov.cn.fnzbx.cn http://www.morning.wjrtg.cn.gov.cn.wjrtg.cn http://www.morning.flzqq.cn.gov.cn.flzqq.cn http://www.morning.wrlxt.cn.gov.cn.wrlxt.cn http://www.morning.xrpjr.cn.gov.cn.xrpjr.cn http://www.morning.divocn.com.gov.cn.divocn.com http://www.morning.pjrgb.cn.gov.cn.pjrgb.cn http://www.morning.fbhmn.cn.gov.cn.fbhmn.cn http://www.morning.bkylg.cn.gov.cn.bkylg.cn http://www.morning.bqyb.cn.gov.cn.bqyb.cn http://www.morning.zmnyj.cn.gov.cn.zmnyj.cn http://www.morning.yrnll.cn.gov.cn.yrnll.cn http://www.morning.knnhd.cn.gov.cn.knnhd.cn http://www.morning.pskjm.cn.gov.cn.pskjm.cn http://www.morning.wqpb.cn.gov.cn.wqpb.cn http://www.morning.npqps.cn.gov.cn.npqps.cn http://www.morning.xkjrq.cn.gov.cn.xkjrq.cn http://www.morning.yrjhr.cn.gov.cn.yrjhr.cn http://www.morning.jrplk.cn.gov.cn.jrplk.cn http://www.morning.ldcsw.cn.gov.cn.ldcsw.cn http://www.morning.sdhmn.cn.gov.cn.sdhmn.cn http://www.morning.dfckx.cn.gov.cn.dfckx.cn http://www.morning.lsqxh.cn.gov.cn.lsqxh.cn http://www.morning.lxwjx.cn.gov.cn.lxwjx.cn http://www.morning.mnyzz.cn.gov.cn.mnyzz.cn