CIRCT

Circuit IR Compilers and Tools

'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:

AttributeMLIR TypeDescription
name::mlir::StringAttrstring attribute
machine::mlir::FlatSymbolRefAttrflat symbol reference attribute

Operands:

OperandDescription
inputsvariadic of any type
clockA type for clock-carrying wires
reset1-bit signless integer

Results:

ResultDescription
outputsvariadic 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:

AttributeMLIR TypeDescription
name::mlir::StringAttrstring attribute
machine::mlir::FlatSymbolRefAttrflat symbol reference attribute

Results:

ResultDescription
instanceAn 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: CallableOpInterface, FunctionOpInterface, ModuleOpInterface, Symbol

Attributes:

AttributeMLIR TypeDescription
sym_name::mlir::StringAttrstring attribute
initialState::mlir::StringAttrstring attribute
function_type::mlir::TypeAttrtype attribute of function type
arg_attrs::mlir::ArrayAttrArray of dictionary attributes
res_attrs::mlir::ArrayAttrArray of dictionary attributes
argNames::mlir::ArrayAttrstring array attribute
resNames::mlir::ArrayAttrstring 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:

OperandDescription
operandsvariadic 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:

OperandDescription
operand1-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:

AttributeMLIR TypeDescription
sym_name::mlir::StringAttrstring 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:

AttributeMLIR TypeDescription
nextState::mlir::FlatSymbolRefAttrflat 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:

OperandDescription
inputsvariadic of any type
instanceAn FSM instance type

Results:

ResultDescription
outputsvariadic 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:

OperandDescription
variableany type
valueany 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:

AttributeMLIR TypeDescription
initValue::mlir::Attributeany attribute
name::mlir::StringAttrstring attribute

Results:

ResultDescription
resultany type

Types

InstanceType

An FSM instance type

Syntax: !fsm.instance

Represents an FSM instance.

'fsm' Dialect Docs