GitHub - riscv-software-src/riscv-isa-sim: Spike, a RISC-V ISA Simulator

ops/2025/1/16 10:22:54/

GitHub - riscv-software-src/riscv-isa-sim: Spike, a RISC-V ISA Simulator

操作手册

$ apt-get install device-tree-compiler libboost-regex-dev libboost-system-dev
$ mkdir build
$ cd build
$ ../configure --prefix=$RISCV
$ make
$ [sudo] make install

具体安装

安装依赖

sudo apt-get install device-tree-compiler libboost-regex-dev libboost-system-dev

安装gcc编译器

sudo apt install gcc-riscv64-unknown-elf

git clone下载源码

git clone https://githubfast.com/riscv-software-src/riscv-isa-sim

编译 

cd riscv-isa-sim
mkdir build
cd build
../configure --prefix=$RISCV
make -j 12
sudo make install

安装完成:

mkdir /include/softfloat
../scripts/mk-install-dirs.sh /include
for dir in fesvr       ; \do \../scripts/mk-install-dirs.sh /include/$dir; \/usr/bin/install -c -m 644 config.h /include/$dir; \done
make: Circular libriscv.so <- libriscv.so dependency dropped.
make: Circular libcustomext.so <- libcustomext.so dependency dropped.
make: Circular libsoftfloat.so <- libsoftfloat.so dependency dropped.
../scripts/mk-install-dirs.sh /lib
for file in libfesvr.a libriscv.so libdisasm.a libcustomext.so libsoftfloat.so; \do \/usr/bin/install -c -m 644 $file /lib; \done
../scripts/mk-install-dirs.sh /bin
for file in elf2hex spike spike-log-parser xspike termios-xspike spike-dasm; \do \/usr/bin/install -c -m 755 $file /bin; \done
../scripts/mk-install-dirs.sh /lib/pkgconfig/
mkdir /lib/pkgconfig
for file in riscv-fesvr.pc riscv-riscv.pc riscv-disasm.pc; \do \/usr/bin/install -c -m 644 $file /lib/pkgconfig/; \done

Compiling and Running a Simple C Program

Install spike (see Build Steps), riscv-gnu-toolchain, and riscv-pk.

Write a short C program and name it hello.c. Then, compile it into a RISC-V ELF binary named hello:

$ riscv64-unknown-elf-gcc -o hello hello.c

Now you can simulate the program atop the proxy kernel:

$ spike pk hello

Simulating a New Instruction

Adding an instruction to the simulator requires two steps:

  1. Describe the instruction's functional behavior in the file riscv/insns/<new_instruction_name>.h. Examine other instructions in that directory as a starting point.

  2. Add the opcode and opcode mask to riscv/opcodes.h. Alternatively, add it to the riscv-opcodes package, and it will do so for you:

     $ cd ../riscv-opcodes$ vi opcodes       // add a line for the new instruction$ make install
    
  3. Add the instruction to riscv/riscv.mk.in. Otherwise, the instruction will not be included in the build and will be treated as an illegal instruction.

  4. Rebuild the simulator.

调试

编译报错fatal error: stdio.h: No such file or directory

riscv64-unknown-elf-gcc -o hello hello.c
hello.c:1:10: fatal error: stdio.h: No such file or directory
    1 | #include <stdio.h>
      |          ^~~~~~~~~
compilation terminated.

没有解决

安装gcc-riscv64-linux-gnu试试

sudo apt install gcc-riscv64-linux-gnu

然后用这条命令:

riscv64-linux-gnu-gcc -o hello hello.c
skywalk@DESKTOP-9C5AU01:~/work$ file hello
hello: ELF 64-bit LSB pie executable, UCB RISC-V, RVC, double-float ABI, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-riscv64-lp64d.so.1, BuildID[sha1]=2fbc3940bdd6f61378b1a8629c6bac6f89b9aa41, for GNU/Linux 4.15.0, not stripped

编译成功!

运行spike pk hello报错could not open pk; searched paths:

spike pk hello
terminate called after throwing an instance of 'std::runtime_error'
  what():  could not open pk; searched paths:
        . (current directory)
        /riscv64-unknown-elf/bin/ (based on configured --prefix and --with-target)


http://www.ppmy.cn/ops/148979.html

相关文章

02.MPLS动态LSP配置实验

MPLS动态LSP配置实验 MPLS动态LSP配置实验基本配置MPLS部分查看LDP会话基本信息查看详细信息查看MPLS动态LSP配置实验 基本配置 接口地址和OSPF配置,省略!全网互通! 注意:8.8.8.8和9.9.9.9也要宣告! MPLS部分 [ar1]mpls lsr-id 1.1.1.1 [ar1]mpls Info: Mpls starting,…

【数据结构】线性表

线性表 线性表顺序表存储结构初始化在尾部添加元素遍历顺序表插入元素时间复杂度 删除元素查找元素动态分配内存地址初始化清空顺序表线性表的顺序存储形式&#xff08;顺序表&#xff09;有哪些很麻烦的地方&#xff1f; 链表链表存储结构单链表 线性表 由n&#xff08;n>0…

异构计算:边缘计算的未来引擎

随着物联网、5G和人工智能技术的快速发展&#xff0c;边缘计算正成为数字化转型的关键支撑。然而&#xff0c;边缘场景对计算平台提出了更高的要求&#xff1a;高性能、低功耗、实时性 和 灵活性 缺一不可。在这样的背景下&#xff0c;异构计算 逐渐成为边缘计算的核心技术方向…

反向代理模块。

1 概念 1.1 反向代理概念 反向代理是指以代理服务器来接收客户端的请求&#xff0c;然后将请求转发给内部网络上的服务器&#xff0c;将从服务器上得到的结果返回给客户端&#xff0c;此时代理服务器对外表现为一个反向代理服务器。 对于客户端来说&#xff0c;反向代理就相当于…

JetBrains IDEs和Visual Studio Code的对比

JetBrains IDEs和Visual Studio Code的对比 JetBrains IDEs是捷克JetBrains公司开发的一系列集成开发环境(IDE)。以下是具体介绍:IntelliJ IDEA是JetBrains 公司的一款产品 主要产品 IntelliJ IDEA:一款功能强大且广泛应用的Java集成开发环境,有开源免费的社区版和商业收…

(STM32笔记)十二、DMA的基础知识与用法 第三部分

我用的是正点的STM32F103来进行学习&#xff0c;板子和教程是野火的指南者。 之后的这个系列笔记开头未标明的话&#xff0c;用的也是这个板子和教程。 DMA的基础知识与用法 三、DMA程序验证1、DMA 存储器到存储器模式实验&#xff08;1&#xff09;DMA结构体解释&#xff08;2…

一.MySQL程序简介

整体介绍 1.服务端mysqld(可执行文件) mysqld --verbose --help 2.客户端mysql(可执行文件) 3.其它工具包程序

【机器遗忘之UNSIR算法】2023年IEEE Trans期刊论文:Fast yet effective machine unlearning

1 介绍 年份&#xff1a;2023 期刊&#xff1a;IEEE Transactions on Neural Networks and Learning Systems 引用量&#xff1a;170 Tarun A K, Chundawat V S, Mandal M, et al. Fast yet effective machine unlearning[J]. IEEE Transactions on Neural Networks and Le…