Main Content

Apply Conditional Execution

You can apply conditional execution to determine whether the receiver blocks or System objects available in the SoC Blockset™ Support Package for AMD FPGA and SoC Devices receive valid data from the radio hardware.

Conditional Execution with Receiver Blocks

The AD936x Receiver and FMCOMMS5 Receiver blocks have a static data valid output port returning a logical value.

  • 1 indicates that the block has received data from the radio hardware.

  • 0 indicates that the block has not received data from the radio hardware. Either Simulink® runs faster than the radio hardware during simulation or the radio hardware has no new data to send to Simulink when the sampling occurs.

Any processing that occurs downstream of the receiver block must run only on valid data. To ensure that data is valid, control the data with an enabled subsystem. The data valid output serves as a convenient control signal for such an enabled subsystem.

Example

To enable the data valid port of the AD936x Receiver block, on the Advanced tab of the block mask, update Data timeout (sec) to a value other than Inf. When this value is set to Inf, the block indefinitely waits for valid data and this port is not required.

AD936x receiver block

When used in a model, the output from this port can help determine data validity.

AD936x receiver block with data valid port connected to conditional algorithm block

Conditional Execution with Receiver System Objects

When you call the comm.SDRRxAD936x or comm.SDRRxFMCOMMS5 System objects, the second output arguments is a logical value that indicates validity of the data packets streaming to MATLAB® from the radio hardware.

  • true indicates that the System object™ has received data from the radio hardware.

  • false indicates that the System object has not received data from the radio hardware.

Any processing that occurs downstream of the System object must have conditions to accept only valid data. Note that if the DataTimeout property is set to Inf, the object indefinitely waits for valid data. In this case, the second output argument of the object indicating data validity is always true and can be ignored.

Example

Create a receiver System object.

rx = sdrrx('AD936x');

% Use second output argument for validation
rx.DataTimeout = 0; 

Receive data using the object. Validate data, then save valid data using a log.

Log = dsp.SignalSink;
for counter = 1:20
    [data,validData,overflow] = rx();
    if validData == 1 
        if overflow ~=1 % contiguous data
             Log(data);
        end
    else
        disp('Not valid data.');
    end
end 

See Also

Blocks

Objects