Main Content

hdlcoder.DUTPort

DUT port object array that represents DUT ports on custom FPGA image

Since R2024a

Description

This object array represents the DUT ports on a custom FPGA image deployed on your radio. When you generate a custom FPGA image using the Target NI USRP Radios Workflow, you map the ports on your Simulink® DUT subsystem to a simplified AXI-Stream interface. The DUT port object array contains information about these DUT ports and the interfaces that they map to, based on the interface mapping information that you configured in the Map Target Interfaces step of the workflow.

Before you create this object array:

After you create an hdlcoder.DUTPort object array, use the mapPort function to map the DUT ports to an RFNoC register or streaming interface. Then you can write to or read from the DUT ports by using the writePort and readPort functions.

The generated setup function file contains the code required to configure your fpga object with the interfaces you configured for your DUT subsystem in Simulink. For more information, see Run and Verify Hardware Implementation.

Creation

Description

dutPort = hdlcoder.DUTPort(portName,PropertyName=Value) creates a DUT port object array and sets properties using name-value arguments.

example

Input Arguments

expand all

Port name, specified as a string. The port name is the name of the port on your DUT subsystem.

Example: dutPort = hdlcoder.DUTPort("Data_In1", ...)

Data Types: string | char

Properties

expand all

Port direction, specified as IN or OUT. This property specifies whether the port carries data in or out of your DUT subsystem.

Example: dutPort = hdlcoder.DUTPort("Data_Out1","Direction","OUT", ...)

Data Types: char

Flag to specify if data on the port is complex, specified as true or false.

Example: dutPort = hdlcoder.DUTPort(portName, ..., "IsComplex","true", ...)

Data Types: char

Port data type, specified as a MATLAB® numeric type or a numerictype (Fixed-Point Designer) object. If the data is real, the data can be any numeric data type up to 32 bits. If the data is complex, the data type can be any numeric data type up to 16 bits.

You assign the port data type in the Data Type column of the interface mapping table in the Map Target Interfaces step in the targeting workflow.

Example: dutPort = hdlcoder.DUTPort(..., "DataType",int16, ... )

Data Types: int8 | int16 | int32 | uint8 | uint16 | uint32 | logical | fi

Port dimensions, specified as a [1 1]. Your model must contain scalar ports only.

Example: dutPort = hdlcoder.DUTPort(..., "Dimension",[1 1], ...)

Target platform interface that the DUT port maps to, specified as a string or character array. The target platform interface is the name that you assign to your interface with the InterfaceID name-value argument when you call the addRFNoCRegisterInterface or addRFNoCStreamInterface function.

Example: dutPort = hdlcoder.DUTPort(..., "IOInterface","DUTName", ...)

Example: dutPort = hdlcoder.DUTPort(..., "IOInterface","RX_STREAM#0", ...)

Data Types: string | char

Register address for interface mapping, specified as a numeric type. This is the register address of the register interface, which is specified in the hand-off information file.

This property is required for register interfaces only.

Example: dutPort = hdlcoder.DUTPort(..., "IOInterfaceMapping","128")

Examples

collapse all

Create a usrp System object, specifying a radio setup configuration previously saved in the Radio Setup wizard.

device = usrp("MyRadio");

Configure your radio with the target interfaces by using the describeFPGA function.

describeFPGA(device,"ModelName_wthandoffinfo.mat"); 

Create an fpga object to access your DUT on the FPGA of your radio.

dut = fpga(device);

Add an RFNoC register interface to your DUT by using the addRFNoCRegisterInterface function.

addRFNoCRegisterInterface(dut, ...
    "InterfaceID","DUTName", ...
    "RFNoCBlock","0/DUTName#0");

Create an hdlcoder.DUTPort object for the DUT port and specify the properties.

DUTPort_Read_Register = hdlcoder.DUTPort("Read_Register", ...
	"Direction","OUT", ...
	"DataType","int16", ...
	"IsComplex",false, ...
	"Dimension",[1 1], ...
	"IOInterface","DUTName", ...
	"IOInterfaceMapping",1);

Using the mapPort function, map the DUT port to the RFNoC interface you added to your DUT.

mapPort(dut,DUTPort_Read_Register);

Connect to the radio and apply radio front end properties by calling the setup function.

setup(device);

Read data from the DUT port by using the readPort function.

data = readPort(dut,"Read_Register")
data = int16

0

Release the hardware resources.

release(dut);

Create a usrp System object, specifying a radio setup configuration previously saved in the Radio Setup wizard.

device = usrp("MyRadio");

Configure your radio with the target interfaces by using the describeFPGA function.

