LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
Entity DDFF IS
PORT
(
OUTER : OUT STD_LOGIC;
INCOUNTO: OUT INTEGER RANGE 0 TO 3;
INNER : IN STD_LOGIC;
EN : IN STD_LOGIC;
CLK : IN STD_LOGIC
);
END ENTITY DDFF;
ARCHITECTURE ONE OF DDFF IS
SIGNAL INCOUNT : INTEGER RANGE 0 TO 3 := 0;
BEGIN
PROCESS(CLK,EN)
BEGIN
IF EN = '1' THEN
IF CLK'EVENT AND CLK = '1' THEN
OUTER <= NOT INNER;
IF INCOUNT < 3 THEN
INCOUNT <= INCOUNT + 1;
INCOUNTO <= INCOUNT;
END IF;
IF INCOUNT = 3 THEN
INCOUNT <= 0;
INCOUNTO <= INCOUNT;
END IF;
END IF;
ELSE
INCOUNT <= 0;
OUTER <= '0';
INCOUNTO <= INCOUNT;
END IF;
END PROCESS;
END ONE;
这是我自己写的一个小程序。目的是来一个时钟,OUTER就输出INNER的反向,同时另一个输出INCOUNTO加1输出。现在的现象就是OUTER能实现我的目的,而INCOUNTO却要在下一个时钟周期到来的时候才会加1,请问这是为什么呢?谢谢! |