主要内容

programFPGA

R2026b

Program FPGA device through JTAG connection

Since R2026b

Description

programFPGA(jtagObj,programFile) programs the FPGA device connected to the selected JTAG cable using the specified bitstream file.

example

programFPGA(jtagObj,programFile,JTAGChainPosition=chainPosition) programs the FPGA device at the position specified by the chainPosition argument. Specify the chainPosition argument when multiple FPGA devices of the same vendor are present in the JTAG scan chain.

Examples

collapse all

Program the FPGA device connected to the selected JTAG cable by using a bitstream file. This example creates a jtagchain object, views the detected devices in the JTAG chain, and programs a selected FPGA device.

Set your system environment for accessing Altera® tools from MATLAB® by using the hdlsetuptoolpath function.

hdlsetuptoolpath('ToolName','Altera Quartus II',...
                 'ToolPath','C:\altera\24.1\quartus\bin\quartus.exe');

Create a jtagchain object for Altera devices. When you create the object, the constructor automatically scans the JTAG chain and populates the Devices property with information about the detected devices.

jtagObj = jtagchain("Altera")
### Checking Quartus tool

jtagObj =

  JTAGChain with properties:

          Vendor: "Altera"
       CableName: "auto"
         Devices: [1×3 table]

The Devices property contains the devices detected in the JTAG chain.

jtagObj.Devices
ans =

  1×3 table

    ChainPosition         Manufacturer               Part
    _____________    _______________________    _____________

          1          "Intel (Altera FPGA)"     "5CSEMA5F31"

After identifying the devices in the JTAG chain, program the FPGA using the programming file /dir/mybitstream.sof at JTAG chain position 1.

programFPGA(jtagObj,'/dir/mybitstream.sof',JTAGChainPosition=1);

Input Arguments

collapse all

Instance of JTAG chain object, specified as a jtagchain object.

Name of the programming file to load to the FPGA, specified as a character vector or string scalar.

You can either navigate to the folder that contains the programming file and specify only the file name, or specify the full file path directly without changing directories.

Example: "arty.runs\impl_1\design_1.bit" — For an AMD® non-Versal® device

Example: "versal.runs\impl_1\design_1.pdi" — For an AMD Versal device

Example: "fpgaproj\design_1.sof" — For an Intel® device

Data Types: char | string

JTAG chain position, specified as a positive integer.

  • When you set Vendor to "AMD" or "Altera":

    • If a single FPGA device is present in the JTAG scan chain, specifying chainPosition is optional. If you do not specify chainPosition in this case, the function uses the FPGA device position detected by the jtagchain object. For example, if the FPGA is at position 2 in the JTAG chain, the function uses a value of 2.

    • If multiple FPGA devices are present in the JTAG scan chain, you must specify chainPosition. If you do not specify chainPosition in this case, the function returns an error.

  • When you set Vendor to "Microchip", the function ignores chainPosition.

Example: JTAGChainPosition=2

Data Types: uint8 | uint16 | uint32 | uint64

Version History

Introduced in R2026b

See Also

|