View Single Post
  #5 (permalink)  
Old 07-25-2007, 07:44 PM
Posts: n/a
Default Re: variable clock frequency generation issue

SB wrote:
> Can anybody suggest what how I should correct this and
> ensure that the "always" block will instantaneously pick-up
> the new value of the "half_period"?

When the #(half_period) is executed, the delay will be evaluated and
the process scheduled for that time in the future. Changing the delay
value will have no effect after that. As someone else said, the only
way to get it to wake up before that time would be a disable

I assume that when the half_period is modified, you want the time from
the previous edge to the next edge to become the half_period. You
don't say what should happen if the half_period gets changed at a time
that is already delayed from the previous edge by more than the new
delay. I would assume that you want the next edge to occur
immediately, since that is the best you can do in that situation.

As someone said, you can get the old delay to terminate with a
disable. But then you still need to get the next edge scheduled at
the proper time. The best mechanism I can see is to record the time
of each edge when you generate it. You need that information when the
delay gets disabled due to half_period changing, to figure out when
the next edge needs to be. With the time of the last edge plus the
new half_period, you can determine the new time for the next edge.
Then you can subtract the current time to get the required delay. If
the result is negative, you should delay by 0, since that is the best
you can do. This will be messy code. You should be considering
whether you really need this capability to respond before the next

Reply With Quote