ENTITY counter_4 IS PORT( clock, reset, load_counter: IN BIT; data: IN BIT_VECTOR( 3 DOWNTO 0 ); -- -- BUFFER means that we can reference the value of this signal from -- inside the architecture. -- reset_alert: OUT BIT; count: BUFFER BIT_VECTOR( 3 DOWNTO 0 ) ); END counter_4; ARCHITECTURE behavioral OF counter_4 IS BEGIN -- -- The process only starts when there is a change to one of the signals in -- its sensitivity list. -- upcount: PROCESS( clock ) BEGIN -- -- You can only use an IF statement if you are inside of a PROCESS. Here, -- the IF statement tests for the rising clock edge. -- IF( clock'event AND clock= '1' ) THEN IF reset = '1' THEN count <= "0000"; ELSIF load_counter = '1' THEN count <= data; ELSE count(0) <= NOT count(0); count(1) <= count(0) XOR count(1); count(2) <= ( count(0) AND count(1) ) XOR count(2); count(3) <= ( count(0) AND count(1) AND count(2) ) XOR count(3); IF count = "0000" THEN reset_alert <= '1'; ELSE reset_alert <= '0'; END IF; -- IF count = "0000" END IF; -- IF load = '1' END IF; -- IF( clock'event AND clock = '1' ) END PROCESS upcount; END behavioral;