楼上正解!
要是加上进位输出的话,就更完美了,那样可以组成级联八进制计数器,更具扩展性。
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY 8_COUNT IS
PORT(CLK,RESET,EN:IN STD_LOGIC;
OUTPUT:OUT INTEGER RANGE 0 TO 7);
END ENTITY;
ARCHITECTURE ART OF 8_COUNT IS
BEGIN
PROCESS(CLK,RESET,EN)
VARIABLE CNT:INTEGER RANGE 0 TO 7 BEGIN
IF RESET='1' THEN
CNT:=0;
ELSIF CLK'EVENT AND CLK='1' THEN
IF EN='1' THEN
CNT:=CNT+1;
ELSE CNT:=0;
END IF;
END IF;
OUTPUT<=CNT;
END PROCESS;
END ART;