Main Content

soc.iosource

Input source on SoC hardware board

Description

Create an soc.iosource object to connect to an input source on an SoC hardware board. Pass the soc.iosource object as an argument to the addSource function of the DataRecorder object.

The sources available on the design running on the SoC hardware board correspond to the blocks you included in your Simulink® model. When you run SoC Builder, it connects your FPGA logic with the matching interface on the board.

SourceBlockAction
'TCP Receive'TCP Read

Read UDP (User Datagram Protocol) data from the Linux® socket buffer.

'UDP Receive'UDP Read

Read TCP/IP data from Linux socket buffer.

'AXI Register Read'Register Read

Read registers from an IP core using the AXI interface.

'AXI Stream Read'Stream Read

Read AXI-4 Stream data using IIO.

Creation

Description

availableSources = soc.iosource(hw) returns a list of input sources available for data logging on the SoC hardware board connected through hw. hw is an socHardwareBoard object.

example

src = soc.iosource(hw,inputSourceName) creates a source object corresponding to inputSourceName on the SoC hardware board connected through hw.

Input Arguments

expand all

Hardware object, specified as a socHardwareBoard object that represents the connection to the SoC hardware board.

Name of an available input source on the SoC hardware board, specified as a character vector. To get the list of input sources available for data logging on the specified SoC hardware board, call the soc.iosource function without arguments.

Example: 'UDP Receive'

Data Types: char

Output Arguments

expand all

List of input data sources available for data logging on the specified SoC hardware board, returned as a cell array. Each cell contains a character vector with the name of an available input data source for data logging on the specified SoC hardware board. Use one of these names as the inputSourceName argument when you create a source object.

Source object for specified input source, returned as an soc.iosource.

Properties

expand all

Name of IP core device, specified as a character vector.

Example: 'mwipcore0:s2mm0'

Dependencies

To enable this property, create a AXI register or AXI stream source object.

Data Types: char

Offset from the base address of the IP core to the register, specified as a positive scalar.

Dependencies

To enable this property, create a AXI register source object.

Data Types: uint32

IP port on hardware board where UDP or TCP data is received specified as a scalar from 1 to 65,535. The object reads UDP or TCP data received on this port of the specified SoC hardware board.

For a TCP object with the NetworkRole property to 'Client', set LocalPort to -1 to assign any random available port on the hardware board as the local port.

Dependencies

To enable this property, create a TCP or UDP source object.

Data Types: uint16

Network role, specified as a character vector.

Example: 'Client'

Dependencies

To enable this property, create a TCP source object.

Data Types: enumerated string

IP address of the remote server from which data is received, specified as a dotted-quad expression.

Dependencies

To enable this property, create a TCP source object.

Data Types: char

IP port number of the remote server from which data is received, specified as an integer from 1 to 65,535.

Dependencies

To enable this property, create a TCP source object.

Data Types: double

Maximum length of UDP or TCP data packet, or word length of AXI register data vector, specified as a positive scalar.

Data Types: double

Size of the data vector read from the IP core, specified as a nonnegative scalar.

Dependencies

To enable this property, create a AXI stream source object.

Data Types: double

Data type of received data, specified as 'uint8', 'uint16', 'uint32', 'int8', 'int16', 'int32', 'double' or 'single'.

Data Types: char

Internal buffer size of object, specified as an array.

Dependencies

To enable this property, create a TCP or UDP source object.

Data Types: double

Sample time, in seconds, at which you want to receive data, specified as an nonnegative scalar.

Data Types: double

Examples

collapse all

Create a connection from MATLAB to the specified SoC hardware board using the IP address, username, and password of the board.

hw = socHardwareBoard('Xilinx Zynq ZC706 evaluation kit','hostname','192.168.1.18','username','root','password','root');

Create a data recording session on the SoC hardware board by using the hw object. The resulting DataRecorder object represents the data recording session on the SoC hardware board.

dr = soc.recorder(hw)
dr = 

  DataRecorder with properties:

          HardwareName: 'Xilinx Zynq ZC706 evaluation kit'
               Sources: {}                            
             Recording: false                         

List the input sources added to the data recording session.

dr.Sources(hw)
ans =

  1×0 empty cell array                       

By default, soc.recorder objects have no added input sources. To add an input source to the data recording session, first create an input source object by using the soc.iosource function. For this example, create an User Datagram Protocol (UDP) source object.

udpSrc = soc.iosource(hw,'UDP Receive')
udpSrc = 

  soc.iosource.UDPRead with properties:

   Main
              LocalPort: 25000
             DataLength: 1
               DataType: 'uint8'
      ReceiveBufferSize: -1
           BlockingTime: 0
    OutputVarSizeSignal: false
             SampleTime: 0.1000
         HideEventLines: true

  Show all properties

Add this UDP source object to the data recording session by using the addSource object function.

addSource(dr,udpSrc,'UDPDataReceived-Port25000')

Verify the result by inspecting the Sources property of the soc.recorder object.

dr.Sources
ans =

  1×1 cell array

    {'UDPDataOnPort25000'}                        

Call the setup function to initialize all hardware peripheral input sources added to the data recording session, and start the data recording process.

setup(dr)

Record data for 60 seconds on the SoC hardware board.

record(dr, 60);

Check the status of the data recording session by using the isRecording object function. The recording status when data recording is in progress is 1.

recordingStatus = isRecording(dr)
recordingStatus =

  logical

   1

The recording status when data recording is complete is 0.

isRecording(dr)
recordingStatus =

  logical

   0

Save recorded data to a TGZ-compressed file.

save(dr,'UDPDataReceived','UDP Data Testing',{'Recorded On Zynq Board'})

This function saves the recorded data as the file UDPDataReceived.tgz in your working folder of the host PC. You can read this file by using an socFileReader object in MATLAB™ or an IO Data Source block in your Simulink model.

Remove the added source from the data recording session by using the removeSource object function.

removeSource(dr,'UDPDataReceived-Port25000')

Verify the result by inspecting the Sources property of the soc.recorder object.

ans =

  1×0 empty cell array                       

Version History

Introduced in R2019a