counters in fsm

Joined
Sep 27, 2006
Messages
4
Reaction score
0
i am trying to increment value of 4-bit counter in fsm , but instead of bin 01 its adding 02 and although the state advancement if on every risiing edge of clk , this counter is incrementing on falling edge as well , i tried using a procedure instead and calling a procedure , but to same effect , any clues ???
any one ???
 
Joined
Nov 19, 2006
Messages
4
Reaction score
0
hope this works for you!!!

here is what I have used in the past and it has worked fine. Its from VHDL- online main frame

good luck

RG


Library IEEE;
use IEEE.Std_Logic_1164.all;

entity COUNTER is
port ( CLK : in std_ulogic;
Q : out integer range 0 to 15 );
end COUNTER;

architecture A of COUNTER is
signal COUNT : integer range 0 to 15 ;
begin
process (CLK)
begin
if CLK`event and CLK = `1` then
if (COUNT >= 9) then
COUNT <= 0;
else
COUNT <= COUNT +1;
end if;
end if;
end process;
Q <= COUNT;
end A;
 
Joined
Nov 19, 2006
Messages
4
Reaction score
0
I have used this in the past I hope it works for you!!
you will have to modify it to fit your needs. This was taken frm VHDL-Online Main frame

rg


Library IEEE;
use IEEE.Std_Logic_1164.all;

entity COUNTER is
port ( CLK : in std_ulogic;
Q : out integer range 0 to 15 );
end COUNTER;

architecture A of COUNTER is
signal COUNT : integer range 0 to 15 ;
begin
process (CLK)
begin
if CLK`event and CLK = `1` then
if (COUNT >= 9) then
COUNT <= 0;
else
COUNT <= COUNT +1;
end if;
end if;
end process;
Q <= COUNT;
end A;
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top