VHDL Code for "111" to "444" counter

This system counts from "111" to "444" and if the value exceeds the value "444" then the system resets to "111". you can also add reset input for efficient coding.   
VHDL CODE FOR "111" TO "444" COUNTER:
LIBRARY IEEE; --LIBRARY DECLARATION 

USE IEEE.STD_LOGIC_1164.ALL;--STD_LOGIC_1164 PACKAGE
USE IEEE.STD_LOGIC_ARITH.ALL;--STD_LOGIC_ARITH PACKAGE
USE IEEE.STD_LOGIC_UNSIGNED.ALL;--STD_LOGIC_UNSIGNED PACKAGE
ENTITY CNTR444 IS --ENTITY WITH ENTITY NAME CNTR444
PORT(CLK: IN STD_LOGIC; --CLK INPUT 
COUNT1,COUNT2,COUNT3:OUT INTEGER); --OUTPUT VARIABLES
END CNTR444;
ARCHITECTURE DATAFLOW OF CNTR444 IS --DATAFLOW
BEGIN
PROCESS(CLK)
VARIABLE TEMP1:INTEGER:=1; --TEMPORARY VARIABLE WITH INITIAL VALUE 1
VARIABLE TEMP2:INTEGER:=1;
VARIABLE TEMP3:INTEGER:=1;--INITIAL VARIABLE ASSIGNED TO "111"
BEGIN
IF(RISING_EDGE(CLK))THEN --CHECKS THE EVENT ON CLOCK
TEMP1:=TEMP1+1; --ON EACH CLOCK EVENT THE VALUE INCREMENTED BY ONE 
IF(TEMP1=10)THEN --AFTER 10 CLOCK PULSE THE SECOND VARIABLE INCREMENTED BY ONE  
TEMP2:=TEMP2+1;
TEMP1:=0; --FIRST VARIABLE RETESTED 
END IF;
IF(TEMP2=10)THEN -- AFTER EVERY 100 CLOCK PULSE THE THIRD VALUE INCREMENTED BY ONE 
TEMP3:=TEMP3+1;
TEMP2:=0;
END IF;
IF(TEMP3=4 AND TEMP2=4 AND TEMP1=5)THEN --WHEN THE VARIABLE VALUE BECOMES"444" VALUE RESETS TO "111"
TEMP1:=1;
TEMP2:=1;
TEMP3:=1;
END IF;
END IF;
COUNT1<=TEMP1;--TEMP VALUE ASSIGNED TO COUNT SIGNAL
COUNT2<=TEMP2;
COUNT3<=TEMP3;
END PROCESS;
END DATAFLOW;


Output:






Comments