"Max" <> wrote in message
news: om...
> I must write a state machine that depend also on number o events that
> occurs in any state.
>
> for example:
>
> I have this ports:
> Port ( clk : in std_logic;
> din : in std_logic;
> sclk : out std_logic);
>
> I need to wait 2 falling edge of din (state 0), then 4 rising edge of
> clk (state 1), and finally I can set sclk to 1 as long as 3 falling
> edge of clk (state 3). Then it restart from state 0.
Various ideas:
To detect falling edge on din, use a piece of logic OUTSIDE the
state machine that takes a copy of din on every clock. Then
falling_edge = (din = '0') and (din_delayed = '1'). Or something
like that.
To count off clocks or whatever, have a counter that's preset to
some value on entry to a state, and decrements on each clock when
in that state; then when the counter reaches zero, it's time to
move on to the next state.
Or alternatively, split each state into several sub-states and
advance from one sub-state to the next unconditionally on
the clock. This approach is probably easier to understand
and code, but is less flexible.
> I tried varius solution but any of them works.
Strange. I can think of lots of solutions that would work.
Can you share your failed solutions with us?
--
Jonathan Bromley, Consultant
DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project Services
Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail:
Fax: +44 (0)1425 471573 Web:
http://www.doulos.com
The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.