Vivado合成功能
 
•同步有限状态机(FSM)组件的特定推理能力。
 
•内置FSM编码策略,以适应您的优化目标。
 
•FSM提取默认启用。
 
•使用-fsm_extraction off可禁用fsm提取。
 
FSM描述
 
Vivado综合支持Moore和Mealy中的有限状态机(FSM)规范形式。FSM由以下部分组成:
 
•状态寄存器
 
•下一个状态功能
 
•输出功能
 
FSM图
 
下图显示了包含Mealy和Moore的FSM表示机器。
 

 
下图显示了一个包含三个进程的FSM图。
 

 
FSM寄存器
 
•指定Vivado合成的重置或通电状态,以识别有限状态机(FSM)或将FSM_ENCODING的值设置为“none”。
 
•状态寄存器可以异步或同步重置为特定状态。
 
注意:FSM使用同步重置逻辑而非异步重置逻辑。
 
自动状态编码
 
当FSM_ENCODING设置为“自动”时,Vivado合成会尝试选择最适合的给定FSM的编码方法。
 
一个热状态编码
 
一个热状态编码具有以下属性:
 
•是状态机的默认编码方案,最多32个状态。
 
•通常是优化速度或减少功耗的好选择。
 
•为每个FSM状态分配一个不同的代码位。
 
•实现状态寄存器,每个状态有一个触发器。
 
•在操作期间的给定时钟周期中,仅断言状态寄存器的一位。
 
•在两种状态之间的转换过程中,只有两位切换。
 
灰度编码
 
灰度编码具有以下属性:
 
•保证只有一位在两个连续状态之间切换。
 
•适用于无分支的长路径控制器。
 
•最大限度地减少危险和故障。
 
•可用于最大限度地减少功耗。
 
Johnson状态编码
 
当使用包含长路径且没有的状态机时,Johnson State编码是有益的分支(如在灰度编码中)。
 
顺序状态编码
 
顺序状态编码具有以下属性:
 
•识别长路径
 
•将连续的基数2代码应用于这些路径上的状态。
 
•最小化下一个状态方程。
 
 Filename: fsm_1.v  
 
 // State Machine with single sequential block  
 
 //fsm_1.v  
 
 module fsm_1(clk,reset,flag,sm_out);  
 
 input clk,reset,flag;  
 
 output reg sm_out;  
 
 parameter s1 = 3'b000;  
 
 parameter s2 = 3'b001;  
 
 parameter s3 = 3'b010;  
 
 parameter s4 = 3'b011;  
 
 parameter s5 = 3'b111;  
 
 reg [2:0] state;  
 
 always@(posedge clk)  
 
 begin  
 
 if(reset)  
 
 begin  
 
 state <= s1;  
 
 sm_out <= 1'b1;  
 
 end  
 
 else  
 
 begin  
 
 case(state) 
 
  s1: if(flag)  
  begin  
  state <= s2;  
  sm_out <= 1'b1;  
  end  
  else  
  begin  
  state <= s3;  
  sm_out <= 1'b0;  
  end  
  s2: begin state <= s4; sm_out <= 1'b0; end  
  s3: begin state <= s4; sm_out <= 1'b0; end  
  s4: begin state <= s5; sm_out <= 1'b1; end  
  s5: begin state <= s1; sm_out <= 1'b1; end  
  endcase  
  end  
  end  
  endmodule  
   FSM Example with Single Sequential Block (VHDL)  
  Filename: fsm_1.vhd  
  -- State Machine with single sequential block  
  -- File: fsm_1.vhd  
  library IEEE;  
  use IEEE.std_logic_1164.all;  
  entity fsm_1 is  
  port(  
  clk, reset, flag : IN std_logic;  
  sm_out : OUT std_logic  
  );  
  end entity;  
  architecture behavioral of fsm_1 is  
  type state_type is (s1, s2, s3, s4, s5);  
  signal state : state_type;  
  begin  
  process(clk)  
  begin  
  if rising_edge(clk) then  
  if (reset = '1') then  
  state <= s1;  
  sm_out <= '1';  
  else  
  case state is  
  when s1 => if flag = '1' then  
  state <= s2;  
  sm_out <= '1';  
  else  
  state <= s3;  
  sm_out <= '0';  
  end if;  
  when s2 => state <= s4;  
  sm_out <= '0';  
  when s3 => state <= s4;  
  sm_out <= '0';  
   when s4 => state <= s5;  
  sm_out <= '1';  
  when s5 => state <= s1;  
  sm_out <= '1';  
  end case;  
  end if;  
  end if;  
  end process;  
  end behavioral;  
  FSM报告
 Vivado合成在日志文件中标记INFO消息,提供有关有限状态的信息机器(FSM)组件及其编码。以下是消息示例:
  INFO: [Synth 8-802] inferred FSM for state register 'state_reg' in module  
  'fsm_test'  
  INFO: [Synth 8-3354] encoded FSM with state register 'state_reg' using  
  encoding 'sequential' in module 'fsm_test'