Skip to content

Commit d6ecdfc

Browse files
committed
Docs v0.8.0
1 parent 87d0416 commit d6ecdfc

File tree

358 files changed

+24710
-0
lines changed

Some content is hidden

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

358 files changed

+24710
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bin
2+
src-gen
3+
include
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include/
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
target C {
2+
timeout: 3 secs
3+
}
4+
5+
main reactor Alignment {
6+
state s: int = 0
7+
timer t1(100 msec, 100 msec)
8+
timer t2(200 msec, 200 msec)
9+
timer t4(400 msec, 400 msec)
10+
11+
reaction(t1) {=
12+
self->s += 1;
13+
=}
14+
15+
reaction(t2) {=
16+
self->s -= 2;
17+
=}
18+
19+
reaction(t4) {=
20+
printf("s = %d\n", self->s);
21+
=}
22+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
target C {
2+
keepalive: true // Do not exit when event queue is empty.
3+
}
4+
5+
preamble {=
6+
#include "platform.h" // Defines lf_sleep() and thread functions.
7+
=}
8+
9+
main reactor {
10+
preamble {=
11+
// Schedule an event roughly every 200 msec.
12+
void* external(void* a) {
13+
while (true) {
14+
lf_sleep(MSEC(200));
15+
lf_schedule(a, 0);
16+
}
17+
}
18+
=}
19+
state thread_id: lf_thread_t = 0
20+
physical action a(100 msec): int
21+
22+
reaction(startup) -> a {=
23+
// Start a thread to schedule physical actions.
24+
lf_thread_create(&self->thread_id, &external, a);
25+
=}
26+
27+
reaction(a) {=
28+
interval_t elapsed_time = lf_time_logical_elapsed();
29+
printf("Action triggered at logical time %lld nsec after start.\n", elapsed_time);
30+
=}
31+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
target C;
2+
preamble {=
3+
int table[] = {4, 3, 2, 1};
4+
=}
5+
reactor A(bank_index:int = 0, value:int = 0) {
6+
reaction (startup) {=
7+
printf("bank_index: %d, value: %d\n", self->bank_index, self->value);
8+
=}
9+
}
10+
main reactor {
11+
a = new[4] A(value = {= table[bank_index] =});
12+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
target C;
2+
3+
reactor Count {
4+
output out:int;
5+
reaction(startup) -> out {=
6+
int count = 0;
7+
while (!lf_check_deadline(self, true)) {
8+
count++;
9+
}
10+
lf_set(out, count);
11+
=} deadline (3 msec) {=
12+
printf("Stopped counting.\n");
13+
=}
14+
}
15+
16+
main reactor {
17+
c = new Count();
18+
reaction(c.out) {=
19+
printf("Counted to %d\n", c.out->value);
20+
=}
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
target C;
2+
reactor Child (
3+
bank_index:int = 0
4+
) {
5+
reaction(startup) {=
6+
printf("My bank index: %d.\n", self->bank_index);
7+
=}
8+
}
9+
reactor Parent (
10+
bank_index:int = 0
11+
) {
12+
c = new[2] Child();
13+
}
14+
main reactor {
15+
p = new[2] Parent();
16+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
target C
2+
3+
reactor Child(bank_index: int = 0, parent_bank_index: int = 0) {
4+
reaction(startup) {=
5+
printf(
6+
"My bank index: %d. My parent's bank index: %d.\n",
7+
self->bank_index, self->parent_bank_index
8+
);
9+
=}
10+
}
11+
12+
reactor Parent(bank_index: int = 0) {
13+
c = new[2] Child(parent_bank_index=bank_index)
14+
}
15+
16+
main reactor {
17+
p = new[2] Parent()
18+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
target C
2+
3+
reactor Child(bank_index: int = 0, parent_bank_index: int = 0) {
4+
output out: int
5+
6+
reaction(startup) -> out {=
7+
lf_set(out, self->parent_bank_index * 2 + self->bank_index);
8+
=}
9+
}
10+
11+
reactor Parent(bank_index: int = 0) {
12+
c = new[2] Child(parent_bank_index=bank_index)
13+
14+
reaction(c.out) {=
15+
for (int i=0; i < c_width; i++) {
16+
printf("Received %d from child %d.\n", c[i].out->value, i);
17+
}
18+
=}
19+
}
20+
21+
main reactor {
22+
p = new[2] Parent()
23+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
target C
2+
3+
import Overwriting from "Overwriting.lf"
4+
5+
main reactor {
6+
s = new Overwriting()
7+
8+
reaction(s.y) {=
9+
if (s.y->value != 0 && s.y->value != 1) {
10+
lf_print_error_and_exit("Outputs should only be 0 or 1!");
11+
}
12+
=}
13+
}

0 commit comments

Comments
 (0)