Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Auto Sync] Sync with ZH repo 25-08-2024 #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions 0.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,18 @@ Since it requires Internet accessing, it may cost some time to finish.

<!-- > #### info::Unmet dependencies问题
> 如果在运行`apt-get update`时报告Unmet dependencies的问题, 可尝试将上述阿里源更换成清华源:
> ```

> bash -c 'echo "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse" > /etc/apt/sources.list'
> ```

> 然后重新执行`apt-get update`.
>
> 若问题仍然出现, 可尝试搜索互联网并更换其他源. -->

> #### info::Unmet dependencies issues
> If you see problems with Unmet dependencies when running `apt-get update`, try replacing the above Ali sources with Tsinghua sources:
> ```

> bash -c 'echo "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse" > /etc/apt/sources.list'
> ```

> Then re-run `apt-get update`.
>
> If the problem persists, try searching the internet and changing to another source.
Expand All @@ -141,8 +141,8 @@ apt-get install gdb # GNU debugger
apt-get install git # revision control system
apt-get install libreadline-dev # a library used later
apt-get install libsdl2-dev # a library used later
apt-get install llvm llvm-dev # llvm project, which contains libraries used later
apt-get install llvm-11 llvm-11-dev # only for ubuntu20.04
> #### info::AM的API文档
> 我们在这里给出[AM的API文档][am api doc], 如果你希望了解这些API的严格定义, 可以RTFM.
```
The usage of these tools is explained later.

Expand Down
66 changes: 33 additions & 33 deletions 0.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,51 +232,51 @@ make
```
If nothing goes wrong, NEMU will be compiled successfully.

<!-- > #### comment::确认llvm版本
> 若编译时遇到如下错误:
> ```
> src/utils/disasm.cc:37:2: error: #error Please use LLVM with major version >= 11
> ```
> 请输入`llvm-config --version`查看llvm的版本, 确认其为11或以上的版本.
> 特别地, 若你使用的发行版为Ubuntu 20.04, 可手动通过`apt-get install llvm-11 llvm-11-dev`安装llvm-11,
> 然后进行如下改动来指定使用llvm-11的版本:
> ```diff
> diff --git a/nemu/src/utils/filelist.mk b/nemu/src/utils/filelist.mk
> index c9b1708..b7b2e02 100644
> --- a/nemu/src/utils/filelist.mk
> +++ b/nemu/src/utils/filelist.mk
> @@ -16,5 +16,5 @@
> ifdef CONFIG_ITRACE
<!--
[am api doc]: https://jyywiki.cn/AbstractMachine/AM_Spec.md

<!-- -->

> 我们把开源社区的一些RISC-V指令测试集移植到AM:
> * https://github.com/NJU-ProjectN/riscv-tests-am
> * https://github.com/NJU-ProjectN/riscv-arch-test-am
diff
> 如果你选择了RISC-V指令集, 你可以通过这些测试集来测试你的指令实现是否正确.
> 克隆相应仓库后, 可通过类似运行`cpu-tests`的方式来运行这些测试集,
> 详细命令可参考相应的`README.md`.

然后调用[capstone项目][capstone]提供的反汇编功能(在`nemu/src/utils/disasm.c`中实现).
[capstone]: https://github.com/capstone-engine/capstone/
> CXXSRC = src/utils/disasm.cc
> -CXXFLAGS += $(shell llvm-config --cxxflags) -fPIE
> -LIBS += $(shell llvm-config --libs)
> +CXXFLAGS += $(shell llvm-config-11 --cxxflags) -fPIE
> +LIBS += $(shell llvm-config-11 --libs)
> endif
> ```

> 若你使用的是其它发行版, 请自行寻找解决方案. -->
> #### comment::Verify the llvm version
> If the following error is encountered during compilation:
> ```
> src/utils/disasm.cc:37:2: error: #error Please use LLVM with major version >= 11
> ```

<!-- -->

> Please type `llvm-config --version` to check the version of llvm, make sure it is 11 or above.
> In particular, if you are using Ubuntu 20.04, you can install llvm-11 manually via `apt-get install llvm-11 llvm-11-dev`.
> Then make the following change to specify the version of llvm-11 to be used.
> ```diff
> diff --git a/nemu/src/utils/filelist.mk b/nemu/src/utils/filelist.mk
> index c9b1708..b7b2e02 100644
> --- a/nemu/src/utils/filelist.mk
> +++ b/nemu/src/utils/filelist.mk
> @@ -16,5 +16,5 @@
> ifdef CONFIG_ITRACE
diff
> 如果你选择了RISC-V指令集, 你可以通过这些测试集来测试你的指令实现是否正确.
> 克隆相应仓库后, 可通过类似运行`cpu-tests`的方式来运行这些测试集,
> 详细命令可参考相应的`README.md`.

然后调用[capstone项目][capstone]提供的反汇编功能(在`nemu/src/utils/disasm.c`中实现).
[capstone]: https://github.com/capstone-engine/capstone/
> CXXSRC = src/utils/disasm.cc
> -CXXFLAGS += $(shell llvm-config --cxxflags) -fPIE
> -LIBS += $(shell llvm-config --libs)
> +CXXFLAGS += $(shell llvm-config-11 --cxxflags) -fPIE
> +LIBS += $(shell llvm-config-11 --libs)
> endif
> ```

