D
D
Daniel2021-02-18 10:21:00
Algorithms
Daniel, 2021-02-18 10:21:00

How to delay the execution of a function so that it waits until the variables with which it works are updated?

The title of the question is heresy, here is an example of a problem.
The task is this. Implement (render) at the lowest level of the ALU processor. For example, the addition operation.
What is. There are 2 variables that need to be added, these variables have OnChange () events on set-ups on each change (or not change).
There is a Sum() function that should be called in OnChange() with a delay, wait until both operands change.
1. And here the main thing is that it should be called only after the OnChange () event has arrived on both parameters, I can do this.
2. And more importantly, I don’t know how to do it at allAn event can only come with 1 variable. And it will not come in the next NanoSeconds (processor cycle) from the second, then take the old value from it (And this contradicts the first condition , but you need to somehow fulfill it.
Somewhere in the code
Buf_1.SetReg1(true); // set the value
/ /....somewhere else in general, in another iteration, or somewhere in the middle of the queue, in short it will be executed in N - time // Buf_1.SetReg2
(true); // there could be nothing here.
Propagation delay - Propagation delay - this is what I want to implement
.

Briefly, propagation delay (if anyone can suggest a solution (algorithm) without processor knowledge, this is when 2 signals to a logical device arrive at different times (picoseconds). And then it may be that after that the 1st signal comes, it will add up with the second (which has not yet had time to update) where the errors will come from.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-02-18
@vabka

I won’t say about nano / picoseconds, but on the scale of seconds / milliseconds this can be implemented.
OnChange of the first/second field arrives
We set a flag that the first/second field has changed
If both fields have changed, then sum them up
Otherwise, we start the timer for some time (for example, 1s)
After the timer fires, we sum both fields regardless of the flags.
After the summation, the flags and the timer are reset.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question