赋值覆盖(Assignment Overlap)
一、简介
SpinalHDL将会检查, 没有任何的信号赋值会完全抹除前面的赋值。
二、例子
下列代码:
class TopLevel extends Component {
val a = UInt(8 bits)
a := 42
a := 66 // Erase the a := 42 assignment
}
将会产生如下报错:
ASSIGNMENT OVERLAP completely the previous one of (toplevel/a : UInt[8 bits])
***
Source file location of the a := 66 assignment via the stack trace
***
可以修复为:
class TopLevel extends Component {
val a = UInt(8 bits)
a := 42
when(something) {
a := 66
}
}
但当某些情况下, 如果用户真的需要去覆盖掉之前的赋值(因为在某些时候覆盖是有意义的), 则可以使用如下表达:
class TopLevel extends Component {
val a = UInt(8 bits)
a := 42
a.allowOverride
a := 66
}