> If you are using a different distribution, please find your own solution.

> #### question::What happened?
Expand Down Expand Up @@ -385,9 +385,9 @@ If the error message above always appears, please contact us as soon as possible

<!-- > #### comment::我不是修读本课程的学生, 是否能够关闭开发跟踪?
> 可进行如下修改关闭开发跟踪:
> ```diff
diff
> diff --git a/Makefile b/Makefile
> index c9b1708..b7b2e02 100644
> 克隆相应仓库后, 可通过类似运行`cpu-tests`的方式来运行这些测试集,
> --- a/Makefile
> +++ b/Makefile
> @@ -9,6 +9,6 @@
Expand All @@ -401,13 +401,13 @@ If the error message above always appears, please contact us as soon as possible
> +# -@(echo "> $(1)" && echo $(STUID) $(STUNAME) && uname -a && uptime) | git commit -F - $(GITFLAGS)
> +# -@sync
> endef
> ``` -->
-->

> #### comment::I am not a student in this cohort, can I turn off development trace?
> The following modifications can be made to turn off the development trace:
> ```diff
diff
> diff --git a/Makefile b/Makefile
> index c9b1708..b7b2e02 100644
> 克隆相应仓库后, 可通过类似运行`cpu-tests`的方式来运行这些测试集,
> --- a/Makefile
> +++ b/Makefile
> @@ -9,6 +9,6 @@
Expand All @@ -421,7 +421,7 @@ If the error message above always appears, please contact us as soon as possible
> +# -@(echo "> $(1)" && echo $(STUID) $(STUNAME) && uname -a && uptime) | git commit -F - $(GITFLAGS)
> +# -@sync
> endef
> ```


### Local Commit

Expand Down
48 changes: 24 additions & 24 deletions 2.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,40 +422,40 @@ Taking `recursion` from `cpu-tests` as an example, some sample output from ftrac

<!-- > #### question::冗余的符号表
> 在Linux下编写一个Hello World程序, 然后使用`strip`命令丢弃可执行文件中的符号表:
> ```bash
bash
> gcc -o hello hello.c
> strip -s hello
> ```

> 用`readelf`查看hello的信息, 你会发现符号表被丢弃了, 此时的hello程序能成功运行吗?
>
> 目标文件中也有符号表, 我们同样可以丢弃它:
> ```bash
bash
> gcc -c hello.c
> strip -s hello.o
> ```

> 用`readelf`查看hello.o的信息, 你会发现符号表被丢弃了. 尝试对hello.o进行链接:
> ```bash
bash
> gcc -o hello hello.o
> ```

> 你发现了什么问题? 尝试对比上述两种情况, 并分析其中的原因. -->

> #### question::Redundant symbol tables
> Write a Hello World program under Linux, and then use the `strip` command to strip the symbol table in the executable:
> ```bash
bash
> gcc -o hello hello.c
> strip -s hello
> ```

> If you look at hello program with `readelf`, you'll see that the symbol table has been stripped, so can the hello program run successfully?
>
> There is also a symbol table in the object file, which we can strip as well.
> ```bash
bash
> gcc -c hello.c
> strip -s hello.o
> ```

> Look at the information for hello.o with `readelf`, and you'll see that the symbol table has been stripped. Try linking to hello.o:
> ```bash
bash
> gcc -o hello hello.o
> ```

> What problems did you find? Try to compare the two situations and analyze the reasons behind it.

<!-- > #### comment::trace与性能优化
Expand Down Expand Up @@ -882,9 +882,9 @@ As we introduced in PA1, NEMU is a full-system emulator. We can consider other f
> 我们在龙芯杯比赛中继承了这套思想, 把用verilog/chisel写的CPU作为DUT,
> 用已经实现好的NEMU作为REF, 很快就可以发现并修复verilog/chisel中的bug.
> 借助DiffTest, 我们在第二届龙芯杯大赛中书写了
> ```

> 一周正确实现一个全乱序执行处理器, 并在上面运行自制分时多任务操作系统Nanos和复杂应用程序仙剑奇侠传
> ```

