FSM handling

fsm - extract and optimize finite state machines

yosys> help fsm
fsm [options] [selection]
This pass calls all the other fsm_* passes in a useful order. This performs
FSM extraction and optimization. It also calls opt_clean as needed:

    fsm_detect          unless got option -nodetect
    fsm_extract

    fsm_opt
    opt_clean
    fsm_opt

    fsm_expand          if got option -expand
    opt_clean           if got option -expand
    fsm_opt             if got option -expand

    fsm_recode          unless got option -norecode

    fsm_info

    fsm_export          if got option -export
    fsm_map             unless got option -nomap

Options:
-expand, -norecode, -export, -nomap
enable or disable passes as indicated above
-fullexpand
call expand with -full option
-encoding type
-fm_set_fsm_file file
-encfile file
passed through to fsm_recode pass
This pass uses a subset of FF types to detect FSMs. Run 'opt -nosdff -nodffe'
before this pass to prepare the design.

The Verific frontend may merge multiplexers in a way that interferes with FSM
detection. Run 'verific -cfg db_infer_wide_muxes_post_elaboration 0' before
reading the source, and 'bmuxmap' after 'proc' for best results.

Note

Help text automatically generated from passes/fsm/fsm.cc:29

fsm_detect - finding FSMs in design

yosys> help fsm_detect
fsm_detect [options] [selection]
This pass detects finite state machines by identifying the state signal.
The state signal is then marked by setting the attribute 'fsm_encoding'
on the state signal to "auto".
-ignore-self-reset
Mark FSMs even if they are self-resetting
Existing 'fsm_encoding' attributes are not changed by this pass.

Signals can be protected from being detected by this pass by setting the
'fsm_encoding' attribute to "none".

This pass uses a subset of FF types to detect FSMs. Run 'opt -nosdff -nodffe'
before this pass to prepare the design for fsm_detect.

The Verific frontend may optimize the design in a way that interferes with FSM
detection. Run 'verific -cfg db_infer_wide_muxes_post_elaboration 0' before
reading the source, and 'bmuxmap -pmux' after 'proc' for best results.

Note

Help text automatically generated from passes/fsm/fsm_detect.cc:259

fsm_expand - expand FSM cells by merging logic into it

yosys> help fsm_expand
fsm_expand [-full] [selection]
The fsm_extract pass is conservative about the cells that belong to a finite
state machine. This pass can be used to merge additional auxiliary gates into
the finite state machine.

By default, fsm_expand is still a bit conservative regarding merging larger
word-wide cells. Call with -full to consider all cells for merging.

Note

Help text automatically generated from passes/fsm/fsm_expand.cc:267

fsm_export - exporting FSMs to KISS2 files

yosys> help fsm_export
fsm_export [-noauto] [-o filename] [-origenc] [selection]
This pass creates a KISS2 file for every selected FSM. For FSMs with the
'fsm_export' attribute set, the attribute value is used as filename, otherwise
the module and cell name is used as filename. If the parameter '-o' is given,
the first exported FSM is written to the specified filename. This overwrites
the setting as specified with the 'fsm_export' attribute. All other FSMs are
exported to the default name as mentioned above.
-noauto
only export FSMs that have the 'fsm_export' attribute set
-o filename
filename of the first exported FSM
-origenc
use binary state encoding as state names instead of s0, s1, ...

Note

Help text automatically generated from passes/fsm/fsm_export.cc:122

fsm_extract - extracting FSMs in design

yosys> help fsm_extract
fsm_extract [selection]
This pass operates on all signals marked as FSM state signals using the
'fsm_encoding' attribute. It consumes the logic that creates the state signal
and uses the state signal to generate control signal and replaces it with an
FSM cell.

The generated FSM cell still generates the original state signal with its
original encoding. The 'fsm_opt' pass can be used in combination with the
'opt_clean' pass to eliminate this signal.

Note

Help text automatically generated from passes/fsm/fsm_extract.cc:417

fsm_info - print information on finite state machines

yosys> help fsm_info
fsm_info [selection]
This pass dumps all internal information on FSM cells. It can be useful for
analyzing the synthesis process and is called automatically by the 'fsm'
pass so that this information is included in the synthesis log file.

Note

Help text automatically generated from passes/fsm/fsm_info.cc:32

fsm_map - mapping FSMs to basic logic

yosys> help fsm_map
fsm_map [selection]
This pass translates FSM cells to flip-flops and logic.

Note

Help text automatically generated from passes/fsm/fsm_map.cc:324

fsm_opt - optimize finite state machines

yosys> help fsm_opt
fsm_opt [selection]
This pass optimizes FSM cells. It detects which output signals are actually
not used and removes them from the FSM. This pass is usually used in
combination with the 'opt_clean' pass (see also 'help fsm').

Note

Help text automatically generated from passes/fsm/fsm_opt.cc:326

fsm_recode - recoding finite state machines

yosys> help fsm_recode
fsm_recode [options] [selection]
This pass reassign the state encodings for FSM cells. At the moment only
one-hot encoding and binary encoding is supported.
-encoding <type>
specify the encoding scheme used for FSMs without the
'fsm_encoding' attribute or with the attribute set to `auto'.
-fm_set_fsm_file <file>
generate a file containing the mapping from old to new FSM encoding
in form of Synopsys Formality set_fsm_* commands.
-encfile <file>
write the mappings from old to new FSM encoding to a file in the
following format:

.fsm <module_name> <state_signal>
.map <old_bitpattern> <new_bitpattern>

Note

Help text automatically generated from passes/fsm/fsm_recode.cc:129