Main Content

fpga

Access DUT on the FPGA of an NI USRP radio device

Since R2024a

Description

This object represents a connection from MATLAB® to the DUT (user logic) on the FPGA on an NI™ USRP™ radio device. To interact with the DUT, use this object with the functions listed in Object Functions.

The diagram shows an overview of the internal architecture of an NI USRP radio. The fpga object enables you to configure register ports and data streaming ports on your DUT, then read and write data to them.

Simplified block diagram of NI USRP radio architecture showing the functionality of the usrp System object. The radio contains PL DDR buffer, user logic, and radio front end. The radio front end block connects to transmit and receive antennas that can be configured as DUT output/transmit antennas and DUT input/capture antennas.

To use this object, first create a connection to your NI USRP radio device using the usrp System object™. Then, use usrp and fpga object functions. The diagram shows the sequence.

Sequence of MATLAB commands to connect to, configure and control the DUT on your NI USRP radio device with the .

For details about the usrp steps, see Object Functions.

Create a fpga object using the usrp System object that you have already created. If you haven't already, use the programFPGA function to load a bitstream, then configure the hardware interfaces with the describeFPGA function.

Add the required RFNoC interfaces with the addRFNoCRegisterInterface and addRFNoCStreamInterface function. Use the hdlcoder.DUTPort (HDL Coder) object to configure the DUT ports, then use the mapPort function to map the DUT ports to the RFNoC interfaces.

Call the setup function to start the radio front end. You can now read and write data to the DUT using the readPort and writePort functions.

Call the release function to release the hardware resources.

Creation

Description

example

dut = fpga(device) creates a hardware object that you can use to connect to the DUT on the FPGA of a target NI USRP radio device, usrp.

Input Arguments

expand all

NI USRP radio device, specified as a usrp System object.

Object Functions

Use the object functions to interact with your FPGA or SoC device.

addRFNoCRegisterInterfaceAdd an RFNoC register interface to your DUT
addRFNoCStreamInterfaceAdd an RFNoC streaming interface to your DUT
mapPortMap a DUT port to an RFNoC interface
writePortWrite input data to a DUT port
readPortRead output data from a DUT port
releaseRelease the hardware resources associated with the fpga object

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

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.

setup(device);

Read data from the DUT port.

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.

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

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.

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

Create a 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");

Map the DUT port to the RFNoC interface you added to your DUT.

mapPort(dut, DUTPort_Data_Out);

Connect to the radio and apply radio front end properties.

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.

[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.

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 a 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");

Map the DUT port to the RFNoC interface 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 the DUT port.

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

Release the hardware resources.

release(dut);

Version History

Introduced in R2024a