Skip to content

Commit 13cba12

Browse files
authored
Merge branch 'main' into blog-package
2 parents 547cef0 + bdc11d6 commit 13cba12

File tree

11 files changed

+172
-30
lines changed

11 files changed

+172
-30
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/reference/target-declaration.mdx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ A target specification may have optional parameters, the names and values of whi
4242
- [**protobufs**](#protobufs): An array of .proto files that are to be compiled and included in the generated code.
4343
- [**runtime-version**](#runtime-version): Specify which version of the runtime system to use.
4444
- [**rust-include**](#rust-include): (Rust only) A set of Rust modules in the generated project.
45-
- [**scheduler**](#scheduler): (C only) Specification of the scheduler to us.
45+
- [**scheduler**](#scheduler): (C only) Specification of the scheduler to use.
4646
- [**single-file-project**](#single-file-project): (Rust only) If true, enables [single-file project layout](#single-file-layout).
4747
- [**single-threaded**](#single-threaded): Specify to not use multithreading.
4848
- [**timeout**](#timeout): A time value (with units) specifying the logical stop time of execution. See [Termination](../writing-reactors/termination.mdx).
@@ -104,7 +104,6 @@ rs={
104104
build-type: <Debug, Release, RelWithDebInfo, or MinSizeRel>,
105105
cargo-features: <array of strings>,
106106
cargo-dependencies: <list of key-value pairs>,
107-
export-dependency-graph: <true or false>,
108107
rust-include: <array of strings>,
109108
single-file-project: <true or false>,
110109
single-threaded: <true or false>,
@@ -380,10 +379,10 @@ This option takes a path as string argument to a folder containing an alternativ
380379
<ShowIf c py ts>
381380
This target does not support the `export-dependency-graph` target option.
382381
</ShowIf>
383-
<ShowIf cpp rs>
382+
<ShowIf cpp>
384383
This parameter takes arguments `true` or `false` to specify whether the compiled binary will export its internal dependency graph as a dot graph when executed. This is a debugging utility.
385384
<ShowOnly rs>
386-
If a [CLI](#command-line-arguments) is generated, the target property is ignored, and the user should instead use the `--export-graph` flag of the generated program.
385+
This feature works when a [CLI](#command-line-arguments) option is enabled and the user use the `--export-graph` flag of the generated program.
387386
</ShowOnly>
388387
</ShowIf>
389388
</ShowIfs>
@@ -477,10 +476,10 @@ The `logging` option is one of `ERROR`, `WARN`, `INFO`, `LOG` or `DEBUG`. It spe
477476
## no-compile
478477

479478
<ShowIfs>
480-
<ShowIf ts rs >
479+
<ShowIf ts>
481480
This target does not support the `no-compile` target option.
482481
</ShowIf>
483-
<ShowIf c cpp py>
482+
<ShowIf c cpp py rs>
484483
If true, then do not invoke a target language compiler nor cmake. Just generate code.
485484
</ShowIf>
486485
</ShowIfs>
@@ -534,19 +533,16 @@ This argument takes a string (with quotation marks) containing any tag, branch n
534533
This target does not support the `rust-include` target option.
535534
</ShowIf>
536535
<ShowIf rs>
537-
This specifies a set of Rust modules in the generated project. See [Linking support files](#linking-support-files).
536+
This specifies a set of Rust modules in the generated project.
538537
</ShowIf>
539538
</ShowIfs>
540539

541540
## scheduler
542541

543542
<ShowIfs>
544-
<ShowIf c cpp py ts >
543+
<ShowIf c cpp py rs ts >
545544
This target does not support the `scheduler` target option.
546545
</ShowIf>
547-
<ShowIf rs>
548-
This specifies the scheduler to use. See[Target Language Details](<../reference/target-language-details.mdx#scheduler-target-property>).
549-
</ShowIf>
550546
</ShowIfs>
551547

552548
## single-file-project
@@ -556,7 +552,7 @@ This specifies the scheduler to use. See[Target Language Details](<../reference/
556552
This target does not support the `single-file-project` target option.
557553
</ShowIf>
558554
<ShowIf rs>
559-
If true, enables [single-file project layout](#single-file-layout).
555+
If true, only main.rs is generated instead of multiple rust source files.
560556
</ShowIf>
561557
</ShowIfs>
562558

@@ -732,7 +728,6 @@ The generated executable may feature a command-line interface (CLI), if it uses
732728
- `--timeout <time value>`: override the default timeout mentioned as a target property. The syntax for times is just like the LF one (e.g. `1msec`, `"2 seconds"`).
733729
- `--workers <number>`: override the default worker count mentioned as a target property. This option is **ignored** unless the runtime crate has been built with the feature `parallel-runtime`.
734730
- `--export-graph`: export the dependency graph (corresponds to `export-dependency-graph` target property). This is a flag, i.e., absent means false, present means true. This means the value of the target property is ignored and not used as default.
735-
- `--log-level`: corresponds to the `logging` target property, but note that the levels have different meanings, and the target property is ignored. See [Logging levels](#logging-levels).
736731
- parameters of the main reactor are translated to CLI parameters.
737732
- Each LF parameter named `param` corresponds to a CLI parameter named `--main-param`. Underscores in the LF parameter name are replaced by hyphens.
738733
- The type of each parameters must implement the trait [`FromStr`](https://doc.rust-lang.org/std/str/trait.FromStr.html).

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"

versioned_docs/version-0.5.0/reference/target-declaration.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ A target specification may have optional parameters, the names and values of whi
4343
- [**protobufs**](#protobufs): An array of .proto files that are to be compiled and included in the generated code.
4444
- [**runtime-version**](#runtime-version): Specify which version of the runtime system to use.
4545
- [**rust-include**](#rust-include): (Rust only) A set of Rust modules in the generated project.
46-
- [**scheduler**](#scheduler): (C only) Specification of the scheduler to us.
46+
- [**scheduler**](#scheduler): (C only) Specification of the scheduler to use.
4747
- [**single-file-project**](#single-file-project): (Rust only) If true, enables [single-file project layout](#single-file-layout).
4848
- [**threading**](#threading): Whether to use multiple threads.
4949
- [**timeout**](#timeout): A time value (with units) specifying the logical stop time of execution. See [Termination](../writing-reactors/termination.mdx).

versioned_docs/version-0.6.0/reference/target-declaration.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ A target specification may have optional parameters, the names and values of whi
4242
- [**protobufs**](#protobufs): An array of .proto files that are to be compiled and included in the generated code.
4343
- [**runtime-version**](#runtime-version): Specify which version of the runtime system to use.
4444
- [**rust-include**](#rust-include): (Rust only) A set of Rust modules in the generated project.
45-
- [**scheduler**](#scheduler): (C only) Specification of the scheduler to us.
45+
- [**scheduler**](#scheduler): (C only) Specification of the scheduler to use.
4646
- [**single-file-project**](#single-file-project): (Rust only) If true, enables [single-file project layout](#single-file-layout).
4747
- [**single-threaded**](#single-threaded): Specify to not use multithreading.
4848
- [**timeout**](#timeout): A time value (with units) specifying the logical stop time of execution. See [Termination](../writing-reactors/termination.mdx).

versioned_docs/version-0.7.0/reference/target-declaration.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ A target specification may have optional parameters, the names and values of whi
4242
- [**protobufs**](#protobufs): An array of .proto files that are to be compiled and included in the generated code.
4343
- [**runtime-version**](#runtime-version): Specify which version of the runtime system to use.
4444
- [**rust-include**](#rust-include): (Rust only) A set of Rust modules in the generated project.
45-
- [**scheduler**](#scheduler): (C only) Specification of the scheduler to us.
45+
- [**scheduler**](#scheduler): (C only) Specification of the scheduler to use.
4646
- [**single-file-project**](#single-file-project): (Rust only) If true, enables [single-file project layout](#single-file-layout).
4747
- [**single-threaded**](#single-threaded): Specify to not use multithreading.
4848
- [**timeout**](#timeout): A time value (with units) specifying the logical stop time of execution. See [Termination](../writing-reactors/termination.mdx).

versioned_docs/version-0.8.0/reference/target-declaration.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ A target specification may have optional parameters, the names and values of whi
4242
- [**protobufs**](#protobufs): An array of .proto files that are to be compiled and included in the generated code.
4343
- [**runtime-version**](#runtime-version): Specify which version of the runtime system to use.
4444
- [**rust-include**](#rust-include): (Rust only) A set of Rust modules in the generated project.
45-
- [**scheduler**](#scheduler): (C only) Specification of the scheduler to us.
45+
- [**scheduler**](#scheduler): (C only) Specification of the scheduler to use.
4646
- [**single-file-project**](#single-file-project): (Rust only) If true, enables [single-file project layout](#single-file-layout).
4747
- [**single-threaded**](#single-threaded): Specify to not use multithreading.
4848
- [**timeout**](#timeout): A time value (with units) specifying the logical stop time of execution. See [Termination](../writing-reactors/termination.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+
```

versioned_docs/version-0.9.0/reference/target-declaration.mdx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ A target specification may have optional parameters, the names and values of whi
4242
- [**protobufs**](#protobufs): An array of .proto files that are to be compiled and included in the generated code.
4343
- [**runtime-version**](#runtime-version): Specify which version of the runtime system to use.
4444
- [**rust-include**](#rust-include): (Rust only) A set of Rust modules in the generated project.
45-
- [**scheduler**](#scheduler): (C only) Specification of the scheduler to us.
45+
- [**scheduler**](#scheduler): (C only) Specification of the scheduler to use.
4646
- [**single-file-project**](#single-file-project): (Rust only) If true, enables [single-file project layout](#single-file-layout).
4747
- [**single-threaded**](#single-threaded): Specify to not use multithreading.
4848
- [**timeout**](#timeout): A time value (with units) specifying the logical stop time of execution. See [Termination](../writing-reactors/termination.mdx).
@@ -104,7 +104,6 @@ rs={
104104
build-type: <Debug, Release, RelWithDebInfo, or MinSizeRel>,
105105
cargo-features: <array of strings>,
106106
cargo-dependencies: <list of key-value pairs>,
107-
export-dependency-graph: <true or false>,
108107
rust-include: <array of strings>,
109108
single-file-project: <true or false>,
110109
single-threaded: <true or false>,
@@ -380,10 +379,10 @@ This option takes a path as string argument to a folder containing an alternativ
380379
<ShowIf c py ts>
381380
This target does not support the `export-dependency-graph` target option.
382381
</ShowIf>
383-
<ShowIf cpp rs>
382+
<ShowIf cpp>
384383
This parameter takes arguments `true` or `false` to specify whether the compiled binary will export its internal dependency graph as a dot graph when executed. This is a debugging utility.
385384
<ShowOnly rs>
386-
If a [CLI](#command-line-arguments) is generated, the target property is ignored, and the user should instead use the `--export-graph` flag of the generated program.
385+
This feature works when a [CLI](#command-line-arguments) option is enabled and the user use the `--export-graph` flag of the generated program.
387386
</ShowOnly>
388387
</ShowIf>
389388
</ShowIfs>
@@ -477,10 +476,10 @@ The `logging` option is one of `ERROR`, `WARN`, `INFO`, `LOG` or `DEBUG`. It spe
477476
## no-compile
478477

479478
<ShowIfs>
480-
<ShowIf ts rs >
479+
<ShowIf ts>
481480
This target does not support the `no-compile` target option.
482481
</ShowIf>
483-
<ShowIf c cpp py>
482+
<ShowIf c cpp py rs>
484483
If true, then do not invoke a target language compiler nor cmake. Just generate code.
485484
</ShowIf>
486485
</ShowIfs>
@@ -534,19 +533,16 @@ This argument takes a string (with quotation marks) containing any tag, branch n
534533
This target does not support the `rust-include` target option.
535534
</ShowIf>
536535
<ShowIf rs>
537-
This specifies a set of Rust modules in the generated project. See [Linking support files](#linking-support-files).
536+
This specifies a set of Rust modules in the generated project.
538537
</ShowIf>
539538
</ShowIfs>
540539

541540
## scheduler
542541

543542
<ShowIfs>
544-
<ShowIf c cpp py ts >
543+
<ShowIf c cpp py rs ts >
545544
This target does not support the `scheduler` target option.
546545
</ShowIf>
547-
<ShowIf rs>
548-
This specifies the scheduler to use. See[Target Language Details](<../reference/target-language-details.mdx#scheduler-target-property>).
549-
</ShowIf>
550546
</ShowIfs>
551547

552548
## single-file-project
@@ -556,7 +552,7 @@ This specifies the scheduler to use. See[Target Language Details](<../reference/
556552
This target does not support the `single-file-project` target option.
557553
</ShowIf>
558554
<ShowIf rs>
559-
If true, enables [single-file project layout](#single-file-layout).
555+
If true, only main.rs is generated instead of multiple rust source files.
560556
</ShowIf>
561557
</ShowIfs>
562558

@@ -732,7 +728,6 @@ The generated executable may feature a command-line interface (CLI), if it uses
732728
- `--timeout <time value>`: override the default timeout mentioned as a target property. The syntax for times is just like the LF one (e.g. `1msec`, `"2 seconds"`).
733729
- `--workers <number>`: override the default worker count mentioned as a target property. This option is **ignored** unless the runtime crate has been built with the feature `parallel-runtime`.
734730
- `--export-graph`: export the dependency graph (corresponds to `export-dependency-graph` target property). This is a flag, i.e., absent means false, present means true. This means the value of the target property is ignored and not used as default.
735-
- `--log-level`: corresponds to the `logging` target property, but note that the levels have different meanings, and the target property is ignored. See [Logging levels](#logging-levels).
736731
- parameters of the main reactor are translated to CLI parameters.
737732
- Each LF parameter named `param` corresponds to a CLI parameter named `--main-param`. Underscores in the LF parameter name are replaced by hyphens.
738733
- The type of each parameters must implement the trait [`FromStr`](https://doc.rust-lang.org/std/str/trait.FromStr.html).

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)