sv_binutils: discard VHDL stuff in comments
[openpower-isa.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, the: CPU instructions, register set, memory model, etc, that describe the way a machine works.
6
7 These pages contain (in a strict machine-readable subset of mdwn)
8 the pseudo-code for all opcodes in the POWER v3.0B Public Spec
9
10 * [[isa/bcd]]
11 * [[isa/branch]]
12 * [[isa/comparefixed]]
13 * [[isa/condition]]
14 * [[isa/fixedarith]]
15 * [[isa/fixedload]]
16 * [[isa/fixedlogical]]
17 * [[isa/fixedshift]]
18 * [[isa/fixedstore]]
19 * [[isa/fixedtrap]]
20 * [[isa/sprset]]
21 * [[isa/stringldst]]
22 * [[isa/system]]
23 * [[isa/simplev]]
24
25 # Pseudocode syntax
26
27 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=soc.git;a=blob;f=src/soc/decoder/pseudo/parser.py;hb=HEAD>
28
29 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:
30
31 if x = 1 then
32 RT <- 1
33 else
34 RT <- 0
35
36 results in the parser seeing the following python code:
37
38 if x == 1:
39 RT = 1
40 else
41 RT = 0
42
43 To support this python-like syntax some of the pseudocode after extraction from the PDF had to be cleaned up and proper indentation added.
44
45 Also worth noting as used in the above example: the following operators are used (see section 1.3 "Notation" of v3.0B PDF):
46
47 * `<-` assignment, instead of "=" as in python
48 * `=` equals comparator, instead of "==" as in python
49 * `||` concatenate, done bitwise, in MSB0 order.
50 * `>u` for unsigned greater (">" is signed)
51 * `<u` for unsigned lessthan ("<" is signed)
52 * X superscript n subscript is instead expressed `[X]*n`
53 * X subscript n or n:m is expressed as `X[n:m]`
54
55 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
56