Giving User-Defined properties for a signal

88 Views Asked by At

Disclaimer: I'm not super familiar with Scala. I have used Spinal/Chisel some to test out what I want to do, as well as create some simple HW, so please forgive me if these questions are "entry-level" from a Scala perspective.

I'm planning to use SpinalHDL for some connection automation. We have a bunch of IP that we can't/won't convert to SpinalHDL and much of it is mixed-signal. Because of this, I have some situations where additional signal information would allow me to further automate the design process. As an example, there are cases where some signals are on various power domains and their connections either need to be limited to said specific power domain or we would have to insert some logic like a level shifter.

Let's say I have a bundle of signals for some IP (this Bundle is on one of my BlackBoxes)

class MyBundle extends Bundle{
  val data     = in UInt(8 bits)
  val valid    = in Bool
  val pwr800mV = in Bool
  val pwr1800mv= in Bool
  val gnd      = in Bool
}

MyBundle is on a BlackBox, and I instantiate several of these in a Component. My idea is to be able to walk through the IOs/Signals in the Bundle and connect them to the appropriate higher level power/ground signal. Example:

class PwrSignal(v : Double = 1.8) extends Bool{
  val voltage = v
}
class MyBundle extends Bundle{
  val data     = in UInt(8 bits)
  val valid    = in Bool
  val pwr800mV = in PwrSignal(0.8)
  val pwr1800mv= in PwrSignal(1.8)
  val gnd      = in Bool
}

class MyComponent extends Component{
  //IO creation
  //pseudo...
  walkBundleSignals{
    if (signal.voltage == 1.8){ signal := top_level_power_1p8v}
  }
}

At first I tried to create a PwrSignal class that extends Bool, however this fails since PwrSignal is not a part of spinal.core.in.

Is there anyway to go about doing this?

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

Derp Alert: Since the default data types override the constructor, you just need to "new" the user defined data type.

class PwrSignal(v : Double = 1.8) extends Bool{
  val voltage = v
}
class MyBundle extends Bundle{
  val data     = in UInt(8 bits)
  val valid    = in Bool
  val pwr800mV = in (new PwrSignal(0.8))
  val pwr1800mv= in (new PwrSignal(1.8))
  val gnd      = in Bool
}