入力 w で 4 つの 1 または 0 のシーケンスを検出するワンホット エンコーディングを使用して、有限ステート マシンを作成するように依頼されました。case ステートメントを使用してコードを既に作成しましたが、9 つのフリップフロップへの入力として論理式を提供する必要もあります。z で正しい出力が得られず、その理由がよくわかりません。
これまでのところ、D フリップフロップ用に次のコードを書きました。
library ieee;
use ieee.std_logic_1164.all;
entity dflipflop is
port (D, clk, reset: in std_logic;
Q: out std_logic);
end dflipflop;
architecture behavior of dflipflop is
begin
process(clk)
begin
if reset <= '0' then
Q <= '0';
elsif rising_edge(clk) then
Q <= D;
end if;
end process;
end behavior;
次に、これをコードの残りの部分として使用します。ここに問題があると思います。
library ieee;
use ieee.std_logic_1164.all;
entity part1 is
port (clk, w, reset : in std_logic;
z: out std_logic);
end part1;
architecture behavior of part1 is
component dflipflop
port (D, clk, reset: in std_logic;
Q: out std_logic);
end component;
signal A, B, C, D, E, F, G, H, I: std_logic;
signal Y1, Y2, Y3, Y4, Y5, Y6, Y7, Y8, Y9: std_logic;
dff1: dflipflop port map (clk=>clk, reset=>reset, D=>Y1, Q=>A);
dff2: dflipflop port map (clk=>clk, reset=>reset, D=>Y2, Q=>B);
dff3: dflipflop port map (clk=>clk, reset=>reset, D=>Y3, Q=>C);
dff4: dflipflop port map (clk=>clk, reset=>reset, D=>Y4, Q=>D);
dff5: dflipflop port map (clk=>clk, reset=>reset, D=>Y5, Q=>E);
dff6: dflipflop port map (clk=>clk, reset=>reset, D=>Y6, Q=>F);
dff7: dflipflop port map (clk=>clk, reset=>reset, D=>Y7, Q=>G);
dff8: dflipflop port map (clk=>clk, reset=>reset, D=>Y8, Q=>H);
dff9: dflipflop port map (clk=>clk, reset=>reset, D=>Y9, Q=>I);
begin
process(clk);
begin
if rising_edge(clk) then
Y1 <= (((not w) and C) or ((not w) and G) or ((not w) and H) or ((not w) and I) or (w and B) or (w and D) or (w and E) or (w and F));
Y2 <= ((not w) and A);
Y3 <= (w and A);
Y4 <= ((not w) and B);
Y5 <= ((not w) and D);
Y6 <= (((not w) and E) or ((not w) and F));
Y7 <= (w and C);
Y8 <= (w and G);
Y9 <= ((w and H) or (w and I));
end if;
end process;
z <= (Y6 OR Y9);
end behavior;
私が間違っている可能性があることについて、誰かがヒントや洞察を提供できますか?