私は VHDL (および一般的なデジタル回路) の初心者で、BCD スタイルのブロックを使用して 2 桁のカウンターを実装しようとしています。この回路の外部にはボタンがあり、押すと目的の桁が 1 つ上がります (目覚まし時計のように)。これは非同期アクションであり、何らかの形式の編集モード (外部強制) で発生します。私が書いたコードは、「elsif raise_edge(digitUp1) then」および「elsif raise_edge(digitUp1) then」ブロックなしで正常に動作しますが、それらが含まれていると失敗します。なぜ機能しないのか、どうすれば修正できるのか、まったくわかりません。「このクロック エッジで割り当て用のレジスタを実装できませんでした」、「できません」などのエラーが発生し続ける
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_signed.all;
-- ToDo: ENFORCE ON ALL COUNTERS (externally) LOGIC TO PAUSE AT MAX/MIN
entity MinuteCounter is
port( clockIn, digitUp1, digitUp2, reset, counting, countUp : in std_logic;
clockOut : out std_logic;
BCD1, BCD2 : out std_logic_vector(3 downto 0));
end MinuteCounter;
architecture structure of MinuteCounter is
signal count1, count2 : std_logic_vector(3 downto 0);
signal carryOut : std_logic;
begin
process( clockIn, digitUp1, digitUp2, countUp, reset, counting)
begin
-- Asynchronous reset
if reset = '1' then
count1 <= "0000";
count2 <= "0000";
-- What to run when there's an active edge of the clock
elsif rising_edge(clockIn) then
-- Code to run when timer is running
if counting = '1' then
-- What to do when counting up
if countUp = '1' then
if ((count1 = "1001") and (count2 = "0101")) then
count1 <= "0000";
count2 <= "0000";
if carryOut = '0' then
carryOut <= '1';
else
carryOut <= '0';
end if;
elsif count1 = "1001" then
count1 <= "0000";
count2 <= count2 + 1;
else
count1 <= count1 + 1;
end if;
-- What to do when counting down (This logic is hard to understand)
else
if ((count1 = "0000") and (count2 = "0000")) then
count1 <= "1001";
count2 <= "0101";
if carryOut = '0' then
carryOut <= '1';
else
carryOut <= '0';
end if;
elsif count1 = "0000" then
count1 <= "1001";
count2 <= count2 - 1;
else
count1 <= count1 - 1;
end if;
end if;
-- When counting is disabled, but there is an active edge (do nothing)
else
count1 <= count1;
count2 <= count2;
end if;
-- Code to run when entering values (will not be run if counting = '1') << Externally enforced
elsif rising_edge(digitUp1) then
if count1 = "1001" then
count1 <= "0000";
count1 <= count1 + 1;
else
count1 <= count1 + 1;
end if;
-- Code to run when entering values (will not be run if counting = '1') << Externally enforced
elsif rising_edge(digitUp2) then
if count2 = "0101" then
count2 <= "0000";
count2 <= count2 + 1;
else
count2 <= count2 + 1;
end if;
-- What to do when there is no active edge or other events (nothing)
else
count1 <= count1;
count2 <= count2;
end if;
end process;
-- Assign outputs
BCD1 <= count1;
BCD2 <= count2;
clockOut <= carryOut;
end structure;