Documentation

Signal Latch

Write input signal value to memory and read memory to output signal upon events

Library

Signal Management

Description

The Signal Latch block is a versatile block for manipulating event-based signals. You can use it to delay or resample signals based on events, not time. This block stores and outputs the values of the in input signal based on events:

  • The block writes the value of the in signal to an internal memory location when a "write to memory" event occurs. The Write to memory upon parameter indicates the type of signal-based event or function call that causes a write event.

  • The block reads the memory value and updates the signal at the out port, if present, when a "read from memory" event occurs. The Read from memory upon parameter indicates the type of internal or external event that causes a read event:

    • If you set Read from memory upon to Write to memory event, then every write event causes a read event. The out signal is like a resampled version of the in signal.

    • Otherwise, the Read from memory upon parameter indicates the type of signal-based event or function call that causes a read event. In this case, write and read events occur independently and are not required to alternate. The out signal is like a delayed resampled version of the in signal.

This block is useful for modeling feedback loops in discrete-event systems in which an output from one component is an input to another component. Because the two components work separately in such a system, the updates of the input and output signals are independent in both causality and timing. This block lets you control the causality and timing associated with storing the output from one component and updating the value received by the other component. For an example that uses this block in a feedback loop, see the Modeling Load Within a Dynamic Voltage Scaling ApplicationModeling Load Within a Dynamic Voltage Scaling Application example.

Ports

Signal Input Ports

LabelDescription
wtsSignal whose updates cause write events. This signal must be an event-based signal. You see this port only if you set Write to memory upon to Sample time hit from port wts.
wtrTrigger signal whose edges cause write events. This signal must be an event-based signal. You see this port only if you set Write to memory upon to Trigger from port wtr.
wvcSignal whose numerical changes in value cause write events. This signal must be an event-based signal. You see this port only if you set Write to memory upon to Change in signal from port wvc.
wfcnFunction-call signal that causes write events. This signal must be an event-based function call. You see this port only if you set Write to memory upon to Function call from port wfcn.
rtsSignal whose updates cause read events. This signal must be an event-based signal. You see this port only if you set Read from memory upon to Sample time hit from port rts.
rtrTrigger signal whose edges cause read events. This signal must be an event-based signal. You see this port only if you set Read from memory upon to Trigger from port rtr.
rvcSignal whose numerical changes in value cause read events. This signal must be an event-based signal. You see this port only if you set Read from memory upon to Change in signal from port rvc.
rfcnFunction-call signal that causes read events. This signal must be an event-based function call. You see this port only if you set Read from memory upon to Function call from port rfcn.
inSignal to be resampled and/or delayed. This signal must be an event-based signal.

Signal Output Ports

LabelDescriptionTime of Update When Statistic Is OnOrder of UpdateInitial Value
st0 or 1, depending on whether the block more recently processed a read or write event.Upon write events and upon read events10
memThe value of the block's internal memory when a write event occurs.Upon write events1Value of Initial memory value parameter
outThe value of the block's internal memory when a read event occurs.Upon read events1

Output signals having the same number in the Order of Update column in the table above are updated in an arbitrary sequence relative to each other; you should not rely on a specific sequence for your simulation results.

The initial value is in effect from the start of the simulation until the first update by the block.

Dialog Box

Write Tab

Initial memory value

The value in the block's internal memory before the first write event occurs.

Write to memory upon

The type of signal-based event or function call that causes a write event.

Trigger type, Type of change in signal value

Trigger type determines whether rising, falling, or either type of trigger edge causes a write event. You see this field only if you set Write to memory upon to Trigger from port wtr.

Type of change in signal value determines whether rising, falling, or either type of value change causes a write event. You see this field only if you set Write to memory upon to Change in signal from port wvc.

Resolve simultaneous signal updates according to event priority

Select this option to control the sequencing of the write event, relative to other simultaneous events in the simulation. If you do not select this option, the application executes the write event immediately upon detecting the signal-based event that causes it. For details, see Resolve Simultaneous Signal Updates.

Event priority for writing to memory

The priority of the write event, relative to other simultaneous events in the simulation. For details, see Specify Event Priorities to Resolve Simultaneous Signal Updates.

Use of this parameter depends on the following:

  • You see this field only if you select Resolve simultaneous signal updates according to event priority on this tab.

  • If you select Resolve simultaneous signal updates according to event priority on both the write tab and the read tab, the software ignores Event priority for reading from memory. Instead, the simulation resolves simultaneous signal updates based on only the Event priority for writing to memory parameter. In this case, the software executes the write event before the read event.

  • If you select the configuration parameter Prevent duplicate events on multiport blocks and branched signals in your model, the software uses the Event priority for writing to memory parameter to help Simulink® to sort blocks in the model. In this case, the software no longer schedules an event that you can view on the SimEvents® event calendar.

Read Tab

Read from memory upon

The type of signal-based event, function call, or internal write event that causes a read event.

Trigger type, Type of change in signal value

Trigger type determines whether rising, falling, or either type of trigger edge causes a read event. You see this field only if you set Read from memory upon to Trigger from port rtr.

Type of change in signal value determines whether rising, falling, or either type of value change causes a read event. You see this field only if you set Read from memory upon to Change in signal from port rvc.

Resolve simultaneous signal updates according to event priority

Select this option to control the sequencing of the read event, relative to other simultaneous events in the simulation. If you do not select this option, the application executes the read event immediately upon detecting the signal-based event that causes it. For details, see Resolve Simultaneous Signal Updates. You see this field only if you set Read from memory upon to an option other than Write to memory event.

Event priority for reading from memory

The priority of the read event, relative to other simultaneous events in the simulation. For details, see Specify Event Priorities to Resolve Simultaneous Signal Updates.

Use of this parameter depends on the following:

  • You see this field only if you select Resolve simultaneous signal updates according to event priority on this tab.

  • If you select Resolve simultaneous signal updates according to event priority on both the write tab and the read tab, the software ignores Event priority for reading from memory. Instead, the simulation resolves simultaneous signal updates based on only the Event priority for writing to memory parameter. In this case, the software executes the write event before the read event.

  • If you select the configuration parameter Prevent duplicate events on multiport blocks and branched signals in your model, the software uses the Event priority for writing to memory parameter to help Simulink to sort blocks in the model. In this case, the software no longer schedules an event that you can view on the SimEvents event calendar.

Status Tab

Report state of the block

Allows you to use the signal output port labeled st.

Report memory value upon write event

Allows you to use the signal output port labeled mem.

Report memory value upon read event

Allows you to use the signal output port labeled out.

Examples

Reading from Memory Upon Each Write Event

In the plot below, the output signal reflects values of the input signal upon each rising or falling value of the wvc signal. Between successive write events, the output signal maintains the value from the most recent write event. Before the first write event, the output signal is 0 because of the initial memory value.

Independent Read and Write Events

In the plot below, the mem signal reflects values of the input signal upon each rising or falling value of the wvc signal, while the out signal reflects values of the mem signal upon each rising or falling value of the rvc signal.

For examples showing the use of this block in a model, see

Was this topic helpful?