The one I found at the Wiki has two problems: 1. it does not support negative values. 2. it fails when the input is a 1-tick long burst and starts to flicker wildly.
The following is an improvement which solves both problems.
Description:
- The output M (memory) is the last non-zero input I (Input).
- A non zero R (reset) signal sets the output to zero.
- 1-tick bursts of R or I are handled properly.
- Negatives are handled properly.
blueprint
Image:
Explanation:During an input, combinator 1 resets combinator 3's memory. combinator 2 temporarily takes charge and handles the output as long as the input is held. Once the input is zeroed, the reset signal is zeroed as well and combinator 3 becomes again in charge of the output and combinator 2 deactivates. Here's a tick-by-tick explanation:
Tick 1:
Combinator 1 receives a non-zero input I.
Tick 2:
combinator 2 sends a reset signal.
Tick 3:
Combinator 3 resets and is now sending nothing.
Simultaneously, to prevent an output flicker, combinator 2 takes charge of the output and sends M.
Tick 10: (assuming input was held for 7 ticks)
Input I is now zero.
Tick 11:
Combinator 1 is now sending nothing, there is no longer a reset signal.
Tick 12:
Combinator 2 is now sending nothing.
Simultaneously, combinator 3 has now become active and is sending M from memory.
Reset explanation:
An R signal is sent to combinator 3, making it lose its memory.