私はモデルシムで VHDL を学び始めたばかりです。
基本的に私が作成しようとしているのは、1 桁のアップ/ダウン BCD カウンター用の合成可能な VHDL コードです。カウンターは、「有効」が「1」の場合にカウントされます。それ以外の場合は同じままです。入力「Init」が初期化されると、カウンターは「Direction」入力の値に応じて 0 または 9 に設定されます。(「Direction」が「1」の場合はアップカウンターです)。
100 if と else を続けて使用する以外に、これを機能させるために使用するより良いツールがあるかどうか疑問に思っています。
これが私のコードです。現在、テストベンチを作成しているため、これが機能するかどうかはまだわかりません。ですから、間違いを見つけた場合は、私に指摘してください。
事前に感謝します。これが私のコードです
entity BCD_counter is
port(clk, direction, init, enable: in bit;
q_out: out integer);
end entity BCD_counter;
architecture behaviour of BCD_counter is
signal q: integer;
begin
process(clk)
begin
if(Clk'event and Clk = '1') then
if(direction = '1') then -- counting up
if(init = '1')then --initialize
q<=0; -- reset to 0
else
if(enable = '1')then -- counting
if (q<9) then
q<=q+1;
else
q<=0;
end if;
else
q<=q;
end if;
end if;
elsif(direction = '0') then --counting down
if(init = '1') then --initialize
q<=9; --reset to 9
else
if(enable = '1') then --counting
if (q>0) then
q<=q-1;
else
q<=9;
end if;
else
q<=q;
end if;
end if;
end if;
end if;
end process;
q_out <= q;
end architecture behaviour;