首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FSM Mealy机器序列检测器。如何使用多个触发器?

FSM Mealy机器序列检测器。如何使用多个触发器?
EN

Stack Overflow用户
提问于 2017-10-25 05:03:39
回答 1查看 789关注 0票数 0

现在我正在维瓦多做一个小项目,一个米利密克罗尼西亚联邦公司。程序必须检测6位序列001011,并在检测到序列时输出"1“。

有关序列检测的代码做得很好,但除此之外,它还必须使用三个触发器: JK、D和T。

对如何添加它们有任何建议或建议吗?

谢谢您抽时间见我。

这是密克罗尼西亚联邦的代码:

代码语言:javascript
复制
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;


entity sequence is
port(
    clk : in std_logic;
    reset : in std_logic;
    x: in std_logic;
    z : out std_logic;
    a : out std_logic;
    b : out std_logic;
    c : out std_logic;
    d : out std_logic;
    e : out std_logic;
    f : out std_logic);
end sequence;

architecture behavioral of sequence is


type state_type is (Q0, Q1, Q2, Q3, Q4, Q5);


signal state, next_state : state_type;

begin


state_register: process (clk, reset)
  begin
    if (reset = '1') then   --if reset is high, goto state Q0
       state <= Q0;
    elsif (clk'event and clk = '1') then    --if not, and rising 
       state <= next_state;                 --edge, go to next state
    end if;
end process;  


next_state_func: process (x, state)
begin 
  case state is 
      when Q0 =>
          if x = '0' then
             next_state <= Q1;
          else 
             next_state <= Q0;
          end if;
      when Q1 =>
           if x = '0' then
             next_state <= Q2;
           else
             next_state <= Q0;
           end if;
      when Q2 =>
           if x = '1' then
              next_state <= Q3;
           else 
              next_state <= Q2;
           end if;
      when Q3 =>
           if x ='0' then
              next_state <= Q4;
           else
              next_state <= Q0;
           end if;
      when Q4 =>
           if x = '1' then
              next_state <= Q5;
           else
              next_state <= Q2;
           end if;
      when Q5 =>
           if x = '1' then
              next_state <= Q0;
           else
              next_state <= Q1;                       
           end if;
      end case;
end process;

-- This process controls the output of the sequence detector.
-- Each state has it's own output along with 'z' which indicates
-- the entire sequence 001011 has been detected.
output_func:  process (x, state)
  begin
  case state is 
      when Q0 => z <= '0';
           a <= '1';
           b <= '0';
           c <= '0';
           d <= '0';
           e <= '0';
           f <= '0';
      when Q1 => z <= '0';
           a <= '0';
           b <= '1';
           c <= '0';
           d <= '0';
           e <= '0';
           f <= '0';
      when Q2 => z <= '0';
           a <= '0';
           b <= '0';
           c <= '1';
           d <= '0';
           e <= '0';
           f <= '0';
      when Q3 => z <= '0';
           a <= '0';
           b <= '0';
           c <= '0';
           d <= '1';
           e <= '0';
           f <= '0';
      when Q4 => z <= '0';
           a <= '0';
           b <= '0';
           c <= '0';
           d <= '0';
           e <= '1';
           f <= '0';
      when Q5 => z <= '1';
           a <= '0';
           b <= '0';
           c <= '0';
           d <= '0';
           e <= '0';
           f <= '1';
    end case;
  end process;

end behavioral;

1:https://i.stack.imgur.com/pVwxL.jpg -这里是包含FSM状态图表的表。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-26 07:31:56

你的代码错了。看看output_func过程;这是组合的,只是解码当前的状态,而不看xaf的输出是不必要的,只是当前状态的6位解码--为什么?z输出是在当前状态为Q5时设置的,这不是您想要的--整个过程都是多余的。如果当前状态为z,而x为1- ie,则需要在主FSM中设置x。关于next_state <= Q0跃迁。

在你的实际问题上-你不能强迫选择任何特定的F/F类型与此代码-合成器将做任何它想做的事,这意味着它将以D类型实现整个事情,因为JK已经过时了20年。T类型也可能是如此。您需要重新开始,并假装您有一个技术和一个具有T、D和JK的库。自己编写这些独立的实体,重新编写代码实例化这些组件,而不是让合成器推断它们。重写你的FSM来使用JKs -你给出的图表显示了你是如何使用的。换句话说,导出每个F/F的J和K输入,z输出可以是D型。你应该能在某个地方适应T-我已经把它留给你了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46924340

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档