Main Content

writePort

Write input data to DUT port

Since R2024a

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 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. 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);

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 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 property of the hdlcoder.DUTPort 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 property of the hdlcoder.DUTPort object.

The number of elements in data must be equal to the FrameSize you specified when you added the interface using the addRFNoCStreamInterface function.

Data is written either continuously or once, depending on the WriteMode that you specified when you added the interface using 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