Skip to content

Commit 1af63f7

Browse files
committed
fpga config and download
1 parent b5329af commit 1af63f7

File tree

5 files changed

+43
-10
lines changed

5 files changed

+43
-10
lines changed

examples/patmos/s4noc_fed_lf/build.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,18 @@ popd
2424
mkdir -p $BIN_DIR
2525

2626
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
27-
patemu $BIN_DIR/$LF_MAIN
27+
read -t 10 -p "Choose action: [e]mulate or [f]pga? (default: e) " action
28+
action=${action:-e}
29+
if [[ "$action" == "e" ]]; then
30+
patemu $BIN_DIR/$LF_MAIN
31+
elif [[ "$action" == "f" ]]; then
32+
if jtagconfig | grep -q "USB-Blaster"; then
33+
mv $BIN_DIR/$LF_MAIN ~/t-crest/patmos/tmp/$LF_MAIN.elf
34+
make -C ~/t-crest/patmos APP=$LF_MAIN config download
35+
else
36+
echo "JTAG not connected. Please connect USB-Blaster."
37+
fi
38+
else
39+
echo "Invalid option. Please choose 'e' for emulate or 'f' for fpga."
40+
fi
2841

lfc/core/src/main/kotlin/org/lflang/generator/uc/UcNetworkChannel.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,7 @@ class UcS4NocChannel(
402402
private val srcS4Noc = src
403403
private val destS4Noc = dest
404404

405-
override fun generateChannelCtorSrc() =
406-
"S4NOCPollChannel_ctor(&self->channel, ${srcS4Noc.core});"
405+
override fun generateChannelCtorSrc() = "S4NOCPollChannel_ctor(&self->channel, ${srcS4Noc.core});"
407406

408407
override fun generateChannelCtorDest() =
409408
"S4NOCPollChannel_ctor(&self->channel, ${destS4Noc.core});"

src/platform/patmos/patmos.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ lf_ret_t PlatformPatmos_wait_until_interruptible(Platform *super, instant_t wake
2323
PlatformPatmos *self = (PlatformPatmos *)super;
2424

2525
instant_t now = super->get_physical_time(super);
26+
LF_DEBUG(PLATFORM, "PlatformPatmos_wait_until_interruptible: now: %llu sleeping until %llu", now, wakeup_time);
2627

2728
// Do busy sleep
2829
do {
@@ -44,6 +45,7 @@ lf_ret_t PlatformPatmos_wait_until(Platform *super, instant_t wakeup_time) {
4445
}
4546

4647
instant_t now = super->get_physical_time(super);
48+
LF_DEBUG(PLATFORM, "PlatformPatmos_wait_until: now: %llu sleeping until %llu", now, wakeup_time);
4749

4850
// Do busy sleep
4951
do {
@@ -59,11 +61,12 @@ lf_ret_t PlatformPatmos_wait_for(Platform *super, interval_t duration) {
5961

6062
instant_t now = super->get_physical_time(super);
6163
instant_t wakeup = now + duration;
64+
LF_DEBUG(PLATFORM, "PlatformPatmos_wait_for: now: %llu sleeping for %llu", now, duration);
6265

6366
// Do busy sleep
6467
do {
6568
now = super->get_physical_time(super);
66-
} while ((now < wakeup));
69+
} while (now < wakeup);
6770

6871
return LF_OK;
6972
}

src/platform/patmos/s4noc_channel.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ void S4NOCPollChannel_poll(NetworkChannel *untyped_self) {
8686

8787
int value = *s4noc_data;
8888
int source = *s4noc_source;
89-
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);
90-
S4NOCPollChannel *receive_channel =
91-
s4noc_global_state.core_channels[source][get_cpuid()]; // Get the receive channel for the source core
89+
S4NOC_CHANNEL_INFO("S4NOCPollChannel_poll: Received data 0x%08x (%c%c%c%c) from source %d", value,
90+
((char *)&value)[0], ((char *)&value)[1], ((char *)&value)[2], ((char *)&value)[3], source);
91+
// Get the receive channel for the source core
92+
S4NOCPollChannel *receive_channel = s4noc_global_state.core_channels[source][get_cpuid()];
9293

9394
((int *)receive_channel->receive_buffer)[receive_channel->receive_buffer_index / 4] = value;
9495
receive_channel->receive_buffer_index += 4;
@@ -116,7 +117,7 @@ void S4NOCPollChannel_poll(NetworkChannel *untyped_self) {
116117
}
117118

118119
void S4NOCPollChannel_ctor(S4NOCPollChannel *self, unsigned int destination_core) {
119-
assert(self != NULL);
120+
assert(self != NULL);
120121

121122
self->super.super.mode = NETWORK_CHANNEL_MODE_POLLED;
122123
self->super.super.expected_connect_duration = SEC(0);
@@ -135,4 +136,7 @@ void S4NOCPollChannel_ctor(S4NOCPollChannel *self, unsigned int destination_core
135136
self->federated_connection = NULL;
136137
self->state = NETWORK_CHANNEL_STATE_CONNECTED;
137138
self->destination_core = destination_core;
139+
memset(self->receive_buffer, 0, S4NOC_CHANNEL_BUFFERSIZE);
140+
memset(self->write_buffer, 0, S4NOC_CHANNEL_BUFFERSIZE);
141+
138142
}
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
#!/bin/bash
2-
2+
LF_MAIN=main
3+
BIN_DIR=./build
34
# Make test
45
make clean
56
make all
6-
patemu ./build/*.elf
7+
read -t 10 -p "Choose action: [e]mulate or [f]pga? (default: e) " action
8+
action=${action:-e}
9+
if [[ "$action" == "e" ]]; then
10+
patemu $BIN_DIR/$LF_MAIN.elf
11+
elif [[ "$action" == "f" ]]; then
12+
if jtagconfig | grep -q "USB-Blaster"; then
13+
mv $BIN_DIR/$LF_MAIN.elf ~/t-crest/patmos/tmp/$LF_MAIN.elf
14+
make -C ~/t-crest/patmos APP=$LF_MAIN config download
15+
else
16+
echo "JTAG not connected. Please connect USB-Blaster."
17+
fi
18+
else
19+
echo "Invalid option. Please choose 'e' for emulate or 'f' for fpga."
20+
fi
721

0 commit comments

Comments
 (0)