Skip to content

Commit 0172e2f

Browse files
committed
stuck at receive
1 parent f3b315a commit 0172e2f

File tree

6 files changed

+20
-37
lines changed

6 files changed

+20
-37
lines changed

examples/patmos/s4noc_fed_lf/build.sh

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,13 @@ popd
1616
pushd ./$LF_MAIN/r2
1717
REACTOR_PATH=$(pwd)/src-gen/$LF_MAIN/r2
1818
./run_lfc.sh
19-
20-
sed -i 's/_lf_environment/_lf_environment_2/g' $REACTOR_PATH/lf_start.c
21-
sed -i 's/lf_exit/lf_exit_2/g' $REACTOR_PATH/lf_start.c
22-
sed -i 's/lf_start/lf_start_2/g' $REACTOR_PATH/lf_start.c
23-
sed -i 's/(Federate/(Federate2/g' $REACTOR_PATH/lf_federate.h $REACTOR_PATH/lf_federate.c
24-
sed -i 's/FederateStartupCoordinator/Federate2StartupCoordinator/g' $REACTOR_PATH/lf_federate.h
25-
sed -i 's/FederateClockSynchronization/Federate2ClockSynchronization/g' $REACTOR_PATH/lf_federate.h
26-
sed -i 's/Reactor_S4NoCFedLF/Reactor_S4NoCFedLF_2/g' $REACTOR_PATH/lf_federate.h $REACTOR_PATH/lf_federate.c
27-
sed -i 's/S4NoCFedLF_r1/S4NoCFedLF_r1_2/g' $REACTOR_PATH/lf_federate.h $REACTOR_PATH/lf_federate.c
28-
19+
sed -i 's/_lf_environment/_lf_environment_2/g; s/lf_exit/lf_exit_2/g; s/lf_start/lf_start_2/g' $REACTOR_PATH/lf_start.c
20+
sed -i 's/(Federate/(Federate2/g; s/FederateStartupCoordinator/Federate2StartupCoordinator/g; s/FederateClockSynchronization/Federate2ClockSynchronization/g; s/Reactor_S4NoCFedLF/Reactor_S4NoCFedLF_2/g; s/S4NoCFedLF_r1/S4NoCFedLF_r1_2/g' $REACTOR_PATH/lf_federate.h $REACTOR_PATH/lf_federate.c
2921
make all OBJECTS="$REACTOR_PATH/lf_federate.bc $REACTOR_PATH/$LF_MAIN/Dst.bc $REACTOR_PATH/lf_start.bc"
3022
popd
3123

3224
mkdir -p $BIN_DIR
3325

34-
patmos-clang -v -O1 main.c ./$LF_MAIN/r1/bin/$LF_MAIN.a ./$LF_MAIN/r2/bin/$LF_MAIN.a \
35-
-o $BIN_DIR/$LF_MAIN
26+
patmos-clang -O2 -Wall -Wextra main.c ./$LF_MAIN/r1/bin/$LF_MAIN.a ./$LF_MAIN/r2/bin/$LF_MAIN.a -o $BIN_DIR/$LF_MAIN
3627
patemu $BIN_DIR/$LF_MAIN
3728

examples/patmos/s4noc_fed_lf/main.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#include <pthread.h>
33

44
#include "S4NoCFedLF/r1/src-gen/S4NoCFedLF/r1/lf_start.h"
5-
// #include "S4NoCFedLF/r1/src-gen/S4NoCFedLF/r2/lf_start.h"
6-
// #include "S4NoCFedLF/r2/src-gen/S4NoCFedLF/r1/lf_start.h"
75
#include "S4NoCFedLF/r2/src-gen/S4NoCFedLF/r2/lf_start.h"
86

97

@@ -35,9 +33,4 @@ int main(void) {
3533

3634
printf("All federates finished.\n");
3735
return 0;
38-
}
39-
40-
// int main(void) {
41-
// printf("Starting S4NOC Federated LF Example\n");
42-
// return 0;
43-
// }
36+
}

