Main Content

readMemoryOffset

Read data from memory regions on FPGA or SoC hardware by using offset address

Since R2023b

    Description

    example

    data = readMemoryOffset(hFPGA,interfaceID,addrOffset,dataLen) reads locations of data, dataLen from the FPGA, hFPGA, starting from the offset address specified in addrOffset and using the interface specified by interfaceID.

    Examples

    collapse all

    Read scalar data from FPGA-accessible memory regions by using the offset address and interface ID.

    Create an fpga object, hFPGA, for an Intel® target.

    hFPGA = fpga("Intel")
    hFPGA = 
    
      fpga with properties:
    
            Vendor: "Intel"
        Interfaces: [0×0 fpgaio.interface.InterfaceBase]
        
    

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

    addAXI4SlaveInterface(hFPGA,InterfaceID = "Registers",...
    BaseAddress = 0x400D0000,...
    AddressRange = 0x10000);

    Write data to a memory location.

    writeMemoryOffset(hFPGA,"Registers",0x100,uint32(5));

    Read data from a single location.

    data = readMemoryOffset(hFPGA,"Registers",0x100,1)
    data =
     
        uint32
     
            5

    Read vector data from FPGA-accessible memory regions by using the offset address and interface ID.

    Create an fpga object, hFPGA, for an Intel target.

    hFPGA = fpga("Intel")
    hFPGA = 
    
      fpga with properties:
    
            Vendor: "Intel"
        Interfaces: [0×0 fpgaio.interface.InterfaceBase]
        
    

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

    addAXI4SlaveInterface(hFPGA,InterfaceID = "Registers",...
    BaseAddress = 0x400D0000,...
    AddressRange = 0x10000);

    Write data to a memory location.

    writeMemoryOffset(hFPGA,"Registers",0x100,uint32(1:5));

    Read data from a single location.

    data = readMemoryOffset(hFPGA,"Registers",0x100,5)
    data =
     
        uint32
     
            1 2 3 4 5

    Input Arguments

    collapse all

    Target FPGA object, specified as an fpga object.

    Name of FPGA interface, specified as a string or character vector.

    Memory offset address specified as a nonnegative integer that is a multiple of 4 or hexadecimal value that is a multiple of 4. The function casts the address to the uint32 or uint64 data type, depending on the memory interface address width. The address offset must be in the range of the interface addresses added to the hFPGA object.

    Example: 0x100 specifies an offset address of 0x100.

    Data Types: uint32 | uint64

    Length of data to read, starting at the location specified by addrOffset, specified as a nonnegative integer. By default, the function reads data from a contiguous address block, and increments the address for each operation.

    When you specify a large operation size, such as when you read a block of DDR memory, the function automatically breaks the operation into multiple bursts, using the maximum supported burst size of 256 words.

    Example: 5 specifies five contiguous memory locations.

    Output Arguments

    collapse all

    Read data, returned as a scalar or vector, depending on the value you specify for dataLen.

    Version History

    Introduced in R2023b