: HELP!
: I need to schedule an IF statement to take place at a fixed delay
: after a signal change. The obvious solution seems to be:
: #max_prop_delay
: if ($time >= din_lastchange + max_prop_delay)
: dout = dina + dinb;
: This doesn't work. It seems that the entire ALWAYS statement waits
: to complete until after the IF statement has executed. Thus, if dina
: changes again before the delay has completed, no further IF statements
: can be executed.
: I tried to get around this using fork-join, conditional operators,
: and intra-assignment delays. None could achieve the desired effect.
: How do I delay an IF statement while keeping the ALWAYS statement active?
I am not exactly sure what you are trying to do here, since this code
fragment is not complete, but there are a couple of things that may do
what you want.
First, if you are only trying to model an adder with delay, then a delayed
assign statement would do it. OUTSIDE all initial and always blocks
use
assign #max_prop_delay dout= dina + dinb;
With this, if dina (or dinb) change multiple times within max_prop_delay,
dout will only change after the last change of dina and dinb.
If you really want to have a module that triggers after the last change
of a signal then it is a bit more complicated.
--
event dina_change;
begin
disable dina_change_block;
#0 -> dina_change;
end
begin: dina_change_block;
#max_prop_delay
if ...
end
--
Thus on every change of dina, the block named dina_change_block, which
may or may not be waiting in the # at the top is disabled, and the
event triggering it is sent right away, causing the block to start
again, and hence start the #max_prop_delay again.
Hope this helps.
--
Avrum Warshawsky
Hewlett-Packard (Canada) LTD.