From c83ee68dbe7dd8bd5a1c75f3e7b2ddb81034b09a Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Sun, 24 May 2026 16:44:11 -0700 Subject: [PATCH 01/13] Added micro-LF tab and first pass on code --- docs/assets/code/uc/.gitignore | 3 + docs/assets/code/uc/src/Alignment.lf | 22 ++++++ docs/assets/code/uc/src/Asynchronous.lf | 31 ++++++++ docs/assets/code/uc/src/BankIndex.lf | 11 +++ docs/assets/code/uc/src/CheckDeadline.lf | 21 ++++++ docs/assets/code/uc/src/ChildBank.lf | 16 +++++ docs/assets/code/uc/src/ChildParentBank.lf | 18 +++++ docs/assets/code/uc/src/ChildParentBank2.lf | 23 ++++++ docs/assets/code/uc/src/Contained.lf | 13 ++++ docs/assets/code/uc/src/Count.lf | 11 +++ docs/assets/code/uc/src/Cycle.lf | 24 +++++++ docs/assets/code/uc/src/CycleReordered.lf | 24 +++++++ docs/assets/code/uc/src/CycleWithDelay.lf | 24 +++++++ docs/assets/code/uc/src/Deadline.lf | 11 +++ docs/assets/code/uc/src/DeadlineTest.lf | 26 +++++++ docs/assets/code/uc/src/Decentralized.lf | 10 +++ .../code/uc/src/DecentralizedFeeback.lf | 46 ++++++++++++ .../code/uc/src/DecentralizedFeebackSTA.lf | 40 +++++++++++ .../code/uc/src/DecentralizedFeebackSplit.lf | 48 +++++++++++++ .../uc/src/DecentralizedFeebackWithAfter.lf | 44 ++++++++++++ docs/assets/code/uc/src/DecentralizedTimer.lf | 18 +++++ .../code/uc/src/DecentralizedTimerAfter.lf | 22 ++++++ .../code/uc/src/DecentralizedTimerHandler.lf | 36 ++++++++++ .../code/uc/src/DecentralizedTimerSTA.lf | 23 ++++++ .../uc/src/DecentralizedTimerSTPDeadline.lf | 22 ++++++ .../uc/src/DecentralizedTimerSTPHandler.lf | 30 ++++++++ .../code/uc/src/DecentralizedZeroDelayLoop.lf | 42 +++++++++++ .../DecentralizedZeroDelayLoopWithChecker.lf | 28 ++++++++ docs/assets/code/uc/src/Destination.lf | 17 +++++ docs/assets/code/uc/src/Double.lf | 10 +++ docs/assets/code/uc/src/Extends.lf | 14 ++++ docs/assets/code/uc/src/Federated.lf | 27 +++++++ docs/assets/code/uc/src/FederatedFeeback.lf | 38 ++++++++++ docs/assets/code/uc/src/GenericDelay.lf | 27 +++++++ docs/assets/code/uc/src/GenericString.lf | 15 ++++ docs/assets/code/uc/src/HelloWorld.lf | 7 ++ docs/assets/code/uc/src/Hierarchy.lf | 19 +++++ docs/assets/code/uc/src/Interleaved.lf | 26 +++++++ docs/assets/code/uc/src/MainReactor.lf | 34 +++++++++ docs/assets/code/uc/src/Methods.lf | 19 +++++ docs/assets/code/uc/src/Microsteps.lf | 15 ++++ docs/assets/code/uc/src/Multiport.lf | 24 +++++++ docs/assets/code/uc/src/MultiportSource.lf | 12 ++++ docs/assets/code/uc/src/MultiportToBank.lf | 25 +++++++ docs/assets/code/uc/src/Overwriting.lf | 18 +++++ docs/assets/code/uc/src/Physical.lf | 12 ++++ docs/assets/code/uc/src/RegressionTest.lf | 16 +++++ docs/assets/code/uc/src/Scale.lf | 10 +++ docs/assets/code/uc/src/Schedule.lf | 12 ++++ docs/assets/code/uc/src/Simultaneous.lf | 30 ++++++++ docs/assets/code/uc/src/SlowingClock.lf | 19 +++++ docs/assets/code/uc/src/Sparse.lf | 16 +++++ docs/assets/code/uc/src/TestCount.lf | 28 ++++++++ docs/assets/code/uc/src/TimeElapsed.lf | 12 ++++ docs/assets/code/uc/src/TimeLag.lf | 14 ++++ docs/assets/code/uc/src/Timer.lf | 9 +++ docs/assets/code/uc/src/Triggering.lf | 13 ++++ docs/assets/code/uc/src/lib/Cos.lf | 13 ++++ docs/assets/code/uc/src/test/AlignmentTest.lf | 20 ++++++ .../code/uc/src/test/ContainedOverwriting.lf | 12 ++++ .../uc/src/test/CountDoubleDestination.lf | 23 ++++++ docs/assets/code/uc/src/test/CountScale.lf | 15 ++++ docs/assets/code/uc/src/test/ExtendsTest.lf | 28 ++++++++ docs/assets/code/uc/src/test/HierarchyTest.lf | 21 ++++++ .../code/uc/src/test/MultiportSourceTest.lf | 33 +++++++++ docs/assets/code/uc/src/test/PhysicalTest.lf | 9 +++ docs/assets/code/uc/src/test/PreambleTest1.lf | 13 ++++ docs/assets/code/uc/src/test/PreambleTest2.lf | 22 ++++++ docs/assets/code/uc/src/test/PreambleTest3.lf | 18 +++++ docs/assets/code/uc/src/test/PreambleTest4.lf | 18 +++++ docs/assets/code/uc/src/test/PreambleTest5.lf | 27 +++++++ docs/assets/code/uc/src/test/PreambleTest6.lf | 25 +++++++ docs/assets/code/uc/src/test/PreambleTest7.lf | 14 ++++ docs/assets/code/uc/src/test/ScheduleTest.lf | 11 +++ .../code/uc/src/test/SlowingClockTest.lf | 42 +++++++++++ docs/assets/code/uc/src/test/SparseTest.lf | 8 +++ .../code/uc/src/test/StructParameter.lf | 16 +++++ docs/developer/website-development.mdx | 16 +++-- docs/reference/expressions.mdx | 2 +- docs/reference/security.mdx | 2 +- docs/reference/target-declaration.mdx | 23 +++++- docs/reference/target-language-details.mdx | 72 ++++++++++++++++++- docs/reference/tracing.mdx | 2 +- docs/writing-reactors/a-first-reactor.mdx | 5 +- docs/writing-reactors/actions.mdx | 11 +-- docs/writing-reactors/causality-loops.mdx | 11 +-- docs/writing-reactors/composing-reactors.mdx | 8 ++- docs/writing-reactors/deadlines.mdx | 11 +-- .../distributed-execution.mdx | 20 ++++-- docs/writing-reactors/extending-reactors.mdx | 5 +- docs/writing-reactors/generics.mdx | 8 ++- docs/writing-reactors/inputs-and-outputs.mdx | 8 ++- docs/writing-reactors/methods.mdx | 5 +- docs/writing-reactors/modal-models.mdx | 2 +- .../writing-reactors/multiports-and-banks.mdx | 29 +++++--- .../parameters-and-state-variables.mdx | 8 ++- docs/writing-reactors/preambles.mdx | 2 +- .../reaction-declarations.mdx | 2 +- docs/writing-reactors/reactions.mdx | 14 ++-- docs/writing-reactors/superdense-time.mdx | 8 ++- docs/writing-reactors/termination.mdx | 2 +- docs/writing-reactors/time-and-timers.mdx | 17 +++-- docusaurus.config.ts | 4 ++ package.json | 1 + .../LangSpecific.tsx | 13 ++-- .../LanguageSelector.tsx | 23 +++--- .../LinguaFrancaMultiTargetUtils/ShowIf.tsx | 2 +- .../LinguaFrancaMultiTargetUtils/index.tsx | 7 +- .../ShikiLFHighlighter/lflang.tmLanguage.json | 11 +++ .../ShikiLFHighlighter/shikiloader.ts | 3 - util/set-default-language.js | 10 +-- 111 files changed, 1871 insertions(+), 109 deletions(-) create mode 100644 docs/assets/code/uc/.gitignore create mode 100644 docs/assets/code/uc/src/Alignment.lf create mode 100644 docs/assets/code/uc/src/Asynchronous.lf create mode 100644 docs/assets/code/uc/src/BankIndex.lf create mode 100644 docs/assets/code/uc/src/CheckDeadline.lf create mode 100644 docs/assets/code/uc/src/ChildBank.lf create mode 100644 docs/assets/code/uc/src/ChildParentBank.lf create mode 100644 docs/assets/code/uc/src/ChildParentBank2.lf create mode 100644 docs/assets/code/uc/src/Contained.lf create mode 100644 docs/assets/code/uc/src/Count.lf create mode 100644 docs/assets/code/uc/src/Cycle.lf create mode 100644 docs/assets/code/uc/src/CycleReordered.lf create mode 100644 docs/assets/code/uc/src/CycleWithDelay.lf create mode 100644 docs/assets/code/uc/src/Deadline.lf create mode 100644 docs/assets/code/uc/src/DeadlineTest.lf create mode 100644 docs/assets/code/uc/src/Decentralized.lf create mode 100644 docs/assets/code/uc/src/DecentralizedFeeback.lf create mode 100644 docs/assets/code/uc/src/DecentralizedFeebackSTA.lf create mode 100644 docs/assets/code/uc/src/DecentralizedFeebackSplit.lf create mode 100644 docs/assets/code/uc/src/DecentralizedFeebackWithAfter.lf create mode 100644 docs/assets/code/uc/src/DecentralizedTimer.lf create mode 100644 docs/assets/code/uc/src/DecentralizedTimerAfter.lf create mode 100644 docs/assets/code/uc/src/DecentralizedTimerHandler.lf create mode 100644 docs/assets/code/uc/src/DecentralizedTimerSTA.lf create mode 100644 docs/assets/code/uc/src/DecentralizedTimerSTPDeadline.lf create mode 100644 docs/assets/code/uc/src/DecentralizedTimerSTPHandler.lf create mode 100644 docs/assets/code/uc/src/DecentralizedZeroDelayLoop.lf create mode 100644 docs/assets/code/uc/src/DecentralizedZeroDelayLoopWithChecker.lf create mode 100644 docs/assets/code/uc/src/Destination.lf create mode 100644 docs/assets/code/uc/src/Double.lf create mode 100644 docs/assets/code/uc/src/Extends.lf create mode 100644 docs/assets/code/uc/src/Federated.lf create mode 100644 docs/assets/code/uc/src/FederatedFeeback.lf create mode 100644 docs/assets/code/uc/src/GenericDelay.lf create mode 100644 docs/assets/code/uc/src/GenericString.lf create mode 100644 docs/assets/code/uc/src/HelloWorld.lf create mode 100644 docs/assets/code/uc/src/Hierarchy.lf create mode 100644 docs/assets/code/uc/src/Interleaved.lf create mode 100644 docs/assets/code/uc/src/MainReactor.lf create mode 100644 docs/assets/code/uc/src/Methods.lf create mode 100644 docs/assets/code/uc/src/Microsteps.lf create mode 100644 docs/assets/code/uc/src/Multiport.lf create mode 100644 docs/assets/code/uc/src/MultiportSource.lf create mode 100644 docs/assets/code/uc/src/MultiportToBank.lf create mode 100644 docs/assets/code/uc/src/Overwriting.lf create mode 100644 docs/assets/code/uc/src/Physical.lf create mode 100644 docs/assets/code/uc/src/RegressionTest.lf create mode 100644 docs/assets/code/uc/src/Scale.lf create mode 100644 docs/assets/code/uc/src/Schedule.lf create mode 100644 docs/assets/code/uc/src/Simultaneous.lf create mode 100644 docs/assets/code/uc/src/SlowingClock.lf create mode 100644 docs/assets/code/uc/src/Sparse.lf create mode 100644 docs/assets/code/uc/src/TestCount.lf create mode 100644 docs/assets/code/uc/src/TimeElapsed.lf create mode 100644 docs/assets/code/uc/src/TimeLag.lf create mode 100644 docs/assets/code/uc/src/Timer.lf create mode 100644 docs/assets/code/uc/src/Triggering.lf create mode 100644 docs/assets/code/uc/src/lib/Cos.lf create mode 100644 docs/assets/code/uc/src/test/AlignmentTest.lf create mode 100644 docs/assets/code/uc/src/test/ContainedOverwriting.lf create mode 100644 docs/assets/code/uc/src/test/CountDoubleDestination.lf create mode 100644 docs/assets/code/uc/src/test/CountScale.lf create mode 100644 docs/assets/code/uc/src/test/ExtendsTest.lf create mode 100644 docs/assets/code/uc/src/test/HierarchyTest.lf create mode 100644 docs/assets/code/uc/src/test/MultiportSourceTest.lf create mode 100644 docs/assets/code/uc/src/test/PhysicalTest.lf create mode 100644 docs/assets/code/uc/src/test/PreambleTest1.lf create mode 100644 docs/assets/code/uc/src/test/PreambleTest2.lf create mode 100644 docs/assets/code/uc/src/test/PreambleTest3.lf create mode 100644 docs/assets/code/uc/src/test/PreambleTest4.lf create mode 100644 docs/assets/code/uc/src/test/PreambleTest5.lf create mode 100644 docs/assets/code/uc/src/test/PreambleTest6.lf create mode 100644 docs/assets/code/uc/src/test/PreambleTest7.lf create mode 100644 docs/assets/code/uc/src/test/ScheduleTest.lf create mode 100644 docs/assets/code/uc/src/test/SlowingClockTest.lf create mode 100644 docs/assets/code/uc/src/test/SparseTest.lf create mode 100644 docs/assets/code/uc/src/test/StructParameter.lf diff --git a/docs/assets/code/uc/.gitignore b/docs/assets/code/uc/.gitignore new file mode 100644 index 000000000..55f4cfeb1 --- /dev/null +++ b/docs/assets/code/uc/.gitignore @@ -0,0 +1,3 @@ +bin +src-gen +include diff --git a/docs/assets/code/uc/src/Alignment.lf b/docs/assets/code/uc/src/Alignment.lf new file mode 100644 index 000000000..1677b17ac --- /dev/null +++ b/docs/assets/code/uc/src/Alignment.lf @@ -0,0 +1,22 @@ +target uC { + 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); + =} +} diff --git a/docs/assets/code/uc/src/Asynchronous.lf b/docs/assets/code/uc/src/Asynchronous.lf new file mode 100644 index 000000000..670e30497 --- /dev/null +++ b/docs/assets/code/uc/src/Asynchronous.lf @@ -0,0 +1,31 @@ +target uC { + 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); + =} +} diff --git a/docs/assets/code/uc/src/BankIndex.lf b/docs/assets/code/uc/src/BankIndex.lf new file mode 100644 index 000000000..1dc3c57b0 --- /dev/null +++ b/docs/assets/code/uc/src/BankIndex.lf @@ -0,0 +1,11 @@ +target uC; +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( + table: int[] = {4, 3, 2, 1} +) { + a = new[4] A(value = {= self->table[bank_index] =}); +} diff --git a/docs/assets/code/uc/src/CheckDeadline.lf b/docs/assets/code/uc/src/CheckDeadline.lf new file mode 100644 index 000000000..8528cffc3 --- /dev/null +++ b/docs/assets/code/uc/src/CheckDeadline.lf @@ -0,0 +1,21 @@ +target uC; + +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); + =} +} diff --git a/docs/assets/code/uc/src/ChildBank.lf b/docs/assets/code/uc/src/ChildBank.lf new file mode 100644 index 000000000..405b43dfb --- /dev/null +++ b/docs/assets/code/uc/src/ChildBank.lf @@ -0,0 +1,16 @@ +target uC; +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(); +} diff --git a/docs/assets/code/uc/src/ChildParentBank.lf b/docs/assets/code/uc/src/ChildParentBank.lf new file mode 100644 index 000000000..269c81fda --- /dev/null +++ b/docs/assets/code/uc/src/ChildParentBank.lf @@ -0,0 +1,18 @@ +target uC + +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() +} diff --git a/docs/assets/code/uc/src/ChildParentBank2.lf b/docs/assets/code/uc/src/ChildParentBank2.lf new file mode 100644 index 000000000..232f42fa5 --- /dev/null +++ b/docs/assets/code/uc/src/ChildParentBank2.lf @@ -0,0 +1,23 @@ +target uC + +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() +} diff --git a/docs/assets/code/uc/src/Contained.lf b/docs/assets/code/uc/src/Contained.lf new file mode 100644 index 000000000..2075e2258 --- /dev/null +++ b/docs/assets/code/uc/src/Contained.lf @@ -0,0 +1,13 @@ +target uC + +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!"); + } + =} +} diff --git a/docs/assets/code/uc/src/Count.lf b/docs/assets/code/uc/src/Count.lf new file mode 100644 index 000000000..91b9ce03e --- /dev/null +++ b/docs/assets/code/uc/src/Count.lf @@ -0,0 +1,11 @@ +target uC + +reactor Count { + state count: int = 0 + output y: int + timer t(0, 100 msec) + + reaction(t) -> y {= + lf_set(y, self->count++); + =} +} diff --git a/docs/assets/code/uc/src/Cycle.lf b/docs/assets/code/uc/src/Cycle.lf new file mode 100644 index 000000000..fa27bcea7 --- /dev/null +++ b/docs/assets/code/uc/src/Cycle.lf @@ -0,0 +1,24 @@ +target uC; +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; +} \ No newline at end of file diff --git a/docs/assets/code/uc/src/CycleReordered.lf b/docs/assets/code/uc/src/CycleReordered.lf new file mode 100644 index 000000000..e7168a2c7 --- /dev/null +++ b/docs/assets/code/uc/src/CycleReordered.lf @@ -0,0 +1,24 @@ +target uC; +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; +} \ No newline at end of file diff --git a/docs/assets/code/uc/src/CycleWithDelay.lf b/docs/assets/code/uc/src/CycleWithDelay.lf new file mode 100644 index 000000000..548467b50 --- /dev/null +++ b/docs/assets/code/uc/src/CycleWithDelay.lf @@ -0,0 +1,24 @@ +target uC; +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 after 0; + b.y -> a.x; +} \ No newline at end of file diff --git a/docs/assets/code/uc/src/Deadline.lf b/docs/assets/code/uc/src/Deadline.lf new file mode 100644 index 000000000..0e8f2a0fa --- /dev/null +++ b/docs/assets/code/uc/src/Deadline.lf @@ -0,0 +1,11 @@ +target uC; +reactor Deadline { + input x:int; + output d:int; // Produced if the deadline is violated. + reaction(x) -> d {= + printf("Normal reaction.\n"); + =} deadline(10 msec) {= + printf("Deadline violation detected.\n"); + lf_set(d, x->value); + =} +} diff --git a/docs/assets/code/uc/src/DeadlineTest.lf b/docs/assets/code/uc/src/DeadlineTest.lf new file mode 100644 index 000000000..136c2d14b --- /dev/null +++ b/docs/assets/code/uc/src/DeadlineTest.lf @@ -0,0 +1,26 @@ +target uC + +import Deadline from "Deadline.lf" + +preamble {= + #include "platform.h" +=} + +main reactor { + logical action a + d = new Deadline() + + reaction(startup) -> d.x, a {= + lf_set(d.x, 0); + lf_schedule(a, 0); + =} + + reaction(a) -> d.x {= + lf_set(d.x, 0); + lf_sleep(MSEC(20)); + =} + + reaction(d.d) {= + printf("Deadline reactor produced an output.\n"); + =} +} diff --git a/docs/assets/code/uc/src/Decentralized.lf b/docs/assets/code/uc/src/Decentralized.lf new file mode 100644 index 000000000..ae97b4eb4 --- /dev/null +++ b/docs/assets/code/uc/src/Decentralized.lf @@ -0,0 +1,10 @@ +target uC { + timeout: 5 sec, + coordination: decentralized +} +import Count, Print from "Federated.lf" +federated reactor { + c = new Count(); + p = new Print(); + c.out -> p.in; +} diff --git a/docs/assets/code/uc/src/DecentralizedFeeback.lf b/docs/assets/code/uc/src/DecentralizedFeeback.lf new file mode 100644 index 000000000..dc46dd061 --- /dev/null +++ b/docs/assets/code/uc/src/DecentralizedFeeback.lf @@ -0,0 +1,46 @@ +target uC { + timeout: 5 sec, + coordination: decentralized +} +reactor CountPrint { + input in:int; + output out:int; + state c:int = 0; + timer t(0, 1 sec); + reaction(t) -> out {= + lf_set(out, self->c++); + =} + reaction(in) {= + lf_print("***** CountPrint Received: %d at tag (%lld, %u)", + in->value, lf_time_logical_elapsed(), lf_tag().microstep + ); + =} STAA(10 msec) {= + lf_print_warning("CountPrint: Safe to process violation!"); + lf_print("Intended time: %lld", in->intended_tag.time - lf_time_start()); + =} +} + +reactor PrintCount { + input in:int; + output out:int; + timer t(0, 999 msec); + state c:int = 0; + reaction(in) {= + lf_print("***** PrintCount Received: %d at tag (%lld, %u)", + in->value, lf_time_logical_elapsed(), lf_tag().microstep + ); + =} STAA(10 msec) {= + lf_print_warning("PrintCount: Safe to process violation!"); + lf_print("Intended time: %lld", in->intended_tag.time - lf_time_start()); + =} + reaction(t) -> out {= + lf_set(out, self->c++); + =} +} + +federated reactor { + c = new CountPrint(); + p = new PrintCount(); + c.out -> p.in; + p.out -> c.in; +} diff --git a/docs/assets/code/uc/src/DecentralizedFeebackSTA.lf b/docs/assets/code/uc/src/DecentralizedFeebackSTA.lf new file mode 100644 index 000000000..7425b454a --- /dev/null +++ b/docs/assets/code/uc/src/DecentralizedFeebackSTA.lf @@ -0,0 +1,40 @@ +target uC { + timeout: 5 sec, + coordination: decentralized +} +reactor CountPrint(STA:time = 10 ms) { + input in:int; + output out:int; + state c:int = 0; + timer t(0, 1 sec); + reaction(t) -> out {= + lf_set(out, self->c++); + =} + reaction(in) {= + lf_print("***** CountPrint Received: %d at tag (%lld, %u)", + in->value, lf_time_logical_elapsed(), lf_tag().microstep + ); + =} +} + +reactor PrintCount(STA:time = 10 ms) { + input in:int; + output out:int; + timer t(0, 1 sec); + state c:int = 0; + reaction(in) {= + lf_print("***** PrintCount Received: %d at tag (%lld, %u)", + in->value, lf_time_logical_elapsed(), lf_tag().microstep + ); + =} + reaction(t) -> out {= + lf_set(out, self->c++); + =} +} + +federated reactor { + c = new CountPrint(); + p = new PrintCount(); + c.out -> p.in; + p.out -> c.in; +} diff --git a/docs/assets/code/uc/src/DecentralizedFeebackSplit.lf b/docs/assets/code/uc/src/DecentralizedFeebackSplit.lf new file mode 100644 index 000000000..f73b7958c --- /dev/null +++ b/docs/assets/code/uc/src/DecentralizedFeebackSplit.lf @@ -0,0 +1,48 @@ +target uC { + timeout: 5 sec, + coordination: decentralized +} +reactor Count { + output out:int; + state c:int(0); + timer t(0, 500 msec); + reaction(t) -> out {= + lf_set(out, self->c++); + =} +} + +reactor Print { + input in:int; + reaction(in) {= + lf_print("***** Print Received: %d at time %lld", + in->value, lf_time_logical_elapsed() + ); + =} STP(10 msec) {= + lf_print_warning("Print: Safe to process violation!"); + lf_print("Intended time: %lld", in->intended_tag.time - lf_time_start()); + =} +} + +reactor PrintCount { + input in:int; + output out:int; + timer t(0, 999 msec); + state c:int(0); + reaction(in) {= + lf_print("***** PrintCount Received: %d", in->value); + =} STP(10 msec) {= + lf_print_warning("PrintCount: Safe to process violation!"); + lf_print("Intended time: %lld", in->intended_tag.time - lf_time_start()); + =} + reaction(t) -> out {= + lf_set(out, self->c++); + =} +} + +federated reactor { + c = new Count(); + pr = new Print(); + p = new PrintCount(); + c.out -> p.in; + p.out -> pr.in; +} diff --git a/docs/assets/code/uc/src/DecentralizedFeebackWithAfter.lf b/docs/assets/code/uc/src/DecentralizedFeebackWithAfter.lf new file mode 100644 index 000000000..1a3993d85 --- /dev/null +++ b/docs/assets/code/uc/src/DecentralizedFeebackWithAfter.lf @@ -0,0 +1,44 @@ +target uC { + timeout: 5 sec, + coordination: decentralized +} +reactor CountPrint(stp_offset:time(0)) { + input in:int; + output out:int; + state c:int(0); + timer t(0, 500 msec); + reaction(t) -> out {= + lf_set(out, self->c++); + =} + reaction(in) {= + lf_print("***** CountPrint Received: %d at time %lld", + in->value, lf_time_logical_elapsed() + ); + =} STP(0 msec) {= + lf_print_warning("CountPrint: Safe to process violation!"); + lf_print("Intended time: %lld", in->intended_tag.time - lf_time_start()); + =} +} + +reactor PrintCount(stp_offset:time(0)) { + input in:int; + output out:int; + timer t(0, 999 msec); + state c:int(0); + reaction(in) {= + lf_print("***** PrintCount Received: %d", in->value); + =} STP(0 msec) {= + lf_print_warning("PrintCount: Safe to process violation!"); + lf_print("Intended time: %lld", in->intended_tag.time - lf_time_start()); + =} + reaction(t) -> out {= + lf_set(out, self->c++); + =} +} + +federated reactor { + c = new CountPrint(); + p = new PrintCount(); + c.out -> p.in after 10 msec; + p.out -> c.in after 10 msec; +} diff --git a/docs/assets/code/uc/src/DecentralizedTimer.lf b/docs/assets/code/uc/src/DecentralizedTimer.lf new file mode 100644 index 000000000..c5ab7bad1 --- /dev/null +++ b/docs/assets/code/uc/src/DecentralizedTimer.lf @@ -0,0 +1,18 @@ +target uC { + timeout: 5 sec, + coordination: decentralized +} +import Count, Print from "Federated.lf" +reactor PrintTimer extends Print { + timer t(0, 1 sec); + reaction(t) {= + lf_print("Timer ticked at (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} +} +federated reactor { + c = new Count(); + p = new PrintTimer(); + c.out -> p.in; +} diff --git a/docs/assets/code/uc/src/DecentralizedTimerAfter.lf b/docs/assets/code/uc/src/DecentralizedTimerAfter.lf new file mode 100644 index 000000000..cc3bdaaeb --- /dev/null +++ b/docs/assets/code/uc/src/DecentralizedTimerAfter.lf @@ -0,0 +1,22 @@ +target uC { + timeout: 5 sec, + coordination: decentralized +} + +import Count, Print from "Federated.lf" + +reactor PrintTimer extends Print { + timer t(10 ms, 1 sec) + + reaction(t) {= + lf_print("Timer ticked at (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} +} + +federated reactor { + c = new Count() + p = new PrintTimer() + c.out -> p.in after 10 ms +} diff --git a/docs/assets/code/uc/src/DecentralizedTimerHandler.lf b/docs/assets/code/uc/src/DecentralizedTimerHandler.lf new file mode 100644 index 000000000..d522492e8 --- /dev/null +++ b/docs/assets/code/uc/src/DecentralizedTimerHandler.lf @@ -0,0 +1,36 @@ +target uC { + timeout: 5 sec, + coordination: decentralized +} + +import Count from "Federated.lf" + +reactor PrintTimer { + timer t(0, 1 sec) + input in: int + + reaction(in) {= + lf_print("Received: %d at (%lld, %d)", in->value, + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} tardy {= + lf_print("****** Violation handler invoked at (%lld, %d). " + "Intended tag was (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep, + in->intended_tag.time - lf_time_start(), in->intended_tag.microstep + ); + =} + + reaction(t) {= + lf_print("Timer ticked at (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} +} + +federated reactor { + c = new Count() + @maxwait(10 ms) + p = new PrintTimer() + c.out -> p.in +} diff --git a/docs/assets/code/uc/src/DecentralizedTimerSTA.lf b/docs/assets/code/uc/src/DecentralizedTimerSTA.lf new file mode 100644 index 000000000..9c93d3490 --- /dev/null +++ b/docs/assets/code/uc/src/DecentralizedTimerSTA.lf @@ -0,0 +1,23 @@ +target uC { + timeout: 5 sec, + coordination: decentralized +} + +import Count, Print from "Federated.lf" + +reactor PrintTimer extends Print { + timer t(0, 1 sec) + + reaction(t) {= + lf_print("Timer ticked at (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} +} + +federated reactor { + c = new Count() + @maxwait(10 ms) + p = new PrintTimer() + c.out -> p.in +} diff --git a/docs/assets/code/uc/src/DecentralizedTimerSTPDeadline.lf b/docs/assets/code/uc/src/DecentralizedTimerSTPDeadline.lf new file mode 100644 index 000000000..cf4a6881b --- /dev/null +++ b/docs/assets/code/uc/src/DecentralizedTimerSTPDeadline.lf @@ -0,0 +1,22 @@ +target uC { + timeout: 5 sec, + coordination: decentralized +} +import Count, Print from "Federated.lf" +reactor PrintTimer(STP_offset:time(10 msec)) extends Print { + timer t(0, 1 sec); + reaction(t) {= + lf_print("Timer ticked at (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} deadline(10 msec) {= + lf_print("**** Deadline violation at (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} +} +federated reactor { + c = new Count(); + p = new PrintTimer(); + c.out -> p.in; +} diff --git a/docs/assets/code/uc/src/DecentralizedTimerSTPHandler.lf b/docs/assets/code/uc/src/DecentralizedTimerSTPHandler.lf new file mode 100644 index 000000000..6d27585d5 --- /dev/null +++ b/docs/assets/code/uc/src/DecentralizedTimerSTPHandler.lf @@ -0,0 +1,30 @@ +target uC { + timeout: 5 sec, + coordination: decentralized +} +import Count from "Federated.lf" +reactor PrintTimer(STP_offset:time(10 usec)) { + timer t(0, 1 sec); + input in:int; + reaction(in) {= + lf_print("Received: %d at (%lld, %d)", in->value, + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} STP(0) {= + lf_print("****** STP violation handler invoked at (%lld, %d). " + "Intended tag was (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep, + in->intended_tag.time - lf_time_start(), in->intended_tag.microstep + ); + =} + reaction(t) {= + lf_print("Timer ticked at (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} +} +federated reactor { + c = new Count(); + p = new PrintTimer(); + c.out -> p.in; +} diff --git a/docs/assets/code/uc/src/DecentralizedZeroDelayLoop.lf b/docs/assets/code/uc/src/DecentralizedZeroDelayLoop.lf new file mode 100644 index 000000000..a5d3bc76d --- /dev/null +++ b/docs/assets/code/uc/src/DecentralizedZeroDelayLoop.lf @@ -0,0 +1,42 @@ +target uC { + timeout: 3 s, + coordination: decentralized +} + +reactor CountPrint { + input in: int + output out: int + state c: int = 0 + timer t(0, 100 ms) + + reaction(t) -> out {= + lf_set(out, self->c++); + =} + + reaction(in) {= + lf_print("***** CountPrint Received: %d at tag (%lld, %u)", + in->value, lf_time_logical_elapsed(), lf_tag().microstep + ); + =} tardy {= + // This should never happen, but it is here to demonstrate the tardy violation handler. + lf_print_warning("CountPrint: Message is tardy!"); + lf_print("Intended time: %lld", in->intended_tag.time - lf_time_start()); + =} +} + +reactor Double { + input in: int + output out: int + + reaction(in) -> out {= + lf_set(out, in->value * 2); + =} +} + +federated reactor { + c = new CountPrint() + p = new Double() + c.out -> p.in + @absent_after(forever) + p.out -> c.in +} diff --git a/docs/assets/code/uc/src/DecentralizedZeroDelayLoopWithChecker.lf b/docs/assets/code/uc/src/DecentralizedZeroDelayLoopWithChecker.lf new file mode 100644 index 000000000..355d6e22a --- /dev/null +++ b/docs/assets/code/uc/src/DecentralizedZeroDelayLoopWithChecker.lf @@ -0,0 +1,28 @@ +target uC { + timeout: 3 s, + coordination: decentralized +} + +import CountPrint, Double from "DecentralizedZeroDelayLoop.lf" +reactor CountPrintWithChecker extends CountPrint { + + reaction(t, in) {= + if (!in->is_present) { + lf_print("***** CountPrint Failed to Receive response at tag (%lld, %u)", + lf_time_logical_elapsed(), lf_tag().microstep + ); + } + =} tardy {= + lf_print("***** CountPrint Received tardy input: %d at tag (%lld, %u)", + in->value, lf_time_logical_elapsed(), lf_tag().microstep + ); + =} +} + +federated reactor { + c = new CountPrintWithChecker() + p = new Double() + c.out -> p.in + @absent_after(20 ms) + p.out -> c.in +} diff --git a/docs/assets/code/uc/src/Destination.lf b/docs/assets/code/uc/src/Destination.lf new file mode 100644 index 000000000..0c1dee02c --- /dev/null +++ b/docs/assets/code/uc/src/Destination.lf @@ -0,0 +1,17 @@ +target uC + +reactor Destination { + input x: int + input y: int + + reaction(x, y) {= + int sum = 0; + if (x->is_present) { + sum += x->value; + } + if (y->is_present) { + sum += y->value; + } + printf("Received %d.\n", sum); + =} +} diff --git a/docs/assets/code/uc/src/Double.lf b/docs/assets/code/uc/src/Double.lf new file mode 100644 index 000000000..576ac4b59 --- /dev/null +++ b/docs/assets/code/uc/src/Double.lf @@ -0,0 +1,10 @@ +target uC + +reactor Double { + input x: int + output y: int + + reaction(x) -> y {= + lf_set(y, x->value * 2); + =} +} diff --git a/docs/assets/code/uc/src/Extends.lf b/docs/assets/code/uc/src/Extends.lf new file mode 100644 index 000000000..4dcb3fa0c --- /dev/null +++ b/docs/assets/code/uc/src/Extends.lf @@ -0,0 +1,14 @@ +target uC; +reactor A { + input a:int; + output out:int; + reaction(a) -> out {= + lf_set(out, a->value); + =} +} +reactor B extends A { + input b:int; + reaction(a, b) -> out {= + lf_set(out, a->value + b->value); + =} +} diff --git a/docs/assets/code/uc/src/Federated.lf b/docs/assets/code/uc/src/Federated.lf new file mode 100644 index 000000000..f353c9acd --- /dev/null +++ b/docs/assets/code/uc/src/Federated.lf @@ -0,0 +1,27 @@ +target uC + +reactor Count { + output out: int + state c: int = 0 + timer t(0, 1 sec) + + reaction(t) -> out {= + lf_set(out, self->c++); + =} +} + +reactor Print { + input in: int + + reaction(in) {= + lf_print("Received: %d at (%lld, %d)", in->value, + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} +} + +federated reactor { + c = new Count() + p = new Print() + c.out -> p.in +} diff --git a/docs/assets/code/uc/src/FederatedFeeback.lf b/docs/assets/code/uc/src/FederatedFeeback.lf new file mode 100644 index 000000000..2f0b65275 --- /dev/null +++ b/docs/assets/code/uc/src/FederatedFeeback.lf @@ -0,0 +1,38 @@ +target uC { + timeout: 5 sec, +} +reactor CountPrint(stp_offset:time(5 msec)) { + input in:int; + output out:int; + state c:int(0); + timer t(0, 500 msec); + reaction(t) -> out {= + lf_set(out, self->c++); + =} + reaction(in) {= + lf_print("***** CountPrint Received: %d at time %lld", + in->value, lf_time_logical_elapsed() + ); + =} +} +reactor PrintCount { + input in:int; + output out:int; + timer t(0, 1 sec); + state c:int(0); + reaction(in) {= + lf_print("***** PrintCount Received: %d at time %lld", + in->value, lf_time_logical_elapsed() + ); + =} + reaction(t) -> out {= + lf_set(out, self->c++); + =} +} + +federated reactor { + c = new CountPrint(); + p = new PrintCount(); + c.out -> p.in; + p.out -> c.in; +} diff --git a/docs/assets/code/uc/src/GenericDelay.lf b/docs/assets/code/uc/src/GenericDelay.lf new file mode 100644 index 000000000..1710d2d37 --- /dev/null +++ b/docs/assets/code/uc/src/GenericDelay.lf @@ -0,0 +1,27 @@ +target uC + +reactor Delay(delay: time = 0) { + input in: T + output out: T + logical action a(delay): T + + reaction(a) -> out {= + lf_set(out, a->value); + =} + + reaction(in) -> a {= + lf_schedule_copy(a, self->delay, &in->value, 1); + =} +} + +main reactor { + d = new Delay(delay = 100 ms) + + reaction(startup) -> d.in {= + lf_set(d.in, 42); + =} + + reaction(d.out) {= + printf("Received %d at time %lld.\n", d.out->value, lf_time_logical_elapsed()); + =} +} diff --git a/docs/assets/code/uc/src/GenericString.lf b/docs/assets/code/uc/src/GenericString.lf new file mode 100644 index 000000000..6749fccee --- /dev/null +++ b/docs/assets/code/uc/src/GenericString.lf @@ -0,0 +1,15 @@ +target uC + +import Delay from "GenericDelay.lf" + +main reactor { + d = new Delay(delay = 100 ms) + + reaction(startup) -> d.in {= + lf_set(d.in, "foo"); + =} + + reaction(d.out) {= + printf("Received %s at time %lld.\n", d.out->value, lf_time_logical_elapsed()); + =} +} diff --git a/docs/assets/code/uc/src/HelloWorld.lf b/docs/assets/code/uc/src/HelloWorld.lf new file mode 100644 index 000000000..706faa326 --- /dev/null +++ b/docs/assets/code/uc/src/HelloWorld.lf @@ -0,0 +1,7 @@ +target uC + +main reactor { + reaction(startup) {= + printf("Hello World.\n"); + =} +} diff --git a/docs/assets/code/uc/src/Hierarchy.lf b/docs/assets/code/uc/src/Hierarchy.lf new file mode 100644 index 000000000..e3dda5785 --- /dev/null +++ b/docs/assets/code/uc/src/Hierarchy.lf @@ -0,0 +1,19 @@ +target uC + +import Count from "Count.lf" +import Scale from "Scale.lf" +import TestCount from "TestCount.lf" + +reactor Container(stride: int = 2) { + output y: int + c = new Count() + s = new Scale(factor=stride) + c.y -> s.x + s.y -> y +} + +main reactor Hierarchy { + c = new Container(stride=4) + t = new TestCount(stride=4, num_inputs=11) + c.y -> t.x +} diff --git a/docs/assets/code/uc/src/Interleaved.lf b/docs/assets/code/uc/src/Interleaved.lf new file mode 100644 index 000000000..c9d95958c --- /dev/null +++ b/docs/assets/code/uc/src/Interleaved.lf @@ -0,0 +1,26 @@ +target uC + +reactor Node(num_nodes: size_t = 4, bank_index: int = 0) { + input[num_nodes] in: int + output[num_nodes] out: int + + reaction(startup) -> out {= + lf_set(out[1], 42); + printf("Bank index %d sent 42 on channel 1.\n", self->bank_index); + =} + + reaction(in) {= + for (int i = 0; i < in_width; i++) { + if (in[i]->is_present) { + printf("Bank index %d received %d on channel %d.\n", + self->bank_index, in[i]->value, i + ); + } + } + =} +} + +main reactor(num_nodes: size_t = 4) { + nodes = new[num_nodes] Node(num_nodes=num_nodes) + nodes.out -> interleaved(nodes.in) +} diff --git a/docs/assets/code/uc/src/MainReactor.lf b/docs/assets/code/uc/src/MainReactor.lf new file mode 100644 index 000000000..4a6844bcf --- /dev/null +++ b/docs/assets/code/uc/src/MainReactor.lf @@ -0,0 +1,34 @@ +target uC +reactor ReactorA { + output output_port: int + @label("timer (offset, period)") + timer t(0, 100 ms) + @label("reaction A1") + reaction(t) -> output_port {= + =} +} +reactor ReactorB { + input input_port: int + output output_port: int + @label("reaction B1") + reaction(input_port) -> output_port {= + =} +} +reactor ReactorC { + input input_port1: int + input input_port2: int + @label("reaction C1") + reaction(input_port1) {= + =} + @label("reaction C2") + reaction(input_port2) {= + =} +} +main reactor { + a = new ReactorA() + b = new ReactorB() + c = new ReactorC() + a.output_port -> c.input_port2 after 200 ms + a.output_port -> b.input_port after 100 ms + b.output_port -> c.input_port1 after 100 ms +} \ No newline at end of file diff --git a/docs/assets/code/uc/src/Methods.lf b/docs/assets/code/uc/src/Methods.lf new file mode 100644 index 000000000..be4deaa6e --- /dev/null +++ b/docs/assets/code/uc/src/Methods.lf @@ -0,0 +1,19 @@ +target uC + +main reactor Methods { + state foo: int = 2 + + method getFoo(): int {= + return self->foo; + =} + + method add(x: int) {= + self->foo += x; + =} + + reaction(startup) {= + lf_print("Foo is initialized to %d", getFoo()); + add(40); + lf_print("2 + 40 = %d", getFoo()); + =} +} diff --git a/docs/assets/code/uc/src/Microsteps.lf b/docs/assets/code/uc/src/Microsteps.lf new file mode 100644 index 000000000..5a6315acb --- /dev/null +++ b/docs/assets/code/uc/src/Microsteps.lf @@ -0,0 +1,15 @@ +target uC + +main reactor { + state count: int = 1 + logical action a + + reaction(startup, a) -> a {= + printf("%d. Logical time is %lld. Microstep is %d.\n", + self->count, lf_tag().time, lf_tag().microstep + ); + if (self->count++ < 5) { + lf_schedule(a, 0); + } + =} +} diff --git a/docs/assets/code/uc/src/Multiport.lf b/docs/assets/code/uc/src/Multiport.lf new file mode 100644 index 000000000..eaec9978d --- /dev/null +++ b/docs/assets/code/uc/src/Multiport.lf @@ -0,0 +1,24 @@ +target uC; +reactor Source { + output[4] out:int; + reaction(startup) -> out {= + for(int i = 0; i < out_width; i++) { + lf_set(out[i], i); + } + =} +} +reactor Destination { + input[4] in:int; + reaction(in) {= + int sum = 0; + for (int i = 0; i < in_width; i++) { + if (in[i]->is_present) sum += in[i]->value; + } + printf("Sum of received: %d.\n", sum); + =} +} +main reactor { + a = new Source(); + b = new Destination(); + a.out -> b.in; +} diff --git a/docs/assets/code/uc/src/MultiportSource.lf b/docs/assets/code/uc/src/MultiportSource.lf new file mode 100644 index 000000000..c39314ab8 --- /dev/null +++ b/docs/assets/code/uc/src/MultiportSource.lf @@ -0,0 +1,12 @@ +target uC + +reactor MultiportSource(bank_index: int = 0) { + timer t(0, 200 msec) + output out: int + state s: int = 0 + + reaction(t) -> out {= + lf_set(out, self->s); + self->s += self->bank_index; + =} +} diff --git a/docs/assets/code/uc/src/MultiportToBank.lf b/docs/assets/code/uc/src/MultiportToBank.lf new file mode 100644 index 000000000..ca5039bd5 --- /dev/null +++ b/docs/assets/code/uc/src/MultiportToBank.lf @@ -0,0 +1,25 @@ +target uC + +reactor Source { + output[3] out: int + + reaction(startup) -> out {= + for(int i = 0; i < out_width; i++) { + lf_set(out[i], i); + } + =} +} + +reactor Destination(bank_index: int = 0) { + input in: int + + reaction(in) {= + printf("Destination %d received %d.\n", self->bank_index, in->value); + =} +} + +main reactor MultiportToBank { + a = new Source() + b = new[3] Destination() + a.out -> b.in +} diff --git a/docs/assets/code/uc/src/Overwriting.lf b/docs/assets/code/uc/src/Overwriting.lf new file mode 100644 index 000000000..8e4b65f07 --- /dev/null +++ b/docs/assets/code/uc/src/Overwriting.lf @@ -0,0 +1,18 @@ +target uC + +reactor Overwriting { + output y: int + state s: int = 0 + timer t1(100 msec, 100 msec) + timer t2(200 msec, 200 msec) + + reaction(t1) -> y {= + self->s += 1; + lf_set(y, self->s); + =} + + reaction(t2) -> y {= + self->s -= 2; + lf_set(y, self->s); + =} +} diff --git a/docs/assets/code/uc/src/Physical.lf b/docs/assets/code/uc/src/Physical.lf new file mode 100644 index 000000000..83f4f767d --- /dev/null +++ b/docs/assets/code/uc/src/Physical.lf @@ -0,0 +1,12 @@ +target uC; +reactor Physical { + input x:int; + physical action a; + reaction(x) -> a {= + lf_schedule(a, 0); + =} + reaction(a) {= + interval_t elapsed_time = lf_time_logical_elapsed(); + printf("Action triggered at logical time %lld nsec after start.\n", elapsed_time); + =} +} diff --git a/docs/assets/code/uc/src/RegressionTest.lf b/docs/assets/code/uc/src/RegressionTest.lf new file mode 100644 index 000000000..fb408e46d --- /dev/null +++ b/docs/assets/code/uc/src/RegressionTest.lf @@ -0,0 +1,16 @@ +target uC { + timeout: 1 sec, + fast: true +} + +import Count from "Count.lf" +import Scale from "Scale.lf" +import TestCount from "TestCount.lf" + +main reactor RegressionTest { + c = new Count() + s = new Scale(factor=4) + t = new TestCount(stride=4, num_inputs=11) + c.y -> s.x + s.y -> t.x +} diff --git a/docs/assets/code/uc/src/Scale.lf b/docs/assets/code/uc/src/Scale.lf new file mode 100644 index 000000000..b583afacb --- /dev/null +++ b/docs/assets/code/uc/src/Scale.lf @@ -0,0 +1,10 @@ +target uC + +reactor Scale(factor: int = 2) { + input x: int + output y: int + + reaction(x) -> y {= + lf_set(y, x->value * self->factor); + =} +} diff --git a/docs/assets/code/uc/src/Schedule.lf b/docs/assets/code/uc/src/Schedule.lf new file mode 100644 index 000000000..30fd7971a --- /dev/null +++ b/docs/assets/code/uc/src/Schedule.lf @@ -0,0 +1,12 @@ +target uC; +reactor Schedule { + input x:int; + logical action a; + reaction(x) -> a {= + lf_schedule(a, MSEC(200)); + =} + reaction(a) {= + interval_t elapsed_time = lf_time_logical_elapsed(); + printf("Action triggered at logical time %lld nsec after start.\n", elapsed_time); + =} +} diff --git a/docs/assets/code/uc/src/Simultaneous.lf b/docs/assets/code/uc/src/Simultaneous.lf new file mode 100644 index 000000000..2247ed8bf --- /dev/null +++ b/docs/assets/code/uc/src/Simultaneous.lf @@ -0,0 +1,30 @@ +target uC + +reactor Destination { + input x: int + input y: int + + reaction(x, y) {= + printf("Time since start: %lld, microstep: %d\n", + lf_time_logical_elapsed(), lf_tag().microstep + ); + if (x->is_present) { + printf(" x is present.\n"); + } + if (y->is_present) { + printf(" y is present.\n"); + } + =} +} + +main reactor { + logical action repeat + d = new Destination() + + reaction(startup) -> d.x, repeat {= + lf_set(d.x, 1); + lf_schedule(repeat, 0); + =} + + reaction(repeat) -> d.y {= lf_set(d.y, 1); =} +} diff --git a/docs/assets/code/uc/src/SlowingClock.lf b/docs/assets/code/uc/src/SlowingClock.lf new file mode 100644 index 000000000..b00aa5d8a --- /dev/null +++ b/docs/assets/code/uc/src/SlowingClock.lf @@ -0,0 +1,19 @@ +target uC + +main reactor SlowingClock(start: time = 100 ms, incr: time = 100 ms) { + state interval: time = start + logical action a + + reaction(startup) -> a {= + lf_schedule(a, self->start); + =} + + reaction(a) -> a {= + instant_t elapsed_logical_time = lf_time_logical_elapsed(); + printf("Logical time since start: %lld nsec.\n", + elapsed_logical_time + ); + self->interval += self->incr; + lf_schedule(a, self->interval); + =} +} diff --git a/docs/assets/code/uc/src/Sparse.lf b/docs/assets/code/uc/src/Sparse.lf new file mode 100644 index 000000000..b898262cc --- /dev/null +++ b/docs/assets/code/uc/src/Sparse.lf @@ -0,0 +1,16 @@ +target uC; +reactor Sparse { + input[100] in: int + reaction(in) {= + // Create an iterator over the input channels. + struct lf_multiport_iterator_t i = lf_multiport_iterator(in); + // Get the least index of a channel with present inputs. + int channel = lf_multiport_next(&i); + // Iterate until no more channels have present inputs. + while(channel >= 0) { + printf("Received %d on channel %d\n", in[channel]->value, channel); + // Get the next channel with a present input. + channel = lf_multiport_next(&i); + } + =} +} diff --git a/docs/assets/code/uc/src/TestCount.lf b/docs/assets/code/uc/src/TestCount.lf new file mode 100644 index 000000000..5a27eb363 --- /dev/null +++ b/docs/assets/code/uc/src/TestCount.lf @@ -0,0 +1,28 @@ +target uC + +reactor TestCount(start: int = 0, stride: int = 1, num_inputs: int = 1) { + state count: int = start + state inputs_received: int = 0 + input x: int + + reaction(x) {= + printf("Received %d.\n", x->value); + if (x->value != self->count) { + printf("ERROR: Expected %d.\n", self->count); + exit(1); + } + self->count += self->stride; + self->inputs_received++; + =} + + reaction(shutdown) {= + printf("Shutdown invoked.\n"); + if (self->inputs_received != self->num_inputs) { + printf("ERROR: Expected to receive %d inputs, but got %d.\n", + self->num_inputs, + self->inputs_received + ); + exit(2); + } + =} +} diff --git a/docs/assets/code/uc/src/TimeElapsed.lf b/docs/assets/code/uc/src/TimeElapsed.lf new file mode 100644 index 000000000..30c76f0b5 --- /dev/null +++ b/docs/assets/code/uc/src/TimeElapsed.lf @@ -0,0 +1,12 @@ +target uC + +main reactor TimeElapsed { + timer t(0, 1 s) + + reaction(t) {= + printf( + "Elapsed logical time is %lld.\n", + lf_time_logical_elapsed() + ); + =} +} diff --git a/docs/assets/code/uc/src/TimeLag.lf b/docs/assets/code/uc/src/TimeLag.lf new file mode 100644 index 000000000..9bec578d5 --- /dev/null +++ b/docs/assets/code/uc/src/TimeLag.lf @@ -0,0 +1,14 @@ +target uC + +main reactor TimeLag { + timer t(0, 1 s) + + reaction(t) {= + interval_t t = lf_time_logical_elapsed(); + interval_t T = lf_time_physical_elapsed(); + printf( + "Elapsed logical time: %lld, physical time: %lld, lag: %lld\n", + t, T, T-t + ); + =} +} diff --git a/docs/assets/code/uc/src/Timer.lf b/docs/assets/code/uc/src/Timer.lf new file mode 100644 index 000000000..a8f4379d4 --- /dev/null +++ b/docs/assets/code/uc/src/Timer.lf @@ -0,0 +1,9 @@ +target uC + +main reactor Timer { + timer t(0, 1 sec) + + reaction(t) {= + printf("Logical time is %lld.\n", lf_time_logical()); + =} +} diff --git a/docs/assets/code/uc/src/Triggering.lf b/docs/assets/code/uc/src/Triggering.lf new file mode 100644 index 000000000..122711ea4 --- /dev/null +++ b/docs/assets/code/uc/src/Triggering.lf @@ -0,0 +1,13 @@ +target uC +reactor Inside { + input x: int + reaction(x) {= + printf("Received %d\n", x->value); + =} +} +main reactor { + i = new Inside() + reaction(startup) -> i.x {= + lf_set(i.x, 42); + =} +} \ No newline at end of file diff --git a/docs/assets/code/uc/src/lib/Cos.lf b/docs/assets/code/uc/src/lib/Cos.lf new file mode 100644 index 000000000..27730290e --- /dev/null +++ b/docs/assets/code/uc/src/lib/Cos.lf @@ -0,0 +1,13 @@ +/** + * This example is included in Preambles.md, but not automatically imported. + * Success of the test is compiling and running. + */ +target uC +preamble {= + #include +=} +reactor Cos { + reaction(startup) {= + printf("The cosine of 1 is %f.\n", cos(1)); + =} +} diff --git a/docs/assets/code/uc/src/test/AlignmentTest.lf b/docs/assets/code/uc/src/test/AlignmentTest.lf new file mode 100644 index 000000000..ba4dd1978 --- /dev/null +++ b/docs/assets/code/uc/src/test/AlignmentTest.lf @@ -0,0 +1,20 @@ +target uC { + timeout: 3 secs +} +main reactor { + 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) {= + if (self->s != 0) { + lf_print_error_and_exit("Value should be 0!"); + } + =} +} \ No newline at end of file diff --git a/docs/assets/code/uc/src/test/ContainedOverwriting.lf b/docs/assets/code/uc/src/test/ContainedOverwriting.lf new file mode 100644 index 000000000..808c48ac7 --- /dev/null +++ b/docs/assets/code/uc/src/test/ContainedOverwriting.lf @@ -0,0 +1,12 @@ +target uC { + timeout: 1 secs +} +import Overwriting from "../Overwriting.lf"; +main reactor { + s = new Overwriting(); + reaction(s.y) {= + printf("At logical time %lld, s = %d.\n", + lf_time_logical_elapsed(), s.y->value + ); + =} +} diff --git a/docs/assets/code/uc/src/test/CountDoubleDestination.lf b/docs/assets/code/uc/src/test/CountDoubleDestination.lf new file mode 100644 index 000000000..1d0b6271c --- /dev/null +++ b/docs/assets/code/uc/src/test/CountDoubleDestination.lf @@ -0,0 +1,23 @@ +target uC { + cmake: false, + compiler: "cc", + flags: "-O3", + fast: true, + logging: log, + timeout: 1 secs +}; +import Count from "../Count.lf"; +import Double from "../Double.lf"; +import Destination from "../Destination.lf"; +import TestCount from "../TestCount.lf"; + +main reactor { + c = new Count(); + d = new Double(); + r = new Destination(); + t = new TestCount(start = 0, stride = 2, num_inputs = 11); + c.y -> d.x; + c.y -> r.x; + d.y -> r.y; + d.y -> t.x; +} \ No newline at end of file diff --git a/docs/assets/code/uc/src/test/CountScale.lf b/docs/assets/code/uc/src/test/CountScale.lf new file mode 100644 index 000000000..aebc36af1 --- /dev/null +++ b/docs/assets/code/uc/src/test/CountScale.lf @@ -0,0 +1,15 @@ +target uC { + fast: true, + timeout: 1 secs +}; +import Count from "../Count.lf"; +import Scale from "../Scale.lf"; +import TestCount from "../TestCount.lf"; + +main reactor { + c = new Count(); + d = new Scale(); + t = new TestCount(start = 0, stride = 2, num_inputs = 11); + c.y -> d.x; + d.y -> t.x; +} \ No newline at end of file diff --git a/docs/assets/code/uc/src/test/ExtendsTest.lf b/docs/assets/code/uc/src/test/ExtendsTest.lf new file mode 100644 index 000000000..10dbbe29b --- /dev/null +++ b/docs/assets/code/uc/src/test/ExtendsTest.lf @@ -0,0 +1,28 @@ +target uC { + timeout: 1 sec, + fast: true +} +import Count from "../Count.lf"; +import TestCount from "../TestCount.lf"; + +reactor A { + input a:int; + output out:int; + reaction(a) -> out {= + lf_set(out, a->value); + =} +} +reactor B extends A { + input b:int; + reaction(a, b) -> out {= + lf_set(out, a->value + b->value); + =} +} + +main reactor { + c = new Count(); + b = new B(); + t = new TestCount(start = 0, stride = 2, num_inputs = 11); + (c.y)+ -> b.a, b.b; + b.out -> t.x; +} diff --git a/docs/assets/code/uc/src/test/HierarchyTest.lf b/docs/assets/code/uc/src/test/HierarchyTest.lf new file mode 100644 index 000000000..d6717b60a --- /dev/null +++ b/docs/assets/code/uc/src/test/HierarchyTest.lf @@ -0,0 +1,21 @@ +target uC { + timeout: 1 sec, + fast: true +} +import Count from "../Count.lf"; +import Scale from "../Scale.lf"; +import TestCount from "../TestCount.lf"; + +reactor Container(stride:int(2)) { + output y:int; + c = new Count(); + s = new Scale(factor = stride); + c.y -> s.x; + s.y -> y; +} + +main reactor { + c = new Container(stride = 4); + t = new TestCount(stride = 4, num_inputs = 11); + c.y -> t.x; +} \ No newline at end of file diff --git a/docs/assets/code/uc/src/test/MultiportSourceTest.lf b/docs/assets/code/uc/src/test/MultiportSourceTest.lf new file mode 100644 index 000000000..db79efc23 --- /dev/null +++ b/docs/assets/code/uc/src/test/MultiportSourceTest.lf @@ -0,0 +1,33 @@ + // Check bank of reactors sending to bank of reactors. +target uC { + timeout: 2 sec, + fast: true, +}; +import MultiportSource from "../MultiportSource.lf"; +reactor Destination( + bank_index:int(0) +) { + state s:int(0); + input in:int; + reaction(in) {= + printf("Destination %d received: %d.\n", self->bank_index, in->value); + if (in->value != self->s) { + printf("ERROR: Expected %d.\n", self->s); + exit(1); + } + self->s += self->bank_index; + =} + reaction(shutdown) {= + if (self->s == 0 && self->bank_index != 0) { + fprintf(stderr, "ERROR: Destination %d received no input!\n", self->bank_index); + exit(1); + } + printf("Success.\n"); + =} +} + +main reactor(width:int(4)) { + a = new[width] MultiportSource(); + b = new[width] Destination(); + a.out -> b.in; +} diff --git a/docs/assets/code/uc/src/test/PhysicalTest.lf b/docs/assets/code/uc/src/test/PhysicalTest.lf new file mode 100644 index 000000000..c1ec6899c --- /dev/null +++ b/docs/assets/code/uc/src/test/PhysicalTest.lf @@ -0,0 +1,9 @@ +target uC; +import Physical from "../Physical.lf"; +main reactor { + timer t(200 msec, 200 msec); + p = new Physical(); + reaction(t) -> p.x {= + lf_set(p.x, 0); + =} +} diff --git a/docs/assets/code/uc/src/test/PreambleTest1.lf b/docs/assets/code/uc/src/test/PreambleTest1.lf new file mode 100644 index 000000000..e7e23b6a7 --- /dev/null +++ b/docs/assets/code/uc/src/test/PreambleTest1.lf @@ -0,0 +1,13 @@ +/** + * This example is included in Preambles.md, but not automatically imported. + * Success of the test is compiling and running. + */ +target uC +main reactor { + preamble {= + #include + =} + reaction(startup) {= + printf("The cosine of 1 is %f.\n", cos(1)); + =} +} diff --git a/docs/assets/code/uc/src/test/PreambleTest2.lf b/docs/assets/code/uc/src/test/PreambleTest2.lf new file mode 100644 index 000000000..72dd66a09 --- /dev/null +++ b/docs/assets/code/uc/src/test/PreambleTest2.lf @@ -0,0 +1,22 @@ +/** + * This example is included in Preambles.md, but not automatically imported. + * Success of the test is compiling and running. + */ +target uC +preamble {= + #include +=} +reactor Cos { + reaction(startup) {= + printf("The cosine of 1 is %f.\n", cos(1)); + =} +} +reactor Sin { + reaction(startup) {= + printf("The sine of 1 is %f.\n", sin(1)); + =} +} +main reactor { + c = new Cos() + s = new Sin() +} diff --git a/docs/assets/code/uc/src/test/PreambleTest3.lf b/docs/assets/code/uc/src/test/PreambleTest3.lf new file mode 100644 index 000000000..c6d721547 --- /dev/null +++ b/docs/assets/code/uc/src/test/PreambleTest3.lf @@ -0,0 +1,18 @@ +/** + * This example is included in Preambles.md, but not automatically imported. + * Success of the test is compiling and running. + */ +target uC +import Cos from "../lib/Cos.lf" +preamble {= + #include +=} +reactor Sin { + reaction(startup) {= + printf("The sine of 1 is %f.\n", sin(1)); + =} +} +main reactor { + c = new Cos() + s = new Sin() +} diff --git a/docs/assets/code/uc/src/test/PreambleTest4.lf b/docs/assets/code/uc/src/test/PreambleTest4.lf new file mode 100644 index 000000000..6d9d95ca0 --- /dev/null +++ b/docs/assets/code/uc/src/test/PreambleTest4.lf @@ -0,0 +1,18 @@ +/** + * This example is included in Preambles.md, but not automatically imported. + * Success of the test is compiling and running. + */ +target uC +main reactor { + preamble {= + int add_42(int i) { + return i + 42; + } + =} + reaction(startup) {= + printf("42 plus 42 is %d.\n", add_42(42)); + =} + reaction(startup) {= + printf("42 plus 1 is %d.\n", add_42(1)); + =} +} diff --git a/docs/assets/code/uc/src/test/PreambleTest5.lf b/docs/assets/code/uc/src/test/PreambleTest5.lf new file mode 100644 index 000000000..3315c40f8 --- /dev/null +++ b/docs/assets/code/uc/src/test/PreambleTest5.lf @@ -0,0 +1,27 @@ +/** + * This example is included in Preambles.md, but not automatically imported. + * Success of the test is compiling and running. + */ +target uC +preamble {= + int add_42(int i); +=} +reactor Add_42 { + reaction(startup) {= + printf("42 plus 42 is %d.\n", add_42(42)); + =} +} +reactor Add_1 { + reaction(startup) {= + printf("42 plus 1 is %d.\n", add_42(1)); + =} +} +main reactor { + preamble {= + int add_42(int i) { + return i + 42; + } + =} + a = new Add_42() + b = new Add_1() +} \ No newline at end of file diff --git a/docs/assets/code/uc/src/test/PreambleTest6.lf b/docs/assets/code/uc/src/test/PreambleTest6.lf new file mode 100644 index 000000000..6e89394a4 --- /dev/null +++ b/docs/assets/code/uc/src/test/PreambleTest6.lf @@ -0,0 +1,25 @@ +/** + * This example is included in Preambles.md, but not automatically imported. + * Success of the test is compiling and running. + */ +target uC +preamble {= + extern const char shared_string[]; +=} +reactor A { + reaction(startup) {= + printf("Reactor A says %s.\n", shared_string); + =} +} +reactor B { + reaction(startup) {= + printf("Reactor B says %s.\n", shared_string); + =} +} +main reactor { + preamble {= + const char shared_string[] = "Hello"; + =} + a = new A() + b = new B() +} diff --git a/docs/assets/code/uc/src/test/PreambleTest7.lf b/docs/assets/code/uc/src/test/PreambleTest7.lf new file mode 100644 index 000000000..630d91002 --- /dev/null +++ b/docs/assets/code/uc/src/test/PreambleTest7.lf @@ -0,0 +1,14 @@ +/** + * This example is included in Preambles.md, but not automatically imported. + * Success of the test is compiling and running. + */ +target uC +preamble {= + typedef int foo; +=} +main reactor { + state x:foo = 0 + reaction(startup) {= + lf_print("State is %d", self->x); + =} +} \ No newline at end of file diff --git a/docs/assets/code/uc/src/test/ScheduleTest.lf b/docs/assets/code/uc/src/test/ScheduleTest.lf new file mode 100644 index 000000000..d6c82b47d --- /dev/null +++ b/docs/assets/code/uc/src/test/ScheduleTest.lf @@ -0,0 +1,11 @@ +target uC { + timeout: 1 sec, + fast: true +} +import Schedule from "../Schedule.lf"; +import Count from "../Count.lf"; +main reactor { + c = new Count(); + d = new Schedule(); + c.y -> d.x; +} \ No newline at end of file diff --git a/docs/assets/code/uc/src/test/SlowingClockTest.lf b/docs/assets/code/uc/src/test/SlowingClockTest.lf new file mode 100644 index 000000000..2b7c040a3 --- /dev/null +++ b/docs/assets/code/uc/src/test/SlowingClockTest.lf @@ -0,0 +1,42 @@ +/** + * Events are scheduled with increasing additional delays of 0, 100, 300, 600 + * msec on a logical action with a minimum delay of 100 msec. + * The use of the logical action ensures the elapsed time jumps exactly from + * 0 to 100, 300, 600, and 1000 msec. + */ +target uC { + timeout: 1 sec, + fast: true, +}; +main reactor(start:time(100 msec), incr:time(100 msec)) { + logical action a; + state interval:time(start); + state expected_time:time(start); + reaction(startup) -> a {= + lf_schedule(a, self->start); + =} + reaction(a) -> a {= + instant_t elapsed_logical_time = lf_time_logical_elapsed(); + printf("Logical time since start: \%lld nsec.\n", + elapsed_logical_time + ); + if (elapsed_logical_time != self->expected_time) { + printf("ERROR: Expected time to be: \%lld nsec.\n", + self->expected_time + ); + exit(1); + } + self->interval += self->incr; + lf_schedule(a, self->interval); + self->expected_time += self->interval; + =} + reaction(shutdown) {= + if (self->expected_time != MSEC(1500)) { + printf("ERROR: Expected the next expected time to be: 1500000000 nsec.\n"); + printf("It was: \%lld nsec.\n", self->expected_time); + exit(2); + } else { + printf("Test passes.\n"); + } + =} +} diff --git a/docs/assets/code/uc/src/test/SparseTest.lf b/docs/assets/code/uc/src/test/SparseTest.lf new file mode 100644 index 000000000..98eafcf5e --- /dev/null +++ b/docs/assets/code/uc/src/test/SparseTest.lf @@ -0,0 +1,8 @@ +target uC +import Sparse from "../Sparse.lf" +main reactor { + s = new Sparse() + reaction(startup) -> s.in {= + lf_set(s.in[12], 42); + =} +} \ No newline at end of file diff --git a/docs/assets/code/uc/src/test/StructParameter.lf b/docs/assets/code/uc/src/test/StructParameter.lf new file mode 100644 index 000000000..414e76f8f --- /dev/null +++ b/docs/assets/code/uc/src/test/StructParameter.lf @@ -0,0 +1,16 @@ +target uC; +main reactor(p:hello_t("Earth", 42)) { + preamble {= + typedef struct hello_t { + char* name; + int value; + } hello_t; + =} + reaction(startup) {= + printf("Parameter p.name=\"%s\", value=%d.\n", self->p.name, self->p.value); + if (self->p.value != 42) { + fprintf(stderr, "FAILED: Expected 42.\n"); + exit(1); + } + =} +} diff --git a/docs/developer/website-development.mdx b/docs/developer/website-development.mdx index 168a5732e..f56bf3b0e 100644 --- a/docs/developer/website-development.mdx +++ b/docs/developer/website-development.mdx @@ -78,20 +78,20 @@ In general, different targets are just a bunch of `Tab` components with `groupId The target selector, which appears on the top, is a `Tab` component with no content. It is defined in `src/components/LinguaFrancaMultiTargetUtils/LanguageSelector.tsx`. ##### Usage -`` where the target languages could be a subset of all targets which we support. The ordering is guaranteed to be `C C++ Python Rust TypeScript`, regardless of the ordering supplied as argument. +`` where the target languages could be a subset of all targets which we support. The ordering is guaranteed to be `C micro-LF C++ Python Rust TypeScript`, regardless of the ordering supplied as argument. ##### Examples -`` +`` :::note[Rendered as] - + ::: -`` +`` :::note[Rendered as] - + ::: @@ -268,23 +268,25 @@ Remember to use relative import! If you don't, you will mess up the versioning. ```tsx import C_HelloWorld from '../assets/code/c/src/HelloWorld.lf'; +import UC_HelloWorld from '../assets/code/uc/src/HelloWorld.lf'; import Cpp_HelloWorld from '../assets/code/cpp/src/HelloWorld.lf'; import Py_HelloWorld from '../assets/code/py/src/HelloWorld.lf'; import Rs_HelloWorld from '../assets/code/rs/src/HelloWorld.lf'; import TS_HelloWorld from '../assets/code/ts/src/HelloWorld.lf'; - + ``` :::note[Rendered as] import C_HelloWorld from '../assets/code/c/src/HelloWorld.lf'; +import UC_HelloWorld from '../assets/code/uc/src/HelloWorld.lf'; import Cpp_HelloWorld from '../assets/code/cpp/src/HelloWorld.lf'; import Py_HelloWorld from '../assets/code/py/src/HelloWorld.lf'; import Rs_HelloWorld from '../assets/code/rs/src/HelloWorld.lf'; import TS_HelloWorld from '../assets/code/ts/src/HelloWorld.lf'; - + ::: diff --git a/docs/reference/expressions.mdx b/docs/reference/expressions.mdx index f6ee9eb89..a710974e1 100644 --- a/docs/reference/expressions.mdx +++ b/docs/reference/expressions.mdx @@ -9,7 +9,7 @@ import { ShowIf, ShowIfs, ShowOnly } from '@site/src/components/LinguaFrancaMultiTargetUtils'; - + A subset of LF syntax is used to write _expressions_, which represent values in the target language. Expressions are used to initialize state variable and to give values to parameters. Arbitrary expressions in the target language can always be given within delimiters `{= ... =}`, but simple forms do not require the delimiters. These simple forms are documented here. diff --git a/docs/reference/security.mdx b/docs/reference/security.mdx index c58afe05d..79ebbe354 100644 --- a/docs/reference/security.mdx +++ b/docs/reference/security.mdx @@ -9,7 +9,7 @@ import { ShowIf, ShowIfs, ShowOnly } from '@site/src/components/LinguaFrancaMultiTargetUtils'; - + :::warning The experimental security features described on this page are under development and not production ready. Users should not expect their federations will be secure if the `auth` target property is enabled. diff --git a/docs/reference/target-declaration.mdx b/docs/reference/target-declaration.mdx index 4ef09a3e4..1d5bb3e71 100644 --- a/docs/reference/target-declaration.mdx +++ b/docs/reference/target-declaration.mdx @@ -9,7 +9,7 @@ import { ShowIf, ShowIfs, ShowOnly, } from '@site/src/components/LinguaFrancaMultiTargetUtils'; - + # Target Declaration @@ -76,6 +76,27 @@ c={ workers: , };` } +uc={ +`target uC { + auth: + build: , + build-type: , + cmake-args: , + cmake-include: , + compiler: , + compiler-flags: , + docker: , + fast: , + files: , + logging: , + no-compile: , + protobufs: , + single-threaded: , + timeout: