package fsm
- Alphabetic
- Public
- All
Type Members
-
trait
EntryPoint extends AnyRef
This trait indicate the entry point of the state machine.
This trait indicate the entry point of the state machine.
- See also
setEntry
-
class
State extends Area with ScalaLocated
Represents a state within a state machine.
Represents a state within a state machine.
States can define behaviors for entry, exit, and active phases using methods like
onEntry,onExit, andwhenIsActive.val fsm = new StateMachine { val stateA: State = new State with EntryPoint { onEntry { counter := 0 } whenIsActive { counter := counter + 1 when(counter === 4) { goto(stateB) } } onExit { io.result := True } } val stateB: State = new State { whenIsActive { goto(stateA) } } }
Example: - class StateBoot extends State
- trait StateCompletionTrait extends AnyRef
-
class
StateDelay extends State with StateCompletionTrait
Allows you to create a state which waits for a fixed number of cycles before executing statements in whenCompleted {...}.
Allows you to create a state which waits for a fixed number of cycles before executing statements in whenCompleted {...}.
The preferred way to use it is:
val stateG : State = new StateDelay(cyclesCount=40) { whenCompleted { goto(stateH) } }
It can also be written in one line:
, val stateG : State = new StateDelay(40) { whenCompleted(goto(stateH)) }
Examples: -
class
StateFsm[T <: StateMachineAccessor] extends State with StateCompletionTrait
Allows you to describe a state containing a nested state machine.
Allows you to describe a state containing a nested state machine.
When the nested state machine is done (exited), statements in whenCompleted { ... } are executed.
This allows embedding a state machine as a state within another state machine. The embedded state machine starts on entry and completes on exit.
// internalFsm is a function defined below val stateC = new StateFsm(fsm=internalFsm()) { whenCompleted { goto(stateD) } } def internalFsm() = new StateMachine { val counter = Reg(UInt(8 bits)) init(0) val stateA : State = new State with EntryPoint { whenIsActive { goto(stateB) } } val stateB : State = new State { onEntry (counter := 0) whenIsActive { when(counter === 4) { exit() } counter := counter + 1 } } }
Example: -
class
StateMachine extends Area with StateMachineAccessor with ScalaLocated
Defines a state machine with states and transitions.
Defines a state machine with states and transitions.
val fsm = new StateMachine { val idleState: State = StateEntryPoint{ ... } val firstState: State = new State { whenIsActive { goto(idleState) } } }
- See also
Example: - trait StateMachineAccessor extends AnyRef
- class StateMachineEnum extends SpinalEnum
- class StateMachineSharableRegUInt extends AnyRef
- class StateMachineSlave extends StateMachine
- case class StateMachineTask(priority: Int, body: () ⇒ Unit) extends Product with Serializable
-
class
StateParallelFsm extends State with StateCompletionTrait
Allows you to handle multiple nested state machines.
Allows you to handle multiple nested state machines.
When all nested state machine are done, statements in whenCompleted { ... } are executed.
val stateD = new StateParallelFsm (internalFsmA(), internalFsmB()) { whenCompleted { goto(stateE) } }
Example:
Value Members
- object State
-
object
StateEntryPoint
Syntactic sugar for
new State with EntryPointSyntactic sugar for
new State with EntryPoint- See also
- object StateMachineCondLargeExample
- object StateMachineCondTransExample
- object StateMachineSharableUIntKey
- object StateMachineSimExample
- object StateMachineSimExample2
- object StateMachineSimpleExample
- object StateMachineStyle1
- object StateMachineStyle2
- object StateMachineStyle3
- object StateMachineTry2Example
- object StateMachineTry3Example
- object StateMachineTry6Example
- object StateMachineTryExample
- object StateMachineWithInnerExample
-
object
StatesSerialFsm
Runs several state machine in serially