'fsm' Dialect
Types and operations for FSM dialect
This dialect defines the fsm dialect, which is intended to represent
finite-state machines.
Operations
fsm.hw_instance (::circt::fsm::HWInstanceOp)
Create a hardware-style instance of a state machine
Syntax:
operation ::= `fsm.hw_instance` $name $machine attr-dict `(` $inputs `)`
`,` `clock` $clock `,` `reset` $reset `:` functional-type($inputs, $outputs)
fsm.hw_instance 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.
Interfaces: InstanceOpInterface
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
name | ::mlir::StringAttr | string attribute |
machine | ::mlir::FlatSymbolRefAttr | flat symbol reference attribute |
Operands:
| Operand | Description |
|---|---|
inputs | variadic of any type |
clock | A type for clock-carrying wires |
reset | 1-bit signless integer |
Results:
| Result | Description |
|---|---|
outputs | variadic of any type |
fsm.instance (::circt::fsm::InstanceOp)
Create an instance of a state machine
Syntax:
operation ::= `fsm.instance` $name $machine attr-dict
fsm.instance represents an instance of a state machine, including an
instance name and a symbol reference of the machine.
Interfaces: HasCustomSSAName
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
name | ::mlir::StringAttr | string attribute |
machine | ::mlir::FlatSymbolRefAttr | flat symbol reference attribute |
Results:
| Result | Description |
|---|---|
instance | An FSM instance type |
fsm.machine (::circt::fsm::MachineOp)
Define a finite-state machine
fsm.machine 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.
Traits: NoTerminator, SymbolTable
Interfaces: ArgAndResultAttrsOpInterface, CallableOpInterface, FunctionOpInterface, ModuleOpInterface, Symbol
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
sym_name | ::mlir::StringAttr | string attribute |
initialState | ::mlir::StringAttr | string attribute |
function_type | ::mlir::TypeAttr | type attribute of function type |
arg_attrs | ::mlir::ArrayAttr | Array of dictionary attributes |
res_attrs | ::mlir::ArrayAttr | Array of dictionary attributes |
argNames | ::mlir::ArrayAttr | string array attribute |
resNames | ::mlir::ArrayAttr | string array attribute |
fsm.output (::circt::fsm::OutputOp)
Output values from a state machine
Syntax:
operation ::= `fsm.output` attr-dict ($operands^ `:` qualified(type($operands)))?
“fsm.output” 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.
Traits: HasParent<StateOp>, ReturnLike, Terminator
Interfaces: RegionBranchTerminatorOpInterface
Operands:
| Operand | Description |
|---|---|
operands | variadic of any type |
fsm.return (::circt::fsm::ReturnOp)
Return values from a region
Syntax:
operation ::= `fsm.return` attr-dict ($operand^)?
“fsm.return” marks the end of a region of fsm.transition and return
values if the parent region is a $guard region.
Traits: HasParent<TransitionOp>, ReturnLike, Terminator
Interfaces: RegionBranchTerminatorOpInterface
Operands:
| Operand | Description |
|---|---|
operand | 1-bit signless integer |
fsm.state (::circt::fsm::StateOp)
Define a state of a machine
Syntax:
operation ::= `fsm.state` $sym_name attr-dict (`output` $output^)? (`transitions` $transitions^)?
fsm.state 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.
Traits: HasParent<MachineOp>, NoTerminator
Interfaces: Symbol
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
sym_name | ::mlir::StringAttr | string attribute |
fsm.transition (::circt::fsm::TransitionOp)
Define a transition of a state
Syntax:
operation ::= `fsm.transition` $nextState attr-dict (`guard` $guard^)? (`action` $action^)?
fsm.transition 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.
Traits: HasParent<StateOp>, NoTerminator
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
nextState | ::mlir::FlatSymbolRefAttr | flat symbol reference attribute |
fsm.trigger (::circt::fsm::TriggerOp)
Trigger an instance
Syntax:
operation ::= `fsm.trigger` $instance attr-dict `(` $inputs `)` `:` functional-type($inputs, $outputs)
fsm.trigger triggers a state machine instance. The inputs and outputs are
correponding to the inputs and outputs of the referenced machine of the
instance.
Operands:
| Operand | Description |
|---|---|
inputs | variadic of any type |
instance | An FSM instance type |
Results:
| Result | Description |
|---|---|
outputs | variadic of any type |
fsm.update (::circt::fsm::UpdateOp)
Update a variable in a state machine
Syntax:
operation ::= `fsm.update` attr-dict $variable `,` $value `:` qualified(type($value))
fsm.update 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.
Traits: HasParent<TransitionOp>, SameTypeOperands
Operands:
| Operand | Description |
|---|---|
variable | any type |
value | any type |
fsm.variable (::circt::fsm::VariableOp)
Declare a variable in a state machine
Syntax:
operation ::= `fsm.variable` $name attr-dict `:` qualified(type($result))
fsm.variable represents an internal variable in a state machine with an
initialization value.
Traits: FirstAttrDerivedResultType, HasParent<MachineOp>
Interfaces: HasCustomSSAName
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
initValue | ::mlir::Attribute | any attribute |
name | ::mlir::StringAttr | string attribute |
Results:
| Result | Description |
|---|---|
result | any type |
Types
InstanceType
An FSM instance type
Syntax: !fsm.instance
Represents an FSM instance.