Main Content

Initialize Deployed Deep Learning Processor Without Using a MATLAB Connection

Generate a file that has instructions to communicate with the deployed deep learning processor IP core by using Deep Learning HDL Toolbox™. Initialize the deployed deep learning processor IP core without a MATLAB® connection by using a utility to parse and execute the instructions in the generated file.

Prerequisites

  • Deep Learning HDL Toolbox Support Package for Intel® FPGA and SoC Devices

    or Deep Learning HDL Toolbox Support Package for Xilinx® FPGA and SoC Devices

  • Set up a secure digital (SD) card by using the guided SD card setup. For Intel boards, see Guided SD Card Setup. For Xilinx boards, see Guided SD Card Setup.

Generate File

To generate a file that has the instructions to program and initialize the generated deep learning processor IP configuration, set the deployment target to File by using the Target method of the dlhdl.Workflow object. For example, this code generates a dlhdl.Workflow object that has the ResNet-18 convolutional neural network as the network, zcu102_single as the target bitstream, and deploys the instructions to a file that is called zcu102socinitdata.dln.

hTarget = dlhdl.Target('Xilinx',Interface = 'File', Filename = 'zcu102socinitdata.dln');
hW = dlhdl.Workflow(Network = resnet18, Bitstream = 'zcu102_single', Target = hTarget);
hW.compile;
hW.deploy;

When you use the deploy method of the dlhdl.Workflow object, and the interface option for dlhdl.Target is set to File, the dlhdl.Workflow object and associated instructions are written to the file whose name is in Filename.

When you do not enter the file name for the dlhdl.Target object, the name of the created file is the bitstream name. For example, in this code the generated file name is zcu102_single.dln.

hTarget = dlhdl.Target('Xilinx',Interface = 'File');
hW = dlhdl.Workflow(Network = resnet18, Bitstream = 'zcu102_single', Target = hTarget);
hW.compile;
hW.deploy;

Generated File Structure

The generated file is a binary file that consists of:

  • A header section that contains information such as the date and time the file was generated, Deep Learning HDL Toolbox version, DDR address range, and so on.

  • A start of data (SOD) section that indicates the start of instructions to read and write data.

  • Data section that has AXI read and write transactions.

  • An end of data command (EOD) that marks the end of the file.

Header Section Information

This table lists the information available in the file header section. Strings are null terminated and uint32 data types are stored in reverse byte order. When your script reads uint32 data types, read the data from right to left. For example, 0xa0000000 is stored in the generated files as 00 00 00 A0.

FieldData TypeExample Information
File versionstring'MWDLNV2'
Date and timestring'25-Oct-2021 12:44:03'
Deep Learning HDL Toolbox namestringDeep Learning HDL Toolbox
Deep Learning HDL Toolbox versionstring'1.2'
Deep Learning HDL Toolbox release informationstring'R2022a'
Deep Learning HDL Toolbox datestring'30-Sep-2021'
Deep learning processor base addressuint320xa0000000
Deep learning processor address rangeuint320x00010000
DDR memory base addressuint320x80000000
DDR memory address rangeuint320x20000000
Target device platformstring'Xilinx'
Device tree node name for deep learning processor IP core transmitstring'mwipcore_dl0:mmrw0'
Device tree node name for deep learning processor IP core receivestring'mwipcore_dl0:mmrd0'
Device tree node name for DDR memory transmitstring'mwipcore_ddr0:mm2s0'
Device tree node name for DDR memory receivestring'mwipcore_ddr0:s2mm0'

This image shows the header information section of the generated file.

Generated file header information section

Data Section

After the header section, each block starts with a three-letter command, listed in this table:

FieldTypeNotes
SODstringStart of data
EODstringEnd of data
TXTstringText field only
WRDstringData to write
RDDstringData to read

Read Data Command

After detecting the SOD command, check for read commands. The read data command appears in the generated file when you are waiting for a done flag from the deep learning processor. When the read command is executed:

  • A while loop is started.

  • A read is executed from a single register.

The read command and while loop end when the value of the data read from the register is equal to the value of the data in the data-to-read section of the read command.

The read data command follows this format:

  • 'RDD.', a null terminated string indicating start of the read command.

  • 'Text description.', a null terminated string that indicated the address from where the data is read and length of the data to be read.

  • Hexadecimal representation of the register address from where data is read. This data is specified as a uint32 data type.

  • Hexadecimal representation of the length of data to be read. This data is specified as a uint32 data type. The length data is the number of 32-bit data packets to be read. For example, a length value of one indicates one 32-bit data packet to read.

  • Hexadecimal representation of the data to be read. This data is specified as a uint32 data type.

In the generated file, uint32 data types are stored in reverse byte order. When your script reads uint32 data types, read the data from right to left. For example, 0xa0000184 is stored in the generated files as 84 01 00 A0.

This image shows a read instruction in the generated file and the structure of the read data command. RDD.RD@ADDR:0xa0000184 Length:1. 0xa0000184 0x00000001 0x00000001.

Read data command structure

Write Data Command

After detecting the SOD command, check for write commands.

The write data command follows this format:

  • 'WRD.', a null terminated string indicating start of the write command.

  • 'Text description.', a null terminated string that indicated the address from where the data is read and length of the data to be read

  • Hexadecimal representation of the register address where data is to be written. This data is specified as a uint32 data type.

  • Hexadecimal representation of the length of data to write. This data is specified as a uint32 data type. The length data is the number of 32-bit data packets to write. For example, a length value of 36 indicates 36 32-bit data packets to write. When there are N data packets to write, the write data format in the generated file after the text description field is address data, length data, data packet 1, data packet 2,…, and data packet N.

  • Hexadecimal representation of the data to write. This data is specified as a uint32 data type.

In the generated file, uint32 data types are stored in reverse byte order. When your script reads uint32 data types, read the data from right to left. For example, 0xa0000184 is stored in the generated files as 84 01 00 A0.

This image shows a write instruction in the generated file and the structure of the write data command. WRD.WR@ADDR:0x81800000 Len:36. 0x81800000 0x00000024 0x00000084.....0x00000003. In this example, there are 36 data packets to write. The first data packet is 0x00000084 and the last data packet is 0x00000003.

Write data command

Initiate Deployed Deep Learning Processor IP Core

To initiate the deployed deep learning processor IP core, create a script to parse the generated file and extract the instructions to program the deep learning processor IP core. The script must perform these actions:

  1. Take the generated file as an input and open the generated file.

  2. Extract the header information.

  3. Detect the start of data (SOD) command. Once the SOD command is detected:

    • Read data by extracting the address, length of data to be read, and data to read information from the read packet structure. Use the readmemory function with the address and length as input arguments.

    • Write data by extracting the write data address and data to write information from the write packet structure. Use the writememory function with the address and data to write as input arguments.

  4. Detect the end of data (EOD) command and close the generated file.

See Also

| | |

Related Topics