ModMultiSim help v3.07 - 4.4.3. Samplers
Download manual: HTML
A sampler has a Data input, and an Output that is a sample of the Data input. The sampler "samples" the Data input when its Sample input is 1. If the Sample input is 0, the Output retains its value. (Those with an electronics background will know this as a transparent latch or gated latch.)
An example might be where Data is temperature, and the temperature is stored (sampled) by Output when Sample is 1. Sample might be set manually by the master, or there may be a Sample statement to set itself to 1 (e.g. once an hour).
A twist on this is where Data is the time and Sample sets itself to 1 when a condition is true, such as water in a tank reaching a specified level. Output would be the time that the water in the tank was last at that level.
Table 16. Sampler
Register Address | Register Name | Statement |
---|---|---|
$100 | Data | |
$101 | Sample | |
$102 | Output | if $101 != 0 then $100 |
The sampler example above is level triggered: the sampler Output follows the Data input so long as the Sample input is 1.
It is often preferable to use edge triggering. This is where the Output changes when the Sample input changes from 0 to 1, but the Sample input has no further effect until it next changes from 0 to 1.
In order to implement edge-triggering, the previous value of the input has to be saved so that a change in the input value can be detected. So the sampler template above can be modified to use edge-triggering by adding the register Last sample (see table below), and testing its value before sampling.
Table 17. Edge-triggered sampler
Register Address | Register Name | Statement |
---|---|---|
$100 | Data | |
$101 | Sample | |
$102 | Last sample | $101 |
$103 | Output |
if $101 != 0 && $102 == 0 then $100 |
-
The $103 statement tests for the Input changing from 0 to 1 (i.e. for a "positive edge"). To test for a negative edge, the statement could be changed to:
if $101 == 0 && $102 != 0 then $100