我有下面的代码是我的数字时钟的一部分:如何使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