Git Product home page Git Product logo

rvcc-course's Introduction

rvcc-course

这里是RVCC课程的相关仓库,存放了课程相关的材料。

欢迎利用PR来对本仓库进行补充。

Q&A 问答

【1】 这个课程都需要准备什么东西?

  1. Linux的运行环境,推荐Ubuntu 20.04。
  2. RISC-V的实验环境(需要编译器和模拟器),如何安装参考问题【2】。
  3. 下载RVCC的仓库,即git clone https://github.com/sunshaoce/rvcc

【2】 如何安装RISCV的实验环境

三种方式,自由选择,新手推荐方式1.

方式一(推荐):解压预先编译好的RISCV环境(基于Ubuntu 20.04)

运行仓库的install-riscv-1.sh即可。

方式二:源代码编译RISCV环境(较难)。

这里我们编译出编译器gcc和模拟器qemu。直接使用本课程的install-riscv-2.sh脚本(请勿直接运行),使用方法参考视频:RISCV环境快速配置

方式三:使用配置好的Docker环境

详情可以参考:https://github.com/ksco/rvcc-env-docker

【3】 如何对RVCC中的项目使用make test

首先,你需要找到你RISCV实验环境的路径,方式一、二的路径为:~/riscv

其次,你需要将test.sh中的下面几行代码,选择为你对应的编译器和模拟器,例子如下方所示。

最后运行RISCV=~/riscv make test,注意这里的~/riscv必须是你RISCV实验环境的路径

方式一、二可以参考下面这个改法:

修改前:

  # 运行程序,传入期待值,将生成结果写入tmp.s汇编文件。
  # 如果运行不成功,则会执行exit退出。成功时会短路exit操作
  ./rvcc "$input" > tmp.s || exit
  # 编译rvcc产生的汇编文件
  clang -o tmp tmp.s
  # $RISCV/bin/riscv64-unknown-linux-gnu-gcc -static -o tmp tmp.s

  # 运行生成出来目标文件
  ./tmp
  # $RISCV/bin/qemu-riscv64 -L $RISCV/sysroot ./tmp
  # $RISCV/bin/spike --isa=rv64gc $RISCV/riscv64-unknown-linux-gnu/bin/pk ./tmp

修改后:

  # 运行程序,传入期待值,将生成结果写入tmp.s汇编文件。
  # 如果运行不成功,则会执行exit退出。成功时会短路exit操作
  ./rvcc "$input" > tmp.s || exit
  # 编译rvcc产生的汇编文件
  # clang -o tmp tmp.s
  $RISCV/bin/riscv64-unknown-linux-gnu-gcc -static -o tmp tmp.s

  # 运行生成出来目标文件
  # ./tmp
  $RISCV/bin/qemu-riscv64 -L $RISCV/sysroot ./tmp
  # $RISCV/bin/spike --isa=rv64gc $RISCV/riscv64-unknown-linux-gnu/bin/pk ./tmp

【4】 跳转脚本(可选)

感谢 @daquexian。

用法是把它复制到 rvcc 项目目录之后:

./jump.sh n 跳转到下一节课程 commit
./jump.sh p 跳转到上一节课程的 commit
./jump.sh <number> 跳转到第 number 节课程的 commit

不想污染 rvcc 目录的话也可以不复制,只要在 rvcc 目录下用正确的脚本路径运行就行。

rvcc-course's People

Contributors

changliuxy avatar daquexian avatar jiangshengdev avatar ksco avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.