门控时钟的原因
问题描述:
我在VHDL中有此代码。当我尝试编译它时 - 它说“门控时钟net clock_en是由一个组合引脚产生的。”有没有人有一个想法如何摆脱这个警告? 我在互联网上搜索过,找不到解决方案。看起来门控时钟有时甚至是有用的,但是在设计硬件时它是一个警告。门控时钟的原因
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
use IEEE.std_logic_arith.all;
entity ledc8x8 is
port(
SMCLK: in std_logic;
RESET: in std_logic;
ROW: out std_logic_vector(0 to 7);
LED: out std_logic_vector(0 to 7)
);
end ledc8x8;
architecture behavioral of ledc8x8 is
signal count: std_logic_vector(7 downto 0) := (others => '0'); -- hlavni citac
signal row_count: std_logic_vector(7 downto 0) := "10000000"; -- prepinac radku
signal clock_en: std_logic; -- CE
signal output_logic: std_logic_vector(7 downto 0); -- "vystup"
begin
process(count, SMCLK, RESET, clock_en)
begin
if RESET = '1' then
count <= (others => '0');
elsif SMCLK = '1' and SMCLK'event then
count <= count + 1;
end if;
if count="11111110" then
clock_en <= '1'; else
clock_en <= '0';
end if ;
end process;
process(clock_en, RESET)
begin
if RESET = '1' then
row_count <= "10000000";
elsif clock_en = '1' and clock_en'event then
row_count <= row_count(0) & row_count(7 downto 1);
end if;
end process;
process(row_count)
begin
case row_count is
when "00000001" => output_logic <= "11110110";
-- more switch options
end case;
end process;
ROW <= row_count;
LED <= output_logic;
end behavioral;
答
您的代码有几个问题。
正如您在答案中发现的那样,您使用的是时钟,并且启用作为时钟。我建议你把它写这样一来,虽然:
process(RESET, SMCLK)
begin
if RESET = '1' then
row_count <= "10000000";
elsif SMCLK = '1' and SMCLK'event then
if clock_en = '1' then
row_count <= row_count(0) & row_count(7 downto 1);
end if;
end if;
end process;
它可以工作的其他方式(可能),但它不是传统的把使支票在同一行的上升沿检查。还请注意,这意味着您不需要在敏感列表中使用clock_en
。
您的其他钟控程序也应该重写。假设你要分配给clock_en
是组合,你应该把它放在一个单独的进程:
process(RESET, SMCLK)
begin
if RESET = '1' then
count <= (others => '0');
elsif SMCLK = '1' and SMCLK'event then
count <= count + 1;
end if;
end process;
process (count)
begin
if count="11111110" then
clock_en <= '1';
else
clock_en <= '0';
end if ;
end process;
你也可以在这里写的第二过程作为一个在线的并发声明:
clock_en <= '1' when count = "11111110" else '0';
由于各种原因,在同一进程中将独立的时钟和非时钟代码组合在一起不是一种推荐的编码风格。
答
带有clock_en'event的行 - 要求上升沿出现问题。替换为要求SMCLK信号的上升沿。
process(RESET, SMCLK)
begin
if RESET = '1' then
row_count <= "10000000";
elsif clock_en = '1' and SMCLK = '1' and SMCLK'event then
row_count <= row_count(0) & row_count(7 downto 1);
end if;
end if;
end process;
感谢您的帮助。感谢。 – Croolman 2014-11-05 18:29:56