赋值覆盖(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
}