Fsm
fsm
¶
Implementation of the FSM dialect by CIRCT
See external documentation.
FSM = Dialect('fsm', [MachineOp, OutputOp, StateOp, TransitionOp, UpdateOp, VariableOp, ReturnOp, TriggerOp, InstanceOp, HWInstanceOp], [InstanceType])
module-attribute
¶
InstanceType
dataclass
¶
Bases: ParametrizedAttribute, TypeAttribute
Source code in xdsl/dialects/fsm.py
name = 'fsm.instancetype'
class-attribute
instance-attribute
¶
MachineOp
¶
Bases: IRDLOperation
Represents a finite-state machine, including a machine name,
the type of machine state, and the types of inputs and outputs. This op also
includes a $body region that contains internal variables and states.
Source code in xdsl/dialects/fsm.py
name = 'fsm.machine'
class-attribute
instance-attribute
¶
body = region_def()
class-attribute
instance-attribute
¶
sym_name = prop_def(SymbolNameConstraint())
class-attribute
instance-attribute
¶
initialState = prop_def(StringAttr)
class-attribute
instance-attribute
¶
function_type = prop_def(FunctionType)
class-attribute
instance-attribute
¶
arg_attrs = opt_prop_def(ArrayAttr[DictionaryAttr])
class-attribute
instance-attribute
¶
res_attrs = opt_prop_def(ArrayAttr[DictionaryAttr])
class-attribute
instance-attribute
¶
arg_names = opt_prop_def(ArrayAttr[StringAttr])
class-attribute
instance-attribute
¶
res_names = opt_prop_def(ArrayAttr[StringAttr])
class-attribute
instance-attribute
¶
traits = traits_def(NoTerminator(), SymbolTable(), SymbolOpInterface())
class-attribute
instance-attribute
¶
__init__(sym_name: str, initial_state: str, function_type: FunctionType | tuple[Sequence[Attribute], Sequence[Attribute]], arg_attrs: ArrayAttr[DictionaryAttr] | None, res_attrs: ArrayAttr[DictionaryAttr] | None, arg_names: ArrayAttr[StringAttr] | None, res_names: ArrayAttr[StringAttr] | None, body: Region | type[Region.DEFAULT] = Region.DEFAULT)
¶
Source code in xdsl/dialects/fsm.py
verify_()
¶
Source code in xdsl/dialects/fsm.py
StateOp
¶
Bases: IRDLOperation
Represents a state of a state machine. This op includes an
$output region with an fsm.output as terminator to define the machine
outputs under this state. This op also includes a transitions region that
contains all the transitions of this state
Source code in xdsl/dialects/fsm.py
name = 'fsm.state'
class-attribute
instance-attribute
¶
output = region_def()
class-attribute
instance-attribute
¶
transitions = region_def()
class-attribute
instance-attribute
¶
sym_name = prop_def(SymbolNameConstraint())
class-attribute
instance-attribute
¶
traits = traits_def(NoTerminator(), SymbolOpInterface(), HasParent(MachineOp))
class-attribute
instance-attribute
¶
__init__(sym_name: str, output: Region | type[Region.DEFAULT] = Region.DEFAULT, transitions: Region | type[Region.DEFAULT] = Region.DEFAULT)
¶
Source code in xdsl/dialects/fsm.py
verify_()
¶
Source code in xdsl/dialects/fsm.py
OutputOp
¶
Bases: IRDLOperation
Represents the outputs of a machine under a specific state. The
types of $operands should be consistent with the output types of the state
machine
Source code in xdsl/dialects/fsm.py
name = 'fsm.output'
class-attribute
instance-attribute
¶
operand = var_operand_def()
class-attribute
instance-attribute
¶
traits = traits_def(IsTerminator(), HasParent(StateOp))
class-attribute
instance-attribute
¶
__init__(operand: Sequence[SSAValue | Operation])
¶
verify_()
¶
Source code in xdsl/dialects/fsm.py
TransitionOp
¶
Bases: IRDLOperation
Represents a transition of a state with a symbol reference
of the next state. This op includes an optional $guard region with an fsm.return
as terminator that returns a Boolean value indicating the guard condition of
this transition. This op also includes an optional $action region that represents
the actions to be executed when this transition is taken
Source code in xdsl/dialects/fsm.py
name = 'fsm.transition'
class-attribute
instance-attribute
¶
guard = region_def()
class-attribute
instance-attribute
¶
action = region_def()
class-attribute
instance-attribute
¶
nextState = prop_def(FlatSymbolRefAttrConstr)
class-attribute
instance-attribute
¶
traits = traits_def(NoTerminator(), HasParent(StateOp))
class-attribute
instance-attribute
¶
__init__(nextState: SymbolRefAttr, guard: Region | type[Region.DEFAULT] = Region.DEFAULT, action: Region | type[Region.DEFAULT] = Region.DEFAULT)
¶
Source code in xdsl/dialects/fsm.py
verify_()
¶
Source code in xdsl/dialects/fsm.py
UpdateOp
¶
Bases: IRDLOperation
Updates the $variable with the $value. The definition op of
$variable should be an fsm.variable. This op should only appear in the
action region of a transtion
Source code in xdsl/dialects/fsm.py
name = 'fsm.update'
class-attribute
instance-attribute
¶
variable = operand_def(Attribute)
class-attribute
instance-attribute
¶
value = operand_def(Attribute)
class-attribute
instance-attribute
¶
traits = traits_def(HasParent(TransitionOp))
class-attribute
instance-attribute
¶
__init__(variable: SSAValue | Operation, value: SSAValue | Operation)
¶
verify_() -> None
¶
Source code in xdsl/dialects/fsm.py
VariableOp
¶
Bases: IRDLOperation
Represents an internal variable in a state machine with an initialization value
Source code in xdsl/dialects/fsm.py
name = 'fsm.variable'
class-attribute
instance-attribute
¶
initValue = prop_def()
class-attribute
instance-attribute
¶
name_var = opt_prop_def(StringAttr)
class-attribute
instance-attribute
¶
result = var_result_def(Attribute)
class-attribute
instance-attribute
¶
__init__(initValue: Attribute, name_var: str | None, result: Sequence[Attribute])
¶
Source code in xdsl/dialects/fsm.py
ReturnOp
¶
Bases: IRDLOperation
Marks the end of a region of fsm.transition and return
values if the parent region is a $guard region
Source code in xdsl/dialects/fsm.py
InstanceOp
¶
Bases: IRDLOperation
Represents an instance of a state machine, including an instance name and a symbol reference of the machine
Source code in xdsl/dialects/fsm.py
name = 'fsm.instance'
class-attribute
instance-attribute
¶
sym_name = prop_def(SymbolNameConstraint())
class-attribute
instance-attribute
¶
machine = prop_def(FlatSymbolRefAttrConstr)
class-attribute
instance-attribute
¶
res = result_def(InstanceType)
class-attribute
instance-attribute
¶
__init__(sym_name: str, machine: SymbolRefAttr, instance: InstanceType)
¶
Source code in xdsl/dialects/fsm.py
verify_()
¶
TriggerOp
¶
Bases: IRDLOperation
Triggers a state machine instance. The inputs and outputs are correponding to the inputs and outputs of the referenced machine of the instance
Source code in xdsl/dialects/fsm.py
name = 'fsm.trigger'
class-attribute
instance-attribute
¶
inputs = var_operand_def()
class-attribute
instance-attribute
¶
instance = operand_def(InstanceType)
class-attribute
instance-attribute
¶
outputs = var_result_def()
class-attribute
instance-attribute
¶
__init__(inputs: Sequence[SSAValue | Operation], instance: SSAValue, outputs: Sequence[Attribute])
¶
verify_()
¶
Source code in xdsl/dialects/fsm.py
HWInstanceOp
¶
Bases: IRDLOperation
Represents a hardware-style instance of a state machine, including an instance name and a symbol reference of the machine. The inputs and outputs are correponding to the inputs and outputs of the referenced machine.