Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Simple question, reset a counter

 
Thread Tools Search this Thread
Old 11-19-2007, 06:33 PM   #1
Default Simple question, reset a counter


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?



Dan
  Reply With Quote
Old 11-19-2007, 06:42 PM   #2
Jonathan Bromley
 
Posts: n/a
Default Re: Simple question, reset a counter
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.MYCOMPANY.com

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


Jonathan Bromley
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
A simple question or two Dont write DVD Video 5 03-27-2007 09:03 PM
Simple region code question... simple answer?? joseph.greer@gmail.com DVD Video 7 01-26-2007 09:07 PM
Simple Question re: NEC dvd+-rw kjanus@gmail.com DVD Video 3 03-31-2006 10:55 PM
simple question CLV3 A+ Certification 4 09-21-2004 04:48 PM
Simple question, join and divide Dr Zero DVD Video 0 12-29-2003 09:52 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46