Skip to content

Commit b36e0bb

Browse files
patmos and s4noc support (#288)
* Patmos and S4NoC support: init commit * Patmos and S4NoC support: 2nd commit * Patmos and S4NoC: 3rd Commit * Patmos and s4noc: 4th Commit: s4noc_channel passed the test * Patmos and s4noc support * Patmos and s4noc support: 6 * Patmos and s4noc : 7 * Patmos and S4NoC: 8 * Patmos and S4NoC 9 * Patmos and S4NoC 10: manipulator to the second-to-last reactors is added. * Patmos and S4NoC 11: compiled * stuck at receive * Recieves with long delay and lacks cb * fpga config and download * failed on fpga solved * global state are set in channel * loop in build.sh * main file generator * unconnected handling * new connectin handling disabled for channel_test * some modifications * s4noc_fed * fpga config & some renaming * readme update * --recursive in readme * log lock * cpu_id in log * handle_new_connection as a macro * poll in wait until * mutex for system events queue * skip handshake when clock-sync is disabled * patmos: wake scheduler on notify by returning LF_SLEEP_INTERRUPTED in wait_until_interruptible * s4noc_fed sample is fixed * A semicolon was forgotten * shutdown and log mutex added to s4noc_fed example * patmos action * template is used. + github action errors solved * Specifying platforms that can use mutex for logging * debugging github errors * warning remove from s4noc_channel.c * Use of macros in s4noc_fed sender/receiver exmpale. Add limited timeout for both Increase the number of msgs Add msg number to msg struct shutdown req when all msgs are sent/received Add common marcos b/w sender and receiver in one header file (common_config.h) Resolve warning in s4noc_fed/main.c and s4noc_channel.c * optimization: -O1 * ar instead of llvm-ar * installing emulator on action.yml * patemu doesn't have --version * clone template * clone reactor-uc branch of lf-patmos template * Path for makefilelist corrected * shorter examples * Update patmos.yml to remove cloning template from * remove clock_sync skip * fix fed env * formatting * merge issue in patmos.c * LF_NETWORK_CHANNEL_EMPTY instead of LF_AGAIN * log lock in platform * fix patmos * remove locking of system_event_queue * last fixes * add riot back * more stuff * skip a test --------- Co-authored-by: tanneberger <github@tanneberger.me>
1 parent 8b9acd8 commit b36e0bb

61 files changed

Lines changed: 2340 additions & 67 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/patmos/action.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Install Patmos and dependencies (Linux only)
2+
description: Install Patmos and dependencies (Linux only)
3+
inputs:
4+
clone-template:
5+
description: "Clone lf-patmos-template next to reactor-uc"
6+
required: false
7+
default: "true"
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Install required packages
12+
shell: bash
13+
run: |
14+
sudo apt-get update
15+
sudo apt-get install -y git openjdk-11-jdk cmake make g++ texinfo flex bison \
16+
subversion libelf-dev graphviz libboost-dev libboost-program-options-dev ruby-full \
17+
liblpsolve55-dev zlib1g-dev gtkwave gtkterm scala autoconf libfl2 expect verilator curl chrpath
18+
19+
- name: Install sbt
20+
shell: bash
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install -y apt-transport-https gnupg
24+
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list
25+
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list
26+
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo -H gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/scalasbt-release.gpg --import
27+
sudo chmod 644 /etc/apt/trusted.gpg.d/scalasbt-release.gpg
28+
sudo apt-get update
29+
sudo apt-get install -y sbt
30+
31+
- name: Clone and build Patmos
32+
shell: bash
33+
run: |
34+
export PATH=$PATH:$HOME/t-crest/local/bin
35+
echo "PATH=$PATH:$HOME/t-crest/local/bin" >> "$GITHUB_ENV"
36+
echo $PATH
37+
mkdir ~/t-crest
38+
cd ~/t-crest
39+
git clone https://github.com/t-crest/patmos-misc.git misc
40+
./misc/build.sh -q
41+
42+
- name: Verify Patmos installation
43+
shell: bash
44+
run: |
45+
patmos-clang --version
46+
if [ $? -ne 0 ]; then
47+
echo "Patmos installation failed"
48+
exit 1
49+
fi
50+
51+
- name: Clone template
52+
shell: bash
53+
run: |
54+
if [ "${{ inputs.clone-template }}" = "true" ]; then
55+
echo "Cloning lf-patmos-template (reactor-uc branch) as sibling of reactor-uc..."
56+
# Clone one level up from GITHUB_WORKSPACE (which is reactor-uc/)
57+
cd "$GITHUB_WORKSPACE/.."
58+
git clone --depth=1 --branch reactor-uc https://github.com/lf-lang/lf-patmos-template.git lf-patmos-template
59+
if [ ! -f "$GITHUB_WORKSPACE/../lf-patmos-template/MakefileTemplate" ]; then
60+
echo "lfc: error: Patmos template not found at: $GITHUB_WORKSPACE/../lf-patmos-template/MakefileTemplate";
61+
exit 1;
62+
fi
63+
echo "Template cloned successfully at $GITHUB_WORKSPACE/../lf-patmos-template"
64+
fi

.github/workflows/patmos.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: "Platform: PATMOS"
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
8+
jobs:
9+
ci:
10+
name: Build examples
11+
runs-on: ubuntu-24.04
12+
env:
13+
REACTOR_UC_PATH: ${{ github.workspace }}
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
with:
18+
submodules: recursive
19+
20+
- name: Install dependencies
21+
uses: ./.github/actions/patmos
22+
23+
- name: Build examples
24+
working-directory: ${{ github.workspace }}/examples/patmos
25+
run: |
26+
./buildAll.sh

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ cmake-build-release
1111
doc/html
1212
doc/latex
1313
doc/markdown/platform
14-
sdkconfig
14+
*.o
15+
*.bc
16+
*.elf
17+
sdkconfig

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,19 @@ information on reactor-uc see our [docs](https://www.lf-lang.org/reactor-uc/)
1616
- Java 17
1717
- Additional requirements depend on the target platform
1818

19+
### Installation & Quick Start
20+
21+
22+
Clone the repository and set REACTOR_UC_PATH:
23+
```sh
24+
git clone https://github.com/lf-lang/reactor-uc.git --recursive
25+
cd reactor-uc
26+
export REACTOR_UC_PATH=$(pwd)
27+
```
28+
29+
1930
## Supported Platforms
20-
`reactor-uc` can run on top of Zephyr, RIOT, Raspberry Pi Pico and POSIX-compliant OSes.
31+
`reactor-uc` can run on top of Zephyr, RIOT, Raspberry Pi Pico, Patmos, and POSIX-compliant OSes.
2132

2233
### Native (macOS and Linux)
2334
`reactor-uc` can also run natively on a host system based on Linux or macOS. This is very useful for developing and testing applications
@@ -87,6 +98,25 @@ cd build
8798
make
8899
```
89100

101+
### Patmos
102+
103+
To install Patmos, follow instructions in [https://github.com/t-crest/patmos/](https://github.com/t-crest/patmos) readme file.
104+
Then clone template repository as a sibling folder to this repo by running these commands:
105+
```shell
106+
cd ..
107+
git clone --branch reactor-uc https://github.com/lf-lang/lf-patmos-template.git lf-patmos-template
108+
cd reactor-uc
109+
```
110+
111+
To compile and run patmos examples, navigate to their folders inside `exmaples/patmos` folder and run `./build.sh`.
112+
113+
To compile and run all examples together, run the following lines:
114+
115+
```shell
116+
cd examples/patmos
117+
./buildAll.sh
118+
```
119+
90120
## Contributing
91121

92122
### Code organization
@@ -125,6 +155,16 @@ make lf-test
125155

126156
This depends on having the `timeout` utility installed. For macOS users run `brew install coreutils`.
127157

158+
Run platform related tests with
159+
```sh
160+
make platform-test
161+
```
162+
163+
Run all examples with
164+
```sh
165+
make examples
166+
```
167+
128168
Compute unit test coverage
129169
```sh
130170
make coverage

examples/fed-template/buildAll.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ cmake -Bbuild
1010
cmake --build build
1111
popd
1212

13-
pushd MyFed/dest
14-
./run_lfc.sh
15-
west build
16-
popd
17-
13+
if ! command -v west &> /dev/null; then
14+
echo "Error: 'west' is not installed."
15+
else
16+
pushd MyFed/dest
17+
./run_lfc.sh
18+
west build
19+
popd
20+
fi

examples/flexpret/buildAll.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
set -e
2-
${REACTOR_UC_PATH}/lfc/bin/lfc-dev src/Smoke.lf
3-
cmake -Bbuild
4-
make -C build
5-
bin/fp-smoke
2+
if [ -z "$FP_SDK_PATH" ]; then
3+
echo "Error: FP_SDK_PATH is not defined. Please set it before running this script."
4+
else
5+
${REACTOR_UC_PATH}/lfc/bin/lfc-dev src/Smoke.lf
6+
cmake -Bbuild
7+
make -C build
8+
bin/fp-smoke
9+
fi

examples/patmos/buildAll.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if ! command -v pasim &> /dev/null; then
6+
echo "Error: pasim command not found. Please ensure it is installed and available in your PATH."
7+
else
8+
# Iterate over each folder and execute the command
9+
for dir in ./*; do
10+
if [ -d "$dir" ]; then
11+
# Skip directories that should not be built via this runner
12+
case "$dir" in
13+
"./s4noc_fed")
14+
echo "Skipping $dir (disabled for buildAll.sh)"
15+
continue
16+
;;
17+
esac
18+
19+
echo "Entering $dir"
20+
pushd "$dir"
21+
chmod +x build.sh
22+
./build.sh
23+
popd
24+
fi
25+
done
26+
fi

examples/patmos/hello/Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Makefile for building a simple Hello World program for the Patmos platform
2+
3+
# Compiler and tools for PATMOS
4+
CC = patmos-clang
5+
6+
# Paths
7+
SRC_DIR = $(CURDIR)
8+
BUILD_DIR = $(CURDIR)/build
9+
10+
# Source files
11+
SOURCES = $(SRC_DIR)/hello.c
12+
13+
# Compiler flags
14+
CFLAGS = -O2 -Wall -Wextra -Werror
15+
16+
# Output binary
17+
OUTPUT = $(BUILD_DIR)/hello.elf
18+
all : $(OUTPUT)
19+
# Build rule
20+
$(OUTPUT): $(SOURCES)
21+
mkdir -p $(BUILD_DIR)
22+
$(CC) $(CFLAGS) $(SOURCES) -o $(OUTPUT)
23+
24+
clean:
25+
rm -rf $(BUILD_DIR)
26+
27+
.PHONY: all clean

examples/patmos/hello/build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
rm -rf build
3+
make all
4+
pasim ./build/hello.elf

examples/patmos/hello/hello.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include <stdio.h>
2+
int main () {
3+
printf("Hello Patmos!\n");
4+
return 0;
5+
}

0 commit comments

Comments
 (0)