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
+88-78
Original file line number
Diff line number
Diff line change
@@ -7,101 +7,111 @@ 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
-
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)
11
15
### 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
27
-
28
-
The reactor can be executed on the SW simulator with:
16
+
Patmos can run in an FPGA, but there are also two simulators available:
29
17
30
-
pasim Minimal.elf
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.
31
20
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:
21
+
Consider the following simple LF program inside the HelloWorld.lf file:
22
+
```lf-c
23
+
target C {
24
+
single-threaded: true
25
+
}
26
+
main reactor {
27
+
reaction(startup) {=
28
+
lf_print("Hello World!");
29
+
=}
30
+
}
34
31
35
32
```
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
33
+
After generating C code using `lfc HelloWorld.lf` command, add a Makefile file to compile LF-generated code inside `src-gen/HelloWorld` folder. In this Makefile mention the name of all generated c files, and the pathes of all header files. Here is a sample of such a Makefile file:
The reactor can also be executed on the hardware emulator of Patmos:
77
+
Then move this Makefile inside the `src-gen/HelloWorld` folder and run the following make command:
44
78
45
-
patemu Minimal.elf
79
+
make -C src-gen/HelloWorld
46
80
47
-
This execution is considerably slower than the SW simulator, as the concrete hardware
48
-
of Patmos is simulated cycle-accurate.
81
+
If you are using an older version of LF that doesn't support Patmos, you need to copy `lf_patmos_support` c and h files in the related folders before executing make command whether manually or by executing the following bash file that automates the copying process (considering those files are located in a folder called `files`)
We want to perform WCET analysis of the single reaction of the Work reactor.
73
-
This reaction, depending on the input data, will either perform a multiplication,
74
-
which is more expensive in Patmos, or an addition. The WCET analysis shall consider
75
-
the multiplication path as the worst-case path. To generate the information for
76
-
WCET analysis by the compiler we have to compile the application as follows:
95
+
If there is no error after making, an HelloWorld.elf file must be generator inside `src-gen\HelloWorld` folder. Then, the reactor can be executed on the SW simulator with the following command:
77
96
78
-
patmos-clang -O2 -mserialize=wcet.pml Wcet.c
97
+
pasim src-gen\HelloWorld\HelloWorld.elf
79
98
80
-
We investigate the C source code `Wcet.c` and find that the reaction we
81
-
are interested is named `reaction_function1`. Therefore, we invoke WCET analysis
82
-
as follows:
99
+
After executing the above command, the following lines must be printed.
0 commit comments