Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e923ce8
Patmos and S4NoC support: init commit
EhsanKhodadad May 6, 2025
de6bb6d
Patmos and S4NoC support: 2nd commit
EhsanKhodadad May 13, 2025
5450bbb
Patmos and S4NoC: 3rd Commit
EhsanKhodadad May 22, 2025
0e3c723
Patmos and s4noc: 4th Commit: s4noc_channel passed the test
EhsanKhodadad May 27, 2025
c2436f6
Patmos and s4noc support
EhsanKhodadad Jun 5, 2025
ad9a2e4
Patmos and s4noc support: 6
EhsanKhodadad Jun 10, 2025
843c316
Patmos and s4noc : 7
EhsanKhodadad Jun 12, 2025
a928619
Patmos and S4NoC: 8
EhsanKhodadad Jun 19, 2025
8a2e842
Patmos and S4NoC 9
EhsanKhodadad Jun 25, 2025
87f79d8
Patmos and S4NoC 10: manipulator to the second-to-last reactors is ad…
EhsanKhodadad Jul 1, 2025
00acbd5
Patmos and S4NoC 11: compiled
EhsanKhodadad Jul 2, 2025
60fed35
stuck at receive
EhsanKhodadad Jul 29, 2025
d2a9731
Recieves with long delay and lacks cb
EhsanKhodadad Aug 14, 2025
481a419
fpga config and download
EhsanKhodadad Aug 18, 2025
7c460af
failed on fpga solved
EhsanKhodadad Aug 26, 2025
e39efaa
global state are set in channel
EhsanKhodadad Aug 28, 2025
68984ba
loop in build.sh
EhsanKhodadad Sep 1, 2025
be2d86e
main file generator
EhsanKhodadad Sep 2, 2025
77e8b97
unconnected handling
EhsanKhodadad Oct 21, 2025
7870744
new connectin handling disabled for channel_test
EhsanKhodadad Oct 22, 2025
3a276f8
some modifications
EhsanKhodadad Oct 22, 2025
5fd3942
s4noc_fed
EhsanKhodadad Oct 30, 2025
dc04629
fpga config & some renaming
EhsanKhodadad Oct 31, 2025
b74cc7d
readme update
EhsanKhodadad Oct 31, 2025
abd0456
--recursive in readme
EhsanKhodadad Oct 31, 2025
7f335fd
log lock
EhsanKhodadad Nov 3, 2025
0486db0
cpu_id in log
EhsanKhodadad Nov 4, 2025
737cd87
handle_new_connection as a
EhsanKhodadad Nov 5, 2025
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ cmake-build-release
doc/html
doc/latex
doc/markdown/platform
*.o
*.bc
*.elf
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,19 @@ information on reactor-uc see our [docs](https://www.lf-lang.org/reactor-uc/)
- Java 17
- Additional requirements depend on the target platform

### Installation & Quick Start


Clone the repository and set REACTOR_UC_PATH:
```sh
git clone https://github.com/lf-lang/reactor-uc.git --recursive
cd reactor-uc
export REACTOR_UC_PATH=$(pwd)
```


## Supported Platforms
`reactor-uc` can run on top of Zephyr, RIOT, Raspberry Pi Pico and POSIX-compliant OSes.
`reactor-uc` can run on top of Zephyr, RIOT, Raspberry Pi Pico, Patmos, and POSIX-compliant OSes.

### Native (macOS and Linux)
`reactor-uc` can also run natively on a host system based on Linux or macOS. This is very useful for developing and testing applications
Expand Down Expand Up @@ -87,6 +98,19 @@ cd build
make
```

### Patmos

To install Patmos, follow instructions in [https://github.com/t-crest/patmos/](https://github.com/t-crest/patmos) readme file.

To compile and run patmos examples, navigate to their folders inside `exmaples/patmos` folder and run `./build.sh`.

To compile and run all examples together, run the following lines:

```shell
cd examples/patmos
./buildAll.sh
```

## Contributing

### Code organization
Expand Down Expand Up @@ -125,6 +149,16 @@ make lf-test

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

Run platform related tests with
```sh
make platform-test
```

Run all examples with
```sh
make examples
```

Compute unit test coverage
```sh
make coverage
Expand Down
13 changes: 8 additions & 5 deletions examples/fed-template/buildAll.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ cmake -Bbuild
cmake --build build
popd

pushd MyFed/dest
./run_lfc.sh
west build
popd

if ! command -v west &> /dev/null; then
echo "Error: 'west' is not installed."
else
pushd MyFed/dest
./run_lfc.sh
west build
popd
fi
12 changes: 8 additions & 4 deletions examples/flexpret/buildAll.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
set -e
${REACTOR_UC_PATH}/lfc/bin/lfc-dev src/Smoke.lf
cmake -Bbuild
make -C build
bin/fp-smoke
if [ -z "$FP_SDK_PATH" ]; then
echo "Error: FP_SDK_PATH is not defined. Please set it before running this script."
else
${REACTOR_UC_PATH}/lfc/bin/lfc-dev src/Smoke.lf
cmake -Bbuild
make -C build
bin/fp-smoke
fi
18 changes: 18 additions & 0 deletions examples/patmos/buildAll.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -e

if ! command -v pasim &> /dev/null; then
echo "Error: pasim command not found. Please ensure it is installed and available in your PATH."
else
# Iterate over each folder and execute the command
for dir in ./*; do
if [ -d $dir ]; then
echo "Entering $dir"
pushd $dir
chmod +x build.sh
./build.sh
popd
fi
done
fi
27 changes: 27 additions & 0 deletions examples/patmos/hello/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Makefile for building a simple Hello World program for the Patmos platform

# Compiler and tools for PATMOS
CC = patmos-clang

# Paths
SRC_DIR = $(CURDIR)
BUILD_DIR = $(CURDIR)/build

# Source files
SOURCES = $(SRC_DIR)/hello.c

# Compiler flags
CFLAGS = -O2 -Wall -Wextra -Werror

# Output binary
OUTPUT = $(BUILD_DIR)/hello.elf
all : $(OUTPUT)
# Build rule
$(OUTPUT): $(SOURCES)
mkdir -p $(BUILD_DIR)
$(CC) $(CFLAGS) $(SOURCES) -o $(OUTPUT)

clean:
rm -rf $(BUILD_DIR)

.PHONY: all clean
4 changes: 4 additions & 0 deletions examples/patmos/hello/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
rm -rf build
make all
pasim ./build/hello.elf
5 changes: 5 additions & 0 deletions examples/patmos/hello/hello.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <stdio.h>
int main () {
printf("Hello Patmos!\n");
return 0;
}
33 changes: 33 additions & 0 deletions examples/patmos/hello_lf/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
REACTOR_UC_PATH ?= $(CURDIR)/../../../
LF_MAIN ?= HelloLF

# The name of the LF application inside "./src" to build/run/flash etc.
SRC_GEN_PATH ?= ./src-gen/$(LF_MAIN)

# Execute the LF compiler if build target is "all"
ifeq ($(firstword $(MAKECMDGOALS)),all)
_ := $(shell $(REACTOR_UC_PATH)/lfc/bin/lfc-dev src/$(LF_MAIN).lf)
endif

# ---- Patmos specific configuration ----
include $(REACTOR_UC_PATH)/make/patmos/patmos-lfc.mk

CFLAGS += -DEVENT_QUEUE_SIZE=$(EVENT_QUEUE_SIZE)
CFLAGS += -DREACTION_QUEUE_SIZE=$(REACTION_QUEUE_SIZE)

# Output directory
BIN_DIR = $(CURDIR)/bin
OUTPUT = $(BIN_DIR)/$(LF_MAIN)

all: $(OUTPUT)

# Build rule
$(OUTPUT): $(SOURCES)
mkdir -p $(BIN_DIR)
$(CC) $(SOURCES) $(CFLAGS) -o $(OUTPUT)

clean:
rm -rf $(BIN_DIR) ./src-gen

.PHONY: all clean

5 changes: 5 additions & 0 deletions examples/patmos/hello_lf/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

rm -rf bin src-gen
make all
pasim ./bin/HelloLF
9 changes: 9 additions & 0 deletions examples/patmos/hello_lf/src/HelloLF.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
target uC {
platform: Patmos
}

main reactor {
reaction(startup) {=
printf("Hello LF on PATMOS!\n");
=}
}
20 changes: 20 additions & 0 deletions examples/patmos/s4noc_fed/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
include $(REACTOR_UC_PATH)/make/patmos/patmos.mk

OUTPUT = s4noc_fed.elf
BIN_DIR = $(CURDIR)/bin

SOURCES += $(CURDIR)/main.c
SOURCES += $(CURDIR)/sender/build/sender.a
SOURCES += $(CURDIR)/receiver/build/receiver.a

all: $(OUTPUT)

$(OUTPUT): $(SOURCES)
@echo "BUILDING $(notdir $@) from $^"
mkdir -p $(BIN_DIR)
$(CC) $(CFLAGS) $(SOURCES) -o $(BIN_DIR)/$(OUTPUT)

clean:
rm -rf $(BIN_DIR)

.PHONY: all clean
31 changes: 31 additions & 0 deletions examples/patmos/s4noc_fed/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# !/bin/bash

LF_MAIN=s4noc_fed
BIN_DIR=bin
CC=patmos-clang

make clean -C ./sender
make clean -C ./receiver

make all -C ./sender
make all -C ./receiver

echo "Linking sender and receiver to create executable"
make clean
make all

read -n 1 -t 10 -p "Choose action: [e]mulate or [f]pga? (default: e) " action
action=${action:-e}
if [[ "$action" == "e" ]]; then
patemu $BIN_DIR/$LF_MAIN.elf
elif [[ "$action" == "f" ]]; then
if jtagconfig | grep -q "USB-Blaster"; then
mv $BIN_DIR/$LF_MAIN.elf ~/t-crest/patmos/tmp/$LF_MAIN.elf
make -C ~/t-crest/patmos APP=$LF_MAIN config download
else
echo "JTAG not connected. Please connect USB-Blaster."
fi
else
echo "Invalid option. Please choose 'e' for emulate or 'f' for fpga."
fi

33 changes: 33 additions & 0 deletions examples/patmos/s4noc_fed/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <stdio.h>
#include <pthread.h>
#include "sender/sender.h"
#include "receiver/receiver.h"

static void* receiver_thread(void* arg) {
(void)arg;
// printf("Starting receiver federate on core/thread 1\n");
lf_start_receiver();
return NULL;
}

static void* sender_thread(void* arg) {
(void)arg;
printf("Starting sender federate on core/thread 2\n");
lf_start_sender();
return NULL;
}

int main(void) {
pthread_t threads[2];
printf("Starting S4NOC Federated Example\n");
pthread_create(&threads[0], NULL, receiver_thread, NULL);
pthread_create(&threads[1], NULL, sender_thread, NULL);

printf("Threads created for federates.\n");

pthread_join(threads[0], NULL);
pthread_join(threads[1], NULL);

printf("All federates finished.\n");
return 0;
}
34 changes: 34 additions & 0 deletions examples/patmos/s4noc_fed/receiver/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
include $(REACTOR_UC_PATH)/make/patmos/patmos.mk

FED = receiver

# Paths
SRC_DIR = $(CURDIR)
BUILD_DIR = $(CURDIR)/build

# Source files
SOURCES = $(FED).c

OBJECTS ?= $(SOURCES:.c=.bc)

# Output binary
OUTPUT = $(FED).a

all: $(OUTPUT)

# Build rule
$(OUTPUT): $(OBJECTS)
@echo "BUILDING $(notdir $@) from $^"
mkdir -p $(BUILD_DIR)
llvm-ar rcsv $(BUILD_DIR)/$(OUTPUT) $^;

%.bc: %.c
@echo "$(notdir $^) COMPILED TO $(notdir $@)"
mkdir -p $(BUILD_DIR)
$(CC) $(CFLAGS) -emit-llvm -c $^ -o $@

clean:
rm -rf $(BUILD_DIR)
rm -f $(FED).bc

.PHONY: all clean
Loading