View Single Post
  #8 (permalink)  
Old 06-30-2003, 11:25 AM
Troels Smit
Guest
 
Posts: n/a
Default Re: event in state machine

> PROCESS
> BEGIN
> WAIT UNTIL sclk = '1';
> lr_1d <= lr;
> lr_2d <= lr_1d;
> lr_3d <= lr_2d;
> END PROCESS;
>
> Now you can use lr_2d and lr_3d within a process to detect an event:
>
> PROCESS
> BEGIN
> WAIT UNTIL sclk = '1';
> IF lr_2d /= lr_3d THEN
> -- do your things
> END IF;
> END PROCESS;
>
> Using a process similar to the one above I'd set a statemachine to start
> counting to 20, send its bits, and then return to state0 where it's waiting
> for your change on lr (IF lr_2d /= lr_3d THEN).
> Regards,
> Pieter Hulshoff


That is a quite interesting way to look for an event, I will defenetly
remember that. The only problem I see it that the clocks are defined
as follows:

input clk --this is fast
counter = counter + 1 -- at clock'event clock='1'

lr <= counter(8);
sclk <= counter(2);
mclk <= counter(0);

and therefore sclk can't really define lr as they are both dependent
on clk.
What I how done for now is to remember what lr was last time, and then
listen for the opposite in a state machine. This has some time-skew
but it works IRL.

Thanks!

/Troels
Reply With Quote