Main Content

fpga

Access DUT on the FPGA of an NI USRP radio device

Since R2024a

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

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 the internal architecture of an NI USRP radio. The fpga object enables you to configure register ports and data streaming ports on your DUT, and then read and write data to them.

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

  1. Create a usrp System object device with a saved radio configuration, "MyRadio".

    • If you have not yet loaded your bitstream onto your radio device, use the programFPGA to do so.

    • Configure the hardware interfaces with the describeFPGA function.

    For details, see the usrp call sequence in Object Functions on the usrp reference page.

  2. Create an fpga object with the usrp System object device.

  3. Add interfaces to the fpga object that correspond to the interfaces in your DUT.

    • Add one RFNoC register interface for all DUT register ports by using the addRFNoCRegisterInterface function.

    • Add an RFNoC streaming interface for each DUT streaming port by using the addRFNoCStreamInterface function.

    • Create an hdlcoder.DUTPort (HDL Coder) object to represent each of your DUT port names. Use this to specify the properties of the port.

    • Use the mapPort function to map the DUT ports to the RFNoC interfaces.

  4. Call the setup function on the usrp System object device to start the radio front end.

  5. Read and write data to the DUT by using the readPort and writePort functions.

  6. Call the release function to release the hardware resources.

The MATLAB code you need to get started is included in the host interface script that you generate in Run and Verify Hardware Implementation of the targeting workflow.

Creation

Description

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

example

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 RFNoC register interface to your DUT
addRFNoCStreamInterfaceAdd RFNoC streaming interface to your DUT
mapPortMap DUT port to RFNoC interface
writePortWrite input data to DUT port
readPortRead output data from DUT port
releaseRelease the hardware resources associated with 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 an hdlcoder.DUTPort (HDL Coder) 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 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.

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

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

Version History

Introduced in R2024a