转自:http://blog.youkuaiyun.com/fandroid/article/details/45969893
参考:https://www.mail-archive.com/gem5-users@gem5.org/msg06627.html
一、准备开始gem5
1、首先看官网的Introduction,编译gem5,完成hello world示例。
Start with Introduction http://gem5.org/Introduction. Compile gem5 for the architecture you are interested, try it with pre-compiled helloworld binary.
2、阅读Documentation和Tutorials。必须阅读Getting start和Running gem5。
When you are able to finish the “helloword” simulation, it’s a good idea to spend time in documents http://gem5.org/Documentation and tutorials http://gem5.org/Tutorials. “Getting start” section and “Running gem5” section are must reads. However, it may be quite hard to understand everything, but you just need to make sure you know what these articles and tutorial slides are talking about at high level. I actually quite like the figure on memory system:
http://www.gem5.org/docs/html/gem5MemorySystem.html
3、做实验,看相关代码
While you read the documents, you can try to run some experiments yourself. For example, different scripts in configs/example, different modes (FS/SE), different workloads, different simulation models (simple atomic, simpletiming, InOrder, O3) etc..
After finish first-round reading and blackbox testing, you can dig into code. I started from http://gem5.org/SimObjectshttp://gem5.org/SimObjects.
I myself is not familiar with python too, but I don’t think it’s hard to read it as long as you have experience in other languages. If there is some keywords, syntax or grammar you don’t understand, go to google or search on http://www.python.org/. For C++ part, I think if you know C and OO concept, it should not be a big problem either – certain things I don’t like about C++ such as templates are used in several places, and may cost you sometime to understand.
4、专注自己感兴趣的部分,如cache、memory、pipelined cpu
While reading source code, I usually keep instrumenting it with printf and run it with helloword binary so I can keep tracking the control flow. Of course, don’t simulate a complex system, simpleatomic is good enough. The only problem I have is compiling gem5 takes too much time. It took me over 20 minutes to build everything on my Dell Precision workstation. So when you insert printf, try to avoid places like header files. Also try to use 64-bit system as more memory can be used – it seems gem5 needs a lot of memory to compile.
After you have basic understanding in how a python config file is used to instantiate C++ object and how a simulation is started, you can spent time in the part you are interested – whether it’s cache or memory, or pipelined cpu. Gem5 has many nice designs that you may not find from other simulators, I myself is also learning. Also, mailing list is always helpful, and you can post your questions if you get stuck.
备注:(可看看这个人的博客,个人觉得不错)http://blog.youkuaiyun.com/wyj7260/article/category/1301132