【发布时间】:2023-03-10 22:10:02
【问题描述】:
我正在尝试设计一个具有一个输入 X 和一个输出 Z 的同步状态机 仅当 x 没有时 z 才为 1。 1 的 mod 3=0 甚至没有。 0的 反正我准备好了状态图
我尝试在 xilinix 上测试代码并打印信号以跟踪它 但它没有像代码中所写的那样正确地从一个状态跳到另一个状态 任何帮助表示赞赏 这是链接中的输出谢谢
http://pastebin.com/14e5ZkX4
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity machine is
Port ( X : in STD_LOGIC;
clk : in STD_LOGIC;
Z : out STD_LOGIC);
end machine;
architecture Behavioral of machine is
signal state,nextstate : integer range 0 to 5 := 0;
signal flag : integer range 0 to 5 := 0;
begin
--state 0 (even and mod3=0)
--state 1 (odd and mod3=0)
--state 2 (even and mod3=1)
--state 3 (odd and mod3=1)
--state 4 (even and mod3=2)
--state 5 (odd and mod3=2)
sequence:process(CLK)
begin
if rising_edge(CLK) then
report "prevstate"& integer'image(state);
report "x" & STD_LOGIC'image(X);
if X='0' then
case state is
when 0=>
nextstate<= 1;
when 1=>
nextstate<= 0;
when 2=>
nextstate<= 3;
when 3=>
nextstate<= 2;
when 4=>
nextstate<= 5;
when 5=>
nextstate<= 4;
end case;
--if x=1
else
case state is
when 0=>
flag<= 1;
nextstate<= 2;
when 1=>
nextstate<= 3;
when 2=>
nextstate<= 4;
when 3=>
nextstate<= 5;
when 4=>
nextstate<= 0;
when 5=>
nextstate<= 1;
end case;
end if;
-- report "flag"& integer'image(flag);
report "next state"& integer'image(nextstate);
state<=nextstate;
if state=1 then
z<='1';
else
z<='0';
end if;
end if;
end process;
end Behavioral;
【问题讨论】:
标签: vhdl synchronous xilinx