To provide an high speed multi threading environnement, SpinalSim use the scala-continuation feature. This feature while very powerfull come with some drawbacks.

You realy have to read this page if you want to do advanced things.

@suspendable annotation

Each function that can block the execution via an sleep/join/waitUntil statement should have its return type annotated with the @suspendable annotation.

For example :

def doStuff(value : Int) : Unit@suspendable = { #= value
  sleep(10) #= value + 1

It’s the reason why you can’block the execution inside scala for loops and foreach/map funcitonal things.

Alternative foreach, map statements

As described in with the @suspendable annotation chapter, you can’t use native foreach/map function on lists. Instead you will have to do the following :

val myList = List(1,2,3)
myList.suspendable.foreach{i =>

Weird type missmatch

//Compilation error

//Compilation OK
val dummy = if(something){

See for more info. (Unit@cpsParam[Unit,Unit] is equivalent to @suspendable)