How to send data from an RFSoC device to the Host PC?

37 次查看(过去 30 天)
Dear all,
I am using AMD Zynq Ultrascale+ ZCU111 evaluation board for a simple receiver design.
Currently I record a signal from an ADC and stream it to the processing system using AXI4-Stream to Software. I can generate a bitstream using SoC Builder, run the external mode model and see the recorded signal.
The question is now how to write, e.g., 1ms of this data stream to a file on the host PC? (e.g. for the FPGA algorithm verification)
Thank you!
UPD: I received an answer from a MATLAB support, will update this question as soon as I try whether this works or not.

回答(1 个)

Abhishek
Abhishek 2025-9-1,8:23
编辑:Abhishek 2025-9-1,13:44
You can capture the "AXI4-Stream" data to a file on your host PC using Simulink's "External" Mode. Here's the direct method:
Step 1: Add and Configure the “Sink” Block:
  • In the Simulink model that contains the software task add a `To File` block. This can be found in the Simulink library under Simulink > Sinks. You need to connect the output of the `AXI4-Stream` to Software block to the input of this `To File` block.
  • Now, Double-click the `To File` block and set the `FileName` to the file name(for eg: `adc_data.mat`) and set the `SaveFormat` parameter to `Array`.
  • Provide a name for the variable that will be saved inside the MAT-file. The corresponding block parameter is `MatrixName`.
Step 2: Enable Data Archiving:
  • Open the model’s configuration by going to Modeling > Model Settings > Code Generation > External Mode.
  • Check the box for `Enable data archiving`. This is important for saving the file to the host PC
Step 3: Set Duration:
  • Set the model's `Stop time` to the desired capture length, for this case, it is 1ms at 100 MSPS, so set it as 100000 samples).
Step 4: Build, Run, and Capture:
  • Use the `SoC Builder` tool to generate the bitstream and software applications. From the Hardware tab in the Simulink toolstrip, click “Monitor & Tune”.
  • Simulink will now connect to the ZCU111 and run the model. The 'adc_data.mat' file containing the captured stream will appear in the MATLAB working directory.
You can refer to the following official documentations of MATLAB:
I hope this helps.
  3 个评论
Abhishek
Abhishek 2025-9-1,13:42
  1. So basically this is a two way process, first, in your main design model (before building), you connect your FPGA signal to the "AXI4-Stream IIO Write" block. This creates the hardware path to send data to the processor. Then, after you run the SoC Builder, you open the generated external mode model. In that model, a "From IIO Device" block will have appeared. That block is your signal, now available to the software. You connect that block to your Scopes or a "To File" block.
  2. My bad, I will fix the link.
Sergei
Sergei 2025-9-1,15:03
编辑:Sergei 2025-9-4,9:50
Thank you again @Abhishek! Clear now how to use the "To File" block. However there are two more questions, which I would be grateful if you helped me to deal with:
1) From this page https://ww2.mathworks.cn/help/soc/ref/axi4streamiiowritehost.html I can see that the "AXI4-Stream IIO write" block is intended for Host->Processor data transfer, which is opposite to what I do, so if the method you describe is the proper one, I am not sure about how to use this block. Are you familiar with any MATLAB examples that use this block?
2) I am using AXI4-Stream to Software as per "Streaming Data from Hardware to Software" example https://uk.mathworks.com/help/soc/ug/hwsw-stream.html instead of the "AXI4-Stream IIO Write" block, which creates an "IO Data Source" block serving as an input to the task in the external mode model instead of the "From IIO Device" block. Do you know whether it is possible to proceed with such a method?
I will also try to put the "To File" block in the current design connecting it to the task output in the external mode model to see whether this works and let you know.
Thank you once again! Looking forward to your answer.

请先登录,再进行评论。

产品


版本

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by