Main Content

writePort

Write input data to DUT port

Since R2024a

Add-On Required: This feature requires the Wireless Testbench™ Support Package for NI™ USRP™ Radios add-on.

Description

Register Port

writePort(dut,portName,data) writes input data data to a specified DUT register port portName on the target DUT DUT.

example

Streaming Port

numSamples = writePort(dut,portName,data) writes input data data to a specified DUT streaming port portName on the target DUT DUT and returns the number of samples transmitted numSamples.

example

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.

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.

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

Create an hdlcoder.DUTPort (HDL Coder) 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);

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.

setup(device);

Write data to the DUT port.

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.

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. 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 (HDL Coder) 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");

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.

setup(device);

Generate random data with length dataLength and write it to the DUT port.

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

Release the hardware resources.

release(dut);

Input Arguments

collapse all

Target DUT on the FPGA of a target NI USRP radio device, specified as an fpga object.

DUT port name, specified as a string. You create the DUT port as an hdlcoder.DUTPort (HDL Coder) object array. Before you specify portName, you must have mapped the port to an RFNoC interface using the mapPort function.

Data Types: string

Register Port

Input data to write to the DUT register port portName, specified as a scalar. The data type must match the data type specified by the DataType (HDL Coder) property of the hdlcoder.DUTPort (HDL Coder) object.

Streaming Port

Input data to write to the DUT streaming port portName, specified as a matrix. The data type must match the data type specified by the DataType (HDL Coder) property of the hdlcoder.DUTPort (HDL Coder) object.

The number of elements in data must be equal to the FrameSize specified in addRFNoCStreamInterface.

Data is written either continuously or once, depending on the value of WriteMode that you specified when you added the RFNoC streaming interface with the addRFNoCStreamInterface function.

Output Arguments

collapse all

Number of successfully transmitted samples, returned as a positive integer.

Data Types: double

Version History

Introduced in R2024a