Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Logic 使用计数器作为输出的vhdl中的FSM_Logic_Vhdl_Fsm_Digital Logic - Fatal编程技术网

Logic 使用计数器作为输出的vhdl中的FSM

Logic 使用计数器作为输出的vhdl中的FSM,logic,vhdl,fsm,digital-logic,Logic,Vhdl,Fsm,Digital Logic,我目前正在写我的第一份FSM,不确定我的逻辑是否正确。我的任务是为以下逻辑创建状态图: A = 00 B = 01 C = 10 D = 11 在以下情况下,输出为1: BDA BAA BAD 为此,我创建了以下vhdl代码: 所以每次我把它送到输出1,我就把它送回B,然后计数+1。这应该在LED上显示为在18位序列中找到它的次数 我的方法正确吗?我对如何在18位序列中移动它感到困惑。我应该将电路板上的swtices作为我的18位,表示为SW。我会用SW(17到0)替换数据吗?这是一条评论,

我目前正在写我的第一份FSM,不确定我的逻辑是否正确。我的任务是为以下逻辑创建状态图:

A = 00
B = 01
C = 10
D = 11
在以下情况下,输出为1:

BDA
BAA
BAD
为此,我创建了以下vhdl代码:

所以每次我把它送到输出1,我就把它送回B,然后计数+1。这应该在LED上显示为在18位序列中找到它的次数


我的方法正确吗?我对如何在18位序列中移动它感到困惑。我应该将电路板上的swtices作为我的18位,表示为SW。我会用
SW(17到0)
替换数据吗?

这是一条评论,不是答案,我把它放在答案中,因为我还没有资格评论

我认为你在FSM概念上有一些问题。也正如在评论中所说,数据_in是标准逻辑,而不是向量。 您一次一位串行地获取输入,因此相应地编写流程。您可以编写代码来检测序列BDA、BAA、BAD,即序列“011100”、“010000”和“010011”。我会写一个简单的FSM代码,这样你可以清楚你的概念,然后你可以尝试

library ieee;
use IEEE.std_logic_1164.all;

entity mealy is
port (clk : in std_logic;
      reset : in std_logic;
      input : in std_logic;
      output : out std_logic
  );
end mealy;

architecture behavioral of mealy is

type state_type is (s0,s1,s2,s3);  --type of state machine.
signal current_s,next_s: state_type;  --current and next state declaration.

begin

process (clk,reset)
begin
 if (reset='1') then
  current_s <= s0;  --default state on reset.
elsif (rising_edge(clk)) then
  current_s <= next_s;   --state change.
end if;
end process;

--state machine process.
process (current_s,input)
begin
  case current_s is
     when s0 =>        --when current state is "s0"
     if(input ='0') then
      output <= '0';
      next_s <= s1;
    else
      output <= '1';
      next_s <= s2;
     end if;   

     when s1 =>;        --when current state is "s1"
    if(input ='0') then
      output <= '0';
      next_s <= s3;
    else
      output <= '0';
      next_s <= s1;
    end if;

    when s2 =>       --when current state is "s2"
    if(input ='0') then
      output <= '1';
      next_s <= s2;
    else
      output <= '0';
      next_s <= s3;
    end if;


  when s3 =>         --when current state is "s3"
    if(input ='0') then
      output <= '1';
      next_s <= s3;
    else
      output <= '1';
      next_s <= s0;
    end if;
  end case;
end process;

end behavioral;
ieee库;
使用IEEE.std_logic_1164.all;
实体米利是
端口(时钟:在标准逻辑中;
复位:在标准逻辑中;
输入:在标准逻辑中;
输出:输出标准逻辑
);
结束米利;
mealy is的建筑行为
类型状态_类型为(s0、s1、s2、s3)--状态机的类型。
信号电流,下一个:状态类型--当前和下一个状态声明。
开始
过程(时钟、复位)
开始
如果(reset='1'),则

当前的_对某些人来说似乎有不同的含义,或者你只是没有向我们展示你的?没有字符文字“00”、“11”或“10”。注意,数据是一个单元素std_逻辑。根据上下文子句和附加use子句,没有可用的“+”运算符。您要求对非功能性源代码中没有证据的执行环境(如testbench)进行评论。您的VHDL设计描述没有传达足够的信息来满足您的要求。@David Koontz好的,有没有办法将18位转换成9-2位的条目,我可以测试以使其正确?也许用移位寄存器?那么,我要算什么才能算是一个数字呢?