FC2カウンター FPGAの部屋 2021年12月
fc2ブログ

FPGAやCPLDの話題やFPGA用のツールの話題などです。 マニアックです。 日記も書きます。

FPGAの部屋

FPGAの部屋の有用と思われるコンテンツのまとめサイトを作りました。Xilinx ISEの初心者の方には、FPGAリテラシーおよびチュートリアルのページをお勧めいたします。

WSL2 の Ubuntu 18.04 に Vivado 2021.2 をインストール

WSL2 の Ubuntu 18.04 に OpenCV 3.4.9 をインストールしたので、WSL2 に Vivado 2021.2 をインストールした。

最初に WSL2 上の Ubuntu 20.04 に Vivado 2021.2 を状況を変えて 6 回インストールしたのだが、うまくインストールすることができなかった。
そこで、WSL2 上の Ubuntu 18.04 で Vivado 2021.2 をインストールしたところ 1 回でインストールすることができた。
WSL_Vivado20212_1_211230.png

WSL2 でインストールして WSLg で settings64.sh を実行して、Vivado 2021.2 を起動した。
WSL_Vivado20212_2_211230.png

Vivado 2021.2 が起動した。
WSL_Vivado20212_3_211230.png

Vitis HLS 2021.2 を起動して、”RBG 24 ビット・データ入出力対応のメディアン・フィルタを Vitis HLS 2021.1 で作成する1”の median_filter_axis_RBG プロジェクトを作成した。
WSL_Vivado20212_4_211231.png

C シミュレーションを行ったところ、エラーになってしまった。
WSL_Vivado20212_5_211231.png

今のところエラーが解消できない。。。
  1. 2021年12月31日 05:00 |
  2. WSL2
  3. | トラックバック:0
  4. | コメント:0

WSL2 の Ubuntu 18.04 に OpenCV 3.4.9 をインストールした

WSL2 に OpenCV をインストールしようとして、WSL2 の Ubuntu 20.04 にビルド・インストールしていたのだが、どうしてもインストールすることができなかった。 そこで、WSL2 の Ubuntu 18.04 に OpenCV 3.4.9 をインストールすることにした。

まずは環境を整える。
sudo apt install -y cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev tesseract-ocr libtesseract-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install -y libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libgtk2.0-dev libgtk-3-dev libpng-dev libjpeg-dev libopenexr-dev libtiff-dev libwebp-dev
sudo apt install -y python3-dev python3-numpy
sudo apt install -y python3-pip
sudo apt install -y python-dev python-numpy


opencv-3.4.9.zip を Chrome ブラウザでダウンロードする。
opencv-3.4.9.zip を解凍し、 opencv-3.4.9 ディレクトリを opencv ディレクトリとしてシンボリック・リンクする。
opencv_contrib-3.4.9.zip を Chrome ブラウザでダウンロードする。
opencv_contrib-3.4.9.zip を解凍し、opencv_contrib-3.4.9 ディレクトリを opencv_contrib ディレクトリとしてシンボリック・リンクする。
unzip -q opencv-3.4.9.zip
ln -s opencv-3.4.9 opencv
unzip -q opencv_contrib-3.4.9.zip
ln -s opencv_contrib-3.4.9 opencv_contrib

OpenCV4wsl_1_211229.png

opencv ディレクトリに cd して、 build ディレクトリを作成し、 build ディレクトリに cd し、 cmake を行った。
cd opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=/home/marsee/opencv_contrib/modules -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_VTK=ON -D INSTALL_C_EXAMPLES=ON -D PYTHON3_EXECUTABLE=/usr/bin/python3.6 -D PYTHON_INCLUDE_DIR=/usr/include/python3.6 -D PYTHON_INCLUDE_DIR2=/usr/include/x86_64-linux-gnu/python3.6m -D PYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.6m.so -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/include/python3.6m/numpy -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 -D WITH_OPENGL=ON -D WITH_CUDA=ON -D CUDA_ARCH_BIN="6.1" -D CUDA_ARCH_PTX="6.1" -DBUILD_opencv_cudacodec=OFF ..

OpenCV4wsl_2_211229.png

make した。
make -j6
OpenCV4wsl_3_211229.png
OpenCV4wsl_4_211229.png

sudo make install
OpenCV4wsl_5_211229.png

sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig

OpenCV4wsl_6_211229.png

example_tutorial_optical_flow を動かしてみよう。
cp -aur ../opencv/samples/data .
cd bin
./example_tutorial_optical_flow

OpenCV4wsl_7_211229.png

ウインドウが表示され、人が歩いているビデオが表示されて、その軌跡が表示されているようだった。
OpenCV4wsl_8_211229.jpg

インストールは成功した。
なお、WSL2 の Ubuntu 20.04 で OpenCV インストールを試してみたのだが、どうやっても” fatal error: Python.h: No such file or directory”を解消することができなかった。
OpenCV4wsl_9_211230.png

最後に、cmake のログの一部を貼っておく。

-- General configuration for OpenCV 3.4.9 =====================================
--   Version control:               unknown
--
--   Extra modules:
--     Location (extra):            /home/marsee/opencv_contrib/modules
--     Version control (extra):     unknown
--
--   Platform:
--     Timestamp:                   2021-12-29T11:50:57Z
--     Host:                        Linux 5.10.60.1-microsoft-standard-WSL2 x86_64
--     CMake:                       3.10.2
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               RELEASE
--
--   CPU/HW features:
--     Baseline:                    SSE SSE2 SSE3
--       requested:                 SSE3
--     Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
--       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
--       SSE4_1 (15 files):         + SSSE3 SSE4_1
--       SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--       AVX (6 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (28 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
--       AVX512_SKX (6 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
--
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++11:                       YES
--     C++ Compiler:                /usr/bin/c++  (ver 7.5.0)
--     C++ flags (Release):         -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):      -Wl,--gc-sections
--     Linker flags (Debug):        -Wl,--gc-sections
--     ccache:                      YES
--     Precompiled headers:         NO
--     Extra dependencies:          dl m pthread rt
--     3rdparty dependencies:
--
--   OpenCV modules:
--     To be built:                 aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dpm face features2d flann freetype fuzzy hfs highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot python3 reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv hdf java js matlab ovis python2 sfm viz
--     Applications:                tests perf_tests examples apps
--     Documentation:               NO
--     Non-free algorithms:         NO
--
--   GUI:
--     GTK+:                        YES (ver 3.22.30)
--       GThread :                  YES (ver 2.56.4)
--       GtkGlExt:                  NO
--     OpenGL support:              NO
--     VTK support:                 NO
--
--   Media I/O:
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
--     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
--     WEBP:                        /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x020e)
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.34)
--     TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.0.9)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 2.3.0)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--
--   Video I/O:
--     DC1394:                      NO
--     FFMPEG:                      YES
--       avcodec:                   YES (ver 57.107.100)
--       avformat:                  YES (ver 57.83.100)
--       avutil:                    YES (ver 55.78.100)
--       swscale:                   YES (ver 4.8.100)
--       avresample:                NO
--     GStreamer:                   YES
--       base:                      YES (ver 1.14.5)
--       video:                     YES (ver 1.14.5)
--       app:                       YES (ver 1.14.5)
--       riff:                      YES (ver 1.14.5)
--       pbutils:                   YES (ver 1.14.5)
--     libv4l/libv4l2:              NO
--     v4l/v4l2:                    linux/videodev2.h
--
--   Parallel framework:            pthreads
--
--   Trace:                         YES (with Intel ITT)
--
--   Other third-party libraries:
--     Intel IPP:                   2019.0.0 Gold [2019.0.0]
--            at:                   /home/marsee/opencv/build/3rdparty/ippicv/ippicv_lnx/icv
--     Intel IPP IW:                sources (2019.0.0)
--               at:                /home/marsee/opencv/build/3rdparty/ippicv/ippicv_lnx/iw
--     Lapack:                      NO
--     Eigen:                       NO
--     Custom HAL:                  NO
--     Protobuf:                    build (3.5.1)
--
--   NVIDIA CUDA:                   NO
--
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/marsee/opencv/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
--
--   Python 3:
--     Interpreter:                 /usr/bin/python3.6 (ver 3.6.9)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython3.6m.so (ver 3.6.9)
--     numpy:                       /usr/include/python3.6m/numpy (ver 1.13.3)
--     install path:                lib/python3.6/dist-packages/cv2/python-3.6
--
--   Python (for build):            /usr/bin/python2.7
--
--   Java:
--     ant:                         NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
--
--   Install to:                    /usr/local
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CUDA_ARCH_BIN
    CUDA_ARCH_PTX


-- Build files have been written to: /home/marsee/opencv/build

  1. 2021年12月30日 04:08 |
  2. WSL2
  3. | トラックバック:0
  4. | コメント:0

xilffs を使用してSDカードにデータを書き込む4(300 Hz で書き込み)

xilffs を使用してSDカードにデータを書き込む3(SD カードの書き込み時間間隔の最大値を確認)”の続き。

Vitis のベアメタル・アプリケーションで SDカードの書き込みを試すということで、前回は、Vitis プラットフォームを使用して、テキスト・ファイルを SD カードに書き込むアプリケーション・プロジェクトを作成し、アプリケーション・ソフトウェアの file_test.c を書いて、SD カードの書き込み性能を探ってみた。結果としては、最大時間間隔は約 2 ms ということが分かった。今回は、300 Hz でデータを書き込めるか?を確かめる。

新たに file_test2 アプリケーション・プロジェクトを作成した。
file_test2_system -> file_test2 -> src に file_test2.c を作成した。
xilffs_22_211229.png

file_test2.c を貼っておく。

// file_test2.c
// 2021/12/22 by marsee
// I wrote file_test2.c referring to xilffs_polled_example.c.
// Reference Links: https://github.com/Xilinx/embeddedsw/blob/master/lib/sw_services/xilffs/examples/xilffs_polled_example.c
// Measure the write time interval with XTime_GetTime()

#include "xparameters.h"    /* SDK generated parameters */
#include "xsdps.h"          /* SD device driver */
#include "ff.h"
#include "xil_cache.h"
#include "xplatform_info.h"
#include "string.h"
#include "stdio.h"
#include "xtime_l.h"

#define WAIT_MS 3.333 // 3.333 ms = 300 Hz

static FIL fil;     /* File object */
static FATFS fatfs;
/*
 * To test logical drive 0, FileName should be "0:/<File name>" or
 * "<file_name>". For logical drive 1, FileName should be "1:/<file_name>"
 */
static char FileName[32] = "Test.txt";
static char *SD_File;

int main(void)
{
    FRESULT Res;
    UINT NumBytesRead;
    UINT NumBytesWritten;
    BYTE work[FF_MAX_SS];
    XTime time;
    double for_time[100];
    double time_ms, time_ms_n;
    /*
     * To test logical drive 0, Path should be "0:/"
     * For logical drive 1, Path should be "1:/"
     */
    TCHAR *Path = "0:/";
    u8 out_str[80] __attribute__ ((aligned(32)));

    printf("SD write File System Test\n");

    sprintf(out_str, "36000000,140000000,54004,0,fc55,151,feec8\n");

    /*
     * Register volume work area, initialize device
     */
    Res = f_mount(&fatfs, Path, 0);

    if (Res != FR_OK) {
        return XST_FAILURE;
    }

    /*
     * Path - Path to logical driver, 0 - FDISK format.
     * 0 - Cluster size is automatically determined based on Vol size.
     */
    Res = f_mkfs(Path, FM_FAT32, 0, work, sizeof work);
    if (Res != FR_OK) {
        return XST_FAILURE;
    }

    /*
     * Open file with required permissions.
     * Here - Creating new file with read/write permissions. .
     * To open file with write permissions, file system should not
     * be in Read Only mode.
     */
    SD_File = (char *)FileName;

    Res = f_open(&fil, SD_File, FA_CREATE_ALWAYS | FA_WRITE | FA_READ);
    if (Res) {
        return XST_FAILURE;
    }

    /*
     * Pointer to beginning of file .
     */
    Res = f_lseek(&fil, 0);
    if (Res) {
        return XST_FAILURE;
    }

    XTime_GetTime(&time);
    time_ms = (double)((long long int)time)/333333.3435;

    /*
     * Write data to file.
     */
    for (int i=0; i<100; i++){
        int len_num = strlen(out_str);
        Res = f_write(&fil, (const void*)out_str, len_num,
                &NumBytesWritten);
        do {
            XTime_GetTime(&time);
            time_ms_n = (double)((long long int)time)/333333.3435;
            usleep(10); // 10us Wait
        } while((time_ms_n - time_ms) < WAIT_MS);
        time_ms = time_ms_n;

        for_time[i] = time_ms;
        if (Res) {
            return XST_FAILURE;
        }
    }

    for (int i=0; i<100; i++){
        if(i == 0)
            printf("%2d %lf\n", i, for_time[i]);
        else
            printf("%2d %lf, %lf\n", i, for_time[i], for_time[i]-for_time[i-1]);
    }

    /*
     * Close file.
     */
    Res = f_close(&fil);
    if (Res) {
        return XST_FAILURE;
    }

    printf("Done\n");

    return 0;

}


トンカチボタンをクリックして、ビルドを行った。
file_test2.elf ファイルが作成された。
xilffs_23_211229.png

Explorer で file_test_system を選択して、Run ボタンをクリックしてソフトウェアを起動した。
Tera Term に時間間隔が表示された。
最初が番号、次が XTime_GetTime(&time); で取得した時刻、最後が時間間隔だ。
xilffs_25_211229.png

SD write File System Test
 0 3754.031451
 1 3757.366112, 3.334662
 2 3760.700624, 3.334512
 3 3764.035142, 3.334518
 4 3767.369630, 3.334488
 5 3770.704151, 3.334521
 6 3774.038639, 3.334488
 7 3777.373151, 3.334512
 8 3780.707639, 3.334488
 9 3784.042160, 3.334521
10 3787.376647, 3.334488
11 3790.711159, 3.334512
12 3794.050537, 3.339378
13 3797.385565, 3.335028
14 3800.720050, 3.334485
15 3804.054568, 3.334518
16 3807.389059, 3.334491
17 3810.723595, 3.334536
18 3814.058086, 3.334491
19 3817.392607, 3.334521
20 3820.727091, 3.334485
21 3824.061612, 3.334521
22 3827.396103, 3.334491
23 3830.730624, 3.334521
24 3834.070485, 3.339861
25 3837.405012, 3.334527
26 3840.739503, 3.334491
27 3844.074024, 3.334521
28 3847.408512, 3.334488
29 3850.743042, 3.334530
30 3854.077529, 3.334488
31 3857.412047, 3.334518
32 3860.746538, 3.334491
33 3864.081071, 3.334533
34 3867.415556, 3.334485
35 3870.750074, 3.334518
36 3874.090523, 3.340449
37 3877.425050, 3.334527
38 3880.759541, 3.334491
39 3884.094062, 3.334521
40 3887.428546, 3.334485
41 3890.763067, 3.334521
42 3894.097558, 3.334491
43 3897.432079, 3.334521
44 3900.766567, 3.334488
45 3904.101100, 3.334533
46 3907.435585, 3.334485
47 3910.770103, 3.334518
48 3914.113009, 3.342906
49 3917.447539, 3.334530
50 3920.782023, 3.334485
51 3924.116538, 3.334515
52 3927.451026, 3.334488
53 3930.785556, 3.334530
54 3934.120044, 3.334488
55 3937.454565, 3.334521
56 3940.789050, 3.334485
57 3944.123571, 3.334521
58 3947.458062, 3.334491
59 3950.792583, 3.334521
60 3954.128240, 3.335658
61 3957.462794, 3.334554
62 3960.797309, 3.334515
63 3964.131821, 3.334512
64 3967.466312, 3.334491
65 3970.800848, 3.334536
66 3974.135339, 3.334491
67 3977.469857, 3.334518
68 3980.804348, 3.334491
69 3984.138877, 3.334530
70 3987.473365, 3.334488
71 3990.807886, 3.334521
72 3994.142374, 3.334488
73 3997.481614, 3.339240
74 4000.816117, 3.334503
75 4004.150638, 3.334521
76 4007.485126, 3.334488
77 4010.819656, 3.334530
78 4014.154144, 3.334488
79 4017.488661, 3.334518
80 4020.823152, 3.334491
81 4024.157685, 3.334533
82 4027.492170, 3.334485
83 4030.826688, 3.334518
84 4034.161179, 3.334491
85 4037.497716, 3.336537
86 4040.832201, 3.334485
87 4044.166713, 3.334512
88 4047.501204, 3.334491
89 4050.835730, 3.334527
90 4054.170221, 3.334491
91 4057.504742, 3.334521
92 4060.839230, 3.334488
93 4064.173760, 3.334530
94 4067.508248, 3.334488
95 4070.842766, 3.334518
96 4074.177257, 3.334491
97 4077.517997, 3.340740
98 4080.852500, 3.334503
99 4084.187014, 3.334515
Done


3.33 ms 間隔でデータを取得できている。

MicroSD カードを ZYBO Z7-10 から取り出して、Windows11にマウントしてみると、TEST.TXT ファイルが生成されていた。
xilffs_26_211229.png

TEST.TXT ファイルを開けてみたところ、データが書き込まれていた。成功だ。
xilffs_27_211229.png

ZYBO Z7-10 ボードのベアメタル・アプリケーションで、xilffs ライブラリを使用し、ポーリングで 300 Hz で MicroSD カードにデータを書き込むことができた。
  1. 2021年12月29日 04:33 |
  2. Vitis
  3. | トラックバック:0
  4. | コメント:0

xilffs を使用してSDカードにデータを書き込む3(SD カードの書き込み時間間隔の最大値を確認)

xilffs を使用してSDカードにデータを書き込む2”の続き。

Vitis のベアメタル・アプリケーションで SDカードの書き込みを試すということで、前回は、ハードウェアをエクスポートし、Vitis を起動して、プラットフォームとアプリケーション・プロジェクトを作成し、xilffs_polled_example.c を用意して、コンパイルした。更に、ZYBO Z7-10 に MicroSD カードを入れて、アプリケーション・ソフトウェアを実行した。今回は、前回作成した Vitis プラットフォームを使用して、テキスト・ファイルを SD カードに書き込むアプリケーション・プロジェクトを作成し、アプリケーション・ソフトウェアの file_test.c を書いて、SD カードの書き込み性能を探ってみた。

Vitis プラットフォームを使用して、テキスト・ファイルを SD カードに書き込むアプリケーション・プロジェクト file_test を作成する。

file_test_system -> file_test -> src に file_test.c を作成した。
file_test.c は xilffs_polled_example.c を引用して作成した。
xilffs_16_211228.png

file_test.c は”36000000,140000000,54004,0,fc55,151,feec8”という、それらしいデータを書き込む(これで何のロガーに使うか分かってしまったかもしれないけど。。。)
そして、

XTime_GetTime(&time);

で書き込み時間間隔を測定するソフトウェアとなっている。
file_test.c を示す。

// file_test.c
// 2021/12/22 by marsee
// I wrote file_test2.c referring to xilffs_polled_example.c.
//@Reference Links: https://github.com/Xilinx/embeddedsw/blob/master/lib/sw_services/xilffs/examples/xilffs_polled_example.c
// Measure the write time interval with XTime_GetTime()

#include "xparameters.h"    /* SDK generated parameters */
#include "xsdps.h"          /* SD device driver */
#include "ff.h"
#include "xil_cache.h"
#include "xplatform_info.h"
#include "string.h"
#include "stdio.h"
#include "xtime_l.h"

static FIL fil;     /* File object */
static FATFS fatfs;
/*
 * To test logical drive 0, FileName should be "0:/<File name>" or
 * "<file_name>". For logical drive 1, FileName should be "1:/<file_name>"
 */
static char FileName[32] = "Test.txt";
static char *SD_File;

int main(void)
{
    FRESULT Res;
    UINT NumBytesRead;
    UINT NumBytesWritten;
    BYTE work[FF_MAX_SS];
    XTime time;
    double for_time[100];
    /*
     * To test logical drive 0, Path should be "0:/"
     * For logical drive 1, Path should be "1:/"
     */
    TCHAR *Path = "0:/";
    u8 out_str[80] __attribute__ ((aligned(32)));

    printf("SD write File System Test\n");

    sprintf(out_str, "36000000,140000000,54004,0,fc55,151,feec8\n");

    /*
     * Register volume work area, initialize device
     */
    Res = f_mount(&fatfs, Path, 0);

    if (Res != FR_OK) {
        return XST_FAILURE;
    }

    /*
     * Path - Path to logical driver, 0 - FDISK format.
     * 0 - Cluster size is automatically determined based on Vol size.
     */
    Res = f_mkfs(Path, FM_FAT32, 0, work, sizeof work);
    if (Res != FR_OK) {
        return XST_FAILURE;
    }

    /*
     * Open file with required permissions.
     * Here - Creating new file with read/write permissions. .
     * To open file with write permissions, file system should not
     * be in Read Only mode.
     */
    SD_File = (char *)FileName;

    Res = f_open(&fil, SD_File, FA_CREATE_ALWAYS | FA_WRITE | FA_READ);
    if (Res) {
        return XST_FAILURE;
    }

    /*
     * Pointer to beginning of file .
     */
    Res = f_lseek(&fil, 0);
    if (Res) {
        return XST_FAILURE;
    }

    /*
     * Write data to file.
     */
    for (int i=0; i<100; i++){
        int len_num = strlen(out_str);
        Res = f_write(&fil, (const void*)out_str, len_num,
                &NumBytesWritten);
        XTime_GetTime(&time);
        for_time[i] = (double)((long long int)time)/333333.3435; // ms
        if (Res) {
            return XST_FAILURE;
        }
    }

    for (int i=0; i<100; i++){
        if(i == 0)
            printf("%2d %lf\n", i, for_time[i]);
        else
            printf("%2d %lf, %lf\n", i, for_time[i], for_time[i]-for_time[i-1]);
    }

    /*
     * Close file.
     */
    Res = f_close(&fil);
    if (Res) {
        return XST_FAILURE;
    }

    printf("Done\n");

    return 0;

}


トンカチボタンをクリックして、ビルドを行った。
file_test.elf ファイルが作成された。
xilffs_20_211228.png

Explorer で file_test_system を選択して、Run ボタンをクリックしてソフトウェアを起動した。
Tera Term に時刻と時間間隔が表示された。単位は ms だ。
xilffs_17_211228.png

ログを示す。

SD write File System Test
0 3045.713658
1 3045.714837, 0.001179
2 3045.715389, 0.000552
3 3045.715980, 0.000591
4 3045.716532, 0.000552
5 3045.717132, 0.000600
6 3045.717684, 0.000552
7 3045.718275, 0.000591
8 3045.718827, 0.000552
9 3045.719427, 0.000600
10 3045.719979, 0.000552
11 3045.720570, 0.000591
12 3046.690773, 0.970203
13 3046.691418, 0.000645
14 3046.692024, 0.000606
15 3046.692633, 0.000609
16 3046.693227, 0.000594
17 3046.693836, 0.000609
18 3046.694424, 0.000588
19 3046.695027, 0.000603
20 3046.695621, 0.000594
21 3046.696230, 0.000609
22 3046.696818, 0.000588
23 3046.697421, 0.000603
24 3048.589899, 1.892478
25 3048.590511, 0.000612
26 3048.591084, 0.000573
27 3048.591669, 0.000585
28 3048.592251, 0.000582
29 3048.592848, 0.000597
30 3048.593430, 0.000582
31 3048.594018, 0.000588
32 3048.594600, 0.000582
33 3048.595197, 0.000597
34 3048.595779, 0.000582
35 3048.596367, 0.000588
36 3049.652643, 1.056276
37 3049.653270, 0.000627
38 3049.653858, 0.000588
39 3049.654470, 0.000612
40 3049.655064, 0.000594
41 3049.655673, 0.000609
42 3049.656261, 0.000588
43 3049.656864, 0.000603
44 3049.657458, 0.000594
45 3049.658067, 0.000609
46 3049.658655, 0.000588
47 3049.659258, 0.000603
48 3051.551673, 1.892415
49 3051.552291, 0.000618
50 3051.552873, 0.000582
51 3051.553461, 0.000588
52 3051.554043, 0.000582
53 3051.554640, 0.000597
54 3051.555222, 0.000582
55 3051.555810, 0.000588
56 3051.556392, 0.000582
57 3051.556989, 0.000597
58 3051.557571, 0.000582
59 3051.558159, 0.000588
60 3052.645830, 1.087671
61 3052.646502, 0.000672
62 3052.647084, 0.000582
63 3052.647663, 0.000579
64 3052.648227, 0.000564
65 3052.648806, 0.000579
66 3052.649370, 0.000564
67 3052.649949, 0.000579
68 3052.650513, 0.000564
69 3052.651092, 0.000579
70 3052.651656, 0.000564
71 3052.652235, 0.000579
72 3052.652799, 0.000564
73 3054.500076, 1.847277
74 3054.500667, 0.000591
75 3054.501258, 0.000591
76 3054.501840, 0.000582
77 3054.502437, 0.000597
78 3054.503019, 0.000582
79 3054.503607, 0.000588
80 3054.504189, 0.000582
81 3054.504786, 0.000597
82 3054.505368, 0.000582
83 3054.505956, 0.000588
84 3054.506538, 0.000582
85 3055.595505, 1.088967
86 3055.596090, 0.000585
87 3055.596693, 0.000603
88 3055.597287, 0.000594
89 3055.597899, 0.000612
90 3055.598493, 0.000594
91 3055.599096, 0.000603
92 3055.599690, 0.000594
93 3055.600299, 0.000609
94 3055.600887, 0.000588
95 3055.601490, 0.000603
96 3055.602084, 0.000594
97 3057.558540, 1.956456
98 3057.559128, 0.000588
99 3057.559719, 0.000591
Done


時間間隔で最大のものは 97 番目の 1.956456 ms のようだ。最大約 2 ms かかっている。

MicroSD カードを ZYBO Z7-10 から取り出して、Windows11にマウントしてみると、TEST.TXT ファイルが生成されていた。
xilffs_18_211228.png

TEST.TXT ファイルを開けてみたところ、データが書き込まれていた。成功だ。
xilffs_21_211228.png

このデータを MicroSD カードに書いたときに、最大時間間隔は約 2 ms ということが分かった。これならば 3.333 ms 間隔(300 Hz)で書いても大丈夫だろう。。。

使用している MicroSD カードは Transcend の 8 GB Class 10 です。
  1. 2021年12月28日 04:40 |
  2. Vitis
  3. | トラックバック:0
  4. | コメント:0

xilffs を使用してSDカードにデータを書き込む2

xilffs を使用してSDカードにデータを書き込む1”の続き。

Vitis のベアメタル・アプリケーションで SDカードの書き込みを試すということで、前回は、Vivado 2021.2 で ZYBO Z7-10 ボード用の xilffs_test プロジェクトを作成し、ブロックデザインを作成し、論理合成、インプリメンテーション、ビットストリームの生成を行った。今回は、ハードウェアをエクスポートし、Vitis を起動して、プラットフォームとアプリケーション・プロジェクトを作成し、xilffs_polled_example.c を用意して、コンパイルした。更に、ZYBO Z7-10 に MicroSD カードを入れて、アプリケーション・ソフトウェアを実行した。

Vivado 2021.2 で ZYBO Z7-10 ボード用の xilffs_test プロジェクトでハードウェアをエクスポートし、xilffs_test_wrapper.xsa ファイルを作成した。
xilffs_5_211227.png

Vitis を起動して、xilffs_test_wrapper プラットフォームと xilffs_test アプリケーション・プロジェクトを作成した。
xilffs_test_wrapper プラットフォームの platform.spr を開いて xilffs_test_wrapper -> ps7_cortexa9_0 -> zynq_fsbl -> Board Support Package をクリックして、Board Support Package の Modify BSP Settings... ボタンをクリックする。
xilffs_6_211227.png

Board Support Package Settings ダイアログが表示された。
xilffs にチェックが入っているのを確認した。
xilffs_7_211227.png

xilffs_test_wrapper プラットフォームの platform.spr を開いて xilffs_test_wrapper -> ps7_cortexa9_0 -> standalone_ps7_cortexa0_C -> Board Support Package をクリックして、Board Support Package の Modify BSP Settings... ボタンをクリックする。
xilffs_8_211227.png

Board Support Package Settings ダイアログが表示された。
xilffs にチェックを入れた。
xilffs_9_211227.png

xilffs_test_system -> xilffs_test -> src -> xilffs_polled_example.c を新規作成し、Xilinx の Github の xilffs のページにサンプルの xilffs_polled_example.c の内容をコピー&ペーストした。
xilffs_10_211227.png

トンカチボタンをクリックして、ビルドを行った。
xilffs_test.elf が生成された。
xilffs_11_211227.png

ZYBO Z7-10 に MicroSD カードを入れて、電源ON した。
Tera Termを起動した。
Vitis の Explorer で xilffs_test_system を選択して、Run ボタンをクリックした。
xilffs_12_211227.png

Tera Termに”SD Polled File System Example Test”が表示され、少し経過したら、”Successfully ran SD Polled File System Example Test”が表示された。
xilffs_13_211227.png

MicroSD カードを ZYBO Z7-10 から取り出して、パソコンで見たところ、TEST.bin ファイルが生成されていた。
xilffs_14_211227.png

TEST.bin ファイルを VScode の HEX editor で見た。
最初の値は 0x07 で 0xFF まで行ったら 0x00 に戻っている。その後 0x00 から 0xFF までを繰り返している。
xilffs_15_211227.png
  1. 2021年12月27日 05:03 |
  2. Vitis
  3. | トラックバック:0
  4. | コメント:0

xilffs を使用してSDカードにデータを書き込む1

今度、データを SD カードに記録する必要が出てきたので、Vitis のベアメタル・アプリケーションで SDカードに書き込む方法を探っていた。

探してみたところ、FPGAプログラミング大全 Xilinx編 第2版の”コラムI SDカードの読み出しを試す”に SD カードの読み出し方法が乗っていた。xilffs ライブラリを使うようだ。

Xilinx Wiki の xilffs のページを示す。

Xilinx の Github の xilffs のページ Xilinx/embeddedsw/lib/sw_services/xilffs/

Xilinx の Github の xilffs のページにサンプルの xilffs_polled_example.c があった。適当なブロックデザインを作成してこれを試してみよう。

Vivado 2021.2 で ZYBO Z7-10 ボード用の xilffs_test プロジェクトを作成した。
適当に Zynq Processing System7 を実装して、 ld0 に AXI_GPIO で接続しただけだ。
xilffs_1_211226.png

xilffs_test ブロックデザインを作成した。
xilffs_2_211226.png

Address Editor 画面を示す。
xilffs_3_211226.png

Create HDL Warpper でトップの HDL の xilffs_test_wrapper.v を作成した。

xilffs_test.xdc の制約ファイルを作成した。

set_property IOSTANDARD LVCMOS33 [get_ports {ld0[0]}]
set_property PACKAGE_PIN M14 [get_ports {ld0[0]}]


論理合成、インプリメンテーション、ビットストリームの生成を行って、成功した。
Project Summary を示す。
xilffs_4_211226.png
  1. 2021年12月26日 04:40 |
  2. Vitis
  3. | トラックバック:0
  4. | コメント:0

Microchip 社の高位合成ツール SmartHLS の fpga-hls-examples をやってみる3(AXI4 Master)

Microchip 社の高位合成ツール SmartHLS の fpga-hls-examples をやってみる2(AXI4 Slave その 2)”の続き。

MicrochipTech/fpga-hls-examples の axi_initiator をやってみよう。
fpga-hls-examples/axi_initiator/axi_initiator.cpp がソースコードとテストベンチだ。

SmartHLS 2021.2 の axi_initiator プロジェクトを示す。
SmartHLS_106_211225.png

Compile Software アイコンをクリックしてソフトウェアとしてコンパイルする。
Run Software アイコンをクリックして実行した。
SmartHLS_107_211225.png

PASS! が表示された。

Compile Software to Hardware アイコンをクリックして、ソフトウェアからハードウェアへのコンパイルを行った。
SmartHLS_108_211225.png

ログを示す。

// ----------------------------------------------------------------------------
// Smart High-Level Synthesis Tool Version 2021.2
// Copyright (c) 2015-2021 Microchip Technology Inc. All Rights Reserved.
// For support, please contact: smarthls@microchip.com
// Date: Sat Dec 25 04:12:11 2021
// ----------------------------------------------------------------------------

SmartHLS Summary Report for Project: axi_initiator.

Table of Contents
  1. RTL Interface
  2. Scheduling Result
  3. Pipeline Result
  4. Memory Usage
  5. Accelerator Information
  6. Resource Binding with Adaptive Latency


====== 1. RTL Interface ======

+-------------------------------------------------------------------------------------------+
| RTL Interface Generated by SmartHLS                                                       |
+-----------+----------------+------------------------+------------------+------------------+
| C++ Name  | Interface Type | Signal Name            | Signal Bit-width | Signal Direction |
+-----------+----------------+------------------------+------------------+------------------+
|           | Control        | clk                    | 1                | input            |
|           |                | finish                 | 1                | output           |
|           |                | ready                  | 1                | output           |
|           |                | reset                  | 1                | input            |
|           |                | start                  | 1                | input            |
+-----------+----------------+------------------------+------------------+------------------+
| initiator | AXI Master     | initiator_ar_addr      | 32               | output           |
|           |                | initiator_ar_burst     | 2                | output           |
|           |                | initiator_ar_len       | 8                | output           |
|           |                | initiator_ar_ready     | 1                | input            |
|           |                | initiator_ar_size      | 3                | output           |
|           |                | initiator_ar_valid     | 1                | output           |
|           |                | initiator_aw_addr      | 32               | output           |
|           |                | initiator_aw_burst     | 2                | output           |
|           |                | initiator_aw_len       | 8                | output           |
|           |                | initiator_aw_ready     | 1                | input            |
|           |                | initiator_aw_size      | 3                | output           |
|           |                | initiator_aw_valid     | 1                | output           |
|           |                | initiator_b_resp       | 2                | input            |
|           |                | initiator_b_resp_ready | 1                | output           |
|           |                | initiator_b_resp_valid | 1                | input            |
|           |                | initiator_r_data       | 64               | input            |
|           |                | initiator_r_last       | 1                | input            |
|           |                | initiator_r_ready      | 1                | output           |
|           |                | initiator_r_resp       | 2                | input            |
|           |                | initiator_r_valid      | 1                | input            |
|           |                | initiator_w_data       | 64               | output           |
|           |                | initiator_w_last       | 1                | output           |
|           |                | initiator_w_ready      | 1                | input            |
|           |                | initiator_w_strb       | 8                | output           |
|           |                | initiator_w_valid      | 1                | output           |
+-----------+----------------+------------------------+------------------+------------------+

The Verilog top-level module ports that are not listed in the above table are unused. Please tie the unused input ports to 0.

====== 2. Scheduling Result ======

Please use SmartHLS's schedule viewer to examine the schedule.

Basic Block Latencies:

+-----------------------------------------------------+
| Function: simple_initiator (non-pipelined function) |
+---------------------------+-------------------------+
| Basic Block               | Cycle Latency           |
+---------------------------+-------------------------+
| %for.body.lr.ph           | 1                       |
| %for.body                 | 2                       |
| %for.end                  | 1                       |
+---------------------------+-------------------------+

====== 3. Pipeline Result ======

+---------------------------------+------------------+-------------+------------------------------+---------------------+-----------------+-----------------+---------+
| Label                           | Function         | Basic Block | Location in Source Code      | Initiation Interval | Pipeline Length | Iteration Count | Latency |
+---------------------------------+------------------+-------------+------------------------------+---------------------+-----------------+-----------------+---------+
| for_loop_axi_initiator_cpp_13_5 | simple_initiator | %for.body   | line 13 of axi_initiator.cpp | 1                   | 2               | 256             | 257     |
+---------------------------------+------------------+-------------+------------------------------+---------------------+-----------------+-----------------+---------+

====== 4. Memory Usage ======

+----------------+
| Local Memories |
+----------------+
| None           |
+----------------+

+-------------------------+
| Local Constant Memories |
+-------------------------+
| None                    |
+-------------------------+

+-----------------------+
| Shared Local Memories |
+-----------------------+
| None                  |
+-----------------------+

+------------------+
| Aliased Memories |
+------------------+
| None             |
+------------------+

+-----------------------------------------------------------------------------------------------+
| I/O Memories                                                                                  |
+--------------------+-----------------------+---------------+-------------+------------+-------+
| Name               | Accessing Function(s) | Type          | Size [Bits] | Data Width | Depth |
+--------------------+-----------------------+---------------+-------------+------------+-------+
| initiator_ar_addr  | simple_initiator      | FIFO (LUTRAM) | 0           | 32         | 0     |
| initiator_ar_burst | simple_initiator      | FIFO (LUTRAM) | 0           | 2          | 0     |
| initiator_ar_size  | simple_initiator      | FIFO (LUTRAM) | 0           | 3          | 0     |
| initiator_ar_len   | simple_initiator      | FIFO (LUTRAM) | 0           | 8          | 0     |
| initiator_r_data   | simple_initiator      | FIFO (LUTRAM) | 0           | 64         | 0     |
| initiator_r_resp   | simple_initiator      | FIFO (LUTRAM) | 0           | 2          | 0     |
| initiator_r_last   | simple_initiator      | FIFO (LUTRAM) | 0           | 1          | 0     |
| initiator_aw_addr  | simple_initiator      | FIFO (LUTRAM) | 0           | 32         | 0     |
| initiator_aw_burst | simple_initiator      | FIFO (LUTRAM) | 0           | 2          | 0     |
| initiator_aw_size  | simple_initiator      | FIFO (LUTRAM) | 0           | 3          | 0     |
| initiator_aw_len   | simple_initiator      | FIFO (LUTRAM) | 0           | 8          | 0     |
| initiator_w_data   | simple_initiator      | FIFO (LUTRAM) | 0           | 64         | 0     |
| initiator_w_strb   | simple_initiator      | FIFO (LUTRAM) | 0           | 8          | 0     |
| initiator_w_last   | simple_initiator      | FIFO (LUTRAM) | 0           | 1          | 0     |
| initiator_b_resp   | simple_initiator      | FIFO (LUTRAM) | 0           | 2          | 0     |
+--------------------+-----------------------+---------------+-------------+------------+-------+


====== 5. Accelerator Information ======

No accelerator function is generated.

====== 6. Resource Binding with Adaptive Latency ======

Binding to resource with adaptive latency is disabled.
You can enable this feature by setting config parameter 'ADAPTIVE_LATENCY_BINDING' to 1.


SW/HW Co-Simulation icon をクリックして、SW/HW 協調シミュレーションを行った。
SmartHLS_109_211225.png

クロック・レイテンシは 261 クロックだった。

SmartHLS メニューから SW/HW Co-Simulation with Waveforms を選択した。
全体波形を示す。
SmartHLS_110_211225.png

最初の部分の拡大波形を示す。
SmartHLS_111_211225.png

気になるのは、カーソル位置で initiator_ar_valid が 1 と認識されるのだが、その前に initiator_r_valid が 1 になっていることだ。
アドレスが来る前にデータを Read できるのはおかしいんじゃないのかな?
まあ、最も、イニシエータ側でなくスレーブ側が出しているので、SmartHLS で作ったイニシエータのバグではないようだ。

Synthesize Hardware to FPGA (RTLsynthesis, place and route, for resource timing and results)(Ctrl+shift+V) アイコンをクリックする。
SmartHLS_112_211225.png

ログを示す。

==================================================================
=====  Summary Report for RTL Simulation and FPGA Synthesis  =====
==================================================================

Project name: axi_initiator
FPGA Vendor: MICROSEMI
Device Family: PolarFire
Device: MPF300TS-1FCG1152I

Table of Contents
  1. Simulation Cycle Latency
  2. Timing Result
  3. Resource Usage


====== 1. Simulation Cycle Latency ======

Number of calls:           1
Cycle latency:         261
SW/HW co-simulation: PASS

====== 2. Timing Result ======

+--------------+---------------+-------------+-------------+----------+-------------+
| Clock Domain | Target Period | Target Fmax | Worst Slack | Period   | Fmax        |
+--------------+---------------+-------------+-------------+----------+-------------+
| clk          | 10.000 ns     | 100.000 MHz | 7.647 ns    | 2.353 ns | 424.989 MHz |
+--------------+---------------+-------------+-------------+----------+-------------+

The reported Fmax is for the HLS core in isolation (from Libero's post-place-and-route timing analysis).
When the HLS core is integrated into a larger system, the system Fmax may be lower depending on the critical path of the system.

====== 3. Resource Usage ======

+--------------------------+---------------+--------+------------+
| Resource Type            | Used          | Total  | Percentage |
+--------------------------+---------------+--------+------------+
| Fabric + Interface 4LUT* | 428 + 0 = 428 | 299544 | 0.14       |
| Fabric + Interface DFF*  | 206 + 0 = 206 | 299544 | 0.07       |
| I/O Register             | 0             | 1536   | 0.00       |
| User I/O                 | 0             | 512    | 0.00       |
| uSRAM                    | 0             | 2772   | 0.00       |
| LSRAM                    | 0             | 952    | 0.00       |
| Math                     | 0             | 924    | 0.00       |
+--------------------------+---------------+--------+------------+

* Interface 4LUTs and DFFs are occupied due to the uses of LSRAM, Math, and uSRAM.
  Number of interface 4LUTs/DFFs = (36 * #.LSRAM) + (36 * #.Math) + (12 * #.uSRAM) = (36 * 0) + (36 * 0) + (12 * 0) = 0.


Fmax は 424.989 MHz だった。
  1. 2021年12月25日 04:55 |
  2. SmartHLS
  3. | トラックバック:0
  4. | コメント:0

SmartHLS の AXI4 Master インターフェース(C++ Library for Custom AXI Master Interface)

Microchip 社の高位合成ツール SmartHLS の AXI4 Master インターフェース生成方法が”Users Guide SmartHLS 2021.3 Documentation の Top-Level RTL Interface の C++ Library for Custom AXI Master Interface”に載っている。

まずは、SmartHLS のライブラリを使用して AXI4 Master インターフェースを作成するためにヘッダファイルをインクルードするそうだ。

#include <hls/axi_interface.hpp>


その後、(”Users Guide SmartHLS 2021.3 Documentation の Top-Level RTL Interface の C++ Library for Custom AXI Master Interface”の翻訳を引用する)

1. AxiInterface クラスのインスタンスを作成し、テンプレートパラメータを使用してアドレス幅、データ幅、およびwstrb幅を指定します。

2. トップレベル関数を参照して、作成したインスタンスを渡します。例えば、
void MyTop(AxiInterface, /* DATA: */ ap_uint<64>, /* WSTRB: */ ap_uint<8>> &master);

3. ヘッダーで定義されているユーティリティ関数(API)を使用して、AXIマスターインターフェイスを制御します。


fpga-hls-examples/axi_initiator/axi_initiator.cpp”を参照るすると、3. の API は以下に示す関数のようだ。

// Request to read data in burst.
axi_m_read_req<ap_uint<32>, ap_uint<64>, ap_uint<8>>(initiator, r_addr, AXIM_MAX_BURST_LEN);

// Request to write data in burst.
axi_m_write_req<ap_uint<32>, ap_uint<64>, ap_uint<8>>(initiator, w_addr, AXIM_MAX_BURST_LEN);

// Write back the data we read + 1.
ap_uint<64> data = axi_m_read_data<ap_uint<32>, ap_uint<64>>(initiator);
axi_m_write_data<ap_uint<32>, ap_uint<64>, ap_uint<8>>(initiator, ap_uint<64>(data + 1), ap_uint<8>(0xFF), is_last);

// After the last write, read the response code.
ap_uint<2> bresp = axi_m_write_resp(initiator);


Users Guide SmartHLS 2021.3 Documentation の Top-Level RTL Interface の C++ Library for Custom AXI Master Interface”の翻訳の一部を引用する。

AXI4スレーブインターフェイスと同じように、このAXI4マスターインターフェイスライブラリは、バーストの追加サポートを備えたAXI4-liteプロトコルのみをサポートします。

SW / HW協調シミュレーションはAXIマスターでサポートされていますが、カーネルが呼び出される前に、ソフトウェアでAXIマスターに対するAXIスレーブの応答をモデル化する必要があります。


そうなのか。。。
  1. 2021年12月24日 04:55 |
  2. SmartHLS
  3. | トラックバック:0
  4. | コメント:0

Microchip 社の高位合成ツール SmartHLS の fpga-hls-examples をやってみる2(AXI4 Slave その 2)

Microchip 社の高位合成ツール SmartHLS の fpga-hls-examples をやってみる1(AXI4 Slave その 1)”の続き。

MicrochipTech/fpga-hls-examples の axi_target をやってみるということで、前回は、ワークスペースに MicrochipTech/fpga-hls-examples をインポートして axi_target を見た。今回は、C シミュレーション、ソフトウェアからハードウェアへのコンパイル、SW/HW 協調シミュレーション、ハードウェアから FPGA への合成を行う。

C シミュレーションからやってみよう。
Compile Software アイコンをクリックしてソフトウェアとしてコンパイルする。
Run Software アイコンをクリックして実行した。
SmartHLS_100_211222.png

ログを示す。

sum_result = 101010366
xor_result = fefefeea
or_result = ffffffff
PASS


Compile Software to Hardware アイコンをクリックして、ソフトウェアからハードウェアへのコンパイルを行った。
SmartHLS_101_211222.png

ログを示す。

// ----------------------------------------------------------------------------
// Smart High-Level Synthesis Tool Version 2021.2
// Copyright (c) 2015-2021 Microchip Technology Inc. All Rights Reserved.
// For support, please contact: smarthls@microchip.com
// Date: Wed Dec 22 20:32:01 2021
// ----------------------------------------------------------------------------

SmartHLS Summary Report for Project: axi_target.

Table of Contents
  1. RTL Interface
  2. Scheduling Result
  3. Pipeline Result
  4. Memory Usage
  5. Accelerator Information
  6. Resource Binding with Adaptive Latency


====== 1. RTL Interface ======

+-------------------------------------------------------------------------------------------+
| RTL Interface Generated by SmartHLS                                                       |
+---------------+----------------+--------------------+------------------+------------------+
| C++ Name      | Interface Type | Signal Name        | Signal Bit-width | Signal Direction |
+---------------+----------------+--------------------+------------------+------------------+
|               | Control        | clk                | 1                | input            |
|               |                | finish             | 1                | output           |
|               |                | ready              | 1                | output           |
|               |                | reset              | 1                | input            |
|               |                | start              | 1                | input            |
+---------------+----------------+--------------------+------------------+------------------+
| target_memory | AXI Slave      | axi_s_ar_addr      | 32               | input            |
|               |                | axi_s_ar_burst     | 2                | input            |
|               |                | axi_s_ar_len       | 8                | input            |
|               |                | axi_s_ar_ready     | 1                | output           |
|               |                | axi_s_ar_size      | 3                | input            |
|               |                | axi_s_ar_valid     | 1                | input            |
|               |                | axi_s_aw_addr      | 32               | input            |
|               |                | axi_s_aw_burst     | 2                | input            |
|               |                | axi_s_aw_len       | 8                | input            |
|               |                | axi_s_aw_ready     | 1                | output           |
|               |                | axi_s_aw_size      | 3                | input            |
|               |                | axi_s_aw_valid     | 1                | input            |
|               |                | axi_s_b_resp       | 2                | output           |
|               |                | axi_s_b_resp_ready | 1                | input            |
|               |                | axi_s_b_resp_valid | 1                | output           |
|               |                | axi_s_r_data       | 64               | output           |
|               |                | axi_s_r_last       | 1                | output           |
|               |                | axi_s_r_ready      | 1                | input            |
|               |                | axi_s_r_resp       | 2                | output           |
|               |                | axi_s_r_valid      | 1                | output           |
|               |                | axi_s_w_data       | 64               | input            |
|               |                | axi_s_w_last       | 1                | input            |
|               |                | axi_s_w_ready      | 1                | output           |
|               |                | axi_s_w_strb       | 8                | input            |
|               |                | axi_s_w_valid      | 1                | input            |
+---------------+----------------+--------------------+------------------+------------------+

The Verilog top-level module ports that are not listed in the above table are unused. Please tie the unused input ports to 0.

====== 2. Scheduling Result ======

Please use SmartHLS's schedule viewer to examine the schedule.

Basic Block Latencies:

+------------------------------------------------+
| Function: calc_kernel (non-pipelined function) |
+-----------------------+------------------------+
| Basic Block           | Cycle Latency          |
+-----------------------+------------------------+
| %entry                | 7                      |
+-----------------------+------------------------+

+-----------------------------------------------------+
| Function: calc_kernel_orig (non-pipelined function) |
+-------------------------+---------------------------+
| Basic Block             | Cycle Latency             |
+-------------------------+---------------------------+
| %entry                  | 5                         |
+-------------------------+---------------------------+

+----------------------------------------------------+
| Function: target_memory_write (pipelined function) |
+--------------------------+-------------------------+
| Basic Block              | Cycle Latency           |
+--------------------------+-------------------------+
| %init.check.i            | 3                       |
+--------------------------+-------------------------+

+---------------------------------------------------+
| Function: target_memory_read (pipelined function) |
+-------------------------+-------------------------+
| Basic Block             | Cycle Latency           |
+-------------------------+-------------------------+
| %init.check.i           | 5                       |
+-------------------------+-------------------------+

====== 3. Pipeline Result ======

+---------------------+---------------------+---------------+--------------------------------+---------------------+-----------------+-----------------+---------+
| Label               | Function            | Basic Block   | Location in Source Code        | Initiation Interval | Pipeline Length | Iteration Count | Latency |
+---------------------+---------------------+---------------+--------------------------------+---------------------+-----------------+-----------------+---------+
| target_memory_write | target_memory_write | %init.check.i | line 115 of axi_slave.mmap.tmp | 1                   | 3               | n/a             | n/a     |
| target_memory_read  | target_memory_read  | %init.check.i | line 119 of axi_slave.mmap.tmp | 1                   | 5               | n/a             | n/a     |
+---------------------+---------------------+---------------+--------------------------------+---------------------+-----------------+-----------------+---------+

====== 4. Memory Usage ======

+--------------------------------------------------------------------------------------------------------------------------------------------+
| Local Memories                                                                                                                             |
+---------------------------------------------------------+-----------------------+-----------------------+-------------+------------+-------+
| Name                                                    | Accessing Function(s) | Type                  | Size [Bits] | Data Width | Depth |
+---------------------------------------------------------+-----------------------+-----------------------+-------------+------------+-------+
| axi_s_read_state                                        | target_memory_read    | Register              | 1           | 1          | 1     |
| axi_s_read_word_addr                                    | target_memory_read    | Register              | 32          | 32         | 1     |
| init_flag_ZGVZ10axi_s_readIN3hls7ap_uintILj32EEENS      | target_memory_read    | Register (Write-Only) | 1           | 1          | 1     |
| init_flag_ZGVZ10axi_s_readIN3hls7ap_uintILj32EEENS_var0 | target_memory_read    | Register (Write-Only) | 1           | 1          | 1     |
| init_flag_ZGVZ11axi_s_writeIN3hls7ap_uintILj32EEEN      | target_memory_write   | Register (Write-Only) | 1           | 1          | 1     |
| init_flag_ZGVZ10axi_s_readIN3hls7ap_uintILj32EEENS_var1 | target_memory_read    | Register (Write-Only) | 1           | 1          | 1     |
| axi_s_read_burst_len_minus1                             | target_memory_read    | Register              | 8           | 8          | 1     |
| axi_s_read_count                                        | target_memory_read    | Register              | 8           | 8          | 1     |
| axi_s_write_state                                       | target_memory_write   | Register              | 1           | 1          | 1     |
| axi_s_write_word_addr                                   | target_memory_write   | Register              | 32          | 32         | 1     |
| axi_s_write_count                                       | target_memory_write   | Register              | 8           | 8          | 1     |
| init_flag_ZGVZ11axi_s_writeIN3hls7ap_uintILj32EEEN_var0 | target_memory_write   | Register (Write-Only) | 1           | 1          | 1     |
+---------------------------------------------------------+-----------------------+-----------------------+-------------+------------+-------+

+-------------------------+
| Local Constant Memories |
+-------------------------+
| None                    |
+-------------------------+

+------------------------------------------------------------------------------------------------------------------------------------+
| Shared Local Memories                                                                                                              |
+--------------------------+-----------------------------------------------------------+----------+-------------+------------+-------+
| Name                     | Accessing Function(s)                                     | Type     | Size [Bits] | Data Width | Depth |
+--------------------------+-----------------------------------------------------------+----------+-------------+------------+-------+
| target_memory_arr_a0     | calc_kernel_orig, target_memory_read, target_memory_write | Register | 8           | 8          | 1     |
| target_memory_arr_a1     | calc_kernel_orig, target_memory_read, target_memory_write | Register | 8           | 8          | 1     |
| target_memory_arr_a2     | calc_kernel_orig, target_memory_read, target_memory_write | Register | 8           | 8          | 1     |
| target_memory_arr_a3     | calc_kernel_orig, target_memory_read, target_memory_write | Register | 8           | 8          | 1     |
| target_memory_arr_a4     | calc_kernel_orig, target_memory_read, target_memory_write | Register | 8           | 8          | 1     |
| target_memory_arr_a5     | calc_kernel_orig, target_memory_read, target_memory_write | Register | 8           | 8          | 1     |
| target_memory_arr_a6     | calc_kernel_orig, target_memory_read, target_memory_write | Register | 8           | 8          | 1     |
| target_memory_arr_a7     | calc_kernel_orig, target_memory_read, target_memory_write | Register | 8           | 8          | 1     |
| target_memory_a          | calc_kernel_orig, target_memory_read, target_memory_write | Register | 32          | 32         | 1     |
| target_memory_b          | calc_kernel_orig, target_memory_read, target_memory_write | Register | 32          | 32         | 1     |
| target_memory_sum_result | calc_kernel_orig, target_memory_read, target_memory_write | Register | 64          | 64         | 1     |
| target_memory_xor_result | calc_kernel_orig, target_memory_read, target_memory_write | Register | 32          | 32         | 1     |
| target_memory_or_result  | calc_kernel_orig, target_memory_read, target_memory_write | Register | 32          | 32         | 1     |
| target_memory_ctrl       | target_memory_read, target_memory_write                   | Register | 1           | 1          | 1     |
+--------------------------+-----------------------------------------------------------+----------+-------------+------------+-------+

+------------------+
| Aliased Memories |
+------------------+
| None             |
+------------------+

+-------------------------------------------------------------------------------------------+
| I/O Memories                                                                              |
+----------------+-----------------------+---------------+-------------+------------+-------+
| Name           | Accessing Function(s) | Type          | Size [Bits] | Data Width | Depth |
+----------------+-----------------------+---------------+-------------+------------+-------+
| axi_s_ar_addr  | target_memory_read    | FIFO (LUTRAM) | 0           | 32         | 0     |
| axi_s_ar_burst | target_memory_read    | FIFO (LUTRAM) | 0           | 2          | 0     |
| axi_s_ar_size  | target_memory_read    | FIFO (LUTRAM) | 0           | 3          | 0     |
| axi_s_ar_len   | target_memory_read    | FIFO (LUTRAM) | 0           | 8          | 0     |
| axi_s_r_data   | target_memory_read    | FIFO (LUTRAM) | 0           | 64         | 0     |
| axi_s_r_resp   | target_memory_read    | FIFO (LUTRAM) | 0           | 2          | 0     |
| axi_s_r_last   | target_memory_read    | FIFO (LUTRAM) | 0           | 1          | 0     |
| axi_s_aw_addr  | target_memory_write   | FIFO (LUTRAM) | 0           | 32         | 0     |
| axi_s_aw_burst | target_memory_write   | FIFO (LUTRAM) | 0           | 2          | 0     |
| axi_s_aw_size  | target_memory_write   | FIFO (LUTRAM) | 0           | 3          | 0     |
| axi_s_aw_len   | target_memory_write   | FIFO (LUTRAM) | 0           | 8          | 0     |
| axi_s_w_data   | target_memory_write   | FIFO (LUTRAM) | 0           | 64         | 0     |
| axi_s_w_strb   | target_memory_write   | FIFO (LUTRAM) | 0           | 8          | 0     |
| axi_s_w_last   | target_memory_write   | FIFO (LUTRAM) | 0           | 1          | 0     |
| axi_s_b_resp   | target_memory_write   | FIFO (LUTRAM) | 0           | 2          | 0     |
+----------------+-----------------------+---------------+-------------+------------+-------+


====== 5. Accelerator Information ======

No accelerator function is generated.

====== 6. Resource Binding with Adaptive Latency ======

Binding to resource with adaptive latency is disabled.
You can enable this feature by setting config parameter 'ADAPTIVE_LATENCY_BINDING' to 1.


Users Guide SmartHLS 2021.3 Documentation の Top-Level RTL Interface の AXI4 Slave Type によると、アドレスマップ・レポートは reports/axi_slave_memory_map.hls.rpt にあるようだ。それを見てみよう。
SmartHLS_102_211222.png

slave_memory_ctrl だが、SmartHLSモジュール用の特別なステータス制御レジスタで、1 を書き込むと SmartHLS で作成されたモジュールが動作する。また、モジュール動作の終了は slave_memory_ctrl を読み込んだ時に 1 が返ってくると動作が終了している。0 が返ってくるとまだ実行中ということだ。

SW/HW Co-Simulation icon をクリックして、SW/HW 協調シミュレーションを行った。
SmartHLS_103_211222.png

Cycle latency は 17 クロックだった。

SmartHLS メニューから SW/HW Co-Simulation with Waveforms を選択した。
全体波形を示す。
SmartHLS_104_211222.png

axi_target はAXI4-Liteインターフェースではなくて、AXI4 インターフェースになっている。そうなんだ。。。
データバス幅は 64 ビット幅になっている。
最初に 4 バースト転送で C コードで設定されたレジスタの設定値を書いている。結果を表示するレジスタは 0 に設定されている。
そして、20 番地(ワード番地で 4)に 1 を書いて axi_target モジュールの実行をスタートさせる。
20 番地を読みだして axi_target モジュールの実行終了を見ている。3 回目に 1 が来て実行終了を知った。
その後 4 バースト転送で、すべてのレジスタを読んでいる。結果のレジスタには正解の値がセットされている。

Synthesize Hardware to FPGA (RTLsynthesis, place and route, for resource timing and results)(Ctrl+shift+V) アイコンをクリックする。
SmartHLS_105_211222.png

ログを示す。

==================================================================
=====  Summary Report for RTL Simulation and FPGA Synthesis  =====
==================================================================

Project name: axi_target
FPGA Vendor: MICROSEMI
Device Family: PolarFire
Device: MPF300TS-1FCG1152I

Table of Contents
  1. Simulation Cycle Latency
  2. Timing Result
  3. Resource Usage


====== 1. Simulation Cycle Latency ======

Number of calls:           1
Cycle latency:          17
SW/HW co-simulation: PASS

====== 2. Timing Result ======

+--------------+---------------+-------------+-------------+----------+-------------+
| Clock Domain | Target Period | Target Fmax | Worst Slack | Period   | Fmax        |
+--------------+---------------+-------------+-------------+----------+-------------+
| clk          | 10.000 ns     | 100.000 MHz | 7.625 ns    | 2.375 ns | 421.053 MHz |
+--------------+---------------+-------------+-------------+----------+-------------+

The reported Fmax is for the HLS core in isolation (from Libero's post-place-and-route timing analysis).
When the HLS core is integrated into a larger system, the system Fmax may be lower depending on the critical path of the system.

====== 3. Resource Usage ======

+--------------------------+-----------------+--------+------------+
| Resource Type            | Used            | Total  | Percentage |
+--------------------------+-----------------+--------+------------+
| Fabric + Interface 4LUT* | 985 + 0 = 985   | 299544 | 0.33       |
| Fabric + Interface DFF*  | 1230 + 0 = 1230 | 299544 | 0.41       |
| I/O Register             | 0               | 1536   | 0.00       |
| User I/O                 | 0               | 512    | 0.00       |
| uSRAM                    | 0               | 2772   | 0.00       |
| LSRAM                    | 0               | 952    | 0.00       |
| Math                     | 0               | 924    | 0.00       |
+--------------------------+-----------------+--------+------------+

* Interface 4LUTs and DFFs are occupied due to the uses of LSRAM, Math, and uSRAM.
  Number of interface 4LUTs/DFFs = (36 * #.LSRAM) + (36 * #.Math) + (12 * #.uSRAM) = (36 * 0) + (36 * 0) + (12 * 0) = 0.


Fmax が 421.053 MHz でとっても速い。

Users Guide SmartHLS 2021.3 Documentation の Top-Level RTL Interface の AXI4 Slave Type の翻訳の一部を引用する。

重要:AXI4スレーブにはいくつかの制限があります。

・SmartHLSモジュールは最大で1つのAXI4スレーブインターフェイスを持つことができ、AXI4スレーブインターフェイスタイプは、構造体データタイプのグローバル変数に対してのみ指定できます。

 ・複数のデータをAXI4スレーブインターフェイスの背後に配置する必要がある場合は、すべてのデータを含む新しい構造体タイプを定義してから、構造体タイプでグローバル変数をインスタンス化し、グローバル変数に上記のプラグマを指定できます。

・AXI4スレーブインターフェイスは常に32ビットアドレスと64ビットデータ幅を使用します。

・AXI4スレーブインターフェイスは、インクリメンタルバーストの追加サポートを備えたAXI4-liteプロトコルのみをサポートします。

・AxBURSTおよびAxSIZE入力信号は、スレーブロジックによって無視されます。

 ・AxBURSTおよびAxSIZE信号の実際の入力値に関係なく、AXI4スレーブは常にインクリメンタルバーストタイプ(AxBURST == 1)を使用し、転送あたりのサイズは8バイト(AxSIZE == 3)です。

・バイトイネーブル書き込み(WSTRBポート経由)は、構造体の要素に揃える必要があります。
 ・共通の構造体要素(の異なるバイト)に対応するWSTRBビットの場合、これらのWSTRBビットはすべて1またはすべて0である必要があります。

 ・たとえば、2つの「int」型整数(それぞれ4バイト、1つの64ビットAXIワードとして一緒にパック)にマップするワードアドレスに書き込む場合、WSTRBポートの上位4ビットはすべて1または0である必要があります。 、および同じことがWSTRBポートの下位4ビットにも当てはまります。つまり、どちらの 'int'型整数の部分バイトも更新できませんが、2つの 'int'型整数のいずれかのすべてのバイトを更新することはできます。

・SW / HW協調シミュレーションは、最上位機能がパイプライン化されていない場合にのみサポートされます。

・AXI4スレーブインターフェイスを使用する場合、最上位関数はvoid戻り型を使用する必要があります。

  1. 2021年12月23日 04:17 |
  2. SmartHLS
  3. | トラックバック:0
  4. | コメント:0

Microchip 社の高位合成ツール SmartHLS の fpga-hls-examples をやってみる1(AXI4 Slave その 1)

今回から、AXI4 Slave や AXI4 Master のサンプルも入っている MicrochipTech/fpga-hls-examples を SmartHLS のワークスペースにインポートしてやってみることにしよう。とりあえずは AX4 Slave をやってみたいと思う。

参考にするのは、Users Guide SmartHLS 2021.3 Documentation の Top-Level RTL Interface の AXI4 Slave Type だ。

SmartHLS で新しいワークスペース(hls_examples_ws)を作成した。
SmartHLS_94_211221.png

SmartHLS の File メニューから Import... を選択した。
SmartHLS_96_211221.png

Import ダイアログが表示された。
General を展開して、Existing Projects into Workspace を選択して、Next>ボタンをクリックする。
SmartHLS_96_211221.png

MicrochipTech/fpga-hls-examples をダウンロードしておいた fpga-hls-examples-main フォルダを選択する。
SmartHLS_97_211221.png

Import Project 画面にインポートされるプロジェクトが表示された。
Finish ボタンをクリックする
SmartHLS_98_211221.png

全てのプロジェクトがインポートされた。
SmartHLS_99_211221.png

プロジェクトの内の axi_target プロジェクトをやってみる。これが AXI4 Slave の実装方法になる。

Users Guide SmartHLS 2021.3 Documentation の Top-Level RTL Interface の AXI4 Slave Type によると SmartHLS の AXI4 Slave の実装方法は

#pragma HLS interface variable(target_memory) type(axi_slave) (注: concurrent_access(true|false) というオプションもあるようだ)
struct TargetLayout target_memory;

のプラグマを付けるようだ。
target_memory が AXI4 Slave のレジスタになるようだ。
axi_target.h を引用する。

#ifndef __AXI_TARGET_H__
#define __AXI_TARGET_H__

#include <cstdint>

struct TargetLayout {
    uint8_t  arr[8];
    uint32_t a;
    uint32_t b;
    uint64_t sum_result;
    uint32_t xor_result;
    uint32_t or_result;
};

#endif // __AXI_TARGET_H__


次回から SmartHLS で AXI4 Slave を実装してみよう。
  1. 2021年12月22日 05:27 |
  2. SmartHLS
  3. | トラックバック:0
  4. | コメント:0

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(Libero SoC でインポートする)

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 3)3”の続き。

Microchip 社の Libero SoC の高位合成ツール SmartHLS の sobel_tutorial をやってみようと思うということで、前回は、HLS 制約を追加して、目標とするクロック周期を 10 ns から 7 ns に変更して、ソフトウェアからハードウェアへのコンパイルとハードウェアからFPGAへの合成を行った。今回は、Libero SoC を立ち上げて、SmartHLS で作成した IP をインスタンス化してみよう。

SmartHLS プロジェクトの create_hdl_plus.tcl を使用して、Libero SoC の SmartDesign にインスタンス化する。
SmartHLS_76_211220.png

Libero SoC を起動した。
SmartHLS_77_211220.png

Project メニューから New Project を選択する。
SmartHLS_78_211220.png

New Project ダイアログが表示された。
Project details 画面で Project name に SmartHLS_test と入力した。
Project location を設定した。
Next>ボタンをクリックする。
SmartHLS_79_211220.png

Device selection 画面で、Part に M2S010-VF256 を指定した。
Next>ボタンをクリックする。
SmartHLS_80_211220.png

Design Template 画面はデフォルトのまま Next>ボタンをクリックする。
SmartHLS_81_211220.png

Add HDL source files 画面もデフォルトのまま Next>ボタンをクリックする。
SmartHLS_82_211220.png

Add constraints 画面もデフォルトのまま Finsih ボタンをクリックする。
SmartHLS_83_211220.png

SmartHLS_test プロジェクトが生成された。
SmartHLS_84_211220.png

SmartDesign を作成する。
Create SmartDesign をダブルクリックして作成する。

Create SmartDesign ダイアログが表示された。
Name に SmartHLS_test と入力して、OKボタンをクリックする。
SmartHLS_85_211220.png

SmartHLS_test が生成された。
SmartHLS_86_211220.png

sobel_part3 を SmartDesign にインスタンス化しよう。

Libero SoC の Project メニューから Excute Script... を選択する。
SmartHLS_87_211220.png

Execute Script ダイアログが表示された。
Script fie に sobel_part3 の create_hdl_plus.tcl を指定した。
Run ボタンをクリックする。
SmartHLS_88_211220.png

Script Execution Report ダイアログが表示された。
成功のようだ。
SmartHLS_89_211220.png

Design Hierarchy タブをクリックするとインポートされた sobel_filter_top が見えた。
sobel_filter_top を右クリックし、右クリックメニューから Instantiate in SmartHLS_test を選択した。
SmartHLS_90_211220.png

sobel_filter_top_0 が SmartHLS_test にインスタンス化された。
SmartHLS_91_211220.png

sobel_filter_top_0 の input_fifo_axi4stream ポートを右クリックし、右クリックメニューから Show/Hide BIF Pins を選択した。
Pin to Expose ダイアログが表示された。
全てのチェックボックスにチェックを入れて、OKボタンをクリックする。
SmartHLS_92_211220.png

チェックボックスにチェックを入れたポートが IP のインスタンス・シンボルに表示された。
SmartHLS_93_211220.png
  1. 2021年12月20日 05:17 |
  2. SmartHLS
  3. | トラックバック:0
  4. | コメント:0

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 3)3

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 3)2”の続き。

Microchip 社の Libero SoC の高位合成ツール SmartHLS の sobel_tutorial をやってみようと思うということで、前回は、sobel_part3 のソフトウェアからハードウェアへのコンパイル、SW/HW 協調シミュレーションと Synthesize Hardware to FPGA を行った。今回は、HLS 制約を追加して、目標とするクロック周期を 10 ns から 7 ns に変更して、ソフトウェアからハードウェアへのコンパイルとハードウェアからFPGAへの合成を行う。

SmartHLS の制約を変更する方法を学習していこう。

HLS 制約はHLS Constraints アイコンをクリックして指定する。
SmartHLS_69_211219.png

Constraint Type の種類を示す。
SmartHLS_70_211219.png

Constraint Type に Set target clock period を指定した。
Constraints Value に 7 を指定した。
Add ボタンをクリックすると、下のウインドウに登録された。
SmartHLS_71_211219.png

再度、Compile Software to Hardware アイコンをクリックして、ソフトウェアからハードウェアへのコンパイルを行った。
Pipeline Length が 12 クロックになっている。
SmartHLS_72_211219.png

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 3)2”の Pipeline Length は 7 クロックだった。確実にパイプラインが長くなっている。

ログを貼っておく。

// ----------------------------------------------------------------------------
// Smart High-Level Synthesis Tool Version 2021.2
// Copyright (c) 2015-2021 Microchip Technology Inc. All Rights Reserved.
// For support, please contact: smarthls@microchip.com
// Date: Sun Dec 19 04:04:22 2021
// ----------------------------------------------------------------------------

SmartHLS Summary Report for Project: sobel_part3.

Table of Contents
  1. RTL Interface
  2. Scheduling Result
  3. Pipeline Result
  4. Memory Usage
  5. Accelerator Information
  6. Resource Binding with Adaptive Latency


====== 1. RTL Interface ======

+-------------------------------------------------------------------------------------------+
| RTL Interface Generated by SmartHLS                                                       |
+-------------+-------------------+-------------------+------------------+------------------+
| C++ Name    | Interface Type    | Signal Name       | Signal Bit-width | Signal Direction |
+-------------+-------------------+-------------------+------------------+------------------+
|             | Control           | clk               | 1                | input            |
|             |                   | finish            | 1                | output           |
|             |                   | ready             | 1                | output           |
|             |                   | reset             | 1                | input            |
|             |                   | start             | 1                | input            |
+-------------+-------------------+-------------------+------------------+------------------+
| input_fifo  | Input AXI Stream  | input_fifo_ready  | 1                | output           |
|             |                   | input_fifo_valid  | 1                | input            |
|             |                   | input_fifo        | 8                | input            |
+-------------+-------------------+-------------------+------------------+------------------+
| output_fifo | Output AXI Stream | output_fifo_ready | 1                | input            |
|             |                   | output_fifo_valid | 1                | output           |
|             |                   | output_fifo       | 8                | output           |
+-------------+-------------------+-------------------+------------------+------------------+

The Verilog top-level module ports that are not listed in the above table are unused. Please tie the unused input ports to 0.

====== 2. Scheduling Result ======

Please use SmartHLS's schedule viewer to examine the schedule.

Basic Block Latencies:

+---------------------------------------------+
| Function: sobel_filter (pipelined function) |
+---------------------+-----------------------+
| Basic Block         | Cycle Latency         |
+---------------------+-----------------------+
| %init.check         | 12                    |
+---------------------+-----------------------+

====== 3. Pipeline Result ======

+--------------+--------------+-------------+-------------------------+---------------------+-----------------+-----------------+---------+
| Label        | Function     | Basic Block | Location in Source Code | Initiation Interval | Pipeline Length | Iteration Count | Latency |
+--------------+--------------+-------------+-------------------------+---------------------+-----------------+-----------------+---------+
| sobel_filter | sobel_filter | %init.check | line 12 of sobel.cpp    | 1                   | 12              | n/a             | n/a     |
+--------------+--------------+-------------+-------------------------+---------------------+-----------------+-----------------+---------+

====== 4. Memory Usage ======

+---------------------------------------------------------------------------------------------------------------------------------------+
| Local Memories                                                                                                                        |
+----------------------------------------------------+-----------------------+-----------------------+-------------+------------+-------+
| Name                                               | Accessing Function(s) | Type                  | Size [Bits] | Data Width | Depth |
+----------------------------------------------------+-----------------------+-----------------------+-------------+------------+-------+
| sobel_filter_i                                     | sobel_filter          | Register              | 32          | 32         | 1     |
| sobel_filter_j                                     | sobel_filter          | Register              | 32          | 32         | 1     |
| sobel_filter_line_buffer_window_a0_a1              | sobel_filter          | Register              | 8           | 8          | 1     |
| sobel_filter_line_buffer_window_a0_a2              | sobel_filter          | Register              | 8           | 8          | 1     |
| sobel_filter_line_buffer_window_a1_a1              | sobel_filter          | Register              | 8           | 8          | 1     |
| sobel_filter_line_buffer_window_a1_a2              | sobel_filter          | Register              | 8           | 8          | 1     |
| sobel_filter_line_buffer_window_a2_a1              | sobel_filter          | Register              | 8           | 8          | 1     |
| sobel_filter_line_buffer_window_a2_a2              | sobel_filter          | Register              | 8           | 8          | 1     |
| sobel_filter_line_buffer_prev_row_index            | sobel_filter          | Register              | 32          | 32         | 1     |
| sobel_filter_line_buffer_prev_row_a0_a0            | sobel_filter          | RAM                   | 4096        | 8          | 512   |
| sobel_filter_line_buffer_prev_row_a1_a0            | sobel_filter          | RAM                   | 4096        | 8          | 512   |
| sobel_filter_count                                 | sobel_filter          | Register              | 32          | 32         | 1     |
| init_flag_ZGVZ12sobel_filterRN3hls4FIFOIhLb0EEES2_ | sobel_filter          | Register (Write-Only) | 1           | 1          | 1     |
+----------------------------------------------------+-----------------------+-----------------------+-------------+------------+-------+

+-------------------------+
| Local Constant Memories |
+-------------------------+
| None                    |
+-------------------------+

+-----------------------+
| Shared Local Memories |
+-----------------------+
| None                  |
+-----------------------+

+------------------+
| Aliased Memories |
+------------------+
| None             |
+------------------+

+-------------------------------------------------------------------------------------+
| I/O Memories                                                                        |
+-------------+-----------------------+------------+-------------+------------+-------+
| Name        | Accessing Function(s) | Type       | Size [Bits] | Data Width | Depth |
+-------------+-----------------------+------------+-------------+------------+-------+
| input_fifo  | sobel_filter          | FIFO (REG) | 0           | 8          | 0     |
| output_fifo | sobel_filter          | FIFO (REG) | 0           | 8          | 0     |
+-------------+-----------------------+------------+-------------+------------+-------+


====== 5. Accelerator Information ======

No accelerator function is generated.

====== 6. Resource Binding with Adaptive Latency ======

Binding to resource with adaptive latency is disabled.
You can enable this feature by setting config parameter 'ADAPTIVE_LATENCY_BINDING' to 1.


Synthesize Hardware to FPGA (RTLsynthesis, place and route, for resource timing and results)(Ctrl+shift+V) アイコンをクリックする。
SmartHLS_73_211219.png

Fmax は 213.995 MHz だった。
Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 3)2”では、Fmax は 203.087 MHz だった。パイプラインは 7 クロックから 12 クロックになっても、10 MHz 程度しか改善されていないので、限界なのかもしれないのかな?

限界を探ってみるために、クロック周期を 4 ns つまり 250 MHz にしてみた。
Compile Software to Hardware アイコンをクリックして、ソフトウェアからハードウェアへのコンパイルを行った。
SmartHLS_74_211219.png

Pipeline Length は 12 クロックのままだった。

Synthesize Hardware to FPGA (RTLsynthesis, place and route, for resource timing and results)(Ctrl+shift+V) アイコンをクリックする。
SmartHLS_75_211219.png

Fmax は 231.000 MHz に向上していた。パイプライン段数が変化しなくても動作周波数が向上する余地があるんだね。。。
  1. 2021年12月19日 05:12 |
  2. SmartHLS
  3. | トラックバック:0
  4. | コメント:0

WSLg で日本語表示、日本語入力

Windows11 にアップグレードして、WSLg を起動した”の続き。

前回は、WSLg を動作させて、nautilus GUI を起動した。今回は、WSLg で日本語表示、日本語入力を行う。

Win11のWSL2 (WSLg)を日本語化 & Mozcで日本語入力”を参考にして、WSLg で日本語表示、日本語入力を行う。

Ubuntu-20.04 で gedit をインストールする。geany ではなぜか?Windows の Chrome からコピー&ペーストできない。。。
sudo apt install gedit

gedit を立ち上げて、”Win11のWSL2 (WSLg)を日本語化 & Mozcで日本語入力”の japanize-wslg.sh をコピー&ペーストして、名前を付けてセーブした。
gedit &
chmod +x japanize-wslg.sh


gedit にコピー&ペーストすると日本語はトーフになっていた。(キャプチャし忘れた。。。)

japanize-wslg.sh を起動した。
./japanize-wslg.sh
WSLg_3_211218.png

WSLg_4_211218.png

Windows Terminal を閉じて、再起動し、gedit で japanize-wslg.sh を見たところ、日本が表示されていた。
WSLg_5_211218.png

半角/全角キーを押して日本語入力にすると日本が入力できた。
WSLg_6_211218.png
  1. 2021年12月18日 15:59 |
  2. WSL2
  3. | トラックバック:0
  4. | コメント:0

Windows11 にアップグレードして、WSLg を起動した

ついにWindows Update で迫られて、Windows11 をインストールしてしまいました。
ついでなので、話題の WSL2でのGUIアプリケーションを動かす WSLg を使ってみた。

WSLg の使い方は、”Windows 11にWSL 2、WSLgをインストール”によると、”Windows Terminal”を起動して、インストールしてあった Ubuntu20.04 を起動すれば良いとのことだった。
WSLg_1_211218.png

sudo apt install nautilus
で nautilus をインストールすれば、
nautilus &
で nautilus が立ち上がった。
WSLg_2_211218.png

  1. 2021年12月18日 15:11 |
  2. WSL2
  3. | トラックバック:0
  4. | コメント:0

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 3)2

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 3)1”の続き。

Microchip 社の Libero SoC の高位合成ツール SmartHLS の sobel_tutorial をやってみようと思うということで、前回は、sobel_part3 をやってみようということでコードの解説と C シミュレーションを行った。今回は、ソフトウェアからハードウェアへのコンパイル、SW/HW 協調シミュレーションと Synthesize Hardware to FPGA を行った。

Compile Software to Hardware アイコンをクリックして、ソフトウェアからハードウェアへのコンパイルを行った。
SmartHLS_65_211218.png

ログを貼っておく。

// ----------------------------------------------------------------------------
// Smart High-Level Synthesis Tool Version 2021.2
// Copyright (c) 2015-2021 Microchip Technology Inc. All Rights Reserved.
// For support, please contact: smarthls@microchip.com
// Date: Sat Dec 18 03:58:32 2021
// ----------------------------------------------------------------------------

SmartHLS Summary Report for Project: sobel_part3.

Table of Contents
  1. RTL Interface
  2. Scheduling Result
  3. Pipeline Result
  4. Memory Usage
  5. Accelerator Information
  6. Resource Binding with Adaptive Latency


====== 1. RTL Interface ======

+-------------------------------------------------------------------------------------------+
| RTL Interface Generated by SmartHLS                                                       |
+-------------+-------------------+-------------------+------------------+------------------+
| C++ Name    | Interface Type    | Signal Name       | Signal Bit-width | Signal Direction |
+-------------+-------------------+-------------------+------------------+------------------+
|             | Control           | clk               | 1                | input            |
|             |                   | finish            | 1                | output           |
|             |                   | ready             | 1                | output           |
|             |                   | reset             | 1                | input            |
|             |                   | start             | 1                | input            |
+-------------+-------------------+-------------------+------------------+------------------+
| input_fifo  | Input AXI Stream  | input_fifo_ready  | 1                | output           |
|             |                   | input_fifo_valid  | 1                | input            |
|             |                   | input_fifo        | 8                | input            |
+-------------+-------------------+-------------------+------------------+------------------+
| output_fifo | Output AXI Stream | output_fifo_ready | 1                | input            |
|             |                   | output_fifo_valid | 1                | output           |
|             |                   | output_fifo       | 8                | output           |
+-------------+-------------------+-------------------+------------------+------------------+

The Verilog top-level module ports that are not listed in the above table are unused. Please tie the unused input ports to 0.

====== 2. Scheduling Result ======

Please use SmartHLS's schedule viewer to examine the schedule.

Basic Block Latencies:

+---------------------------------------------+
| Function: sobel_filter (pipelined function) |
+---------------------+-----------------------+
| Basic Block         | Cycle Latency         |
+---------------------+-----------------------+
| %init.check         | 7                     |
+---------------------+-----------------------+

====== 3. Pipeline Result ======

+--------------+--------------+-------------+-------------------------+---------------------+-----------------+-----------------+---------+
| Label        | Function     | Basic Block | Location in Source Code | Initiation Interval | Pipeline Length | Iteration Count | Latency |
+--------------+--------------+-------------+-------------------------+---------------------+-----------------+-----------------+---------+
| sobel_filter | sobel_filter | %init.check | line 12 of sobel.cpp    | 1                   | 7               | n/a             | n/a     |
+--------------+--------------+-------------+-------------------------+---------------------+-----------------+-----------------+---------+

====== 4. Memory Usage ======

+---------------------------------------------------------------------------------------------------------------------------------------+
| Local Memories                                                                                                                        |
+----------------------------------------------------+-----------------------+-----------------------+-------------+------------+-------+
| Name                                               | Accessing Function(s) | Type                  | Size [Bits] | Data Width | Depth |
+----------------------------------------------------+-----------------------+-----------------------+-------------+------------+-------+
| sobel_filter_i                                     | sobel_filter          | Register              | 32          | 32         | 1     |
| sobel_filter_j                                     | sobel_filter          | Register              | 32          | 32         | 1     |
| sobel_filter_line_buffer_window_a0_a1              | sobel_filter          | Register              | 8           | 8          | 1     |
| sobel_filter_line_buffer_window_a0_a2              | sobel_filter          | Register              | 8           | 8          | 1     |
| sobel_filter_line_buffer_window_a1_a1              | sobel_filter          | Register              | 8           | 8          | 1     |
| sobel_filter_line_buffer_window_a1_a2              | sobel_filter          | Register              | 8           | 8          | 1     |
| sobel_filter_line_buffer_window_a2_a1              | sobel_filter          | Register              | 8           | 8          | 1     |
| sobel_filter_line_buffer_window_a2_a2              | sobel_filter          | Register              | 8           | 8          | 1     |
| sobel_filter_line_buffer_prev_row_index            | sobel_filter          | Register              | 32          | 32         | 1     |
| sobel_filter_line_buffer_prev_row_a0_a0            | sobel_filter          | RAM                   | 4096        | 8          | 512   |
| sobel_filter_line_buffer_prev_row_a1_a0            | sobel_filter          | RAM                   | 4096        | 8          | 512   |
| sobel_filter_count                                 | sobel_filter          | Register              | 32          | 32         | 1     |
| init_flag_ZGVZ12sobel_filterRN3hls4FIFOIhLb0EEES2_ | sobel_filter          | Register (Write-Only) | 1           | 1          | 1     |
+----------------------------------------------------+-----------------------+-----------------------+-------------+------------+-------+

+-------------------------+
| Local Constant Memories |
+-------------------------+
| None                    |
+-------------------------+

+-----------------------+
| Shared Local Memories |
+-----------------------+
| None                  |
+-----------------------+

+------------------+
| Aliased Memories |
+------------------+
| None             |
+------------------+

+-------------------------------------------------------------------------------------+
| I/O Memories                                                                        |
+-------------+-----------------------+------------+-------------+------------+-------+
| Name        | Accessing Function(s) | Type       | Size [Bits] | Data Width | Depth |
+-------------+-----------------------+------------+-------------+------------+-------+
| input_fifo  | sobel_filter          | FIFO (REG) | 0           | 8          | 0     |
| output_fifo | sobel_filter          | FIFO (REG) | 0           | 8          | 0     |
+-------------+-----------------------+------------+-------------+------------+-------+


====== 5. Accelerator Information ======

No accelerator function is generated.

====== 6. Resource Binding with Adaptive Latency ======

Binding to resource with adaptive latency is disabled.
You can enable this feature by setting config parameter 'ADAPTIVE_LATENCY_BINDING' to 1.


パイプラインの Initiation Interval は 1 クロックになっている。レイテンシは 1 クロックだ。
4. Memory Usage の sobel_filter_line_buffer_prev_row_a0_a0 と sobel_filter_line_buffer_prev_row_a1_a0 はコードの line_buffer でウインドウサイズが 3 なので、自動的に 2 個のラインバッファを生成してくれるようだ。 512 x 8 バイトのラインバッファが 2 個ある。

SW/HW Co-Simulation icon をクリックして、SW/HW 協調シミュレーションを行った。
SmartHLS_66_211218.png

Cycle latency は 262,667 クロックだった。512 x 512 ピクセルの総ピクセル数は 262,144 ピクセルなので、262667 / 262144 ≒ 1.00 クロック / ピクセルとなった。ほぼ 1 クロック / ピクセルとなった。

SmartHLS メニューから SW/HW Co-Simulation with Waveforms を選択した。
拡大した波形を示す。
SmartHLS_67_211218.png

ずーと、1 クロックに 1 ピクセルずつ処理できている。

Synthesize Hardware to FPGA (RTLsynthesis, place and route, for resource timing and results)(Ctrl+shift+V) アイコンをクリックする。
SmartHLS_68_211218.png

ログを貼っておく。

==================================================================
=====  Summary Report for RTL Simulation and FPGA Synthesis  =====
==================================================================

Project name: sobel_part3
FPGA Vendor: MICROSEMI
Device Family: SmartFusion2
Device: M2S010-VF256

Table of Contents
  1. Simulation Cycle Latency
  2. Timing Result
  3. Resource Usage


====== 1. Simulation Cycle Latency ======

Number of calls:      262,658
Cycle latency:      262,667
SW/HW co-simulation: PASS

====== 2. Timing Result ======

+--------------+---------------+-------------+-------------+----------+-------------+
| Clock Domain | Target Period | Target Fmax | Worst Slack | Period   | Fmax        |
+--------------+---------------+-------------+-------------+----------+-------------+
| clk          | 10.000 ns     | 100.000 MHz | 5.076 ns    | 4.924 ns | 203.087 MHz |
+--------------+---------------+-------------+-------------+----------+-------------+

The reported Fmax is for the HLS core in isolation (from Libero's post-place-and-route timing analysis).
When the HLS core is integrated into a larger system, the system Fmax may be lower depending on the critical path of the system.

====== 3. Resource Usage ======

+--------------------------+-----------------+-------+------------+
| Resource Type            | Used            | Total | Percentage |
+--------------------------+-----------------+-------+------------+
| Fabric + Interface 4LUT* | 453 + 288 = 741 | 12084 | 6.13       |
| Fabric + Interface DFF*  | 378 + 288 = 666 | 12084 | 5.51       |
| I/O Register             | 0               | 414   | 0.00       |
| User I/O                 | 0               | 138   | 0.00       |
| RAM64x18                 | 8               | 22    | 36.36      |
| RAM1K18                  | 0               | 21    | 0.00       |
| MACC                     | 0               | 22    | 0.00       |
+--------------------------+-----------------+-------+------------+

* Interface 4LUTs and DFFs are occupied due to the uses of MACC, RAM1K18, and RAM64x18.
  Number of interface 4LUTs/DFFs = (36 * #.MACC) + (36 * #.RAM1K18) + (36 * #.RAM64x18) = (36 * 0) + (36 * 0) + (36 * 8) = 288.



Fmax は 203.087 MHz となった。今まで一番、動作周波数が低いが 1 クロックで 1 ピクセル、ソーベル・フィルタ処理することができる。
  1. 2021年12月18日 04:43 |
  2. SmartHLS
  3. | トラックバック:0
  4. | コメント:0

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 3)1

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 2)4”の続き。

Microchip 社の Libero SoC の高位合成ツール SmartHLS の sobel_tutorial をやってみようと思うということで、前回は、sobel_part2 の SW/HW 協調シミュレーションと Synthesize Hardware to FPGA を行った。今回は、sobel_part3 をやってみよう。

sobel_part3 は回路の入出力がストリームになっている。

#include <hls/image_processing.hpp>
#include <hls/streaming.hpp>
void sobel_filter(FIFO<unsigned char> &input_fifo,
                  FIFO<unsigned char> &output_fifo)


また、”SmartHLS's line buffer library.”を使用している。

static LineBuffer<unsigned char, WIDTH, 3> line_buffer;


WIDTH が 512 列で 3 が 3x3 のウインドウを示しているようだ。
line_buffer へのピクセルのプッシュ方法は、

line_buffer.ShiftInPixel(input_pixel);

でできるようだ。
ラインバッファのウインドウへのアクセスは

int pixel = line_buffer.window[m + 1][n + 1];

このように行われている。

また、驚いたことに、前の LineBuffer が static 宣言されていることからも推測できるように、1 ピクセル毎に main() 関数から sobel_filter 関数が呼ばれている。。。

    // Write input pixels and run the hardware model.
    for (int i = 0; i < HEIGHT; i++) {
        for (int j = 0; j < WIDTH; j++) {
            input_fifo.write(elaine_512_input[i][j]);
            sobel_filter(input_fifo, output_fifo);
        }
    }


ストリーム入出力にしたら、1 クロック毎に関数を呼ぶ必要があるのだろうか?その辺りを確かめてみたい。

sobel_part3 プロジェクトを SmartFusion2 の M2S010-VF256 デバイスで作成した。
SmartHLS_62_211216.png

Compile Software アイコンをクリックして、C コードをコンパイルした。
成功だ。
SmartHLS_63_211217.png

Run Software アイコンをクリックして、実行した。
PASS!が表示されて、成功だ。
SmartHLS_64_211217.png
  1. 2021年12月17日 04:33 |
  2. SmartHLS
  3. | トラックバック:0
  4. | コメント:0

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 2)4

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 2)3”の続き。

Microchip 社の Libero SoC の高位合成ツール SmartHLS の sobel_tutorial をやってみようと思うということで、前回は、sobel_tutorial にパイプライン化するために 2 重ループを 1 重ループにして Pipeline プラグマを付けると書いてあったが、本当に 2 重ループではパイプライン化されないのか? sobel_part1 プロジェクトの 2 重ループで確かめたところ、パイプライン化することができた。今回は、sobel_part2 の SW/HW 協調シミュレーションと Synthesize Hardware to FPGA を行った。

sobel_part2 プロジェクトで、SW/HW Co-Simulation icon をクリックして、SW/HW 協調シミュレーションを行った。
SmartHLS_59_211215.png

Cycle latency は 1,040,413 クロックだった。
2 重ループの”Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 2)3”の 1,052,677 に比べて、短くなっている。やはり、1 重ループの実装の方が 2 重ループよりレイテンシが短くなるようだ。それでも 1052677 / 1040413 ≒ 1.012 なので、1.2 % 程の違いしかない。

元のsobel_part1 との比較は、3392549 / 1040413 ≒ 3.26 倍、レイテンシが短くなった。

SmartHLS メニューから SW/HW Co-Simulation with Waveforms を選択した。
拡大した波形を示す。
SmartHLS_60_211215.png

ずーと連続して、4 クロックに 1 回の Write が入っていて、2 重ループの時のような行が変わった時の Wait が無い。だから、1 重ループの方がレイテンシが短いのだろう?

Synthesize Hardware to FPGA (RTLsynthesis, place and route, for resource timing and results)(Ctrl+shift+V) アイコンをクリックする。
SmartHLS_61_211215.png

ログを示す。

==================================================================
=====  Summary Report for RTL Simulation and FPGA Synthesis  =====
==================================================================

Project name: sobel_part2
FPGA Vendor: MICROSEMI
Device Family: SmartFusion2
Device: M2S010-VF256

Table of Contents
  1. Simulation Cycle Latency
  2. Timing Result
  3. Resource Usage


====== 1. Simulation Cycle Latency ======

Number of calls:           1
Cycle latency:     1,040,413
SW/HW co-simulation: PASS

====== 2. Timing Result ======

+--------------+---------------+-------------+-------------+----------+-------------+
| Clock Domain | Target Period | Target Fmax | Worst Slack | Period   | Fmax        |
+--------------+---------------+-------------+-------------+----------+-------------+
| clk          | 10.000 ns     | 100.000 MHz | 6.151 ns    | 3.849 ns | 259.808 MHz |
+--------------+---------------+-------------+-------------+----------+-------------+

The reported Fmax is for the HLS core in isolation (from Libero's post-place-and-route timing analysis).
When the HLS core is integrated into a larger system, the system Fmax may be lower depending on the critical path of the system.

====== 3. Resource Usage ======

+--------------------------+---------------+-------+------------+
| Resource Type            | Used          | Total | Percentage |
+--------------------------+---------------+-------+------------+
| Fabric + Interface 4LUT* | 772 + 0 = 772 | 12084 | 6.39       |
| Fabric + Interface DFF*  | 533 + 0 = 533 | 12084 | 4.41       |
| I/O Register             | 0             | 414   | 0.00       |
| User I/O                 | 0             | 138   | 0.00       |
| RAM64x18                 | 0             | 22    | 0.00       |
| RAM1K18                  | 0             | 21    | 0.00       |
| MACC                     | 0             | 22    | 0.00       |
+--------------------------+---------------+-------+------------+

* Interface 4LUTs and DFFs are occupied due to the uses of MACC, RAM1K18, and RAM64x18.
  Number of interface 4LUTs/DFFs = (36 * #.MACC) + (36 * #.RAM1K18) + (36 * #.RAM64x18) = (36 * 0) + (36 * 0) + (36 * 0) = 0.


Fmax は 259.808 MHz だった。sobel_part1 は 282.247 MHz だったので、多少 Fmax は下がっている。

sobel_part2 では、for ループを 1 重ループにして、Pipeline プラグマを付加したところ、sobel_part1 に比べて約 3.26 倍程度レイテンシが短くなった。また、2 重ループの内側のループに Pipeline プラグマを付加した場合と比べてレイテンシの差は約 1.2 % だった。
  1. 2021年12月16日 05:20 |
  2. SmartHLS
  3. | トラックバック:0
  4. | コメント:0

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 2)3

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 2)2”の続き。

Microchip 社の Libero SoC の高位合成ツール SmartHLS の sobel_tutorial をやってみようと思うということで、前回は、sobel_part2 のソフトウェアからハードウェアへのコンパイルを行った。今回は、sobel_tutorial にパイプライン化するために 2 重ループを 1 重ループにして Pipeline プラグマを付けると書いてあったが、本当に 2 重ループではパイプライン化されないのか? sobel_part1 プロジェクトの 2 重ループで確かめてみた。

sobel_part1 プロジェクトの sobel.cpp の内側の for ループに

#pragma HLS loop pipeline

を追加した。
SmartHLS_51_211215.png

再度、Compile Software to Hardware アイコンをクリックして、ソフトウェアからハードウェアへのコンパイルを行った。
SmartHLS_52_211215.png

やはり、2 重ループの内側の for ループに Pipeline プラグマを加えてもパイプライン化できるようだ。
Initiation Interval (開始間隔)は 4 クロック、パイプライン長は 10 クロック、Iteration Count は 512 ピクセル、Latency は 2054 クロックだった。

sobel_part1.v の行数は、1233 行となって、パイプライン化前の 1041 行から増えているし、sobel_part2.v の 1214 行よりも増えている。
SmartHLS_53_211215.png

Launch Schedule Viewer アイコンをクリックして、Schedule Viewer を起動した。
SmartHLS_54_211215.png

sobel_filter をダブルクリックした。
Control Flow Graph が表示された。
SmartHLS_55_211215.png

BB_for_body3 をダブルクリックした。
Pipeline Viewer が表示された。
SmartHLS_56_211215.png

Pipeline Stage 3 を見ると、”Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 2)2”と同様に 8 個の load があった。RAM ブロックのポートが 2 個だというので、4 クロック/ステージになっているようだ。

SW/HW Co-Simulation icon をクリックして、SW/HW 協調シミュレーションを行った。
SmartHLS_57_211215.png

Cycle latency: 1,052,677 だった。
パイプライン化されていない時のレイテンシは 3,392,549 なので、約 3.22 倍くらい速くなっている。
10526776 / (512 * 512 ピクセル) ≒ 4.02 クロック / ピクセル
大体 4 クロック / ピクセルというのはパイプラインのステージのクロック数に等しいので、2 重ループの内側ループをパイプライン化しても、1 重化したループをパイプライン化してもレイテンシはほとんど変わらないということじゃないだろうか?(多少 1 重ループよりも 2 重ループの方がレイテンシが長いようだ)

SmartHLS メニューから SW/HW Co-Simulation with Waveforms を選択した。
ModelSim が起動して、最後に”“Are you sure you want to finish?”のダイアログが出る。No ボタンをクリックしないと ModelSim が終了してしまう。
波形を UnDock した。
波形を拡大した。
SmartHLS_58_211215.png

Read は 2 チャンネルとも read_en_b がずっと 1 でリードの切れ目は(たぶん)画像の行の切れ目以外は無いようだ。
Write は 4 クロックに 1 回出ているようだ。
  1. 2021年12月15日 06:14 |
  2. SmartHLS
  3. | トラックバック:0
  4. | コメント:0

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 2)2

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 2)1”の続き。

Microchip 社の Libero SoC の高位合成ツール SmartHLS の sobel_tutorial をやってみようと思うということで、前回は、sobel_part2 プロジェクトを新規作成し、C シミュレーションを行った。今回は、sobel_part2 のソフトウェアからハードウェアへのコンパイルを行った。

Compile Software to Hardware アイコンをクリックして、ソフトウェアからハードウェアへのコンパイルを行った。
SmartHLS_44_211214.png

summary.hls.rpt を示す。

// ----------------------------------------------------------------------------
// Smart High-Level Synthesis Tool Version 2021.2
// Copyright (c) 2015-2021 Microchip Technology Inc. All Rights Reserved.
// For support, please contact: smarthls@microchip.com
// Date: Tue Dec 14 04:10:28 2021
// ----------------------------------------------------------------------------

SmartHLS Summary Report for Project: sobel_part2.

Table of Contents
  1. RTL Interface
  2. Scheduling Result
  3. Pipeline Result
  4. Memory Usage
  5. Accelerator Information
  6. Resource Binding with Adaptive Latency


====== 1. RTL Interface ======

+------------------------------------------------------------------------------------+
| RTL Interface Generated by SmartHLS                                                |
+----------+----------------+------------------+------------------+------------------+
| C++ Name | Interface Type | Signal Name      | Signal Bit-width | Signal Direction |
+----------+----------------+------------------+------------------+------------------+
|          | Control        | clk              | 1                | input            |
|          |                | finish           | 1                | output           |
|          |                | ready            | 1                | output           |
|          |                | reset            | 1                | input            |
|          |                | start            | 1                | input            |
+----------+----------------+------------------+------------------+------------------+
| in       | Memory         | in_address_a     | 18               | output           |
|          |                | in_address_b     | 18               | output           |
|          |                | in_clken         | 1                | output           |
|          |                | in_read_data_a   | 8                | input            |
|          |                | in_read_data_b   | 8                | input            |
|          |                | in_read_en_a     | 1                | output           |
|          |                | in_read_en_b     | 1                | output           |
+----------+----------------+------------------+------------------+------------------+
| out      | Memory         | out_address_a    | 18               | output           |
|          |                | out_address_b    | 18               | output           |
|          |                | out_clken        | 1                | output           |
|          |                | out_write_data_a | 8                | output           |
|          |                | out_write_data_b | 8                | output           |
|          |                | out_write_en_a   | 1                | output           |
|          |                | out_write_en_b   | 1                | output           |
+----------+----------------+------------------+------------------+------------------+

The Verilog top-level module ports that are not listed in the above table are unused. Please tie the unused input ports to 0.

====== 2. Scheduling Result ======

Please use SmartHLS's schedule viewer to examine the schedule.

Basic Block Latencies:

+-------------------------------------------------+
| Function: sobel_filter (non-pipelined function) |
+-----------------------+-------------------------+
| Basic Block           | Cycle Latency           |
+-----------------------+-------------------------+
| %for.end53            | 1                       |
| %entry                | 1                       |
| %for.body             | 11                      |
+-----------------------+-------------------------+

====== 3. Pipeline Result ======

+-------------------------+--------------+-------------+-------------------------+---------------------+-----------------+-----------------+---------+
| Label                   | Function     | Basic Block | Location in Source Code | Initiation Interval | Pipeline Length | Iteration Count | Latency |
+-------------------------+--------------+-------------+-------------------------+---------------------+-----------------+-----------------+---------+
| for_loop_sobel_cpp_20_5 | sobel_filter | %for.body   | line 20 of sobel.cpp    | 4                   | 11              | 260100          | 1040407 |
+-------------------------+--------------+-------------+-------------------------+---------------------+-----------------+-----------------+---------+

====== 4. Memory Usage ======

+----------------+
| Local Memories |
+----------------+
| None           |
+----------------+

+-------------------------+
| Local Constant Memories |
+-------------------------+
| None                    |
+-------------------------+

+-----------------------+
| Shared Local Memories |
+-----------------------+
| None                  |
+-----------------------+

+------------------+
| Aliased Memories |
+------------------+
| None             |
+------------------+

+------------------------------------------------------------------------+
| I/O Memories                                                           |
+------+-----------------------+------+-------------+------------+-------+
| Name | Accessing Function(s) | Type | Size [Bits] | Data Width | Depth |
+------+-----------------------+------+-------------+------------+-------+
| in   | sobel_filter          | ROM  | 0           | 8          | 0     |
| out  | sobel_filter          | RAM  | 0           | 8          | 0     |
+------+-----------------------+------+-------------+------------+-------+


====== 5. Accelerator Information ======

No accelerator function is generated.

====== 6. Resource Binding with Adaptive Latency ======

Binding to resource with adaptive latency is disabled.
You can enable this feature by setting config parameter 'ADAPTIVE_LATENCY_BINDING' to 1.


Initiation Interval は4 クロック、Pipeline Length は 11 クロック、Iteration Count は 260100 回、Latency は 1040407 クロックのようだ。
Initiation Interval は4 クロックになった理由は Schedule Viewer を見ると分かるそうだ。
生成された sobel_part2.v を見た。
SmartHLS_45_211214.png

1214 行だった。sobel_part1.v は 1041 行なので増えている。

コンソールを見ると、load が 8 個ある。RAM ブロックはデュアル・ポートなので、4 クロックかかるそうだ。
SmartHLS_46_211214.png

Launch Schedule Viewer アイコンをクリックして、Schedule Viewer を起動した。
SmartHLS_47_211214.png

sobel_filter をダブルクリックした。
SmartHLS_48_211214.png

BB_for_body をダブルクリックした。
Pipeline Viewer が表示された。
SmartHLS_49_211214.png

パイプライン・ステージは3 で、現在は 1 ステージ目が表示されている。1 ステージに 4 サイクルあるのが分かる。
縦は 1 クロックで実行される命令のようだ。
3 ステージ目を示す。
SmartHLS_50_211214.png

このステージでは 8 個の load があるのが分かる。これで 1 ステージが 4 クロックに分かれるようになるようだ。
  1. 2021年12月14日 04:49 |
  2. SmartHLS
  3. | トラックバック:0
  4. | コメント:0

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう(part 2)1

”Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう5”の続き。

Microchip 社の Libero SoC の高位合成ツール SmartHLS の sobel_tutorial をやってみようと思うということで、前回は、SW/HW 協調シミュレーションと Synthesize Hardware to FPGA を行った。今回は、sobel_part2 プロジェクトを新規作成し、C シミュレーションを行った。

パート 2 では、パイプライン化を行う。initiation interval (II) とリソースの関係がチュートリアルには書いてある。いずこも同じようだ。
SmartHLS のパイプライン化は、ループの前に

#pragma HLS loop pipeline

を書くそうだ。それが、sobel フィルタ・チュートリアルの part2 なので、早速、sobel_part2 プロジェクトを作成する。

SmartHLS の File メニューから New -> SmartHLS C/C++ Project を選択した。
New Project ダイアログの SmartHLS C/C++ Project が表示された。
Project name に sobel_part2 を入力した。
SmartHLS_37_211213.png

ソースファイル追加画面では、sobel_tutorial\part2 の 3 個のファイルを追加した。
SmartHLS_38_211213.png

テストベンチ追加画面では、デフォルトのままとした。
SmartHLS_39_211213.png

FPGA デバイスを選択する画面では、FPGA Family: に SmartFusion2 、FPGA Device: に Custom Device を選択した。Custom Device: に M2S010-VF256 を入力した。
SmartHLS_40_211213.png

sobel_part2 プロジェクトが作成された。
sobel.cpp のコードを見ると pipeline プラグマだけでなく、ループも 1 次元にしてある。
sobel_tutorial には、2 重ループに pipeline プラグマを書くと、内側のループがパイプライン化されるが、512 回の反復は不可能というようなことが書いてあった。パイプライン化するには 1 重ループにする必要があるのか?
SmartHLS_41_211213.png

Compile Software アイコンをクリックして、C コードをコンパイルした。
成功だ。
SmartHLS_42_211213.png

Run Software アイコンをクリックして、実行した。
PASS!が表示されて、成功だ。
SmartHLS_43_211213.png
  1. 2021年12月13日 04:55 |
  2. SmartHLS
  3. | トラックバック:0
  4. | コメント:0

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう5

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう4”の続き。

Microchip 社の Libero SoC の高位合成ツール SmartHLS の sobel_tutorial をやってみようと思うということで、前回は、Schedule Viewer を起動して、機能を確認した。今回は、SW/HW 協調シミュレーションと Synthesize Hardware to FPGA を行う。

SW/HW Co-Simulation icon をクリックして、SW/HW 協調シミュレーションを行った。
やっていることは、ModelSim を使用して、sobel_part1.v の sobel_filter_top モジュールをシミュレーションし、main() 関数をソフトウェアで実行する。自分で Verilog HDL のテストベンチを作らなくても SmartHLS の生成した HDL ファイルをシミュレーションすることができる。いずれのツールも同じようなことをやっているようだ。
SmartHLS_32_211212.png

出力ログの一部を示す。

PASS!
make[1]: Leaving directory '/cygdrive/c/Users/marse/Documents/SmartHLS/Sobel_filter/sobel_part1'
make[1]: Entering directory '/cygdrive/c/Users/marse/Documents/SmartHLS/Sobel_filter/sobel_part1'
Number of calls: 1
Cycle latency: 3,392,549
SW/HW co-simulation: PASS
make[1]: Leaving directory '/cygdrive/c/Users/marse/Documents/SmartHLS/Sobel_filter/sobel_part1'

06:12:41 Build Finished (took 1m:12s.115ms)


512 x 512 ピクセルの画像なので、262,144 ピクセル。
3,392,549 / 262,144 ≒ 12.94 クロック/ピクセルだった。

次に ModelSim の波形付き SW/HW Co-Simulation icon をやってみよう。
これは、メニューから選ぶ必要があるようだ。
SmartHLS メニューから SW/HW Co-Simulation with Waveforms を選択した。
ModelSim が起動して、最後に”“Are you sure you want to finish?”のダイアログが出る。No ボタンをクリックしないと ModelSim が終了してしまう。
SmartHLS_33_211212.png

波形を UnDock した。
全体の波形を示す。(ModelSim の使い方をまだ覚えているっぽい)
SmartHLS_34_211212.png

波形を拡大した。
Read は a, b 両方、つまり 2 チャンネル使用しているが、Write は a のみで 1 チャンネルのみ使用しているようだ。
SmartHLS_35_211212.png

Synthesize Hardware to FPGA (RTLsynthesis, place and route, for resource timing and results)(Ctrl+shift+V) アイコンをクリックする。
SmartHLS は Libero を起動して、論理合成、配置配線して、リソースやタイミング結果を表示してくれるようだ。
SmartHLS_36_211212.png

summay.result.rpt を示す。

==================================================================
=====  Summary Report for RTL Simulation and FPGA Synthesis  =====
==================================================================

Project name: sobel_part1
FPGA Vendor: MICROSEMI
Device Family: SmartFusion2
Device: M2S010-VF256

Table of Contents
  1. Simulation Cycle Latency
  2. Timing Result
  3. Resource Usage


====== 1. Simulation Cycle Latency ======

Number of calls:           1
Cycle latency:     3,392,549
SW/HW co-simulation: PASS

====== 2. Timing Result ======

+--------------+---------------+-------------+-------------+----------+-------------+
| Clock Domain | Target Period | Target Fmax | Worst Slack | Period   | Fmax        |
+--------------+---------------+-------------+-------------+----------+-------------+
| clk          | 10.000 ns     | 100.000 MHz | 6.457 ns    | 3.543 ns | 282.247 MHz |
+--------------+---------------+-------------+-------------+----------+-------------+

The reported Fmax is for the HLS core in isolation (from Libero's post-place-and-route timing analysis).
When the HLS core is integrated into a larger system, the system Fmax may be lower depending on the critical path of the system.

====== 3. Resource Usage ======

+--------------------------+---------------+-------+------------+
| Resource Type            | Used          | Total | Percentage |
+--------------------------+---------------+-------+------------+
| Fabric + Interface 4LUT* | 685 + 0 = 685 | 12084 | 5.67       |
| Fabric + Interface DFF*  | 430 + 0 = 430 | 12084 | 3.56       |
| I/O Register             | 0             | 414   | 0.00       |
| User I/O                 | 0             | 138   | 0.00       |
| RAM64x18                 | 0             | 22    | 0.00       |
| RAM1K18                  | 0             | 21    | 0.00       |
| MACC                     | 0             | 22    | 0.00       |
+--------------------------+---------------+-------+------------+

* Interface 4LUTs and DFFs are occupied due to the uses of MACC, RAM1K18, and RAM64x18.
  Number of interface 4LUTs/DFFs = (36 * #.MACC) + (36 * #.RAM1K18) + (36 * #.RAM64x18) = (36 * 0) + (36 * 0) + (36 * 0) = 0.


FMax は 282.247 MHz だそうだ。結構速い。
  1. 2021年12月12日 08:00 |
  2. SmartHLS
  3. | トラックバック:0
  4. | コメント:0

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう4

”Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう3”の続き。

Microchip 社の Libero SoC の高位合成ツール SmartHLS の sobel_tutorial をやってみようと思うということで、前回は、ソフトウェアからハードウェアへのコンパイルを行った。今回は、Schedule Viewer を起動して、機能を確認した。

Launch Schedule Viewer アイコンをクリックして、Schedule Viewer を起動した。
SmartHLS_26_211211.png

Schedule Viewer- scheduling.hls.rpt ダイアログが表示された。
Control Flow Graph タブをクリックして、Control-Flow Graph を表示している。
SmartHLS_27_211211.png

BB_ と先頭についた 8 個の基本ブロックからできている。

Call Graph タブをクリックした。
SmartHLS_28_211211.png

もう一度、Control Flow Graph タブをクリックして、Control-Flow Graph に戻って、BB_for_cond14_preheader をダブルクリックした。
SmartHLS_29_211211.png

すると、Schedule Chart タブが選択された。
真ん中のペインが命令で、右端のペインが命令のスケジュールを示す。
SmartHLS_30_211211.png

水色のスケジュールにマウスを置くと、マウスを置いたスケジュールが黄色くなって、その命令の入力が赤の枠で囲まれ、出力がオレンジの枠で囲まれる。
SmartHLS_31_211211.png

Schedule Viewer を閉じた。
  1. 2021年12月11日 04:15 |
  2. SmartHLS
  3. | トラックバック:0
  4. | コメント:0

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう3

”Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう2”の続き。

Microchip 社の Libero SoC の高位合成ツール SmartHLS の sobel_tutorial をやってみようと思うということで、前回は、SmartHLS の実行手順をチュートリアルで確認し、C シミュレーションを行った。今回は、ソフトウェアからハードウェアへのコンパイルを行った。

Compile Software to Hardware ボタンをクリックして、ソフトウェアからハードウェアへのコンパイルを行った。
しかし、エラーになってしまった。
SmartHLS_22_211210.png

原因は、SmartFusion2 FPGA チップの型番が間違っていたからのようだ。

[LegupConfig.cpp:2173: checkValidPart] Error: Could not find SmartFusion2 part number: 'M2S010-VFG256'
[LegupConfig.cpp:2173: checkValidPart] Error: SmartHLS has exited due to an error. Please contact smarthls@microchip.com for more details.


SmartFusion2 SoC”で確認したところ、パッケージが VFG256 じゃなくて VF256 のようだ。
SmartHLS 2021.2 の SmartHLS メニューから Set Target FPGA を選択した。
Set Target FPGA ダイアログが表示された。
M2S010-VFG256 を M2S010-VF256 に変更した。
SmartHLS_23_211210.png

これでもう一度、Compile Software to Hardware ボタンをクリックして、ソフトウェアからハードウェアへのコンパイルを行った。
SmartHLS_24_211210.png

今度は成功した。
summary.hls.rpt を示す。

// ----------------------------------------------------------------------------
// Smart High-Level Synthesis Tool Version 2021.2
// Copyright (c) 2015-2021 Microchip Technology Inc. All Rights Reserved.
// For support, please contact: smarthls@microchip.com
// Date: Fri Dec 10 04:22:39 2021
// ----------------------------------------------------------------------------

SmartHLS Summary Report for Project: sobel_part1.

Table of Contents
  1. RTL Interface
  2. Scheduling Result
  3. Pipeline Result
  4. Memory Usage
  5. Accelerator Information
  6. Resource Binding with Adaptive Latency


====== 1. RTL Interface ======

+------------------------------------------------------------------------------------+
| RTL Interface Generated by SmartHLS                                                |
+----------+----------------+------------------+------------------+------------------+
| C++ Name | Interface Type | Signal Name      | Signal Bit-width | Signal Direction |
+----------+----------------+------------------+------------------+------------------+
|          | Control        | clk              | 1                | input            |
|          |                | finish           | 1                | output           |
|          |                | ready            | 1                | output           |
|          |                | reset            | 1                | input            |
|          |                | start            | 1                | input            |
+----------+----------------+------------------+------------------+------------------+
| in       | Memory         | in_address_a     | 18               | output           |
|          |                | in_address_b     | 18               | output           |
|          |                | in_clken         | 1                | output           |
|          |                | in_read_data_a   | 8                | input            |
|          |                | in_read_data_b   | 8                | input            |
|          |                | in_read_en_a     | 1                | output           |
|          |                | in_read_en_b     | 1                | output           |
+----------+----------------+------------------+------------------+------------------+
| out      | Memory         | out_address_a    | 18               | output           |
|          |                | out_address_b    | 18               | output           |
|          |                | out_clken        | 1                | output           |
|          |                | out_write_data_a | 8                | output           |
|          |                | out_write_data_b | 8                | output           |
|          |                | out_write_en_a   | 1                | output           |
|          |                | out_write_en_b   | 1                | output           |
+----------+----------------+------------------+------------------+------------------+

The Verilog top-level module ports that are not listed in the above table are unused. Please tie the unused input ports to 0.

====== 2. Scheduling Result ======

Please use SmartHLS's schedule viewer to examine the schedule.

Basic Block Latencies:

+-------------------------------------------------+
| Function: sobel_filter (non-pipelined function) |
+--------------------------------+----------------+
| Basic Block                    | Cycle Latency  |
+--------------------------------+----------------+
| %entry                         | 1              |
| %for.cond1.preheader           | 1              |
| %for.body3                     | 2              |
| %for.body3.for.inc54_crit_edge | 1              |
| %for.cond14.preheader          | 9              |
| %for.inc54                     | 2              |
| %for.inc57                     | 1              |
| %for.end59                     | 1              |
+--------------------------------+----------------+

====== 3. Pipeline Result ======

No pipeline is generated.

====== 4. Memory Usage ======

+----------------+
| Local Memories |
+----------------+
| None           |
+----------------+

+-------------------------+
| Local Constant Memories |
+-------------------------+
| None                    |
+-------------------------+

+-----------------------+
| Shared Local Memories |
+-----------------------+
| None                  |
+-----------------------+

+------------------+
| Aliased Memories |
+------------------+
| None             |
+------------------+

+------------------------------------------------------------------------+
| I/O Memories                                                           |
+------+-----------------------+------+-------------+------------+-------+
| Name | Accessing Function(s) | Type | Size [Bits] | Data Width | Depth |
+------+-----------------------+------+-------------+------------+-------+
| in   | sobel_filter          | ROM  | 0           | 8          | 0     |
| out  | sobel_filter          | RAM  | 0           | 8          | 0     |
+------+-----------------------+------+-------------+------------+-------+


====== 5. Accelerator Information ======

No accelerator function is generated.

====== 6. Resource Binding with Adaptive Latency ======

Binding to resource with adaptive latency is disabled.
You can enable this feature by setting config parameter 'ADAPTIVE_LATENCY_BINDING' to 1.


コンパイルされた sobel_part1.vhd を示す。
VHDL ファイルは sobel_filter_top コンポーネントを呼び出すだけで、メインの HDL 記述は Verilog HDL の方にあるようだ。

-- ----------------------------------------------------------------------------
-- Smart High-Level Synthesis Tool Version 2021.2
-- Copyright (c) 2015-2021 Microchip Technology Inc. All Rights Reserved.
-- For support, please contact: smarthls@microchip.com
-- Date: Fri Dec 10 04:22:39 2021
-- ----------------------------------------------------------------------------

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;


library work;
use work.legup_types_pkg.all;
entity sobel_filter_top_vhdl is
port (
                 i_clk  :   in  std_logic;
               i_reset  :   in  std_logic;
               i_start  :   in  std_logic;
               o_ready  :   out std_logic;
              o_finish  :   out std_logic;
            o_in_clken  :   out std_logic;
        o_in_read_en_a  :   out std_logic;
        o_in_address_a  :   out std_logic_vector(17 downto 0);
      i_in_read_data_a  :   in  std_logic_vector(7 downto 0);
        o_in_read_en_b  :   out std_logic;
        o_in_address_b  :   out std_logic_vector(17 downto 0);
      i_in_read_data_b  :   in  std_logic_vector(7 downto 0);
           o_out_clken  :   out std_logic;
      o_out_write_en_a  :   out std_logic;
    o_out_write_data_a  :   out std_logic_vector(7 downto 0);
       o_out_read_en_a  :   out std_logic;
       o_out_address_a  :   out std_logic_vector(17 downto 0);
     i_out_read_data_a  :   in  std_logic_vector(7 downto 0);
      o_out_write_en_b  :   out std_logic;
    o_out_write_data_b  :   out std_logic_vector(7 downto 0);
       o_out_read_en_b  :   out std_logic;
       o_out_address_b  :   out std_logic_vector(17 downto 0);
     i_out_read_data_b  :   in  std_logic_vector(7 downto 0)
);
end sobel_filter_top_vhdl;

architecture behavior of sobel_filter_top_vhdl is

component sobel_filter_top
port (
                 clk    :   in  std_logic;
               reset    :   in  std_logic;
               start    :   in  std_logic;
               ready    :   out std_logic;
              finish    :   out std_logic;
            in_clken    :   out std_logic;
        in_read_en_a    :   out std_logic;
        in_address_a    :   out std_logic_vector(17 downto 0);
      in_read_data_a    :   in  std_logic_vector(7 downto 0);
        in_read_en_b    :   out std_logic;
        in_address_b    :   out std_logic_vector(17 downto 0);
      in_read_data_b    :   in  std_logic_vector(7 downto 0);
           out_clken    :   out std_logic;
      out_write_en_a    :   out std_logic;
    out_write_data_a    :   out std_logic_vector(7 downto 0);
       out_read_en_a    :   out std_logic;
       out_address_a    :   out std_logic_vector(17 downto 0);
     out_read_data_a    :   in  std_logic_vector(7 downto 0);
      out_write_en_b    :   out std_logic;
    out_write_data_b    :   out std_logic_vector(7 downto 0);
       out_read_en_b    :   out std_logic;
       out_address_b    :   out std_logic_vector(17 downto 0);
     out_read_data_b    :   in  std_logic_vector(7 downto 0)
);
end component;

begin


sobel_filter_top_inst : sobel_filter_top
port map (
                   clk  =>  i_clk,
                 reset  =>  i_reset,
                 start  =>  i_start,
                 ready  =>  o_ready,
                finish  =>  o_finish,
              in_clken  =>  o_in_clken,
          in_read_en_a  =>  o_in_read_en_a,
          in_address_a  =>  o_in_address_a,
        in_read_data_a  =>  i_in_read_data_a,
          in_read_en_b  =>  o_in_read_en_b,
          in_address_b  =>  o_in_address_b,
        in_read_data_b  =>  i_in_read_data_b,
             out_clken  =>  o_out_clken,
        out_write_en_a  =>  o_out_write_en_a,
      out_write_data_a  =>  o_out_write_data_a,
         out_read_en_a  =>  o_out_read_en_a,
         out_address_a  =>  o_out_address_a,
       out_read_data_a  =>  i_out_read_data_a,
        out_write_en_b  =>  o_out_write_en_b,
      out_write_data_b  =>  o_out_write_data_b,
         out_read_en_b  =>  o_out_read_en_b,
         out_address_b  =>  o_out_address_b,
       out_read_data_b  =>  i_out_read_data_b
);


end behavior;


sobel.cpp が

void sobel_filter(unsigned char in[HEIGHT][WIDTH],
unsigned char out[HEIGHT][WIDTH]);

で引数が 2 次元配列 なので、sobel_part1.vhd がメモリ・アクセスになっているようだが、2 ポートあるのはなぜだろうか?

Verilog HDL は 1041 行あった。
SmartHLS_25_211210.png
  1. 2021年12月10日 06:03 |
  2. SmartHLS
  3. | トラックバック:0
  4. | コメント:0

Zynq UltraScale+ MPSoC の I2C ペリフェラルの使用方法

MicroZed Chronicles: Kria & Raspberry Pi Camera”+ガウシアンフィルタ+メディアンフィルタ+ソーベルフィルタを ikzwm さんの Debian 11 で動作させるために、Zynq UltraScale+ MPSoC の I2C ペリフェラルの使用方法を学ぶ必要が出てきた。ここで、”Zynq UltraScale+ MPSoC TRM 457 UG1085 (v1.4) 2017 年 2 月 2 日”の 458 ページの”第 22 章 I2C コントローラー”を見て、勉強していこう。

Zynq UltraScale+ MPSoC TRM 457 UG1085 (v1.4) 2017 年 2 月 2 日”の 458 ページから引用。
I2C コントローラーの機能について
•プロセッシング システム (PS) は次の機能を持つ I2C デバイ ス をサポート し ています。
• I2C バス規格 Ver. 2
• 16 バイ ト FIFO をサポート
• プログラム可能な通常/高速バス データ レート
• マルチマス ターをサポー ト
• マスター モード
 ° 書き込み転送
 ° 読み出し転送
 ° 拡張アドレス をサポート
 ° プロセッサの処理が低速な場合、 HOLD を許可する こ と によ りクロック ストレッチをサポート
 ° ストールを防ぐための TO 割り込みフラグをサポート
 ° リピート スタートをサポート
 ° スレーブ モニター モー ド
• ス レーブ モード
 ° スレーブ トランスミッター
 ° スレーブ レシーバー
 ° 完全にプ ロ グ ラ ム可能な ス レーブ応答ア ド レ ス
 ° オーバーフ ロー条件を防ぐための HOLD をサポー ト
 ° ストールを防ぐための TO 割 り 込みフ ラ グをサポート
 ° データがすぐに利用でき ない場合、クロックストレッチによ り 通信を遅らせる こ と が可能
• ソフトウェアでステータス をポー リ ングするか、 割り込みで駆動 されるデバイ ス と し て動作
• プログラム可能な割り込み生成

Zynq UltraScale+ MPSoC の I2C ペリフェラルなので、MIO に SDA, SCL を出力するか、もしくは EMIO で PL 経由で SDA, SCL を出力する。

Zynq UltraScale+ MPSoC TRM 457 UG1085 (v1.4) 2017 年 2 月 2 日”の図 22‐2: I2C モジ ュールのブロ ッ ク図を引用する。
Zynq_MPSoC_1_211209.png

I2C モジュールは、インターフェースは APB で、 4 個のレジスタ・セットを持っている。Control FSM と Clock Enable Generator, RX Shift Register を持っている。

Zynq UltraScale+ MPSoC TRM 457 UG1085 (v1.4) 2017 年 2 月 2 日”の 462 ページの”表 22‐2: I2C レジス タの概要”と”表 22‐3: I2C レジスタのまとめ”を引用する。
Zynq_MPSoC_2_211209.png

MicroZed Chronicles: Kria & Raspberry Pi Camera”の helloworld.c のコードに

XIicPs_SetSClk(&iic_cam, IIC_SCLK_RATE);

がある。これは、”Zynq UltraScale+ MPSoC TRM 457 UG1085 (v1.4) 2017 年 2 月 2 日”の”表 22‐29: I2C CLK の取得”の様に設定しているものと思われる。
”表 22‐29: I2C CLK の取得”を引用する。
Zynq_MPSoC_3_211209.png

実際のクロック値 = (入力クロック / (22U x (Div_a + 1U) x (Div_b + 1U))
  1. 2021年12月09日 06:35 |
  2. Zynq UltraScale+ MPSoC
  3. | トラックバック:0
  4. | コメント:0

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう2

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう1”の続き。

Microchip 社の Libero SoC の高位合成ツール SmartHLS の sobel_tutorial をやってみようと思うということで、前回は、Github の MicrochipTech/fpga-hls-examples を Download Zip して、SmartHLS 2021.2 で sobel_part1 プロジェクトを作成した。今回は、SmartHLS の実行手順をチュートリアルで確認し、C シミュレーションを行った。

SmartHLS™ Tutorial for Microchip PolarFire®: Sobel Filtering for Image Edge Detection Revision 3.0 June 2021”の 10 ページを引用する。
SmartHLS_15_211208.png
SmartHLS_16_211208.png

”Figure 11: SmartHLS Design Flow Steps”によると、高位合成ツールとしては同じような工程をたどって HDL コードを合成するようだ。
SmartHLS は、C でのシミュレーションの後、制約を追加するのだろうか?

SmartHLS™ Tutorial for Microchip PolarFire®: Sobel Filtering for Image Edge Detection Revision 3.0 June 2021”の 11 ページからを見ていく。
sobel.cpp を見ると、”void sobel_filter()”の下に、”#pragma HLS function top”が書いてあるが、これが合成する最上位関数ということだ。下に別に main() 関数があるので、C シミュレーションは、そこからスタートする。
SmartHLS_17_211208.png

input.h には、グレースケール 8 ビットの 512 x 512 ピクセルの画像の数値が”unsigned char elaine_512_input[512][512]”に記述されている。
SmartHLS_18_211208.png

output.h には、ソーベル・フィルタをかけたデータと比較するため”unsigned char elaine_512_golden_output[512][512]”が用意されている。
SmartHLS_19_211208.png

それでは、C シミュレーションを行う。
Compile Software ボタンをクリックして、コンパイルした。
SmartHLS_20_211208.png

Run Software ボタンをクリックして、コンパイルしたソフトウェアを実行した。
PASS!と表示された。
SmartHLS_21_211208.png
  1. 2021年12月08日 04:51 |
  2. SmartHLS
  3. | トラックバック:0
  4. | コメント:0

Microchip 社の高位合成ツール SmartHLS の sobel_tutorial をやってみよう1

Microchip 社の Libero SoC の高位合成ツール SmartHLS の sobel_tutorial をやってみようと思う。
SmartHLS™ Tutorial for Microchip PolarFire®: Sobel Filtering for Image Edge Detection Revision 3.0 June 2021”を参考にやってみよう。

最初に、Github の MicrochipTech/fpga-hls-examples を Download Zip した。
fpga-hls-examples-main.zip がダウンロードできて、展開すると fpga-hls-examples-main フォルダが生成できた。
SmartHLS_1_211207.png

fpga-hls-examples-main フォルダの下に sobel_tutorial フォルダがあって、その下に part1, part2, part3 がある。
SmartHLS_2_211207.png

SmartHLS を起動した。
Eclipse Launcher が起動した。
Workspace を設定して OKボタンをクリックする。
SmartHLS_3_211207.png

SmartHLS が起動した。
SmartHLS_4_211207.png

新規プロジェクトを作成する。
Fileメニューから New -> SmartHLS C/C++ Project を選択する。
SmartHLS_5_211207.png

New Project ダイアログが表示された。
Project name に sobel_part1 と入力する。
New SmartHLS Project が選択されている。
Next>ボタンをクリックする。
SmartHLS_6_211207.png

次の画面で、Add Files ボタンをクリックして、ファイルを追加する。
SmartHLS_7_211207.png

fpga-hls-examples-main/sobel_tutorial/part1 フォルダの input.h, output.h, sobel.cpp を選択する。
”開く”ボタンをクリックする。
SmartHLS_8_211207.png

3 つのファイルが追加される。
Next>ボタンをクリックする。
SmartHLS_9_211207.png

Test Bench は sobel.cpp に入っているので、デフォルトのまま、Next>ボタンをクリックする。
SmartHLS_10_211207.png

Choose target FPGA device 画面で、FPGA Family に SmartFusion2 、FPGA Device に Custom Device, Custom Device に M2S010-VFG256 を選択する。
(2021/12/10:追記M2S010-VFG256 じゃなくて M2S010-VF256 を設定する必要がある。
Finish ボタンをクリックする。
SmartHLS_11_211207.png

sobel_part1 プロジェクトが生成された。
SmartHLS_12_211207.png

最初に、SmartHLS を起動したので、ツールのパスを設定する。
SmartHLS メニューから Tool Path Settings を選択する。
SmartHLS_13_211207.png

Set Path to Tool Executable Files ダイアログが表示された。
デフォルトのままで問題なさそうなので、OKボタンをクリックする。
SmartHLS_14_211207.png
  1. 2021年12月07日 05:14 |
  2. SmartHLS
  3. | トラックバック:0
  4. | コメント:0

”MicroZed Chronicles: Kria & Raspberry Pi Camera”+ガウシアンフィルタ+メディアンフィルタ+ソーベルフィルタを ikzwm さんの Debian 11 で動作させる3

”MicroZed Chronicles: Kria & Raspberry Pi Camera”+ガウシアンフィルタ+メディアンフィルタ+ソーベルフィルタを ikzwm さんの Debian 11 で動作させる2”の続き。

ガウシアン・フィルタとメディアン・フィルタを”MicroZed Chronicles: Kria & Raspberry Pi Camera”のブロック・デザインに追加する2”を ikzwm さんの Debian 11 で動作させてみたいということで、前回は、それらのデバイス・ツリーをロードして、UIO と U-DMA-BUF についての情報を確認した。今回は、fpga/examples/Kria_PCAM ディレクトリの下に build ディレクトリを作成し、Vitis HLS で作成した IP のドライバをコピーして、Makefile を作成し、 display_port_appn.cpp を試作した。
なお、元ネタは Adam Taylor さんの”MicroZed Chronicles: Kria & Raspberry Pi Camera”だ。

fpga/examples/Kria_PCAM ディレクトリの下に build ディレクトリを作成した。
cd ~/examples/Kria_PCAM
mkdir build
cd build


gaussian_filter, median_filter, sobel_fitler 各 IP のドライバを ~/examples/Kria_PCAM/build ディレクトリに SFTP でアップロードした。
kira_PCAM_gm_30_211206.png

display_port_appn.cpp を新規作成した。
kira_PCAM_gm_31_211206.png

現在の ~/examples/Kria_PCAM/build ディレクトリの様子を示す。
kira_PCAM_gm_32_211206.png

u-dma-buf だけ設定する display_port_appn.cpp を作成した。
kira_PCAM_gm_33_211206.png

// display_port_appn.cpp
// 2021/12/06 by marsee
//

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>

#include "xgaussian_filter_axis.h"
#include "xmedian_filter_axis.h"
#include "xsobel_filter_axis.h"

int main(){
    XGaussian_filter_axis gfilter_ap;
    XMedian_filter_axis mfilter_ap;
    XSobel_filter_axis sfilter_ap;
    volatile unsigned int *udmabuf4_buf;
    int udmabuf4_fd, fd_phys_addr;
    char  attr[1024];
    unsigned long  phys_addr;
    int Xdma_status;
    int i;
    
    // udmabuf4
    udmabuf4_fd = open("/dev/udmabuf4", O_RDWR); // frame_buffer, The chache is enabled. 
    if (udmabuf4_fd == -1){
        fprintf(stderr, "/dev/udmabuf4 open error\n");
        exit(-1);
    }
    udmabuf4_buf = (volatile unsigned int *)mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, udmabuf4_fd, 0);
    if (!udmabuf4_buf){
        fprintf(stderr, "udmabuf4_buf mmap error\n");
        exit(-1);
    }

    // phys_addr of udmabuf4
    fd_phys_addr = open("/sys/class/u-dma-buf/udmabuf4/phys_addr", O_RDONLY);
    if (fd_phys_addr == -1){
        fprintf(stderr, "/sys/class/u-dma-buf/udmabuf4/phys_addr open error\n");
        exit(-1);
    }
    read(fd_phys_addr, attr, 1024);
    sscanf(attr, "%lx", &phys_addr);  
    close(fd_phys_addr);
    printf("phys_addr = %x\n", (int)phys_addr);

    return(0);
}


Makefile を作成した。
kira_PCAM_gm_34_211206.png

# Makefile(display_port_appn)
# Referred to http://www.ie.u-ryukyu.ac.jp/~e085739/c.makefile.tuts.html

PROGRAM = display_port_appn
OBJS = display_port_appn.o xgaussian_filter_axis_linux.o xgaussian_filter_axis.o xmedian_filter_axis_linux.o xmedian_filter_axis.o xsobel_filter_axis_linux.o xsobel_filter_axis.o

CC = gcc
CFLAGS = -Wall -O2

.SUFFIXES: .c .o

.PHONY: all

all: display_port_appn

display_port_appn: $(OBJS)
    $(CC) -Wall -o $@ $(OBJS)
    
.c.o:
    $(CC) $(CFLAGS) -c $<

    
.PHONY: clean
clean:
    $(RM) $(PROGRAM) $(OBJS)


make
kira_PCAM_gm_35_211206.png
kira_PCAM_gm_36_211206.png

dispaly_port_appn アプリケーションが作成された。
kira_PCAM_gm_37_211206.png

前回から KV260 を停止しているので、パッケージをロードする。
cd ~/examples/KriaPCAM/
sudo mkdir /config/device-tree/overlays/fpga
sudo cp fpga-load_pcam.dtb /config/device-tree/overlays/fpga/dtbo
sudo mkdir /config/device-tree/overlays/fclk0
sudo cp fclk0-zynqmp.dtb /config/device-tree/overlays/fclk0/dtbo
sudo mkdir /config/device-tree/overlays/kria_pcam
sudo cp kria_pcam.dtb /config/device-tree/overlays/kria_pcam/dtbo
sudo chmod 666 /dev/uio*
sleep 1
sudo chmod 666 /dev/udmabuf*
ls -la /dev/uio*
ls -la /dev/udmabuf*

kira_PCAM_gm_38_211206.png

./display_port_appn
でアプリケーションを起動した。

phys_addr = 70600000

が表示された。成功だ。
kira_PCAM_gm_39_211206.png
  1. 2021年12月06日 05:29 |
  2. KRIA KV260 Vision AI Starter Kit
  3. | トラックバック:0
  4. | コメント:0

Microchip の Libero SoC 2021.2 と SmartHLS 2021.2 をインストールした

Microchip のサイトは見ている場所によってページが変わるのか?家で見るとなんか状況が変わっているようで、インストール方法を再現して書くことができないのだが、インストール方法は”Microsemi 開発環境構築”を見ると良いと思う。
正式なインストールガイドは”UG9124 Software Installation and LicensingGuide Libero SoC May 2020”を参照のこと。

なお、Libero SoC 2021.2 をインストールすると、SmartHLS 2021.2 も同時にインストールすることができる。
ライセンスは、”Microsemi 開発環境構築”にも書いてあるが Silver ライセンスが無料のライセンスだ。

Libero SoC 2021.2 の起動画面を示す。
Libero_SoC_1_211205.png

SmartHLS 2021.2 の起動画面を示す。
Eclipse のようだ。
Libero_SoC_2_211205.png

これでHello FPGA のプロジェクトを作成できそうだ。

Libero SoCのマニュアルは”User Guides and Manuals - Libero SoC v2021.2”にある。

SmartHLS User Guide

Libero SoC チュートリアルビデオ

SmartHLS™ Tutorial for Microchip PolarFire®: Sobel Filtering for Image Edge Detection Revision 3.0 June 2021

MicrochipTech/fpga-hls-examples” SmartHLS のチュートリアル用ファイル

M2S-HELLO-FPGA-KITのリソースサイト
  1. 2021年12月05日 05:06 |
  2. Libero SoC
  3. | トラックバック:0
  4. | コメント:0

”MicroZed Chronicles: Kria & Raspberry Pi Camera”+ガウシアンフィルタ+メディアンフィルタ+ソーベルフィルタを ikzwm さんの Debian 11 で動作させる2

”MicroZed Chronicles: Kria & Raspberry Pi Camera”+ガウシアンフィルタ+メディアンフィルタ+ソーベルフィルタを ikzwm さんの Debian 11 で動作させる1”の続き。

ガウシアン・フィルタとメディアン・フィルタを”MicroZed Chronicles: Kria & Raspberry Pi Camera”のブロック・デザインに追加する2”を ikzwm さんの Debian 11 で動作させてみたいということで、前回は、各種デバイス・ツリーを作成し、コンパイルした。今回は、それらのデバイス・ツリーをロードして、UIO と U-DMA-BUF についての情報を見ていこう。
なお、元ネタは Adam Taylor さんの”MicroZed Chronicles: Kria & Raspberry Pi Camera”だ。

bin ファイルを /lib/firmware/ にコピーする。
cd ~/examples/Kria_PCAM/
sudo cp kria_pcam.bin /lib/firmware/
ls -l /lib/firmware/kria_pcam.bin

kira_PCAM_gm_26_211204.png

fpgaをコンフィグレーションした。
sudo mkdir /config/device-tree/overlays/fpga
sudo cp fpga-load_pcam.dtb /config/device-tree/overlays/fpga/dtbo

fclk0-zynqmp.dtb をロードした。
sudo mkdir /config/device-tree/overlays/fclk0
sudo cp fclk0-zynqmp.dtb /config/device-tree/overlays/fclk0/dtbo

kria_pcam.dtb をロードした。
sudo mkdir /config/device-tree/overlays/kria_pcam
sudo cp kria_pcam.dtb /config/device-tree/overlays/kria_pcam/dtbo

kira_PCAM_gm_27_211204.png

シリアル・コンソールの表示を示す。
kira_PCAM_gm_28_211204.png

[   36.166845] systemd-journald[150]: File /var/log/journal/fa5ba2ddbe3544a08d55124c9fe30f95/user-1000.journal corrupted or uncleanly shut down, renaming and replacing.
[   83.274161] fpga_manager fpga0: writing kria_pcam.bin to Xilinx ZynqMP FPGA Manager
[   83.751378] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /fpga-full/firmware-name
[  137.382921] fclkcfg: loading out-of-tree module taints kernel.
[  137.390050] zynqmp_clk_divider_set_rate() set divider failed for pl0_ref_div1, ret = -13
[  137.398320] fclkcfg axi:fclk0: driver version : 1.7.2
[  137.403376] fclkcfg axi:fclk0: device name    : axi:fclk0
[  137.408771] fclkcfg axi:fclk0: clock  name    : pl0_ref
[  137.413995] fclkcfg axi:fclk0: clock  rate    : 99999999
[  137.419319] fclkcfg axi:fclk0: clock  enabled : 1
[  137.424028] fclkcfg axi:fclk0: remove rate    : 1000000
[  137.429247] fclkcfg axi:fclk0: remove enable  : 0
[  137.433941] fclkcfg axi:fclk0: driver installed.
[  154.037650] u-dma-buf udmabuf4: driver version = 3.2.4
[  154.042851] u-dma-buf udmabuf4: major number   = 242
[  154.047840] u-dma-buf udmabuf4: minor number   = 0
[  154.052632] u-dma-buf udmabuf4: phys address   = 0x0000000070600000
[  154.058900] u-dma-buf udmabuf4: buffer size    = 1048576
[  154.064210] u-dma-buf axi:kria_pcam-udmabuf4: driver installed.


ls -la で uio と udmabuf を見た。
uioは 0 から 12 まで実装されていた。
ls -la /dev/uio*
ls -la /dev/udmabuf*

kira_PCAM_gm_29_211204.png

/sys/class/uio を見ると
uio4 の name が axi_intc-uio
uio5 の name が axi_vdma-uio
uio6 の name が gaussian_filter_axis-uio
uio7 の name が median_filter_axis-uio
uio8 の name が mipi_csi2_rx_subsyst-uio
uio9 の name が sobel_filter_axis-uio
uio10 の name が v_demosaic-uio
uio11 の name が v_gamma_lut-uio
uio12 の name が v_tc-uio
だった。
  1. 2021年12月04日 13:27 |
  2. KRIA KV260 Vision AI Starter Kit
  3. | トラックバック:0
  4. | コメント:0

”MicroZed Chronicles: Kria & Raspberry Pi Camera”+ガウシアンフィルタ+メディアンフィルタ+ソーベルフィルタを ikzwm さんの Debian 11 で動作させる1

DMA_pow2_test の Vivado 2021.2 プロジェクトを ikzwm さんの Debian 11 で動作させることができた。
次は、”ガウシアン・フィルタとメディアン・フィルタを”MicroZed Chronicles: Kria & Raspberry Pi Camera”のブロック・デザインに追加する2”を ikzwm さんの Debian 11 で動作させてみたい。
なお、元ネタは Adam Taylor さんの”MicroZed Chronicles: Kria & Raspberry Pi Camera”だ。

まずは、パソコンで kria_pcam.bin を作成する。
Kira_PCAM/Vitis/vitis_work/kria_n/hw ディレクトリに design_1_wrapper.bif を作成した。
design_1_wrapper.bif を示す。

all:
{
    [destination_device = pl] design_1_wrapper.bit
}


bootgen で bin ファイルに変換する。
bootgen -image design_1_wrapper.bif -arch zynqmp -w -o kria_pcam.bin
kira_PCAM_gm_18_211202.png
kria_pcam.bin が生成された。

次は、KV260 の Debian 11 での作業となる。
KV260 の fpga/examples ディレクトリに Kria_PCAM ディレクトリを作成した。
cd examples
mkdir Kria_PCAM
cd Kria_PCAM

Kria_PCAM ディレクトリに fpga_load_pcam.dts を作成した。
fpga_load_pcam.dts を示す。
kira_PCAM_gm_20_211203.png

/dts-v1/;
/ {
    fragment@0 {
        target-path = "/fpga-full";
        __overlay__ {
            firmware-name = "kria_pcam.bin";
        };
    };
};


Kria_PCAM ディレクトリに clk0-zynqmp.dts を作成した。
clk0-zynqmp.dts を示す。
kira_PCAM_gm_19_211203.png

/dts-v1/;/plugin/;
/ {
    fragment@0 {
        target-path = "/axi";
        __overlay__ {
            fclk0 {
                compatible    = "ikwzm,fclkcfg-0.10.a";
                clocks        = <&zynqmp_clk 0x47>;
                insert-rate   = "100000000";
                insert-enable = <1>;
                remove-rate   = "1000000";
                remove-enable = <0>;
            };
        };
    };
};


Kria_PCAM ディレクトリに kria_pcam.dts を作成した。
kria_pcam.dts を示す。
kira_PCAM_gm_21_211203.png

/dts-v1/;/plugin/;
/ {
    fragment@0 {
        target-path = "/axi";
        #address-cells = <2>;
        #size-cells = <2>;

        __overlay__ {
            #address-cells = <2>;
            #size-cells = <2>;

            axi_intc-uio {
                compatible = "generic-uio";
                reg = <0x0 0x00A0010000 0x0 0x10000>;
            };
            
            axi_vdma-uio {
                compatible = "generic-uio";
                reg = <0x0 0x00A0020000 0x0 0x10000>;
            };
            
            gaussian_filter_axis-uio {
                compatible = "generic-uio";
                reg = <0x0 0x00A0070000 0x0 0x10000>;
            };
            
             median_filter_axis-uio {
                compatible = "generic-uio";
                reg = <0x0 0x00A0080000 0x0 0x10000>;
            };
            
             mipi_csi2_rx_subsyst-uio {
                compatible = "generic-uio";
                reg = <0x0 0x00A0000000 0x0 0x1000>;
            };
            
             sobel_filter_axis-uio {
                compatible = "generic-uio";
                reg = <0x0 0x00A0060000 0x0 0x10000>;
            };
            
            v_demosaic-uio {
                compatible = "generic-uio";
                reg = <0x0 0x00A0030000 0x0 0x10000>;
            };
            
             v_gamma_lut-uio {
                compatible = "generic-uio";
                reg = <0x0 0x00A0040000 0x0 0x10000>;
            };
            
             v_tc-uio {
                compatible = "generic-uio";
                reg = <0x0 0x00A0050000 0x0 0x10000>;
            };
            
            kria_pcam-udmabuf4 {
                compatible  = "ikwzm,u-dma-buf";
                device-name = "udmabuf4";
                size = <0x00100000>;
            };
        };
    };
};


ホスト・パソコンから kria_pcam.bin を SFTP して持ってきた。
kira_PCAM_gm_22_211203.png

各 dts ファイルを dtc でコンパイルした。
dtc -I dts -O dtb -o fpga-load_pcam.dtb fpga_load_pcam.dts
dtc -I dts -O dtb -o fclk0-zynqmp.dtb fclk0-zynqmp.dts
dtc -I dts -O dtb -o kria_pcam.dtb kria_pcam.dts

kira_PCAM_gm_23_211203.png
kira_PCAM_gm_24_211203.png

dtb ファイルが生成された。
kira_PCAM_gm_25_211203.png
  1. 2021年12月03日 04:58 |
  2. KRIA KV260 Vision AI Starter Kit
  3. | トラックバック:0
  4. | コメント:0
»