我正在CoolRunner 2上運行一個60分鐘計時器的小項目。我想驅動四個7段顯示器來開發VHDL中的新技能,我大多是模擬工程師,所以如果你在VHDL中有任何提示,我會向他們開放。但我的問題是:我有四個計數器一起計數59分59秒,然後重置,但我的第三個計數器不增加(counter3
)。當我運行測試臺時,它只能達到59秒,然後重置。計數器溢出或情況不是肉
下面我附上了我的櫃檯代碼1,2,3,4。有人能看到任何拼寫錯誤或明顯的錯誤嗎?
--counter1-------------------------------------------------------------
Process (CLK1Hz,RST,SW1,overflow4)
begin
if (RST = '0') or (overflow4 = '1') then
Counter1 <=0;
elsif Rising_edge (CLK1Hz)then
if (SW1 = '1') then
counter1 <= counter1 + 1;
if Counter1 = 8 then
overflow1 <= '1';
elsif counter1 = 9 then
Counter1 <= 0;
overflow1 <= '0';
end if;
end if;
end if;
end process;
--counter2---------------------------------------------------------------
Process (CLK1Hz,RST,SW1,overflow1,overflow4,counter1)
begin
if (RST = '0') or (overflow4 = '1') then
Counter2 <=0;
elsif Rising_edge (CLK1Hz) then
if (SW1 = '1') and (overflow1 = '1') then
counter2 <= counter2 + 1;
if counter2 = 5 and counter1 = 8 then
overflow2 <= '1';
elsif counter2 = 5 and counter1 = 9 then
counter2 <= 0;
overflow2 <= '0';
end if;
end if;
end if;
end process;
--counter3----------------------------------------------------------------
Process (CLK1Hz,RST,SW1,overflow2,overflow4,counter1,counter2)
begin
if (RST = '0') or (overflow4 = '1') then
Counter3 <=0;
elsif Rising_edge (CLK1Hz) then
if (SW1 = '1') and (overflow2 = '1') then
counter3 <= counter3 + 1;
if counter3 = 9 and counter2 = 5 and counter1 = 8 then
overflow3 <= '1';
elsif counter3 = 9 and counter2 = 5 and counter1 = 9 then
counter3 <= 0;
overflow3 <= '0';
end if;
end if;
end if;
end process;
--counter4----------------------------------------------------------------
Process (CLK1Hz,RST,SW1,overflow3,overflow4,counter1,counter2,counter3)
begin
if (RST = '0') or (overflow4 = '1') then
Counter4 <=0;
elsif Rising_edge (CLK1Hz) then
if(SW1 = '1') and (overflow3 = '1') then
counter4 <= counter4 + 1;
if counter4 = 6 then
counter4 <= 0;
overflow4 <= '1';
else overflow4 <= '0';
end if;
end if;
end if;
end process;
更新1:這個問題似乎它是整數劑量不接受和功能,所以我嘗試將其轉換爲無符號的,但是這不會女巫出來的問題。
請格式化並縮進您的代碼。 – Paebbels
希望這有助於您更好地理解我的代碼 –
我推薦使用啓用輸入和溢出輸出來編寫一個模數5/9的計數器。然後你可以將這個計數器的多個實例鏈接在一起。 –