Main Content

writeMemory

Write data to memory regions on FPGA or SoC hardware

Since R2023a

    Description

    example

    writeMemory(hFPGA,addr,data) writes all words specified in data to the FPGA, hFPGA, starting from the address specified in addr and incrementing the address for each word. The address must be in the range of one of the AXI4 Slave or Memory interfaces added to the hFPGA object. The write operation writes to the appropriate interface based on the address provided.

    Examples

    collapse all

    Write scalar data to FPGA-accessible memory.

    Create a fpga object, hFPGA, for a Xilinx® target.

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

    Add the memory interface to the hFPGA object by using the addMemoryInterface function. Specify the memory interface name, base address, and address range. Save the memory interface object to hInterface.

    hInterface = addMemoryInterface(hFPGA, InterfaceID = "myInterface",...
    BaseAddress = 0x80000000,AddressRange = 0x20000000)
    
    hInterface = 
    
      Memory with properties:
    
         InterfaceID: "myInterface"
         BaseAddress: "0x80000000"
        AddressRange: "0x20000000"
         WriteDriver: [1×1 matlabshared.libiio.sharedmem.write]
          ReadDriver: [1×1 matlabshared.libiio.sharedmem.read]
          InputPorts: [0×0 string]
         OutputPorts: [0×0 string]

    Write data to a memory location.

    writeMemory(hFPGA,0x80000000,uint32(5));

    Write vector data to FPGA-accessible memory.

    Create a fpga object, hFPGA, for a Xilinx target.

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

    Add the memory interface to the hFPGA object by using the addMemoryInterface function. Specify the memory interface name, base address, and address range. Save the memory interface object to hInterface.

    hInterface = addMemoryInterface(hFPGA, InterfaceID = "myInterface",...
    BaseAddress = 0x80000000,AddressRange = 0x20000000)
    
    hInterface = 
    
      Memory with properties:
    
         InterfaceID: "myInterface"
         BaseAddress: "0x80000000"
        AddressRange: "0x20000000"
         WriteDriver: [1×1 matlabshared.libiio.sharedmem.write]
          ReadDriver: [1×1 matlabshared.libiio.sharedmem.read]
          InputPorts: [0×0 string]
         OutputPorts: [0×0 string]

    Write data to a memory location.

    writeMemory(hFPGA,0x80000000,uint32(1:5));

    Input Arguments

    collapse all

    Target FPGA object, specified as an fpga object.

    Starting address for the write operation, 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 must be in the range of one of the AXI4 Slave or Memory interfaced added to the hFPGA object.

    Example: 0x80000000 specifies a starting address of 0x80000000.

    Data Types: uint32 | uint64

    Data words to write, specified as a uint32 scalar or vector. By default, the function writes the data to a contiguous address block and increments the address for each operation.

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

    Example: [1:100] specifies 100 contiguous memory locations.

    Data Types: uint32

    Version History

    Introduced in R2023a