主要编辑:
阅读 Will Dean 的评论后问题得到解决。原始问题在修改后的代码下方:
-- REVISED CODE (NOW WORKS)
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
entity CLOCK_DIVIDER is
port(
reset : in std_logic;
clk : in std_logic;
half_clk : out std_logic
);
end CLOCK_DIVIDER;
architecture CLOCK_DIVIDER of CLOCK_DIVIDER is
signal tick : std_logic;
begin
process(clk, reset)
begin
if reset = '1' then
tick <= '0';
elsif clk = '1' and clk'EVENT then
if tick = '0' then
tick <= '1';
elsif tick = '1' then
tick <= '0';
end if;
end if;
end process;
process(tick)
begin
half_clk <= tick;
end process
end CLOCK_DIVIDER;
修改后的代码的综合逻辑块是一个异步复位 DFF,它以 half_clk 作为输出,反相 half_clk 作为输入,这意味着 half_clk 的值在 clk 的每个上升沿发生变化。
谢谢,威尔迪恩:)
==== ==== ==== ==== ====
下面的原始问题:
==== ==== ==== ==== ====
我需要一个简单的时钟分频器(只是除以二),而不是使用模板,我想我会尝试自己写一个来继续训练。
不幸的是,合成的逻辑块似乎不起作用——我按顺序展示了逻辑块和代码(我真的认为应该起作用)。
逻辑块 http://img808.imageshack.us/img808/3333/unledly.png
我真正想知道的是,“tick”DFF 到底是怎么回事——它显然是从 mux-selector 获取输入的……是的。
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
entity CLOCK_DIVIDER is
port(
reset : in std_logic;
clk : in std_logic;
half_clk : out std_logic
);
end CLOCK_DIVIDER;
architecture CLOCK_DIVIDER of CLOCK_DIVIDER is
signal tick : std_logic;
begin
process(clk, reset)
begin
if reset = '1' then
half_clk <= '0';
tick <= '0';
elsif clk = '1' and clk'EVENT then
if tick = '0' then
half_clk <= '0';
tick <= '1';
elsif tick = '1' then
half_clk <= '1';
tick <= '0';
end if;
end if;
end process;
end CLOCK_DIVIDER;
我确信代码中的错误很明显,但我一直盯着自己盲目地试图找到它。