【发布时间】:2018-05-14 00:06:49
【问题描述】:
现在我正在做一个关于在下降沿使用 D 触发器的项目,其中 x 和 y 是输入,z 是输出。
只有当 x 和 y 都为 0 并且它们在前一个时钟周期中都为 0 并且仅在时钟的下降沿发生转换时,电路才会给出 z ='1'。
变量 a 和 b 将代表状态 Q0(a) 和 Q1(b)。
Mealy 机有 Q0 和 Q1 两种状态,转换如下:
Q0
xyz
0 0 1
0 1 x
1 0 0 --> 进入下一个状态(Q1)
1 1 x
第一季度
xyz
0 0 0 --> 仅在这一次进入下一个状态 (Q0) z='0'
0 1 x
1 0 x
1 1 0 --> 保持当前状态(Q1)
问题是当从 Q1 转换到 Q0 时,z 仍然是“1”而不是“0”。
对于我如何才能绕过这种快速过渡有什么建议吗?
这是目前为止的代码:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity Mealys is
Port (
inicio: in std_logic;
clk: in std_logic;
x: in std_logic;
y: in std_logic;
z: out std_logic;
a: out std_logic;
b: out std_logic
);
end Mealys;
architecture behavior of Mealys is
type nombres_estados is (Q0, Q1);
signal estado: nombres_estados;
signal entrada_aux: std_logic_vector (1 downto 0);
begin
entrada_aux <= x & y;
FF_D: process (clk)
begin
if (inicio = '1') then
estado <= Q0;
elsif falling_edge(clk) then
case estado is
when Q0 =>
case entrada_aux is
when "00" => estado<=Q0;
when "10" => estado<=Q1;
when others => estado<=Q0;
end case;
when Q1 =>
case entrada_aux is
when "00" => estado<=Q0;
when "11" => estado<=Q1;
when others => estado<=Q1;
end case;
when others => estado<=Q0;
end case;
end if;
end process;
next_decode: process(estado, entrada_aux)
begin
case (estado) is
when Q0 =>
a <= '1';
b <= '0';
if entrada_aux <= "00" then
z<='1';
elsif entrada_aux <= "10" then
z<='0';
end if;
when Q1 =>
a <= '0';
b <= '1';
if entrada_aux <= "00" then
z<='0';
elsif entrada_aux <= "11" then
z<='0';
end if;
end case;
end process;
end behavior;
感谢您的宝贵时间。
【问题讨论】:
标签: vhdl state-machine vivado flip-flop