We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome,
Firefox,
Internet Explorer 11,
Safari. Thank you!

AR# 60799

Description

This answer record describes the Vivado Synthesis Attributes fsm_encoding, fsm_safe_state, srl_style, and also provides coding examples for them.

The coding examples are attached to this answer record.

The answer record also contains information related to known issues and good coding practices.

Note: Each coding example can be used to directly create a Vivado project.

Please refer to the header in each source file for the Synthesis attributes covered in each example.

Solution

FSM_ENCODING

The fsm_encoding attribute directs Vivado Synthesis on what encoding style is to be used with a finite state machine. The value of "auto" is the default and allows Vivado Synthesis to choose the best FSM encoding based on the coding style. An FSM must first be inferred for the fsm_encoding to be used.

"auto" - Uses Hamming-3 encoding for auto-correction for one bit/flip.

"reset_state" Forces the state machine into the reset state using Hamming-2 encoding detection for one bit/flip.

Setting the fsm_safe_state to a value of "reset_state" will have the encoded state machine use a reset condition in the case where an invalid state is found.

A reset condition would be any state assignment to a state assignment on reset. Below is an example:

if (reset ='1') then state <= s1;

"power_on_state" Forces the state machine into the power-on state using Hamming-2 encoding detection for one bit/flip.

The "power_on_state" value for the fsm_safe_state attribute will have the same functionality as the "reset_state". This can be used in cases where there is no reset condition defined in the RTL and the intention is to use the initial INIT values of the state registers as a safe state.

"default_state" Forces the state machine into the state that is specified with the default state in RTL, even if that state is unreachable, using Hamming-2 encoding detection for one bit/flip.

For Verilog, the "default" keyword can be used along with the fsm_safe_state attribute to specify that the default value should be used for the safe state. For VHDL, the "when others" keywords has the same effect. With the default_state set for the fsm_safe_state attribute, the value applied to the state register in the default or "when others" section of a case statement will be used as the safe state.

The srl_style attribute directs Vivado Synthesis on whether a an SRL primitive should be inferred, and if a register is to be placed before the SRL, after the SRL, or both. For example, setting the srl_style attribute to a value of "reg_srl", will infer an SRL with a register driving the input of the SRL.