(no commit message)
[libreriscv.git] / openpower / isa.mdwn
1 # ISA Pseudo-code
2
3 <!-- this is a test comment -->
4
5 ISA is the [[!wikipedia Instruction_set_architecture]] of a machine,
6 the: CPU instructions, register set, memory model, etc, that describe
7 the way a machine works.
8
9 These pages contain (in a strict machine-readable subset of mdwn)
10 the pseudo-code for all opcodes in the POWER v3.0B Public Spec
11
12 * [[isa/bcd]]
13 * [[isa/branch]]
14 * [[isa/comparefixed]]
15 * [[isa/condition]]
16 * [[isa/fixedarith]]
17 * [[isa/fixedload]]
18 * [[isa/fixedlogical]]
19 * [[isa/fixedshift]]
20 * [[isa/fixedstore]]
21 * [[isa/fixedtrap]]
22 * [[isa/sprset]]
23 * [[isa/stringldst]]
24 * [[isa/system]]
25
26 FP instructions: useful for testing <http://weitz.de/ieee/>
27
28 * [[isa/fpload]]
29 * [[isa/fpstore]]
30 * [[isa/fpmove]]
31 * [[isa/fparith]]
32 * [[isa/fpcvt]]
33
34 Scalar instructions added as part of [[sv/svp64]] development, these are
35 all **DRAFT FORM** and they are all stand-alone Scalar (no hard dependency
36 on Simple-V).
37 Explanation of the rules for twin register targets
38 (implicit RS, FRS) explained in SVP64 [[sv/svp64/appendix]]
39
40 * [[isa/svfixedarith]]
41 * [[isa/svfparith]]
42 * [[isa/bitmanip]]
43
44 Scalar "Post-Increment" Draft Load/Store with Update
45
46 * [[isa/pifixedload]]
47 * [[isa/pifixedstore]]
48
49 Part of the DRAFT Simple-V Specification:
50
51 * [[isa/simplev]]
52
53 A useful aide to finding Power ISA instructions: <https://power-isa-beta.mybluemix.net>
54
55 # Pseudocode syntax
56
57 The syntax is shown in the v3.0B OpenPOWER Reference Manual. The implementation of a parser, using python-ply, is here: <https://git.libre-soc.org/?p=openpower-isa.git;a=blob;f=src/openpower/decoder/pseudo/parser.py;hb=HEAD>
58
59 The parser is based on the python-ply GardenSnake.py example (except bugs were fixed in it, first). Extra tokens, in the lexer phase, are inserted dynamically into the stream to make the parser think that it is seeing python-like syntax where in fact it is not. Example: when a pseudocode keyword "THEN" is seen, this is substituted for ":". The keyword "ELSE" will also automatically have a second ":" token inserted in order to comply with python syntax. Thus the following pseudocode:
60
61 if x = 1 then
62 RT <- 1
63 else
64 RT <- 0
65
66 results in the parser seeing the following python code:
67
68 if x == 1:
69 RT = 1
70 else
71 RT = 0
72
73 To support this python-like syntax some of the pseudocode after extraction from the PDF had to be cleaned up and proper indentation added.
74
75 Also worth noting as used in the above example: the following operators are used (see section 1.3 "Notation" of v3.0B PDF):
76
77 * `<-` assignment, instead of "=" as in python
78 * `=` equals comparator, instead of "==" as in python
79 * `||` concatenate, done bitwise, in MSB0 order.
80 * `>u` for unsigned greater (">" is signed)
81 * `<u` for unsigned lessthan ("<" is signed)
82 * X superscript n subscript is instead expressed `[X]*n`
83 * X subscript n or n:m is expressed as `X[n:m]`
84
85 The reason for the addition of the unsigned comparator operators is because numbers in the pseudocode are bitpatterns, not assigned a type or a sign as would normally be done in a standard programming language
86