Skip to content

Commit 4783c7d

Browse files
authored
Merge pull request #296 from EhsanKhodadad/main
Patmos
2 parents fab6109 + 1a4e70d commit 4783c7d

File tree

5 files changed

+152
-0
lines changed

5 files changed

+152
-0
lines changed

docs/embedded/patmos.mdx

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: Patmos
3+
description: Developing LF Programs for Patmos.
4+
---
5+
# Overview
6+
Lingua Franca's C-runtime supports [Patmos](https://github.com/t-crest/patmos),
7+
a bare-metal execution platform that is optimized for time-predictable execution.
8+
The time-predictability aspect of Patmos makes it easier to obtain a worst-case
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+
}
28+
29+
main reactor {
30+
reaction(startup) {=
31+
printf("Hello World!\n");
32+
=}
33+
}
34+
35+
36+
```
37+
You can generate C code using `lfc HelloPatmos.lf` command in the above folder:
38+
39+
```
40+
cd test/C/src/patmos/
41+
lfc HelloPatmos.lf
42+
```
43+
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:
45+
46+
```
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
55+
```
56+
57+
The reactor can also be executed on the hardware emulator of Patmos:
58+
59+
```
60+
patemu HelloPatmos
61+
```
62+
63+
This execution is considerably slower than the SW simulator, as the concrete hardware
64+
of Patmos is simulated cycle-accurate. Here is a sample of its output:
65+
66+
```
67+
Hello World!
68+
---- Elapsed logical time (in nsec): 0
69+
---- Elapsed physical time (in nsec): 3,459,000
70+
```

docs/sidebars.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ const sidebars: SidebarsConfig = {
176176
"type": "doc",
177177
"id": "embedded/arduino"
178178
},
179+
{
180+
"type": "doc",
181+
"id": "embedded/patmos"
182+
},
179183
{
180184
"type": "doc",
181185
"id": "embedded/zephyr"
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: Patmos
3+
description: Developing LF Programs for Patmos.
4+
---
5+
# Overview
6+
Lingua Franca's C-runtime supports [Patmos](https://github.com/t-crest/patmos),
7+
a bare-metal execution platform that is optimized for time-predictable execution.
8+
The time-predictability aspect of Patmos makes it easier to obtain a worst-case
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+
}
28+
29+
main reactor {
30+
reaction(startup) {=
31+
printf("Hello World!\n");
32+
=}
33+
}
34+
35+
36+
```
37+
You can generate C code using `lfc HelloPatmos.lf` command in the above folder:
38+
39+
```
40+
cd test/C/src/patmos/
41+
lfc HelloPatmos.lf
42+
```
43+
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:
45+
46+
```
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
55+
```
56+
57+
The reactor can also be executed on the hardware emulator of Patmos:
58+
59+
```
60+
patemu HelloPatmos
61+
```
62+
63+
This execution is considerably slower than the SW simulator, as the concrete hardware
64+
of Patmos is simulated cycle-accurate. Here is a sample of its output:
65+
66+
```
67+
Hello World!
68+
---- Elapsed logical time (in nsec): 0
69+
---- Elapsed physical time (in nsec): 3,459,000
70+
```

versioned_docs/version-0.9.0/sidebars.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ const sidebars: SidebarsConfig = {
176176
"type": "doc",
177177
"id": "embedded/arduino"
178178
},
179+
{
180+
"type": "doc",
181+
"id": "embedded/patmos"
182+
},
179183
{
180184
"type": "doc",
181185
"id": "embedded/zephyr"

versioned_sidebars/version-0.9.0-sidebars.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@
162162
"type": "doc",
163163
"id": "embedded/arduino"
164164
},
165+
{
166+
"type": "doc",
167+
"id": "embedded/patmos"
168+
},
165169
{
166170
"type": "doc",
167171
"id": "embedded/zephyr"

0 commit comments

Comments
 (0)