1. Preface
After compiling the minimally configured Fragrant Core (CONFIG=Minimal), you can continue to try out the next two GUI tools according to the readme guidelines. But the goal is not to formally start analyzing code and functionality, but to expect that it will make sense for beginners to experience their own setbacks in this visual way, which will help them stay interested in the introductory stage.
2. Virtual oscilloscope gtkwave
1. Introduction
gtkwave is used to play back and display the waveforms recorded by Xiangshan core in the simulation process (that is, not real-time), and retrieve the level or data of each IO or bus inside the chip from the granularity of the CPU clock to locate the bug.
2. Installation and Use
First enter the path of the Xiangshan project to see if there are compiled emu files.
cwq@ubuntu:~/1_xiangshan/xs-env/XiangShan$ ls ./build/emu ./build/emu
Then execute the following command to generate the waveform file vcd - only record CPU clock cycles between 10000 and 11000:
(The process was extremely slow because I was using emu with full configuration, not minimal configuration of fragrances. Finally, I only ran for a while and then aborted with Ctrl+C)
cwq@ubuntu:~/1_xiangshan/xs-env/XiangShan$ ./build/emu -i $NOOP_HOME/ready-to-run/linux.bin --dump-wave -b 10000 -e 11000 Emu compiled at Dec 7 2021, 06:53:16 The image is /home/cwq/1_xiangshan/xs-env/XiangShan/ready-to-run/linux.bin Using simulated 8192MB RAM dump wave to /home/cwq/1_xiangshan/xs-env/XiangShan/build/2021-12-08@07:07:50.vcd... --diff is not given, try to use $(NEMU_HOME)/build/riscv64-nemu-interpreter-so by default NemuProxy using /home/cwq/1_xiangshan/xs-env/NEMU/build/riscv64-nemu-interpreter-so [src/isa/riscv64/init.c,50,init_isa] NEMU will start from pc 0x80000000 The first instruction of core 0 has commited. Difftest enabled. bbl loader freq-mhz = 500 CLINT: set frequency to 500 MHz vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv vvvvvvvvvvvvvvvvvvvvvvvvvvvv rrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvvvv rrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv rrrrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv rrrrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv rrrrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv rrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvv rrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvv rr vvvvvvvvvvvvvvvvvvvvvv rr vvvvvvvvvvvvvvvvvvvvvvvv rr rrrr vvvvvvvvvvvvvvvvvvvvvvvvvv rrrr rrrrrr vvvvvvvvvvvvvvvvvvvvvv rrrrrr rrrrrrrr vvvvvvvvvvvvvvvvvv rrrrrrrr rrrrrrrrrr vvvvvvvvvvvvvv rrrrrrrrrr rrrrrrrrrrrr vvvvvvvvvv rrrrrrrrrrrr rrrrrrrrrrrrrr vvvvvv rrrrrrrrrrrrrr rrrrrrrrrrrrrrrr vv rrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrr INSTRUCTION SETS WANT TO BE FREE [ 0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000 [ 0.000000] Linux version 4.18.0-00046-g2ba394515c09-dirty (wkf@xiangshan-05) (gcc version 9.2.0 (GCC)) #113 Thu Feb 4 21:45:54 CST 2021 [ 0.000000] bootconsole [early0] enabled [ 0.000000] Initial ramdisk at: 0x(____ptrval____) (23552 bytes) [ 0.000000] Zone ranges: [ 0.000000] DMA32 empty [ 0.000000] Normal [mem 0x0000000080200000-0x0000000081ffffff] [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000080200000-0x0000000081ffffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x0000000081ffffff] ^CCore 0: SOME SIGNAL STOPS THE PROGRAM at pc = 0xffffffff800ba514 ...
Then connect to Ubuntu with MobaXterm - since MobaXterm comes with the ability to open remote GUI tools (like "X server"?), execute the following command to install gtkwave and open the waveform file generated in the previous step:
sudo apt-get install gtkwave gtkwave ./build/2021-12-08@07:07:50.vcd
You can see the following interface:
Then open a few pins at the top left corner and you can see a waveform similar to the following:
(both the level of a single IO and the hexadecimal value of a 32 bit wide bus)
3. Comments
gtkwave reflects very fine details and is very powerful. At the same time, the simulation speed becomes very slow.
3. LogViewer
1. Introduction
The logviewer is essentially a text viewer, featuring the ability to quickly open very large files (unlimited size), highlight different types of information, and perform functions such as analysis and statistics.
2. Installation and Use
Because the full version of Xiang Shan runs linux too slowly, I choose the smallest configuration version of Xiang Shan to run coremark and generate log files faster (emu_minimal used in the command is the minimum configuration EMU I compiled and saved in advance):
sudo apt-get install lnav ./emu_minimal -i $NOOP_HOME/ready-to-run/coremark-2-iteration.bin 2>&1 | tee > test1.log lnav test1.log
You can see the following:
Press the up and down keys, then press the m key to mark a line (you don't know exactly what you can do, but it looks convenient; it would be better if you could skip and browse these markup lines quickly.)
You can refer to this article ( https://www.howtoing.com/ubuntu-lnav-log-viewer ) to toss about.
3. Comments
There is no in-depth study of the log viewer's specific functionality yet, but the official website can find the most complete instructions for use. It is believed that the comparator can be easily viewed with text editors such as vim or nano.
Return to the specific usage when it is formally needed.