examples/patmos/s4noc_fed_lf/src/S4NoCFedLF.lf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
target uC {
22
platform: PATMOS,
3-
timeout: 10 sec
3+
timeout: 20 sec
44
}
55

66
reactor Src(id: int = 0) {
@@ -33,12 +33,11 @@ reactor Dst {
3333
}
3434

3535
federated reactor {
36-
@interface_s4noc(core=0)
36+
@interface_s4noc(core=2)
3737
r1 = new Src(id=42)
3838

3939
@interface_s4noc(core=1)
4040
r2 = new Dst()
4141

42-
// @link(left="0", right="1")
4342
r1.out -> r2.in
4443
}

src/platform/patmos/s4noc_channel.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,21 @@ static lf_ret_t S4NOCPollChannel_send_blocking(NetworkChannel *untyped_self, con
3737

3838
volatile _IODEV int *s4noc_data = (volatile _IODEV int *)(PATMOS_IO_S4NOC + 4);
3939
volatile _IODEV int *s4noc_dest = (volatile _IODEV int *)(PATMOS_IO_S4NOC + 8);
40+
// S4NOC_CHANNEL_DEBUG("S4NOCPollChannel_send_blocking called with message: %p", message);
4041

4142
if (self->state == NETWORK_CHANNEL_STATE_CONNECTED) {
4243
int message_size = serialize_to_protobuf(message, self->write_buffer + 4, S4NOC_CHANNEL_BUFFERSIZE - 4);
4344

4445
*((int *)self->write_buffer) = message_size;
45-
46+
S4NOC_CHANNEL_DEBUG("S4NOCPollChannel_send_blocking: message size: ((%d)).", message_size);
4647
int total_size = message_size + 4;
4748
*s4noc_dest = self->destination_core;
4849
int bytes_send = 0;
4950
while (bytes_send < total_size) {
5051
*s4noc_data = ((int *)self->write_buffer)[bytes_send / 4];
5152
bytes_send += 4;
5253
}
53-
S4NOC_CHANNEL_DEBUG("Sent %d bytes", bytes_send);
54+
S4NOC_CHANNEL_DEBUG("Sent ((%d)) bytes", bytes_send);
5455
return LF_OK;
5556
} else {
5657
return LF_ERR;
@@ -61,7 +62,7 @@ static void S4NOCPollChannel_register_receive_callback(NetworkChannel *untyped_s
6162
void (*receive_callback)(FederatedConnectionBundle *conn,
6263
const FederateMessage *msg),
6364
FederatedConnectionBundle *conn) {
64-
S4NOC_CHANNEL_INFO("Register receive callback at %p", receive_callback);
65+
// S4NOC_CHANNEL_INFO("Register receive callback at %p", receive_callback);
6566
S4NOCPollChannel *self = (S4NOCPollChannel *)untyped_self;
6667

6768
self->receive_callback = receive_callback;
@@ -70,43 +71,42 @@ static void S4NOCPollChannel_register_receive_callback(NetworkChannel *untyped_s
7071

7172
void S4NOCPollChannel_poll(NetworkChannel *untyped_self) {
7273
S4NOCPollChannel *self = (S4NOCPollChannel *)untyped_self;
73-
S4NOC_CHANNEL_INFO("S4NOCPollChannel_poll called");
74+
// S4NOC_CHANNEL_INFO("S4NOCPollChannel_poll called");
7475

7576
volatile _IODEV int *s4noc_status = (volatile _IODEV int *)PATMOS_IO_S4NOC;
7677
volatile _IODEV int *s4noc_data = (volatile _IODEV int *)(PATMOS_IO_S4NOC + 4);
7778
volatile _IODEV int *s4noc_source = (volatile _IODEV int *)(PATMOS_IO_S4NOC + 8);
7879

7980
if (((*s4noc_status) & 0x02) == 0) {
80-
S4NOC_CHANNEL_INFO("S4NOCPollChannel_poll: No data available");
81+
S4NOC_CHANNEL_INFO("S4NOCPollChannel_poll: No data is available"); //if i remove it platform-test doesn't work
8182
return;
8283
}
8384

8485
int value = *s4noc_data;
8586
int source = *s4noc_source;
86-
S4NOC_CHANNEL_INFO("S4NOCPollChannel_poll: Received value 0x%08x (%c%c%c%c) from source %d", value,
87-
((char *)&value)[0], ((char *)&value)[1], ((char *)&value)[2], ((char *)&value)[3], source);
87+
S4NOC_CHANNEL_INFO("S4NOCPollChannel_poll: Received data 0x%08x (%c%c%c%c) from source %d", value, ((char *)&value)[0], ((char *)&value)[1], ((char *)&value)[2], ((char *)&value)[3], source);
8888
S4NOCPollChannel *receive_channel =
8989
s4noc_global_state.core_channels[source][get_cpuid()]; // Get the receive channel for the source core
9090

9191
((int *)receive_channel->receive_buffer)[receive_channel->receive_buffer_index / 4] = value;
9292
receive_channel->receive_buffer_index += 4;
93-
S4NOC_CHANNEL_DEBUG("receive_buffer_index %d", receive_channel->receive_buffer_index);
93+
S4NOC_CHANNEL_DEBUG("receive_buffer_index ((%d))", receive_channel->receive_buffer_index);
9494
unsigned int expected_message_size = *((int *)receive_channel->receive_buffer);
95-
S4NOC_CHANNEL_DEBUG("Expected message size: %d", expected_message_size);
95+
S4NOC_CHANNEL_DEBUG("Expected message size: ((%d))", expected_message_size);
9696
if (receive_channel->receive_buffer_index >= expected_message_size + 4) {
9797
int bytes_left = deserialize_from_protobuf(&receive_channel->output,
9898
receive_channel->receive_buffer + 4, // skip the 4-byte size header
9999
expected_message_size // only the message payload
100100
);
101-
S4NOC_CHANNEL_DEBUG("Bytes Left after attempted to deserialize: %d", bytes_left);
101+
// S4NOC_CHANNEL_DEBUG("Bytes Left after attempted to deserialize: %d", bytes_left);
102102

103103
if (bytes_left >= 0) {
104104
receive_channel->receive_buffer_index = bytes_left;
105105
if (receive_channel->receive_callback != NULL) {
106-
S4NOC_CHANNEL_DEBUG("calling user callback at %p!", receive_channel->receive_callback);
106+
// S4NOC_CHANNEL_DEBUG("calling user callback at %p!", receive_channel->receive_callback);
107107
receive_channel->receive_callback(self->federated_connection, &receive_channel->output);
108108
} else {
109-
S4NOC_CHANNEL_WARN("No receive callback registered, dropping message");
109+
// S4NOC_CHANNEL_WARN("No receive callback registered, dropping message");
110110
}
111111
}
112112
}

test/platform/patmos/s4noc_channel_test/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ BUILD_DIR = $(CURDIR)/build
99
# Source files
1010
SOURCES += $(SRC_DIR)/$(APP).c
1111

12-
CFLAGS += -DLF_LOG_LEVEL_ALL=LF_LOG_LEVEL_INFO
12+
CFLAGS += -DLF_LOG_LEVEL_ALL=LF_LOG_LEVEL_DEBUG
1313

1414
# Output binary
1515
OUTPUT = $(BUILD_DIR)/$(APP).elf

test/platform/patmos/s4noc_channel_test/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void send_message(void) {
6767
const char *message = MESSAGE_CONTENT;
6868
memcpy(port_message->payload.bytes, message, sizeof(MESSAGE_CONTENT)); // NOLINT
6969
port_message->payload.size = sizeof(MESSAGE_CONTENT);
70-
LF_INFO(NET, "Sender: Sending message with connection number %i and content %s\n", port_message->conn_id, (char *)port_message->payload.bytes);
70+
// LF_INFO(NET, "Sender: Sending message with connection number %i and content %s\n", port_message->conn_id, (char *)port_message->payload.bytes);
7171
TEST_ASSERT_OK(sender->send_blocking(sender, &msg));
7272
}
7373

0 commit comments

Comments
 (0)