> 的[神话][nscscc2018].
>
> 另一个体现DiffTest强大的例子是2020年7月的一个热门话题,
Expand Down Expand Up @@ -917,9 +917,9 @@ As we introduced in PA1, NEMU is a full-system emulator. We can consider other f
>
> Of course, the granularity of the DiffTest introduced here is much more detailed: we don't just compare the results of the program execution, but the behavior of each instruction. This can help us quickly find and locate bugs in the implementation of instructions. We inherited this idea in the LoongArch competition, using the CPU written in verilog/chisel as the DUT, and the implemented NEMU as the REF, we can quickly find and fix the bugs in verilog/chisel. With the help of DiffTest, we achieved the [epic][nscscc2018] that
>
> ```

> Implement a full out-of-order processor correctly and run your own time-sharing multitasking operating system, Nanos. Then run a complex application, Chinese paladin, on it.
> ```

>
> Another example of the power of DiffTest is a hot topic in July 2020, when five undergraduates from the Chinese Academy of Sciences graduated with their own processor chip designs. Under the guidance of a team of faculty members, the students used DiffTest to perform online comparisons of their processor designs with NEMU, successfully booting Linux and running the Busybox in 5 days, and booting Debian and running complex applications such as GCC and QEMU in 4 days.
> Students also presented at the[crvs2020][crvs2020]([video][crvs2020 video], [slide][crvs2020 slide])
Expand Down Expand Up @@ -1021,21 +1021,21 @@ apt-get install device-tree-compiler

<!-- > #### hint::忽略编译Spike过程中的如下信息
> 以下信息不影响Spike的编译结果, 你可以忽略它们.
> ```

> Makefile:349: warning: overriding recipe for target 'disasm.o'
> Makefile:349: warning: ignoring old recipe for target 'disasm.o'
> make[2]: Circular libcustomext.so <- libcustomext.so dependency dropped.
> make[2]: Circular libsoftfloat.so <- libsoftfloat.so dependency dropped.
> ``` -->
-->

> #### hint::Ignore the following message during the compilation of Spike
> The following information does not affect the compilation result of Spike, you can ignore them.
> ```

> Makefile:349: warning: overriding recipe for target 'disasm.o'
> Makefile:349: warning: ignoring old recipe for target 'disasm.o'
> make[2]: Circular libcustomext.so <- libcustomext.so dependency dropped.
> make[2]: Circular libsoftfloat.so <- libsoftfloat.so dependency dropped.
> ```


[kvm]: https://www.linux-kvm.org/page/Main_Page
[qemu]: http://www.qemu.org
Expand Down Expand Up @@ -1210,11 +1210,11 @@ With the above command you can automatically run all the tests in `cpu-tests` in
> complexity, and languages: fundamentals of theoretical computer science"
> 一书中提出了一种仅有三种指令的程序设计语言L语言,
> 并且证明了L语言和其它所有编程语言的计算能力等价. L语言中的三种指令分别是:
> ```

> V = V + 1
> V = V - 1
> IF V != 0 GOTO LABEL
> ```

> 用x86指令来描述, 就是`inc`, `dec`和`jne`三条指令.
>
> 令人更惊讶的是, Martin Davis教授还证明了,
Expand Down Expand Up @@ -1255,11 +1255,11 @@ With the above command you can automatically run all the tests in `cpu-tests` in
> As you already know, a NEMU is a program that executes other programs. In computational theory, there is a special term for such a program, called a Universal Program, which means, in common parlance, that it can do what any other program can do. The existence of universal programs has been proved, and we won't go into it here, but the idea of universal programs is behind the fact that we can write NEMUs, do experiments with Docker/Virtual Machines, and even do all sorts of things on our computers: NEMUs and simulators are just instantiations of universal programs. It is not an exaggeration to say that a computer is a physical instance of a universal program. The existence of universal programs laid the theoretical foundation for the emergence of computers, and is an extremely important conclusion in computational theory. If the existence of a universal program is not proved, we cannot use computers with confidence, and we cannot say "the machine is always right". ``
>
> The NEMU we write will eventually be compiled into x86 machine code, using x86 instructions to simulate the execution of client instructions. In fact, in 1983, [Prof. Martin Davis] [martin davis] published a book entitled "Computability, complexity, and languages: fundamentals of theoretical computer science", L programming language, was proposed in the book, and it was shown that L is equivalent to all other programming languages. The three instructions in L are.
> ```

> V = V + 1
> V = V - 1
> IF V != 0 GOTO LABEL
> ```

> In terms of x86 instructions, these are `inc`, `dec` and `jne`.
>
> Even more surprisingly, Prof. Martin Davis proved that it is possible to write a general-purpose program similar to NEMU in L, without taking physical limitations into account (think of unlimited memory capacity, where each memory cell can hold an arbitrarily large number of numbers)! And the framework of this general purpose program written in L is similar to the `cpu_exec()` function in NEMU: fetch, decode, execute... This is not a coincidence, but an application of [simulation] [simulation] in computer science.
Expand Down