f094c2c2cd0f1f73109ff81c84fc5d650235f47f
[libreriscv.git] / docs / pypowersim.mdwn
1 # Links
2
3 * <https://bugs.libre-soc.org/show_bug.cgi?id=758>
4 * [Pypowersim](https://git.libre-soc.org/?p=openpower-isa.git;a=blob;f=src/openpower/decoder/isa/pypowersim.py)
5 * [Media directory](https://git.libre-soc.org/?p=openpower-isa.git;a=tree;f=media;hb=HEAD)
6 * [MP3 test directory](https://git.libre-soc.org/?p=openpower-isa.git;a=tree;f=media/audio/mp3;hb=HEAD)
7
8 # Pypowersim Guide
9
10 These are multimedia tests intended to cover the inner loops of various
11 Audio/Video CODECs (such as MP3).
12
13 **Note:** There's no GUI, UART, or console. To check that the tests ran
14 succesfully, you need to dump the memory contents and inspect them.
15
16
17 ## Pypowersim
18
19 **NOTE**: This is a basic description, as the author has not studied or used
20 the simulator in great detail.
21
22 Pypowersim is a Python script containing useful functions for PowerISA testing.
23 Assembler code written in SV is decoded by a given ISA class instance, and a
24 simulation is managed cycle by cycle, for instruction and memory debugging.
25 Use of QEMU as a co-simulator is also supported.
26
27 To find out about input arg information, run the script with "-h/--help" or
28 no arguments to get the help message:
29
30 * python3 openpower-isa/src/openpower/decoder/isa/pypowersim.py
31
32 ## Tests
33
34 ### About
35
36 The tests consist of running the "pypowersim" tool with several input arg's:
37
38 * ".gpr" text file for initialising the General Purpose (integer) Registers
39 * ".spr" text file for initialising the Special Purpose Registers
40 * Initialising the Program Counter
41 * Loading given binaries into specified memory locations
42 * Select which memory regions to dump to a file
43 * Select the executable to run
44
45 There are other options available (such as initialising the Floating Point
46 Registers).
47 for
48
49 ### Before running the tests!
50
51 **NOTE**: Is this correct?
52
53 As the SVP64 spec and Libre-SOC CPU is developing, the available opcodes
54 will grow. Make sure to update the auto-generated Python functions
55 simulating the instructions by calling:
56
57 * run "pywriter"
58
59 (This is an installed utility, so should be in your PATH)
60
61 ### Download audio data (**only need to do this once?**)
62
63 Call the Makefile inside "openpower-isa/media" to download the audio
64 samples:
65
66 * run "make wget"
67
68 ### Running both tests
69
70 Run the Makefile in the "openpower-isa/media" directory with "tests" arg:
71
72 * run "make tests"
73
74 All the debug will go to standard output, so you may wish to direct it to a
75 log file (the file will be **big**!).
76
77 To suppress verbose debug log, uncomment "#export SILENCELOG = 1" in the
78 Makefile.
79
80 ### Running "mp3_x" tests individually
81
82 Inside "openpower-isa/media" directory run:
83
84 * ./audio/mp3/mp3_0.sh 0 out
85
86 The "out" file will be created in the "media" directory. Change the name
87 if you don't want the second test to overwrite the results of the first.
88
89 ### Checking results
90
91 If you run both tests through the makefile, the shell script
92 automatically compares the input "sample0" file with the
93 generated "out" file.
94
95 For manual checking, you need to know where the "out" file is, and then
96 use the "cmp" program to compare byte by byte the sample and output
97 files.
98
99 * cmp out0 data/audio/mp3/mp3_0_data/samples0
100
101 No output indicates the files are identical.