4 | 4 |
|
5 | 5 |
::
|
6 | 6 |
|
7 | |
$ <hello_world.subv ./validate.py | ./survey.py | ./format.py | ./pack.py | ./elf.py >hello_world.elf
|
8 | |
$ ./qemu.sh hello_world.elf
|
|
7 |
$ <examples/hello_world.subv ./validate.py | ./survey.py | ./format.py | ./pack.py | ./elf.py >examples/hello_world.elf
|
|
8 |
$ ./qemu.sh examples/hello_world.elf
|
9 | 9 |
|
10 | 10 |
Pipeline
|
11 | 11 |
--------
|
|
20 | 20 |
|
21 | 21 |
and now front to back with a little example::
|
22 | 22 |
|
23 | |
$ ./validate.py <ex.subv >ex.valid
|
24 | |
$ ./survey.py <ex.valid >ex.survey
|
25 | |
$ ./format.py <ex.survey >ex.format
|
26 | |
$ ./pack.py <ex.format >ex.pack
|
27 | |
$ ./elf.py <ex.pack >ex.elf
|
|
23 |
$ ./validate.py <examples/ex.subv >examples/ex.valid
|
|
24 |
$ ./survey.py <examples/ex.valid >examples/ex.survey
|
|
25 |
$ ./format.py <examples/ex.survey >examples/ex.format
|
|
26 |
$ ./pack.py <examples/ex.format >examples/ex.pack
|
|
27 |
$ ./elf.py <examples/ex.pack >examples/ex.elf
|
28 | 28 |
$ ./qemu.sh ex.elf
|
29 | 29 |
|
30 | 30 |
``ex.subv``: hand-writable::
|
31 | 31 |
|
32 | |
== code 0x80000000
|
33 | |
# repeatedly print "Hi\n"
|
34 | |
main:
|
35 | |
# load 0x10010000 (UART0) into t0
|
36 | |
37/lui 5/rd/t0 0x10010/imm20
|
37 | |
# store 0x48 (H) in UART0+0
|
38 | |
13/opi 0/subop/add 6/rd/t1 0/rs/x0 48/imm12
|
39 | |
23/store 2/width/word 5/rs/t0 6/rs/t1 0/off12
|
40 | |
# store 0x69 (i) in UART0+0
|
41 | |
13/opi 0/subop/add 6/rd/t1 0/rs/x0 69/imm12
|
42 | |
23/store 2/width/word 5/rs/t0 6/rs/t1 0/off12
|
43 | |
# store 0x0a (\n) in UART0+0
|
44 | |
13/opi 0/subop/add 6/rd/t1 0/rs/x0 0a/imm12
|
45 | |
23/store 2/width/word 5/rs/t0 6/rs/t1 0/off12
|
46 | |
# jump back up to the top
|
47 | |
6f/jal 0/rd/x0 main/off21
|
|
32 |
== code 0x80400000
|
|
33 |
# repeatedly print "Hi\n"
|
|
34 |
main:
|
|
35 |
# load 0x10000000 (UART0) into t0
|
|
36 |
37/lui 5/rd/t0 10000/imm20
|
|
37 |
# store 0x48 (H) in UART0+0
|
|
38 |
13/opi 0/subop/add 6/rd/t1 0/rs/x0 48/imm12
|
|
39 |
23/store 0/width/byte 5/rs/t0 0/off12 6/rs/t1
|
|
40 |
# store 0x69 (i) in UART0+0
|
|
41 |
13/opi 0/subop/add 6/rd/t1 0/rs/x0 69/imm12
|
|
42 |
23/store 0/width/byte 5/rs/t0 0/off12 6/rs/t1
|
|
43 |
# store 0x0a (\n) in UART0+0
|
|
44 |
13/opi 0/subop/add 6/rd/t1 0/rs/x0 0a/imm12
|
|
45 |
23/store 0/width/byte 5/rs/t0 0/off12 6/rs/t1
|
|
46 |
# jump back up to the top
|
|
47 |
6f/jal 0/rd/x0 main/off21
|
48 | 48 |
|
49 | 49 |
``ex.valid``: mnemonics validated and discarded::
|
50 | 50 |
|
51 | |
== code 0x80000000
|
52 | |
# repeatedly print "Hi\n"
|
53 | |
main:
|
54 | |
# load 0x10010000 (UART0) into t0
|
55 | |
37/u 5/rd 10010/imm20
|
56 | |
# store 0x48 (H) in UART0+0
|
57 | |
13/i 6/rd 0/funct3 0/rs 48/imm12
|
58 | |
23/s 5/rs1 0/imm12 2/funct3 6/rs2
|
59 | |
# store 0x69 (i) in UART0+0
|
60 | |
13/i 6/rd 0/funct3 0/rs 69/imm12
|
61 | |
23/s 5/rs1 0/imm12 2/funct3 6/rs2
|
62 | |
# store 0x0a (\n) in UART0+0
|
63 | |
13/i 6/rd 0/funct3 0/rs a/imm12
|
64 | |
23/s 5/rs1 0/imm12 2/funct3 6/rs2
|
65 | |
# jump back up to the top
|
66 | |
6f/j 0/rd main/off21
|
|
51 |
== code 0x80400000
|
|
52 |
# repeatedly print "Hi\n"
|
|
53 |
main:
|
|
54 |
# load 0x10000000 (UART0) into t0
|
|
55 |
37/u 5/rd 10000/imm20
|
|
56 |
# store 0x48 (H) in UART0+0
|
|
57 |
13/i 6/rd 0/funct3 0/rs 48/imm12
|
|
58 |
23/s 0/funct3 5/rs1 0/imm12 6/rs2
|
|
59 |
# store 0x69 (i) in UART0+0
|
|
60 |
13/i 6/rd 0/funct3 0/rs 69/imm12
|
|
61 |
23/s 0/funct3 5/rs1 0/imm12 6/rs2
|
|
62 |
# store 0x0a (\n) in UART0+0
|
|
63 |
13/i 6/rd 0/funct3 0/rs a/imm12
|
|
64 |
23/s 0/funct3 5/rs1 0/imm12 6/rs2
|
|
65 |
# jump back up to the top
|
|
66 |
6f/j 0/rd main/off21
|
67 | 67 |
|
68 | 68 |
``ex.survey``: references resolved and labels removed::
|
69 | 69 |
|
70 | |
== code 0x80000000
|
71 | |
# repeatedly print "Hi\n"
|
72 | |
# main:
|
73 | |
# load 0x10010000 (UART0) into t0
|
74 | |
37/u 5/rd 10010/imm20
|
75 | |
# store 0x48 (H) in UART0+0
|
76 | |
13/i 6/rd 0/funct3 0/rs 48/imm12
|
77 | |
23/s 5/rs1 0/imm12 2/funct3 6/rs2
|
78 | |
# store 0x69 (i) in UART0+0
|
79 | |
13/i 6/rd 0/funct3 0/rs 69/imm12
|
80 | |
23/s 5/rs1 0/imm12 2/funct3 6/rs2
|
81 | |
# store 0x0a (\n) in UART0+0
|
82 | |
13/i 6/rd 0/funct3 0/rs a/imm12
|
83 | |
23/s 5/rs1 0/imm12 2/funct3 6/rs2
|
84 | |
# jump back up to the top
|
85 | |
6f/j 0/rd -1c/imm21
|
|
70 |
== code 0x80400000
|
|
71 |
# repeatedly print "Hi\n"
|
|
72 |
# main:
|
|
73 |
# load 0x10000000 (UART0) into t0
|
|
74 |
37/u 5/rd 10000/imm20
|
|
75 |
# store 0x48 (H) in UART0+0
|
|
76 |
13/i 6/rd 0/funct3 0/rs 48/imm12
|
|
77 |
23/s 0/funct3 5/rs1 0/imm12 6/rs2
|
|
78 |
# store 0x69 (i) in UART0+0
|
|
79 |
13/i 6/rd 0/funct3 0/rs 69/imm12
|
|
80 |
23/s 0/funct3 5/rs1 0/imm12 6/rs2
|
|
81 |
# store 0x0a (\n) in UART0+0
|
|
82 |
13/i 6/rd 0/funct3 0/rs a/imm12
|
|
83 |
23/s 0/funct3 5/rs1 0/imm12 6/rs2
|
|
84 |
# jump back up to the top
|
|
85 |
6f/j 0/rd -1c/imm21
|
86 | 86 |
|
87 | 87 |
``ex.format``: arguments sliced and diced and put into the ISA order::
|
88 | 88 |
|