You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/embedded/patmos.mdx
+46-83
Original file line number
Diff line number
Diff line change
@@ -7,101 +7,64 @@ Lingua Franca's C-runtime supports [Patmos](https://github.com/t-crest/patmos),
7
7
a bare-metal execution platform that is optimized for time-predictable execution.
8
8
The time-predictability aspect of Patmos makes it easier to obtain a worst-case
9
9
execution time (WCET) for reactions.
10
+
## Prerequisites
11
+
- Linux or macOS development system. (use WSL on Windows)
12
+
- DE2-115 Development Kit, which is equipped with Altera Cyclone IV FPGA (optional)
13
+
### Getting Started
14
+
To know how to install the toolchain for building Patmos, read the Patmos project's readme at https://github.com/t-crest/patmos or study the sixth chapter of its handbook available here: [Patmos Reference Handbook](http://patmos.compute.dtu.dk/patmos_handbook.pdf)
15
+
### Compiling and Running Lingua Franca codes
16
+
Patmos can run in an FPGA, but there are also two simulators available:
17
+
18
+
1.`pasim`: a software ISA simulator that is written in C++.
19
+
2.`patemu`: a cycle-accurate hardware emulator generated from the hardware description.
20
+
21
+
Consider the following simple LF program inside the HelloPatmos.lf file located in `test/C/src/patmos/HelloPatmos.lf`:
22
+
```lf-c
23
+
target C {
24
+
platform: "Patmos",
25
+
single-threaded: true,
26
+
build-type: Debug,
27
+
}
10
28
11
-
### Compiling and Running Reactors
12
-
Patmos can run in an FPGA, but there are also two
13
-
simulators available:
14
-
15
-
1.`pasim` a software ISA simulator that is written in C++.
16
-
2.`patemu` a cycle-accurate hardware emulator generated from the hardware description.
17
-
18
-
To execute reactions on Patmos, the [Patmos toolchain](https://github.com/t-crest/patmos) needs
19
-
to be installed. The web page contains a quick start, detailed information including how to
To execute the "hello world" reactor on Patmos use the LF compiler to generate the C code.
24
-
Compile the reactor with the Patmos compiler (in `src-gen`):
25
-
26
-
patmos-clang Minimal.c -o Minimal.elf
29
+
main reactor {
30
+
reaction(startup) {=
31
+
printf("Hello World!\n");
32
+
=}
33
+
}
34
+
27
35
28
-
The reactor can be executed on the SW simulator with:
36
+
```
37
+
You can generate C code using `lfc HelloPatmos.lf` command in the above folder:
29
38
30
-
pasim Minimal.elf
39
+
```
40
+
cd test/C/src/patmos/
41
+
lfc HelloPatmos.lf
42
+
```
31
43
32
-
As Patmos is a bare metal runtime that has no notion of calendar time, its start time
33
-
is considered the epoch and the following output will be observed:
44
+
If there is no error after making, an executable file must be generator inside `src-gen/patmos/HelloPatmos` folder. Then, the reactor can be executed on the SW simulator with the following command:
34
45
35
46
```
36
-
Start execution at time Thu Jan 1 00:00:00 1970
37
-
plus 640000 nanoseconds.
38
-
Hello World.
39
-
Elapsed logical time (in nsec): 0
40
-
Elapsed physical time (in nsec): 3970000
47
+
cd ../../src-gen/patmos/HelloPatmos/build
48
+
pasim HelloPatmos
49
+
```
50
+
After executing the above command, the following lines must be printed.
51
+
```
52
+
Hello World!
53
+
---- Elapsed logical time (in nsec): 0
54
+
---- Elapsed physical time (in nsec): 770,000
41
55
```
42
56
43
57
The reactor can also be executed on the hardware emulator of Patmos:
44
58
45
-
patemu Minimal.elf
46
-
47
-
This execution is considerably slower than the SW simulator, as the concrete hardware
0 commit comments