VHDLコードを書き込んだだけですが、正しく動作しません。私はDフリップフロップを使って、このような数えられた不安定なカウンタを書きたいと思っています:0 –> 13 –> 5 –> 7 –> 12 –> 6 –> 3 –> 15 –> 10 -> 0
。それが必要 VHDLによる不安定なカウンタコード
- : これらの特性を有するべきですアクティブな高クロックを持つ。
私は以下のコードを書いていますが、わかりません。誰も私を助けることができますか?
library IEEE ;
use IEEE.std_logic_1164.all ;
-- and_gate
entity and_gate is
port(Input1, Input2:in bit;
Output:out bit);
end and_gate;
architecture behavioral of and_gate is
begin
Output <= (Input1 and Input2) ;
end behavioral;
-- or_gate
entity or_gate is
port(Input1, Input2:in bit;
Output:out bit);
end or_gate;
architecture behavioral of or_gate is
begin
Output <= (Input1 or Input2);
end behavioral;
-- not_gate
entity not_gate is
port(Input : in bit; Output : out bit);
end not_gate;
architecture behavioral of not_gate is
begin
Output <= not(Input);
end behavioral;
-- D-FF
entity DFF is
port(CLK,RESET,EN,DIN :in bit;
COUNT :out bit);
end DFF;
architecture behavioral of DFF is
begin
LSEQ :process(RESET,CLK)
begin
if(RESET ='0')then
COUNT <='0';
elsif(CLK'event and CLK ='1')then
if(EN ='1')then
COUNT <=DIN;
end if;
end if;
end process;
end behavioral;
-- counter
entity counter is
port (CLK,RESET,EN: in bit;
COUNT : out bit_vector(3 downto 0));
end counter;
architecture counter_structural of counter is
component and_gate
port(Input1,Input2 : in bit; Output: out bit);
end component;
component or_gate
port(Input1,Input2 : in bit; Output : out bit);
end component;
component not_gate
port(Input : in bit; Output : out bit);
end component;
component DFF
port(CLK,RESET,EN,DIN :in bit; COUNT :out bit);
end component;
signal A,B,C,D,ai,bi,ci,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15 : bit;
begin
Gate1: not_gate port map (A,ai);
Gate2: not_gate port map (B,bi);
Gate3: and_gate port map (ai,bi,a1);
Gate4: and_gate port map (C,D,a2);
Gate5: or_gate port map (a1,a2,a3);
Gate6: DFF port map (CLK,RESET,EN,a3,COUNT(0));
Gate7: and_gate port map (ai,B,a4);
Gate8: not_gate port map (c,ci);
Gate9: and_gate port map (ai,D,a5);
Gate10: or_gate port map (a4,ci,a6);
Gate11: or_gate port map (a5,a6,a7);
Gate12: DFF port map (CLK,RESET,EN,a7,COUNT(1));
Gate13: and_gate port map (A,B,a8);
Gate14: and_gate port map (C,D,a9);
Gate15: or_gate port map (a8,a9,a10);
Gate16: DFF port map (CLK,RESET,EN,a10,COUNT(2));
Gate17: and_gate port map (ai,B,a11);
Gate18: and_gate port map (ci,D,a12);
Gate19: and_gate port map (ai,D,a13);
Gate20: or_gate port map (a11,a12,a14);
Gate21: or_gate port map (a13,a14,a15);
Gate22: DFF port map (CLK,RESET,EN,a15,COUNT(3));
end counter_structural ;
[最小限で完全で検証可能な例](https://stackoverflow.com/help/mcve)の一部です。問題を再現するために必要なすべての情報と検証可能です。「動作しません」は問題文。何が正しく行っていないのですか? (何をしていますか?)テストベンチはありますか?カウントオーダーは必須ですか? – user1155120
この構造の回路図を含めてください。このコードに基づいて、それはちょうど私につながったゲートの束のように見えます。 – JHBonarius