# NWPU-gem5-CSArch **Repository Path**: nwpu-ercesi/nwpu-gem5-csarch ## Basic Information - **Project Name**: NWPU-gem5-CSArch - **Description**: GEM5-based Computer Architecture Simulation Project with ARM ISA for Computer Arch Course (U10M11007.02) of NWPU. - **Primary Language**: Python - **License**: BSD-3-Clause - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 39 - **Forks**: 10 - **Created**: 2023-03-06 - **Last Updated**: 2025-08-05 ## Categories & Tags **Categories**: chips **Tags**: None ## README #+TITLE: CS Arch Lab of NWPU #+AUTHOR: Meng Zhang #+DATE: 2021-10-27 * Introduction This repo is for the course U10M11007 of NWPU, Computer Organization and Architecture, which partially supported by University-Industry Collaborative Education Program, Ministy of Education (Phytium-NWPU). Lab experiment includes: 1. ARM and RISCV Instructions & GEM5 2. Debugging Trace and stats 3. Cache Sub-System 4. ARM Software Flow with GEM5 SE 5. Out of Order Multi Instruction Parallelism * How to Use this repo This repo includes 5 labs, which focus processor architecture using open-source simulator GEM5. The experiment of GEM5 is docker based. #+BEGIN_COMMENT GitKraken is a very cool git client and can be download [here](http://10.69.47.7/owncloud/index.php/s/Fh3ZT8WsjredRR4). However, after update on 2019/06/19, private repository won't be allowed for free use anymore, please don't update. With the authority of the license, we recomand a GitHub academic accout, which can be applied on [GitHub Education](https://education.github.com/pack/join). On a more open free side, a totally open source program, [TortoiseGit](https://tortoisegit.org/download/) would be an alternative. #+END_COMMENT Firstly, just clone https://gitee.com/nwpu-ercesi/nwpu-gem5-csarch.git to your local folder. If you use Linux or BSP liked System (such as MacOS), just follow this command line #+begin_src shell git clone https://gitee.com/nwpu-ercesi/nwpu-gem5-csarch.git #+end_src ** Docker Container Image [[https://www.docker.com][Docker]] is a set of platform-as-a-service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels. All containers are run by a single operating-system kernel and are thus more lightweight than virtual machines. In this lab project, Docker is adopted for GEM5 simulator. The image can be pull from the Docker resource repository. #+begin_src shell docker pull gcr.io/gem5-test/ubuntu-20.04_all-dependencies:v22-0 #+end_src ** Docker Registry Mirrors As the understandable concern of the cyber security and the WWW resources is monopolized oversea, the Docker Hub presents the unacceptable laggy in China. The Registry mirrors which servers are located in China is a reasonable approache to speed up the PULL of image from Docker Hub. Some userful information can be found at [[https://zhuanlan.zhihu.com/p/460489756][Zhihu]]. We recommand to register a personal Aliyun registry mirror and add it in the configuration file daemon.json. #+begin_src { "registry-mirrors": [ "https://alimirrorusername.mirror.aliyuncs.com" ] } #+end_src Change the ~alimirrorusername~ to your registry username of Aliyun Docker mirror. ** Build Docker Image from Dockerfile As the ~gcr.io~ is laggy or banned for unkown reason, the Dockerfile is provided in this repo. The ~docker build~ command listed below will build the docker image which has the essential libraries of gem5. The command should be run in the dir which contains the Dockerfile, for example in our gitee repository dir. #+begin_src shell docker build -t gem5-ercesi:latest . #+end_src ** How to Run Docker Container f the Docker image has been imported, the Docker would run by the command below. #+begin_src shell docker run -u $UID:$GID \ --volume :/mnt/gem5arm \ --rm -it gem5-ercesi:latest #+end_src In which, the the argument ~-i~ denotes an interactive mode of docker container execution, ~t~ implies a TTY prompt mode as while as bash is for a bash shell in command line. To keep the container clean, we recommand not to save any user file in container. So the ~--rm~ is added in the script to remove the container after exit. If you don't use the ~--rm~ optional argument, please resume the opened container next time. ~~ in the run script is where the GEM5 source code downloaded. An example command below is for Windows users. #+begin_src shell docker run -u gem5 --volume D://gem5_local:/mnt/gem5arm --rm -it gem5-ercesi:latest #+end_src Please note the performance of any app running in a docker container is limited by the resource assigned to the container. If any can be worked in the original OS, please do it in the original OS, such as doing git or compile in linux of mac os system. The next step is cloning gem5 remote repo. It is recommande to use git clone from github or gitee.com. #+begin_src shell git clone https://github.com/gem5/gem5.git #+end_src Note: Before compile the gem5, pre-commit libary is recommanded to install. #+begin_src shell pip install pre-commit==2.20.0 #+end_src ** Resume an Opened Container When the end of the Docker lab, we use ~exit~ command to exit the Docker promot. #+begin_src shell docker ps -a #+end_src To restart the seleceted container, ~docker start~ command can be used. #+begin_src shell docker start [container ID] #+end_src If the run command used as that mentioned before, a sample command line is introdueced below. #+begin_src shell docker exec -it [container ID] bash #+end_src * Contributors As this repo is transfered from the Inner Source, and all the old history is deleted due to the copyright consideration, the contributors of this repo are not listed in git configurations. We listed all contributors below. [[mailto: zhangm@nwpu.edu.cn][Meng Zhang]]; [[mailto: ][Hui Li]]; [[mailto: ][Zhendi Yu]]