DSP Builder for Intel® FPGAs (Advanced Blockset): Handbook

ID 683337
Date 4/01/2024
Public
Document Table of Contents

3.6.1. Hardware Verification

DSP Builder provides an interface for accessing the FPGA directly from MATLAB. This interface allows you to use MATLAB data structures to provide stimuli for the FPGA and read the results from the FPGA.

This interface provides memory-mapped read and write accesses to your design running on an FPGA using the System Console system debugging tool.

Table 10.  Methods for SystemConsole ClassCall these methods as SystemConsole.<method_name>[arguments]. Use these methods to scan and establish the master connection to the FPGA.
Method Description
executeTcl(script) Executes a Tcl script specified through <script> string in SystemConsole.
designLoad(path) Loads the design (.sof) file specified through <path> parameter to FPGA.
refreshMasters Detects and lists all available master connections.
openMaster(index)

Creates and returns a master connection to a specified master link. The <index> specifies the index (starting 1) of the connection from the list returned by refreshMasters function.

For example, M=SystemConsole.openMaster(1);

Table 11.  Methods for Master ClassRead and write through a master connection. Call these methods on a master object returned by SystemConsole.openMaster(index) method.
Method Description
close()

Closes the connection associated with the master object.

Note: Always call this method when you finish working with current master connection.
setTimeOutValue(timeout) Use this method to override the default timeout value of 60 seconds for the master connection object. The specified <timeout> value in seconds.
read(type, address, size [, timeout]) Returns a list of <size> number of values of type <type> read from memory on FPGA starting at address <address>.

For example,

data = masterObj.read(‘single’, 1024, 10)

Reads consequent 10 4-byte values (40 bytes overall) with a starting address of 1,024 and returns the results as list of 10 ‘single’ typed values.

write(type, address, data [, timeout])

Writes <data> (a list of values of type <type>) to memory starting at address <address>.

For example:

masterObj.write(‘uint16’, 1024, 1:10);

Writes values 1 to 10 to memory starting address 1,024, where each value occupies 2 bytes in memory (overall 20 bytes are written).

read16(type, address, size [,timeout]) Same as read but using 16-bit transactions.
write16(type, address, data [, timeout]) Same as write but using 16-bit transactions.
Table 12.  Parameters for read(type, address, size [, timeout])
Parameter Description
<type>

The type of each element in returned array.

  • 1 byte : ‘char’, ‘uint8’, ‘int8’
  • 2 bytes: ‘uint16’, ‘int16’
  • 4 bytes: ‘uint32’, ‘int32’, ‘single’
  • 8 bytes: ‘uint64’, ‘int64’, ‘double’
<address>

The start address for the read operation. You can specify as a hexadecimal string.

Note: The address should specify a byte address
<size> The number of <type> (type specifies 1/2/4/8 bytes based on value) values to read.

<timeout>

An optional parameter to override the default timeout value for this operation only.
Table 13.  Parameters for write(type, address, data [, timeout])
Parameter Description
<type>

The type each element in specified <data>. Each type specifies 1/2/4/8 bytes:

  • 1 byte : ‘char’, ‘uint8’, ‘int8’
  • 2 bytes: ‘uint16’, ‘int16'
  • 4 bytes: ‘uint32’, ‘int32’, ‘single’
  • 8 bytes: ‘uint64’, ‘int64’, ‘double’
<address>

The start address for the write operation. You can specify as a hexadecimal string.

Note:

The address should be specified as a byte address

<data> An array or single element data to be written to memory.
<timeout> An optional parameter to override the default timeout value for this operation only.

Transaction Size

The JTAG and USB Bridge Avalon host uses a 32-bit data path. Because DSP Builder’s Avalon agent does not use byte enables, you must ocnfigure the agent to 32 bits or less (refer to Avalon Memory-Mapped Agent Settings).

DSP Builder provides memory-mapped access to the FPGA. This interface can read and write in multiples of 8, 16, 32, and 64 bits at 16 or 32-bit transaction sizes:

  • If the number of bits you read or write is greater than the transaction size, DSP Builder performs multiple transactions.
  • If the number of bits you read is less than a multiple of the transaction size, the number of bits read in hardware is rounded up, but the extra bits are not returned to the calling function.
  • If the number of bits you write is less than a multiple of the transaction size, the number of bits DSP Builder writes is rounded up by padding with extra bits. The extra bits are retrieved via read-modify-write. If the address is write-only, the padding is all zeros, which can corrupt data.

The transaction size should usually match the agent’s data width.