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.

Type constraint definition 

An FSM instance type 

Represents an FSM instance.

Operation definition 

fsm.hw_instance (::circt::fsm::HWInstanceOp) 

Create a hardware-style instance of a state machine

Syntax:

operation ::= `fsm.hw_instance` $sym_name $machine attr-dict `(` $inputs `)` `:`
              functional-type($inputs, $outputs) (`,` `clock` $clock^ `:` type($clock))?
              (`,` `reset` $reset^ `:` type($reset))?

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.

Traits: AttrSizedOperandSegments

Interfaces: Symbol

Attributes: 

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

Operands: 

OperandDescription
inputsany type
clockany type
resetany type

Results: 

ResultDescription
outputsany type

fsm.instance (::circt::fsm::InstanceOp) 

Create an instance of a state machine

Syntax:

operation ::= `fsm.instance` $sym_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, Symbol

Attributes: 

AttributeMLIR TypeDescription
sym_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: FunctionLike, HasParentmlir::ModuleOp, IsolatedFromAbove, NoTerminator, SymbolTable

Interfaces: Symbol

Attributes: 

AttributeMLIR TypeDescription
sym_name::mlir::StringAttrstring attribute
stateType::mlir::TypeAttrany type attribute
type::mlir::TypeAttrany type attribute

fsm.output (::circt::fsm::OutputOp) 

Output values from a state machine

Syntax:

operation ::= `fsm.output` attr-dict ($operands^ `:` 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, ReturnLike, Terminator

Operands: 

OperandDescription
operandsany 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, ReturnLike, Terminator

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, SingleBlockImplicitTerminator

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 a $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 $action region that represents the actions to be executed when this transition is taken.

Traits: HasParent, SingleBlockImplicitTerminator

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
inputsany type
instanceAn FSM instance type

Results: 

ResultDescription
outputsany type

fsm.update (::circt::fsm::UpdateOp) 

Update a variable in a state machine

Syntax:

operation ::= `fsm.update` attr-dict $variable `,` $value `:` 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, 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 `:` type($result)

fsm.variable represents an internal variable in a state machine with an initialization value.

Traits: FirstAttrDerivedResultType, HasParent

Interfaces: HasCustomSSAName

Attributes: 

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

Results: 

ResultDescription
resultany type

Type definition 

InstanceType 

An FSM instance type

Represents an FSM instance.