-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'add-flexpret-docs' of github.com:magnmaeh/lf-lang.githu…
…b.io into add-flexpret-docs
- Loading branch information
Showing
365 changed files
with
26,388 additions
and
2,088 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
bin | ||
src-gen | ||
include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include/ |
22 changes: 22 additions & 0 deletions
22
versioned_docs/version-0.7.0/assets/code/c/src/Alignment.lf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
target C { | ||
timeout: 3 secs | ||
} | ||
|
||
main reactor Alignment { | ||
state s: int = 0 | ||
timer t1(100 msec, 100 msec) | ||
timer t2(200 msec, 200 msec) | ||
timer t4(400 msec, 400 msec) | ||
|
||
reaction(t1) {= | ||
self->s += 1; | ||
=} | ||
|
||
reaction(t2) {= | ||
self->s -= 2; | ||
=} | ||
|
||
reaction(t4) {= | ||
printf("s = %d\n", self->s); | ||
=} | ||
} |
31 changes: 31 additions & 0 deletions
31
versioned_docs/version-0.7.0/assets/code/c/src/Asynchronous.lf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
target C { | ||
keepalive: true // Do not exit when event queue is empty. | ||
} | ||
|
||
preamble {= | ||
#include "platform.h" // Defines lf_sleep() and thread functions. | ||
=} | ||
|
||
main reactor { | ||
preamble {= | ||
// Schedule an event roughly every 200 msec. | ||
void* external(void* a) { | ||
while (true) { | ||
lf_sleep(MSEC(200)); | ||
lf_schedule(a, 0); | ||
} | ||
} | ||
=} | ||
state thread_id: lf_thread_t = 0 | ||
physical action a(100 msec): int | ||
|
||
reaction(startup) -> a {= | ||
// Start a thread to schedule physical actions. | ||
lf_thread_create(&self->thread_id, &external, a); | ||
=} | ||
|
||
reaction(a) {= | ||
interval_t elapsed_time = lf_time_logical_elapsed(); | ||
printf("Action triggered at logical time %lld nsec after start.\n", elapsed_time); | ||
=} | ||
} |
12 changes: 12 additions & 0 deletions
12
versioned_docs/version-0.7.0/assets/code/c/src/BankIndex.lf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
target C; | ||
preamble {= | ||
int table[] = {4, 3, 2, 1}; | ||
=} | ||
reactor A(bank_index:int = 0, value:int = 0) { | ||
reaction (startup) {= | ||
printf("bank_index: %d, value: %d\n", self->bank_index, self->value); | ||
=} | ||
} | ||
main reactor { | ||
a = new[4] A(value = {= table[bank_index] =}); | ||
} |
21 changes: 21 additions & 0 deletions
21
versioned_docs/version-0.7.0/assets/code/c/src/CheckDeadline.lf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
target C; | ||
|
||
reactor Count { | ||
output out:int; | ||
reaction(startup) -> out {= | ||
int count = 0; | ||
while (!lf_check_deadline(self, true)) { | ||
count++; | ||
} | ||
lf_set(out, count); | ||
=} deadline (3 msec) {= | ||
printf("Stopped counting.\n"); | ||
=} | ||
} | ||
|
||
main reactor { | ||
c = new Count(); | ||
reaction(c.out) {= | ||
printf("Counted to %d\n", c.out->value); | ||
=} | ||
} |
16 changes: 16 additions & 0 deletions
16
versioned_docs/version-0.7.0/assets/code/c/src/ChildBank.lf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
target C; | ||
reactor Child ( | ||
bank_index:int = 0 | ||
) { | ||
reaction(startup) {= | ||
printf("My bank index: %d.\n", self->bank_index); | ||
=} | ||
} | ||
reactor Parent ( | ||
bank_index:int = 0 | ||
) { | ||
c = new[2] Child(); | ||
} | ||
main reactor { | ||
p = new[2] Parent(); | ||
} |
18 changes: 18 additions & 0 deletions
18
versioned_docs/version-0.7.0/assets/code/c/src/ChildParentBank.lf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
target C | ||
|
||
reactor Child(bank_index: int = 0, parent_bank_index: int = 0) { | ||
reaction(startup) {= | ||
printf( | ||
"My bank index: %d. My parent's bank index: %d.\n", | ||
self->bank_index, self->parent_bank_index | ||
); | ||
=} | ||
} | ||
|
||
reactor Parent(bank_index: int = 0) { | ||
c = new[2] Child(parent_bank_index=bank_index) | ||
} | ||
|
||
main reactor { | ||
p = new[2] Parent() | ||
} |
23 changes: 23 additions & 0 deletions
23
versioned_docs/version-0.7.0/assets/code/c/src/ChildParentBank2.lf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
target C | ||
|
||
reactor Child(bank_index: int = 0, parent_bank_index: int = 0) { | ||
output out: int | ||
|
||
reaction(startup) -> out {= | ||
lf_set(out, self->parent_bank_index * 2 + self->bank_index); | ||
=} | ||
} | ||
|
||
reactor Parent(bank_index: int = 0) { | ||
c = new[2] Child(parent_bank_index=bank_index) | ||
|
||
reaction(c.out) {= | ||
for (int i=0; i < c_width; i++) { | ||
printf("Received %d from child %d.\n", c[i].out->value, i); | ||
} | ||
=} | ||
} | ||
|
||
main reactor { | ||
p = new[2] Parent() | ||
} |
13 changes: 13 additions & 0 deletions
13
versioned_docs/version-0.7.0/assets/code/c/src/Contained.lf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
target C | ||
|
||
import Overwriting from "Overwriting.lf" | ||
|
||
main reactor { | ||
s = new Overwriting() | ||
|
||
reaction(s.y) {= | ||
if (s.y->value != 0 && s.y->value != 1) { | ||
lf_print_error_and_exit("Outputs should only be 0 or 1!"); | ||
} | ||
=} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
target C | ||
|
||
reactor Count { | ||
state count: int = 0 | ||
output y: int | ||
timer t(0, 100 msec) | ||
|
||
reaction(t) -> y {= | ||
lf_set(y, self->count++); | ||
=} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
target C; | ||
reactor A { | ||
input x:int; | ||
output y:int; | ||
reaction(x) -> y {= | ||
// ... something here ... | ||
=} | ||
} | ||
reactor B { | ||
input x:int; | ||
output y:int; | ||
reaction(x) {= | ||
// ... something here ... | ||
=} | ||
reaction(startup) -> y {= | ||
// ... something here ... | ||
=} | ||
} | ||
main reactor { | ||
a = new A(); | ||
b = new B(); | ||
a.y -> b.x; | ||
b.y -> a.x; | ||
} |
24 changes: 24 additions & 0 deletions
24
versioned_docs/version-0.7.0/assets/code/c/src/CycleReordered.lf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
target C; | ||
reactor A { | ||
input x:int; | ||
output y:int; | ||
reaction(x) -> y {= | ||
// ... something here ... | ||
=} | ||
} | ||
reactor B { | ||
input x:int; | ||
output y:int; | ||
reaction(startup) -> y {= | ||
// ... something here ... | ||
=} | ||
reaction(x) {= | ||
// ... something here ... | ||
=} | ||
} | ||
main reactor { | ||
a = new A(); | ||
b = new B(); | ||
a.y -> b.x; | ||
b.y -> a.x; | ||
} |
Oops, something went wrong.