Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Simple question, reset a counter

Reply
Thread Tools

Simple question, reset a counter

 
 
Dan
Guest
Posts: n/a
 
      11-19-2007
Hi,

I've created a FSM and, inside it, a counter to count the clock cycles
between transitions.

Maybe it's too simple but I don't see how can I reset the *counter* from
inside the state machine?

Example:

entity FSM is
Port ( Clk : in STD_LOGIC;
Reset : in STD_LOGIC;
...);

end FSM;

architecture Behavioral of FSM is

component Counter
port ( Clk : in STD_LOGIC;
Clear : in STD_LOGIC;
....);
end component;

.....

U1: Counter port map (<I don't know what signals include here>);

.....

when S2 =>
if .... then
Next_State <= S3;
Signal <= '1'; -- Reset the counter
end if;

.....

The "Reset" signal of the FSM returns to state S0, so that's not what I
want, I only want to reset the counter.

I'm stuck, any ideas?

 
Reply With Quote
 
 
 
 
Jonathan Bromley
Guest
Posts: n/a
 
      11-19-2007
On Mon, 19 Nov 2007 19:33:02 +0100, Dan wrote:

>I've created a FSM and, inside it, a counter to count the clock cycles
>between transitions.
>
>Maybe it's too simple but I don't see how can I reset the *counter* from
>inside the state machine?


You've already done it! Create a signal that's an output from
the FSM - as you've done, in your transition from state S2 to S3.
Use that signal directly as the counter's reset.

Even better, don't instantiate a counter at all. Instead,
provide a variable in your FSM process that counts down on
every clock. Some states (the states that need the counter)
will wait until the counter hits zero before proceeding.
Transitions into those states will preset the counter
to an appropriate timeout value. This has been discussed
many times here, including at least one very recent occasion.
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Page File counter and Private Bytes Counter George2 C++ 1 01-31-2008 09:27 AM
Reset network creation counter J.H. Holliday Wireless Networking 4 06-11-2005 08:09 PM
Session("counter") vs. ViewState("counter")...a newbie question The Eeediot ASP .Net 3 12-22-2004 09:31 PM
PIX reset ACL hit counter Norbert H. Kunth Cisco 2 06-14-2004 11:18 AM
Sony dsc-p50 Reset picture counter, suggestions?? Jenny3kids@msn.net Digital Photography 3 05-05-2004 10:07 AM



Advertisments