diff options
Diffstat (limited to 'assignment-13')
-rw-r--r-- | assignment-13/ufpl.tex | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/assignment-13/ufpl.tex b/assignment-13/ufpl.tex index 2129484..462180a 100644 --- a/assignment-13/ufpl.tex +++ b/assignment-13/ufpl.tex @@ -31,12 +31,14 @@ Rewrite rules can be set to trigger only when a share changes. There are specialised instructions to deal with an LCD shield. Buttons and timing are provided by way of predefined read-only shares. Type safety is guaranteed using poor man's GADTs by John van Groningen. +An iTasks simulator can be used to interactively design programs.% + \footnote{\uFPL\ is tested on the nightly of January 7, 2018.} An example of a program in \uFPL\ is given in \cref{lst:score}. It keeps scores of two players and displays it on the LCD. There are four named rules (\texttt{a}, \texttt{b}, \texttt{r} and \texttt{print}) - that are executed in parallel by means of the \texttt{|||} operator. -The first two rules ensure that the scores of player A and player B are incremented when a button is pressed. + that are executed in parallel using the \texttt{|||} operator. +The first two rules increment the scores when a button is pressed. The third rule resets the scores when button 2 is pressed. The fourth rule is triggered whenever either score changes, and prints the score on the screen. @@ -74,8 +76,7 @@ The first checks whether some condition holds, Rules can be chained with \clean{:.} and named rules with \clean{|||}. \begin{listing*}[p] - \inputminted[firstline=76,lastline=80]{clean}{uFPL.dcl} - \inputminted[firstline=84,lastline=93]{clean}{uFPL.dcl} + \inputminted[firstline=76,lastline=93]{clean}{uFPL.dcl} \caption{Rules in our DSL.\label{lst:rules}} \end{listing*} @@ -96,7 +97,7 @@ Wrapper functions as \clean{rwInt :: String Int -> Expr Int RW} from \module{uFP \end{listing*} \subsection{Code generation} -A separate module, \module{uFPL.C}, provides types to represent simple (Arduino) C programs. +A separate module, \module{uFPL.C}, provides types to represent simple C programs. In \module{uFPL}, the \clean{gen} class takes care of generation to this C representation. Every named rule becomes a separate C function. @@ -209,18 +210,18 @@ Example errors are shown in \cref{fig:itasks-errors}. \end{figure*} A number of actions is available to simulate the program. -It is not possible to update arbitrary shares, but for buttons and timing specialised actions are available (\cref{fig:itasks-score:simulation}). The most basic action is \enquote{Step}, which executes every named rule once. -Buttons can be toggled, which changes their value but does not execute any code. +It is not possible to update arbitrary shares, but for buttons and timing specialised actions are available (\cref{fig:itasks-score:simulation}). +Buttons can be toggled, which changes their value without executing any code. Pressing a button means setting it to \clean{true}, doing a step and resetting it to \clean{false}.% \footnote{The system does not take into account that only one button can be pressed at the same time due to the resistor ladder on the LCD shield.} When a program uses timing, - actions exist for incrementing the value of \clean{millis} with \clean{100} or \clean{1000} (without stepping the program). + actions exist for incrementing the value of \clean{millis} with \clean{100} or \clean{1000} (without stepping). There also exists a fully automatic simulator which increments the value of \clean{millis} by \clean{1000} and performs a step every second. However, due to (presumed) limitations of the iTasks framework, - this uses a lot of CPU power and the state share sometimes misses an iteration. + this is CPU-intensive and the state share sometimes misses an iteration. In the left bottom view, the states of the shares and the display ($16\times2$ is assumed) are shown. |