You're reading an old version of this documentation.
For the latest stable release version, please have a look at master.

Register defined as component input

Introduction

In SpinalHDL, it is not allowed to define an component input as a register. The reason of that is for the user to avoid having surprise when he drive sub components inputs.

Example

The following code :

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

will throw :

REGISTER DEFINED AS COMPONENT INPUT : (toplevel/io_a : in UInt[8 bits]) is defined as a registered input of the toplevel component, but isn't allowed.
  ***
  Source file location of the toplevel/io_a definition via the stack trace
  ***

A fix could be :

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