參考網址

AMD Vitis_HLS 手冊

https://docs.amd.com/r/en-US/ug1399-vitis-hls

template

https://blog.csdn.net/weixin_42418557/article/details/118786586

constexpr (編譯階段執行程式)

https://viml.nchc.org.tw/4-const-keyword-in-cpp/

在 VSCODE 編輯 HLS

https://zhuanlan.zhihu.com/p/550568337

<aside> 💡

需要在 C++ 的 include path 加入 VITIS HLS headerfiles,建議直接把所有標頭檔資料夾複製出來,不然可能會污染改到原本的程式碼。

</aside>

加 include 資料夾進 include path

cd <my_folder>
cp -r <Vitis_HLS>/<version>/include .
// .vscode/task.json
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: clang++ 建置使用中檔案",
            "command": "/usr/bin/clang++",
            "args": [
                "-fcolor-diagnostics",
                "-fansi-escape-codes",
                "-g",
                "-std=c++14",
                "-I${workspaceFolder}/include",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "偵錯工具產生的工作。"
        }
    ],
    "version": "2.0.0"
}

問題

  1. 某些編譯器版本會有complex形態衝突,原始函式庫已有 std::complex 程式裡又宣告 std::complex

    error: reference to 'complex' is ambiguous
    
    note: candidate found by name lookup is 'std::complex'
       21 | template<typename _Tp> class complex;
    

    解法:在宣告 std::complex 前加 guard 在編譯階段自動檢查

    // Error : complex 衝突
    namespace std {
    template<typename _Tp> class complex;
    }
    
    // 正確 : 編譯階段檢查要不要再宣告
    #include <complex>
    #if !defined(_LIBCPP_COMPLEX) && !defined(_GLIBCXX_COMPLEX)
    namespace std {
    template<typename _Tp> class complex;
    }
    #endif
    

重要觀念

修飾詞 #pragma HLS

進階用法

變數類別