Read/Write memory of Xilinx FPGA using Matlab and Vivado

34 Ansichten (letzte 30 Tage)
Christopher Saltonstall
Christopher Saltonstall am 4 Okt. 2023
Beantwortet: Bhanu Prakash am 29 Dez. 2023
I have a Xilinx Kintex 7 FPGA that is is connected via USB JTAG to my computer. I would like to read the memory of the FPGA.
Currently, I am using Vivado to connect to the FPGA, then program it with a .bin file and then read the memory (the Vivado command follows). I would like to perform this process using Matlab so that it can be automated and synced with other opperations.
I can currently program the FPGA with the bit stream using the following Matlab commands.
hdlsetuptoolpath('ToolName','Xilinx Vivado',...
'ToolPath','C:\Vivado\2021.1\Win\bin\vivado')
filProgramFPGA('Xilinx Vivado','/dir/mybitstream.bit',1);
Now I want to read the memory. The command that I use in Vivado is
readback_hw_device -bin_file C:/<path>/<filename>.bin
Is it possible to directly send this command to Vivado via Matlab to have it read the memory? Alternatively, is there another way to read memory using Matlab that does not use aximanager?
There are several articles showing how to read memory in Matlab that require the use of the aximanager. However, I did not write the bit stream. So, I can't add aximanager functionality.

Antworten (1)

Bhanu Prakash
Bhanu Prakash am 29 Dez. 2023
Hi Christopher,
Yes, it is possible to send a command to Xilinx Vivado via MATLAB. You can do that by using the commands mentioned below in the MATLAB command line:
  • Define the Xilinx Vivado installation path:
vivado_path = path_to_vivado.bat;
  • Create a TCL script locally having the required command/commands to run in Vivado.
  • Define the path to the TCL script:
tcl_path = path_to_TCL_script;
  • Construct the command string as follows:
cmd_str = sprintf('"%s" -mode batch -source "%s"', vivado_path, tcl_path);
  • Execute the command using the ‘system’ command in MATLAB:
[status, cmdout] = system(cmd_str);
If the command runs successfully, then the value of ‘status’ will be 0, meaning that the read operation is successful and the ‘cmdout’ gives you the output of the command line when Vivado executes the TCL script.
For more information on the ‘system’ function, kindly refer to the following documentation:
Hope this helps!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by