Ross Test: From MATLAB to C++ for Vitis HLS

Ross Test: From MATLAB to C++ for Vitis HLS

AMD Ross includes a skill called hls-matlab-to-cpp for converting MATLAB code into synthesizable C++ for HLS. The proposal is not limited to generating code: HLS skills can call flows that include compilation, synthesis, co-simulation, and implementation. Here, we’ll prepare the repository and a small MATLAB function for a compatible agent to process.

This example walks through the flow; it does not promise identical results on every run. AMD warns that results may vary across models, runs, and prompt formulations. That’s why you should review the code and reports produced by the tools before accepting a conversion.

flowchart TD
    A["Clone repository"] --> B["Install HLS skill"]
    B --> C["Prepare MATLAB function"]
    C --> D["Request conversion from the agent"]
    D --> E["Review C++ and HLS flow"]

Prepare the environment and repository

Ross combines skills and MCP servers: skills guide specific tasks, while servers connect the agent to compatible tools. For the HLS flow, AMD says the skills work directly with source code and project files using command-line tools such as v++ and vitis-run; they don’t need MCP.

Install the AMD tools you plan to use and a client compatible with MCP or skills. AMD mentions VS Code, Cursor, and Codex CLI, among others. The repository recommends cloning the project locally: replace the example path with the location you choose.

git clone https://github.com/Xilinx/ross-ai-assistant.git
cd ross-ai-assistant

To install skills using the interactive method, you need Node.js and npx. The following command installs only the conversion skill in the current workspace; the repository also offers a global installation, but you shouldn’t mix methods.

npx skills add "$PWD" --skill hls-matlab-to-cpp

Ross also offers the Vivado AI extension for VS Code, which includes the Vivado MCP server, skills, and documentation search configuration. If you choose that extension, don’t combine its installation with the standalone MCP server: the repository recommends choosing just one configuration for that component. The HLS skill, meanwhile, works with the code and project through command-line tools.

Create a small MATLAB input

We’ll start with a simple matrix operation: multiplying a square matrix by a vector. The function has explicit sizes and a clear loop, making it easier to request a conversion and compare the logic. Save the file as matvec.m.

function y = matvec(A, x)
% Multiplica una matriz cuadrada A por un vector x.
    n = size(A, 1);
    y = zeros(n, 1);

    for i = 1:n
        for j = 1:n
            y(i) = y(i) + A(i, j) * x(j);
        end
    end
end

The function doesn’t set the matrix sizes in the code. In your prompt to the agent, specify the size you want to evaluate and ask it to explain any changes needed to make the C++ version synthesizable. AMD identifies matlab-kernel-gemm as an example of the skill, but doesn’t specify a universal interface for providing files or a single invocation command here: that depends on the client you use.

Request the conversion and check it

Once the skill is installed, invoke it by name in your client and attach the file. The repository shows that skills are called by name, using the command format supported by the client; its example is /hls-optimize. You can ask for something specific, such as the following, adapting the syntax to your agent:

/hls-matlab-to-cpp
Convierte matvec.m a C++ sintetizable para Vitis HLS.
Usa matrices cuadradas de tamaño fijo para este ejemplo.
Explica las decisiones sobre tipos y dimensiones.
Incluye un test de referencia y señala qué archivos del proyecto HLS
necesitas para ejecutar compilación y síntesis.

The goal of the prompt is to get a proposal you can inspect, not to assume the agent has already run synthesis. Check that the function preserves the mathematical operation, that the dimensions match, and that the test compares the output with MATLAB. AMD describes hls-matlab-to-cpp as converting MATLAB sample code to C++ for HLS, and also cites examples involving edge detection, GEMM, and SVD.

If the agent returns a C++ function with fixed sizes, a minimal reference example could look like this. This is illustrative code for testing the operation in C++; it doesn’t replace the project or the configuration Vitis HLS requires for your target.

#include <cmath>
#include <iostream>

constexpr int N = 2;

void matvec(const float A[N][N], const float x[N], float y[N]) {
    for (int i = 0; i < N; ++i) {
        y[i] = 0.0f;
        for (int j = 0; j < N; ++j) {
            y[i] += A[i][j] * x[j];
        }
    }
}

int main() {
    const float A[N][N] = {{1.0f, 2.0f}, {3.0f, 4.0f}};
    const float x[N] = {5.0f, 6.0f};
    float y[N] = {};

    matvec(A, x, y);
    if (std::fabs(y[0] - 17.0f) > 0.001f) return 1;
    if (std::fabs(y[1] - 39.0f) > 0.001f) return 1;

    std::cout << y[0] << " " << y[1] << '\n';
    return 0;
}

This program can be compiled as standard C++ to verify the calculation on the CPU. For HLS, ask the agent to use the flow available in the project and report compilation, synthesis, and results separately. The main HLS skills can invoke hls-run-flow, which covers csim, csynth, cosim, and implementation; the repository says it can also be called directly.

Common mistakes when trying the skill

Don’t install the skills twice. The repository warns that if you install the complete plugin, you shouldn’t add the same skills again with npx skills add or copy them manually: each skill could be loaded twice. The plugin bundles all the skills, while the interactive installation lets you choose one.

It’s also easy to confuse analysis with an actual run. AMD distinguishes between consulting documentation, interacting with tool sessions, and automating flows using skills. Check the response to see whether the agent ran the flow or only proposed changes; request reports when available, and review both functional results and resource usage and performance.

Finally, Vitis HLS requires version 2025.2 or later, according to AMD’s page; Vivado compatibility is listed as all versions. AI results are nondeterministic, so a conversion that looks correct still needs to be validated in your project’s flow.

With the repository cloned, the skill installed, and a small example ready, you can now try the MATLAB→C++→HLS workflow. The next step is to adapt the case to a real design and check what synthesis and its reports show.

Sources: GitHub, AMD, AMD