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

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)

相关推荐
星霜笔记2 小时前
Docker 部署 MariaDB+phpMyAdmin+Nextcloud 完整教程
运维·数据库·docker·容器·mariadb
阿珊和她的猫3 小时前
v-scale-scree: 根据屏幕尺寸缩放内容
开发语言·前端·javascript
fouryears_234175 小时前
Flutter InheritedWidget 详解:从生命周期到数据流动的完整解析
开发语言·flutter·客户端·dart
我好喜欢你~6 小时前
C#---StopWatch类
开发语言·c#
lifallen7 小时前
Java Stream sort算子实现:SortedOps
java·开发语言
IT毕设实战小研7 小时前
基于Spring Boot 4s店车辆管理系统 租车管理系统 停车位管理系统 智慧车辆管理系统
java·开发语言·spring boot·后端·spring·毕业设计·课程设计
wyiyiyi7 小时前
【Web后端】Django、flask及其场景——以构建系统原型为例
前端·数据库·后端·python·django·flask
天宇_任8 小时前
Mysql数据库迁移到GaussDB注意事项
数据库·mysql·gaussdb
cui__OaO8 小时前
Linux软件编程--线程
linux·开发语言·线程·互斥锁·死锁·信号量·嵌入式学习
鱼鱼说测试9 小时前
Jenkins+Python自动化持续集成详细教程
开发语言·servlet·php