Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patmos on V0.9.0 #297

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions docs/embedded/patmos.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: Patmos
description: Developing LF Programs for Patmos.
---
# Overview
Lingua Franca's C-runtime supports [Patmos](https://github.com/t-crest/patmos),
a bare-metal execution platform that is optimized for time-predictable execution.
The time-predictability aspect of Patmos makes it easier to obtain a worst-case
execution time (WCET) for reactions.
## Prerequisites
- Linux or macOS development system. (use WSL on Windows)
- DE2-115 Development Kit, which is equipped with Altera Cyclone IV FPGA (optional)
### Getting Started
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)
### Compiling and Running Lingua Franca codes
Patmos can run in an FPGA, but there are also two simulators available:

1. `pasim`: a software ISA simulator that is written in C++.
2. `patemu`: a cycle-accurate hardware emulator generated from the hardware description.

Consider the following simple LF program inside the HelloPatmos.lf file located in `test/C/src/patmos/HelloPatmos.lf`:
```lf-c
target C {
platform: "Patmos",
single-threaded: true,
build-type: Debug,
}

main reactor {
reaction(startup) {=
printf("Hello World!\n");
=}
}


```
You can generate C code using `lfc HelloPatmos.lf` command in the above folder:

```
cd test/C/src/patmos/
lfc HelloPatmos.lf
```

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:

```
cd ../../src-gen/patmos/HelloPatmos/build
pasim HelloPatmos
```
After executing the above command, the following lines must be printed.
```
Hello World!
---- Elapsed logical time (in nsec): 0
---- Elapsed physical time (in nsec): 770,000
```

The reactor can also be executed on the hardware emulator of Patmos:

```
patemu HelloPatmos
```

This execution is considerably slower than the SW simulator, as the concrete hardware
of Patmos is simulated cycle-accurate. Here is a sample of its output:

```
Hello World!
---- Elapsed logical time (in nsec): 0
---- Elapsed physical time (in nsec): 3,459,000
```
6 changes: 5 additions & 1 deletion docs/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ const sidebars: SidebarsConfig = {
"type": "doc",
"id": "embedded/arduino"
},
{
"type": "doc",
"id": "embedded/patmos"
},
{
"type": "doc",
"id": "embedded/zephyr"
Expand Down Expand Up @@ -245,4 +249,4 @@ const sidebars: SidebarsConfig = {
]
};

export default sidebars;
export default sidebars;
Loading