describeFPGA(device,"ModelName_wthandoffinfo.mat"); 

Create an fpga object to access your DUT on the FPGA of your radio.

dut = fpga(device);

Add an RFNoC register interface to your DUT by using the addRFNoCRegisterInterface function.

addRFNoCRegisterInterface(dut, ...
    "InterfaceID","DUTName", ...
    "RFNoCBlock","0/DUTName#0");

Create an hdlcoder.DUTPort object for the DUT port and specify the properties.

DUTPort_Write_Register = hdlcoder.DUTPort("Write_Register", ...
	"Direction","IN", ...
	"DataType","int16", ...
	"IsComplex",false, ...
	"Dimension",[1 1], ...
	"IOInterface","DUTName", ...
	"IOInterfaceMapping",128);

Using the mapPort function, map the DUT port to the RFNoC interface you added to your DUT.

mapPort(dut,DUTPort_Write_Register);

Connect to the radio and apply radio front end properties by calling the setup function.

setup(device);

Write data to the DUT port by using the writePort function.

data = 20;
writePort(dut,"Write_Register",data)

Release the hardware resources.

release(dut);

Create a usrp System object, specifying a radio setup configuration previously saved in the Radio Setup wizard.

device = usrp("MyRadio");

Configure your radio with the target interfaces by using the describeFPGA function.

describeFPGA(device,"ModelName_wthandoffinfo.mat"); 

Create an fpga object to access your DUT on the FPGA of your radio.

dut = fpga(device);

Add an RFNoC streaming interface to your DUT by using the addRFNoCStreamInterface function.

addRFNoCStreamInterface(dut, ...
    "InterfaceID","RX_STREAM#0", ...
    "Streamer","0/RX_STREAM#0", ...
    "Direction","OUT", ...
    "FrameSize",1000, ...
    "DDRAllocation",1000, ...
    "Timeout",[]);

Create an hdlcoder.DUTPort object for the DUT port and specify the properties.

DUTPort_Data_Out = hdlcoder.DUTPort("Data_Out", ...
	"Direction", "OUT", ...
	"DataType", "uint32", ...
	"IsComplex", false, ...
	"Dimension", [1 1], ...
	"IOInterface", "RX_STREAM#0");

Using the mapPort function, map the DUT port to the RFNoC interface that you added to your DUT.

mapPort(dut,DUTPort_Data_Out);

Connect to the radio and apply radio front end properties by calling the setup function.

setup(device);

Call the usrp System object as a function to start the radio front end. Request 1000 samples.

device(1000);

Read data from the DUT port by using the readPort function.

[dataRx,numSamps,overflow] = readPort(dut,"Data_Out")
dataRx = 1000×1 uint32 column vector

    4294901766
             5
        262150
             4
    4294901760
    4294639613
        131073
    4294574078
    4294639617
    4294967294
      ⋮

numSamps = 
1000
overflow = logical
   0

Release the hardware resources.

release(dut);

Create a usrp System object, specifying a radio setup configuration previously saved in the Radio Setup wizard.

device = usrp("MyRadio");

Configure your radio with the target interfaces by using the describeFPGA function.

describeFPGA(device,"ModelName_wthandoffinfo.mat"); 

Create an fpga object to access your DUT on the FPGA of your radio.

dut = fpga(device);

Add an RFNoC streaming interface to your DUT by using the addRFNoCStreamInterface function. Specify a frame size and DDR allocation of dataLength samples.

dataLength = 1000;
addRFNoCStreamInterface(dut, ...
    "InterfaceID","TX_STREAM#0", ...
    "Streamer","0/TX_STREAM#0", ...
    "Direction","IN", ...
    "FrameSize",dataLength, ...
    "DDRAllocation",dataLength, ...
    "WriteMode","continuous");

Create an hdlcoder.DUTPort object for the DUT port and specify the properties.

DUTPort_Data_In = hdlcoder.DUTPort("Data_In", ...
	"Direction", "IN", ...
	"DataType", "uint32", ...
	"IsComplex", false, ...
	"Dimension", [1 1], ...
	"IOInterface", "TX_STREAM#0");

Using the mapPort function, map the DUT port to the RFNoC interface that you added to your DUT.

mapPort(dut,DUTPort_Data_In);

Connect to the radio and apply radio front end properties by calling the setup function.

setup(device);

Generate random data with length dataLength and write it to the DUT port by using the writePort function.

data = randn(dataLength,1);
numSamps = writePort(dut,"Data_In",data)
numSamps = 
1000

Release the hardware resources.

release(dut);

Version History

Introduced in R2024a