探索程序的编译和执行
- 编写c程序
- 使用不同汇编器编译c程序来生成不用的二进制文件
- 开发处理器核
- 研究不同汇编器编译的程序以及cpu使用不同方法实现的指令对程序执行的影响
- 设计汇编器
- 自定义指令架构
- 编译更加复杂的源程序
- 比较执行速率
- A machine---Used to upstall ubuntu
- A ubuntu(20.04) operating system---Used to upstall Google
- A google browser---Used to solve all problems
Find a directory that you like, then build your project directory.
mkdir paradise
cd paradise
echo export NOOP_HOME=$(pwd) >> ~/.bashrc
echo export AM_HOME=$(pwd)/abstract-machine >> ~/.bashrc
echo export NEMU_HOME=$(pwd)/NEMU >> ~/.bashrc
echo export DRAMSIM3_HOME=$(pwd)/DRAMsim3 >> ~/.bashrc
source ~/.bashrc
cd $NEMU_HOME
make menuconfig
make riscv64-xs-ref_defconfig
make -j4
cd $DRAMSIM3_HOME
mkdir build
cd build
cmake -D COSIM=1 ..
make -j4
cmake .. -DTHERMAL=1
After configuring the environment above, you will have some cross-compilers on your machine:
- mips32-nemu
- native
- riscv32-nemu
- riscv64-mycpu
- riscv64-nemu
- spike
- x86_64-qemu
- x86-nemu
- x86-qemu
A short of tests are provided in the am-kernels directory, starting your Compile_execute journey.
Such as:
cd $NOOP_HOME
cd am-kernels/tests/cpu-tests
make ARCH=riscv64-mycpu ALL=add
ARCH=the cross-compiler you want to use, ALL=the test name you want to compile
Only use ARCH argument will compile all of tests in pwd.
Then, you will find the binary file in the build directory.
After completing all of above step by step, you can run the test with your own CPU.
Such as:
cd $NOOP_HOME
make emu
./build/emu -i am-kernels/tests/cpu-tests/build/riscv64-mycpu/add-riscv64-mycpu.bin
Indicates that the test has passed after a HIT GOOD TRAP
is displayed on the terminal.
If your CPU is not right, you can see ABORT
or HIT BAD TRAP
.
Use Difftest to debug your CPU.