hfbroady
Newbie level 5
- Joined
- Dec 4, 2010
- Messages
- 10
- Helped
- 3
- Reputation
- 6
- Reaction score
- 3
- Trophy points
- 1,283
- Location
- Rochester,NY,USA
- Activity points
- 1,343
I trying to write a MOD-5 counter that counts like this 000,001,010,110,111,000. This is what I have so far. When I simulate the code this is the count I get 000,001,010,011,100,101,110,111,000. Not sure why the simulation goes to 5. Here is the code.
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY mod5 Is
PORT( CLK,CLR:IN BIT;
QOUT:BUFFER INTEGER RANGE 0 to 7);
END mod5;
ARCHITECTURE arc OF mod5 is
BEGIN
PROCESS (CLK,CLR)
BEGIN
IF (CLK'EVENT and CLK='1') THEN
QOUT<=QOUT +1;
IF (QOUT=2) THEN
QOUT<=6;
QOUT<=QOUT + 1;
END IF;
END IF;
END PROCESS;
END arc;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY mod5 Is
PORT( CLK,CLR:IN BIT;
QOUT:BUFFER INTEGER RANGE 0 to 7);
END mod5;
ARCHITECTURE arc OF mod5 is
BEGIN
PROCESS (CLK,CLR)
BEGIN
IF (CLK'EVENT and CLK='1') THEN
QOUT<=QOUT +1;
IF (QOUT=2) THEN
QOUT<=6;
QOUT<=QOUT + 1;
END IF;
END IF;
END PROCESS;
END arc;