## 锁存器检测(Latch detected) ### 一、简介 SpinalHDL会检查在综合时没有组合逻辑信号会引入锁存器。换句话说, 这是检查没有组合信号被部分赋值。 ### 二、例子 下述代码: ```Scala class TopLevel extends Component { val cond = in(Bool) val a = UInt(8 bits) when(cond) { a := 42 } } ``` 会产生如下报错: ``` LATCH DETECTED from the combinatorial signal (toplevel/a : UInt[8 bits]), defined at *** Source file location of the toplevel/io_a definition via the stack trace *** ``` 修复为: ```Scala class TopLevel extends Component { val cond = in(Bool) val a = UInt(8 bits) a := 0 when(cond) { a := 42 } } ```