一、mux出现LATCH,如在在异步的when里面,如果连接线没有otherwise分支会出现
[error] LATCH DETECTED from the combinatorial signal (toplevel/io_pus_0 : UInt[1 bits]), defined at
[error] common.genmux$.$anonfun$main$5(mux.scala:137)
[error] common.genmux$$$Lambda$44/321675814.apply(Unknown Source)
[error] common.genmux$mux.<init>(mux.scala:62)
[error] common.genmux$.$anonfun$main$4(mux.scala:137)
[error] common.genmux$$$Lambda$6/1651945012.apply(Unknown Source)
[error] spinal.sim.JvmThread.run(SimManager.scala:51)
二、when、elsewhen、otherwise可在循环中使用。
when实例会一个var的变量,然后elsewhen更新变量,otherwise不能更新变量
var v=when(...){}
v=v.eslewhen(...){}
v.otherwise(){}
以下一个例子
var mux = when(io_w(0)) { io_before.asInstanceOf[T] := io_pus(0) } for (i <- 1 until io_pus.size) { println(s"www2 i=${i} io_pus.size=${io_pus.size}") if (i != io_pus.size - 1) { mux = mux.elsewhen(io_w(i)) { io_before.asInstanceOf[T] := io_pus(i) } } else { mux.otherwise { io_before.asInstanceOf[T] := io_pus(i) } } }
三、类或者函数的构造函数的参数可实现构造函数的传递
如:
class mux[T <: Data](gen: => T){
io.valCallback(out(gen), s"orig")
}
实现会的原因
new mux[UInt](UInt(1 bits))