我有下面的代碼是我的數字時鐘的一部分:如何使VHDL輸出信號無國籍
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_unsigned.all;
-- Seconds counter
entity SecCounter is
port(
s_enable: in std_logic;
s_load: in std_logic; -- When high, sets this counter to the value in the data inputs
s_clk: in std_logic; -- Clock
s_input: in std_logic_vector(5 downto 0); -- Data inputs
s_output: out std_logic_vector(5 downto 0); --Outputs
s_wrap: out std_logic
);
end SecCounter;
architecture imp of SecCounter is
-- Intermediate signal to mainpulate the seconds as integer
signal sec: integer range 0 to 60 := 22;
begin
s_output <= std_logic_vector(to_unsigned(sec,6)); -- Assign the input to the binary value of sec
process(s_clk, s_load, s_enable) -- If clk, enable, or load is changed
begin
s_wrap <= '0'; -- Clear the wrap
if (s_enable = '0' and s_load = '1') then -- Set the clock
sec <= to_integer(unsigned(s_input));
elsif (s_enable = '1' and rising_edge(s_clk)) then -- Increment the counter
sec <= sec + 1;
end if;
if sec = 60 then -- Restart counter and toggle the next counter
sec <= 0;
s_wrap <= '1';
end if;
end process;
end imp;
s_wrap充當使下一個櫃檯。我想要做的是,如果這個計數器等於60,我想爲單個時鐘邊緣啓用下一個計數器。我試圖通過將s_wrap設置爲true,然後在下一個時鐘邊沿將其設置爲false;但是,它不會改變。有沒有辦法讓is_wrap無狀態?如果不是,我該如何解決這個問題?
您正在使用'ieee.std_logic_unsigned .all',這有幾個問題。此外,它與您正在使用的'numeric_std'衝突。只要刪除'std_logic_unsigned'使用條款。 – Philippe 2011-05-02 07:48:29