IO线束

简介

SpinalHDL 将检查每个 io 线束是否仅包含输入/输出/双向信号。其他类型的信号称为无方向信号。

示例

下面的代码:

class TopLevel extends Component {
  val io = new Bundle {
    val a = UInt(8 bits)
  }
}

会报错:

IO BUNDLE ERROR : A direction less (toplevel/io_a :  UInt[8 bits]) signal was defined into toplevel component's io bundle
  ***
  Source file location of the toplevel/io_a definition via the stack trace
  ***

一个可能的修复方法是:

class TopLevel extends Component {
  val io = new Bundle {
    val a = in UInt(8 bits)  // provide 'in' direction declaration
  }
}

但是,如果出于元硬件描述的原因,您确实希望 io.a 没有方向,您可以这样做:

class TopLevel extends Component {
  val io = new Bundle {
    val a = UInt(8 bits)
  }
  a.allowDirectionLessIo
}