基于RISC-V自定义指令的数学函数的高效实现

邢根, 胡志远, 毕大炜

集成电路与嵌入式系统 ›› 2025, Vol. 25 ›› Issue (5) : 1-7.

PDF(1116 KB)
PDF(1116 KB)
集成电路与嵌入式系统 ›› 2025, Vol. 25 ›› Issue (5) : 1-7. DOI: 10.20193/j.ices2097-4191.2024.0089
封面文章

基于RISC-V自定义指令的数学函数的高效实现

作者信息 +

Efficient implementation of mathematical functions based on RISC-V custom instructions

Author information +
文章历史 +

摘要

在工业控制算法中,数学函数的计算往往需要大量的时钟周期,会影响算法的性能。本文对相关数学函数计算方法进行深入分析和方案对比,设计了一种适合硬件电路实现的基于Remez算法的分段查表多项式拟合方法来计算浮点数学函数,同时实现了相应的硬件电路以RISC-V自定义指令的方式与RISC-V处理器内核紧耦合。实验结果表明,与无自定义扩展指令相比,处理器计算数学函数的延迟减小了93.62%。相较于CORDIC指令集计算数学函数的方法,计算延迟减小了79.83%。这一成果为低成本、高实时性要求的RISC-V架构的嵌入式微处理器提供了新的思路和解决方案。

Abstract

In industrial control algorithms, the calculation of mathematical functions typically requires a large number of clock cycles, affecting the performance of the algorithms. This paper conducts an in-depth analysis and comparison of related methods for calculating floating mathematical functions, and designs a piecewise table lookup polynomial fitting method based on the Remez algorithm. This method is suitable for hardware circuit implementation to calculate mathematical functions. At the same time, the corresponding hardware circuits are implemented in the form of RISC-V custom instructions, closely coupled with the RISC-V processor core. The experimental results show that compared with no custom extension instructions, the processor's delay in calculating mathematical functions is reduced by 93.62%. Compared with the method of calculating mathematical functions using the CORDIC instruction set, the calculation delay is reduced by 79.83%. This achievement provides new ideas and solutions for RISC-V architecture embedded microprocessors with low-cost, high real-time requirements.

关键词

RISC-V / 软硬件协同优化 / 数学函数 / 分段多项式拟合 / 嵌入式系统

Key words

RISC-V / hardware-software co-optimization / mathematical functions / piecewise polynomial fitting / embedded system

引用本文

导出引用
邢根, 胡志远, 毕大炜. 基于RISC-V自定义指令的数学函数的高效实现[J]. 集成电路与嵌入式系统. 2025, 25(5): 1-7 https://doi.org/10.20193/j.ices2097-4191.2024.0089
XING Gen, HU Zhiyuan, BI Dawei. Efficient implementation of mathematical functions based on RISC-V custom instructions[J]. Integrated Circuits and Embedded Systems. 2025, 25(5): 1-7 https://doi.org/10.20193/j.ices2097-4191.2024.0089
中图分类号: TN492 (专用集成电路)   

参考文献

[1]
OBERMAN S F.Floating Point Division and Square Root Algorithms and Implementation in the AMD-K7 Microprocessor[C]// Proceedings 14th IEEE Symposium on Computer Arithmetic (Cat. No.99CB36336).IEEE, 2002. DOI:10.1109/ARITH.1999.762835.
[2]
李飞, 郭绍忠, 郝江伟, 等. 面向RISC-V的基础数学库实现[J]. 电子学报, 2024, 52(5):1633-1647.
LI F, GUO S Z, HAO J W, et al. Implementation of Basic Mathematical Library for RISC-V[J]. Acta Electronica Sinica, 2024, 52(5):1633-1647 (in Chinese).
[3]
吴昊, 刘楠, 丁朋, 等. 改进CORDIC算法实现及其在边缘检测中的应用[J]. 电子测量技术, 2023, 46(16):148-157.
WU H, LIU N, DING P, et al. Improved CORDIC Algorithm Implementation and Its Application in Edge Detection[J]. Electronic Measurement Technology, 2023, 46(16):148-157 (in Chinese).
[4]
胡雄龙, 陈进华, 乔海, 等. 跳跃迭代的高速高精COR-DIC算法及FPGA实现[J]. 计算机仿真, 2023, 40(10):365-370,398.
HU X L, CHEN J H, QIAO H, et al. High Speed and High-Precision CORDIC Algorithm with Jump Iteration and Its FPGA Implementation[J]. Computer Simulation, 2023, 40(10):365-370,398 (in Chinese).
[5]
侯强, 彭玉龙, 王育新, 等. 低时延CORDIC算法计算平方根电路设计研究[J]. 湖南大学学报(自然科学版), 2022, 49(2):111-116.
HOU Q, PENG Y L, WANG Y X, et al. Research on Low-Latency CORDIC Algorithm for Computing Square Root Circuit Design[J]. Journal of Hunan University (Natural Sciences), 2022, 49(2):111-116 (in Chinese).
[6]
程甜甜, 宋宇鲲. 基于FPGA的2底指数函数算法优化与实现[J]. 电子科技, 2023, 36(9):66-72.
CHENG T T, SONG Y K. Optimization and Implementation of 2-Base Exponential Function Algorithm Based on FPGA[J]. Electronic Science and Technology, 2023, 36(9):66-72 (in Chinese).
[7]
龙科莅, 汪东, 陈虎, 等. 基于Piecewise算法的反正切运算器的设计[J]. 计算机工程与科学, 2022, 44(8):1342-1348.
LONG K L, WANG D, CHEN H, et al. Design of Arctan Calculator Based on Piecewise Algorithm[J]. Computer Engineering and Science, 2022, 44(8):1342-1348 (in Chinese).
[8]
潘树朋, 刘有耀. RISC-V微处理器以及商业IP的综述[J]. 单片机与嵌入式系统应用, 2020, 20(6):5-8,12.
PAN S P, LIU Y Y. A Survey on RISC-V Microprocessors and Commercial IPs[J]. Microcontrollers & Embedded Systems, 2020, 20(6):5-8,12 (in Chinese).
[9]
郑添, 蔡刚, 黄志洪. 基于RISC-V架构的CORDIC指令集设计与实现[J]. 单片机与嵌入式系统应用, 2022, 22(8):20-23.
ZHENG T, CAI G, HUANG Z H. Design and Implementation of CORDIC Instruction Set Based on RISC-V Architecture[J]. Microcontrollers & Embedded Systems, 2022, 22(8):20-23 (in Chinese).
[10]
蒲清涛, 仵杰. 基于RISC-V架构MCU的永磁同步电机控制系统设计[J]. 电子制作, 2024, 32(21):18-22,27.
PU Q T, WU J. Design of Permanent Magnet Synchronous Motor Control System Based on RISC-V Architecture MCU[J]. Electronic Manufacturing, 2024, 32(21):18-22,27 (in Chinese).
[11]
王凯. 基于NPU张量加速单元的激活函数实现与验证技术研究[D]. 西安: 西安电子科技大学, 2023.
WANG K. Research on Implementation and Verification Technology of Activation Functions Based on NPU Tensor Acceleration Unit[D]. Xi'an: Xidian University, 2023 (in Chinese).
[12]
SADEGAN M, STINE J, WALTERS E. Optimized linear,quadratic,and cubic interpolators for elementary function hardware implementations[J]. Electronics, 2016, 5(2):17.

责任编辑: 薛士然
PDF(1116 KB)

Accesses

Citation

Detail

段落导航
相关文章

/