Main Content

readPort

Reads output data and returns it with the port data type and dimension

Description

example

data = readPort(hFPGA, portName) reads the output data and returns this value with the port data type and dimension.

Examples

collapse all

This example shows how to read data from the DUT ports that are mapped to AXI4 slave interfaces.

Create an fpga object with Xilinx as Vendor.

hFPGA = fpga("Xilinx")
hFPGA = 

  fpga with properties:

       Vendor: "Xilinx"
   Interfaces: [0x0 fpgaio.interface.InterfaceBase]

    

Add the AXI4 slave interface to the hFPGA object by using the addAXI4SlaveInterface function.

%% AXI4 Slave
addAXI4SlaveInterface(hFPGA, ...
	"InterfaceID", "AXI4-Lite", ...
	"BaseAddress", 0xA0000000, ...
	"AddressRange", 0x10000);

Specify the DUT ports in the HDL IP core as an hdlcoder.DUTPort object array and then map the port to the AXI4 slave interface.

hPort = hdlcoder.DUTPort("h_out1", ...
	"Direction", "OUT", ...
	"DataType", numerictype(1,16,10), ...
	"Dimension", [1 1], ...
	"IOInterface", "AXI4-Lite", ...
	"IOInterfaceMapping", "0x104");

Map the DUT port objects to the AXI4 slave interface and then read data by using the readPort function.

mapPort(hFPGA, hPort);

data = readPort(hFPGA, "h_out1");

This example shows how to read data from the DUT ports that are mapped to AXI4-Stream interfaces.

Create an object for the target device.

hFPGA = fpga("Xilinx")
hFPGA = 

  fpga with properties:

       Vendor: "Xilinx"
   Interfaces: [0x0 fpgaio.interface.InterfaceBase]

    

Add the AXI4-Stream interface to the hFPGA object by using the addAXI4StreamInterface function.

addAXI4StreamInterface(hFPGA, ...
	"InterfaceID", "AXI4-Stream", ...
	"WriteEnable", true, ...
      "ReadEnable", true, ...
	"WriteFrameLength", 1024, ...
	"ReadFrameLength", 1024);

Specify the DUT port as an hdlcoder.DUTPort object array and then map the port to the AXI4-Stream interface.

hPort = hdlcoder.DUTPort("y_out", ...
	"Direction", "OUT", ...
	"DataType", numerictype(1,16,10), ...
	"Dimension", [1 1], ...
	"IOInterface", "AXI4-Stream");

Map the DUT port objects to the AXI4-Stream interface and then read data by using the readPort function.

mapPort(hFPGA, hPort);

data = readPort(hFPGA, "y_out");

Input Arguments

collapse all

fpga object for the target vendor, 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 the portName, you must have mapped the port to an AXI interface by using the mapPort function.

Output Arguments

collapse all

Output data that is read from the DUT port, PortName, returned as a scalar or a vector.

Introduced in R2020b