![]() |
|
|
|||||||
![]() |
VHDL - Simple question, reset a counter |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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 |
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |