VIETNAM NATIONAL UNIVERSITY HO CHI MINH CITY HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY FACULTY OF COMPUTER SCIENCE AND ENGINEERING CAPSTONE PROJECT AN AI ACCELERATOR ON A RISC-V SYSTEM-ON-CHIP MAJOR: COMPUTER ENGINEERING THESIS COMMITTEE: COMPUTER ENGINEERING 1 SUPERVISOR: Assoc. TRAN NGOC THINH REVIEWER: Assoc. PHAM QUOC CUONG STUDENT 1: NGUYEN LY DANG KHOA (1952785) STUDENT 2: LE NGUYEN TAN LOC (1952088) Ho Chi Minh City, 12/2023 1 ĐẠI HỌC QUỐC GIA TP.HCM CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM TRƯỜNG ĐẠI HỌC BÁCH KHOA Độc lập - Tự do - Hạnh phúc KHOA:KH & KT Máy tính NHIỆM VỤ LUẬN VĂN/ ĐỒ ÁN TỐT NGHIỆP BỘ MÔN:KTMT Chú ý: Sinh viên phải dán tờ này vào trang nhất của bản thuyết trình HỌ VÀ TÊN: Nguyễn Lý Đăng Khoa MSSV: 1952785 HỌ VÀ TÊN: Lê Nguyễn Tân Lộc MSSV: 1952088 NGÀNH: Kỹ thuật Máy tính LỚP: 1. Đầu đề luận văn/ đồ án tốt nghiệp: An AI accelerator in a RISC-V System-on-Chip (Xây dựng Bộ tăng tốc AI trong Hệ thống trên chip RISC-V) 2.
Nhiệm vụ (yêu cầu về nội dung và số liệu ban đầu): • Study RISC-V architecture • Study simulation software, and reconfigurable RISC-V SOCs on FPGA platforms • Survey research works, algorithms on AI, and machine learning can be ported to RISC-V system-on-chip • Implement a suitable RISC-V SOC on FPGA platforms • Implement a suitable AI accelerator on RISC-V SOC • Compare with other implementations • Test with a simple application. Ngày giao nhiệm vụ: 28/08/2023 4. Ngày hoàn thành nhiệm vụ: 01/01/2024 5. Họ tên giảng viên hướng dẫn: Phần hướng dẫn: 1) PGS.
Trần Ngọc Thịnh Nội dung và yêu cầu LVTN/ ĐATN đã được thông qua Bộ môn. CHỦ NHIỆM BỘ MÔN GIẢNG VIÊN HƯỚNG DẪN CHÍNH (Ký và ghi rõ họ tên) (Ký và ghi rõ họ tên) PGS. Trần Ngọc Thịnh PHẦN DÀNH CHO KHOA, BỘ MÔN: Người duyệt (chấm sơ bộ): Đơn vị: Ngày bảo vệ: Điểm tổng kết: Nơi lưu trữ LVTN/ĐATN: TRƯỜNG ĐẠI HỌC BÁCH KHOA CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM KHOA KH & KT MÁY TÍNH Độc lập - Tự do - Hạnh phúc ---------------------------- Ngày 02 tháng 01 năm 2024 PHIẾU ĐÁNH GIÁ LUẬN VĂN/ ĐỒ ÁN TỐT NGHIỆP (Dành cho người hướng dẫn/phản biện) 1. Họ và tên SV1: Nguyễn Lý Đăng Khoa MSSV1: 1952785 Ngành (chuyên ngành): KTMT Họ và tên SV2: Lê Nguyễn Tân Lộc MSSV1: 1952088 Ngành (chuyên ngành): KTMT 2.
Đề tài: An AI accelerator in a RISC-V System-on-Chip (Xây dựng Bộ tăng tốc AI trong Hệ thống trên chip RISC-V) 3. Họ tên người hướng dẫn: Assoc. Trần Ngọc Thịnh 4. Tổng quát về bản thuyết minh: Số trang: 132 Số chương: 7 Số bảng số liệu: 33 Số hình vẽ: 89 Số tài liệu tham khảo: 18 Phần mềm tính toán: Hiện vật (sản phẩm) 5.
Những ưu điểm chính của LV/ ĐATN: Study and implement a suitable SOC RISC-V architecture, named CVA5-SOC Study and implement a suitable AI accelerator that can accelerate CNN deep learning model processing based on hardware pipeline/parallel capabilities, in addition to quantizing data from 32-bit to 8-bit to save resources and optimize memory access. Integrate AI Accelerator core into SOC CVA5 into CVA5-Vector-SOC system based on instruction extension capability of CVA5, build appropriate translation and training software for the entire system; The system's testing with the MNIST dataset demonstrates an accuracy of up to 97.37%, surpassing the CVA5-SOC system's performance by over 9. Notably, it achieves this with an 8.6 times reduction in resource utilization and a 2.3 times decrease in energy consumption. Những thiếu sót chính của LV/ĐATN: The system is not well optimized in terms of resource consumption.
The system has not been implemented on the Zedboard FPGA board yet. The system has not been compared and evaluated with other implementations. The system has not been tested with some simple IoTs applications. Đề nghị: Được bảo vệ Bổ sung thêm để bảo vệ Không được bảo vệ 8.
Các câu hỏi SV phải trả lời trước Hội đồng: 9. Đánh giá chung (bằng chữ: Xuất sắc, Giỏi, Khá, TB): Fair Good (khá) Điểm : 7/10 Ký tên (ghi rõ họ tên) Trần Ngọc Thịnh TRƯỜNG ĐẠI HỌC BÁCH KHOA CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM KHOA KH & KT MÁY TÍNH Độc lập - Tự do - Hạnh phúc ---------------------------- Ngày 02 tháng 01 năm 2024 PHIẾU ĐÁNH GIÁ LUẬN VĂN/ ĐỒ ÁN TỐT NGHIỆP (Dành cho người phản biện) 2. Họ và tên SV: - Nguyễn Lý Đăng Khoa 1952785 Computer Engineering - Lê Nguyễn Tân Lộc 1952088 Computer Engineering 2. Đề tài: An AI accelerator in a RISC-V System-on-Chip (Xây dựng Bộ tăng tốc AI trong hệ thống trên chip RISC-V) 3.
Họ tên người hướng dẫn/phản biện: Phạm Quốc Cường 4. Tổng quát về bản thuyết minh: Số trang: Số chương: Số bảng số liệu Số hình vẽ: Số tài liệu tham khảo: Phần mềm tính toán: Hiện vật (sản phẩm) 5. Những ưu điểm chính của LV/ ĐATN: - The students have designed and implemented the proposed vector processing module with RTL model and sucessfully integrated it into a RISC-V processor - The system is simulated correctly and tested with a dataset 6. Những thiếu sót chính của LV/ĐATN: - The system has not yet been tested with a real FPGA board.
Hence, the soundness and correctness of the system has not been validated yet. - With simulation only, the accuracy, power consumption, etc., results cannot be used for comparing with other implementations and it makes the system less reliability. Đề nghị: Được bảo vệ x Bổ sung thêm để bảo vệ □ Không được bảo vệ □ 8. Các câu hỏi SV phải trả lời trước Hội đồng: 9.
Đánh giá chung (bằng chữ: Xuất sắc, Giỏi, Khá, TB): Điểm: 6/10 Ký tên (ghi rõ họ tên) Phạm Quốc Cường Protestation We hereby declare that except where specific reference is made to the work of others, the contents of this dissertation are original and have not been submitted in whole or in part for any other degree or qualification in any other university. This dissertation is our own work and contains nothing which is the outcome of work done in collaboration with others, except as specified in the text and Acknowledgements. Ho Chi Minh University of Technology, December 2023, Project author Nguyen Ly Dang Khoa Le Nguyen Tan Loc Computer Engineering Capstone Project (CO4347) Page 7 Acknowlegdement We would like to express our special thanks of gratitude to our teacher Assoc. Tran Ngoc Thinh who gave us the opportunity to do this wonderful project on the topic of An AI accelerator in a RISC-V System- on-Chip.
Without their help and guidance, this project would not have been possible. We would also like to thank all the teachers of Ho Chi Minh City Univer- sity of Technology and the Faculty of Computer Science and Engineering, who have taught us many valuable and important lessons, knowledge and experiences while studying at the university. Last of all, we gave our thanks to our parents, and friends who helped support us finishing this project on time Page 8 Faculty of Computer Science and Engineering Abstract With the current advancement of semiconductor technology, the need for fast prototyping to showcase proof of concept for new architectures of CPU cores has led to a wide adoption of deploying soft cores on Field- programmable gate array (FPGA) boards. Along with this, the RISC-V in- struction specification fills the need of an open-source Instruction Set Ar- chitecture (ISA) that enables independent CPU cores development, which was once under the exclusive control of major CPU instruction set own- ers such as Intel (with X86) or ARM (with ARM).
RISC-V has evolved over years from a research project at UC Berkeley in 2010 to a RISC-V Founda- tion and the RISC-V ISA has been adopted by many companies for nu- merious applications, from microcontroller and embedded systems to high-performance computing and data center processors. In the field of machine learning, RISC-V provides a vector instruction set specification, which supports element wise parallel computing, this is the key advan- tage of vector operations over the scalar operations that helps to acceler- ate the computation processes of machine learning algorithm. In this project, we implement our custom vector instructions based on the standard vector extension of RISC-V onto a RISC-V soft core namely CVA5, with the aim to accelerate matrix operations of neural network inference activities. The FPGA board in use is the Zedboard.
We approached the project by integrating our design of vector processing units into the CVA5 architecture. The reason for this approach is because of the nature of the CVA5 core, which provides interfaces for additional processing units inte- gration. With this approach, the result yields the total speedup of approx- imately 10 times faster than the scalar core while the area increases by 8 times. The power consumption increases by 1.4012 time compared with the original scalar core.
Computer Engineering Capstone Project (CO4347) Page 9 Page 10 Faculty of Computer Science and Engineering Contents 1 Project Introduction 21 1.3 Aims and Objectives .3 Project Execution Step. 25 2 Theoretical Background and CVA5 Overview 27 2.1 Deep learning Introduction .2 Convolutional Neural Network .2 Neural Network Model Quantization .1 Quantization of Neral Network Model .2 Operation for Quantization .3 RISC-V Instruction Set Architecture .1 RISC-V Instruction Set .3 The need for Vector Instruction in Accelerating AI .4 The need for RISC-V SoC on FPGA .5 Single Instruction Single Data vs Single Instruction Multiple Data .4 On choosing CVA5 core for implementation .5 CVA5 Core General Architecture .1 A Minimal RISC-V Vector Processor for Embedded Systems .2 RISC-V vector processor for acceleration of machine learning algo- rithms .2 Vector Arithmetic Unit .1 A Minimal RISC-V Vector Processor for Embedded Systems .3 Vector Register File .1 A Minimal RISC-V Vector Processor for Embedded Systems. 51 4 Vector Instructions Specification 53 4.1 Vector Control/Status Instructions. 53 Computer Engineering Capstone Project (CO4347) Page 11 4.2 Vector Arithmetic and Data transfer Instructions .3 Vector Load/Store Instruction Specification.
57 5 Vector processing unit design and integration into CVA5 59 5.1 Overall CVA5 vector supporting architecture .2 Pre-issue vector instruction processing .1 Vector Renamer Architecture .2 Vector Register File Architecture .3 Vector processing at Execution Stage .1 Vector ALU Unit .2 Vector Multiplier Unit .3 Vector Compare Unit .4 Vector Load/Store Unit .5 Vector CSRs Unit .4 Vector processing at Writeback Stage .5 Design and Integration Conclusion .1 Project Hardware Design .2 Project Software Design. 99 7 Result and Evaluation 109 7.2 Implementation of CVA5-Vector Core .3 Implementation of CVA5-SoC and CVA5-Vector-SoC .1 Implementation of CVA5-SoC .2 Implementation of CVA5-Vector-SoC .4 Implementation of CVA5-Vector-SoC on Zedboard .1 Convolution Layer Testing .2 Max Pooling Layer Testing .3 Fully-connected Layer Testing .4 Full CNN Model Testing .1 Overall work summary .2 Bottle neck and potential improvement. 130 Page 12 Faculty of Computer Science and Engineering List of Figures 1.1 Semico Research Prediction [15] .1 A CNN is composed of an input layer, an output layer, and many hidden layers in between .2 Overview of training and inference in deep learning.1 RISC-V Foundation Official Logo [11] .2 Comparison of Single Instruction Single Data (SISD) and Single Instruc- tion Multiple Data (SIMD).1 CVA5 Processor Pipeline Details and Components.1 CVA5 Pipeline Decoupling [3] .2 CVA5 simplified structural view[3] .3 CVA5 Pipeline Stages [3] .4 Store queue forwarding illustration .5 Register File block diagram .6 Renamer block diagram .1 A Minimal RISC-V Vector Processor for Embedded Systems Architecture .2 RISC-V Vector Processor for acceleration of machine learning algorithms Architecture .1 A Minimal RISC-V Vector Processor for Embedded Systems Vector ALUs Unit .1 Illustration of VLEN and SEW in use.2 Illustration of LMUL in use.1 Vector supporting CVA5 architecture .1 Vector renamer block diagram .