1*05f23f57SWilliam Wang# XiangShan 264fc9c9dSZihao Yu 3*05f23f57SWilliam WangXiangShan is a processor targeting super-scalar out-of-order execution. 4*05f23f57SWilliam WangCurrently it supports riscv64GC. 564fc9c9dSZihao Yu 664fc9c9dSZihao Yu## Compile chisel code 764fc9c9dSZihao Yu 89b259174SZihao Yu* Install `mill`. Refer to [the Manual section in this guide][mill]. 99e38a5d4Slinjiawei* Run `make init` to init git submodules 1064fc9c9dSZihao Yu* Run `make` to generate verilog code. The output file is `build/TopMain.v`. 1164fc9c9dSZihao Yu 129b259174SZihao Yu[mill]: http://lihaoyi.com/mill#manual 1364fc9c9dSZihao Yu 1464fc9c9dSZihao Yu## Run programs by simulation 1564fc9c9dSZihao Yu 16*05f23f57SWilliam Wang### Prepare environment 17*05f23f57SWilliam Wang 18534f7036SZihao Yu* Set a new environment variable `NEMU_HOME` to the **absolute path** of the NEMU project. 19*05f23f57SWilliam Wang* Set a new environment variable `NOOP_HOME` to the **absolute path** of the XiangShan project. 2064fc9c9dSZihao Yu* Clone the [AM project](https://github.com/NJU-ProjectN/nexus-am.git). 2164fc9c9dSZihao Yu* Set a new environment variable `AM_HOME` to the **absolute path** of the AM project. 225c647eb5SZihao Yu* Add a new AM `riscv64-noop` in the AM project if it is not provided. 2364fc9c9dSZihao Yu 24*05f23f57SWilliam Wang### Verilator simulation 2564fc9c9dSZihao Yu 26*05f23f57SWilliam WangInstall verilator: 27*05f23f57SWilliam Wang 28*05f23f57SWilliam WangTBD 29*05f23f57SWilliam Wang 30*05f23f57SWilliam WangGenerate verilog files and compile them using verilator: 31*05f23f57SWilliam Wang* Move to project root, run `make emu` to compile verilator simulator. You can use `make emu config=CONFIG_NAME` to choose different size of XiangShan. 32*05f23f57SWilliam Wang* To speed up compiling, use `make emu REMOTE=YOUR_REMOTE_SERVER`. (If you have remote server setuped) 33*05f23f57SWilliam Wang 34*05f23f57SWilliam WangRun program generated by verilator: 35*05f23f57SWilliam Wang* If compile succeed, you can run the application in the AM project by `make ARCH=riscv64-noop run`. 36*05f23f57SWilliam Wang* Or you can run emulator and select image manually: `./build/emu -i PROGRAM_IMAGE` 37*05f23f57SWilliam Wang* Use parameters to control emulator behavior: `./build/emu [-b DUMP_BEGIN_TIME] [-e DUMP_END_TIME] [--force-dump-result] [--dump-wave] -i PROGRAM_IMAGE`. 38*05f23f57SWilliam Wang* Run `./build/emu` for further instructions. 39*05f23f57SWilliam Wang 40*05f23f57SWilliam WangExample: 41*05f23f57SWilliam Wang```makefile 42*05f23f57SWilliam Wangmake emu config=MinimalSimConfig 43*05f23f57SWilliam Wang./build/emu -b 0 -e 0 --force-dump-reult -i ./mem.bin 445c647eb5SZihao Yu``` 455c647eb5SZihao Yu 46*05f23f57SWilliam Wang`debug` dir provides some scripts for verilator simulation. 475c647eb5SZihao Yu 48*05f23f57SWilliam Wang### VCS simulation 495c647eb5SZihao Yu 50*05f23f57SWilliam WangMake sure you have VCS installed. 515c647eb5SZihao Yu 52*05f23f57SWilliam Wang* Run `make simv` to compile vcs simulator. 53*05f23f57SWilliam Wang* After that, run `./simv`