Portability | portable |
---|---|

Stability | experimental |

Maintainer | forsyde-dev@ict.kth.se |

The synchronuous library defines process constructors and processes for the synchronous computational model. A process constructor is a higher order function which together with combinational function(s) and values as arguments constructs a process.

- mapSY :: (a -> b) -> Signal a -> Signal b
- zipWithSY :: (a -> b -> c) -> Signal a -> Signal b -> Signal c
- zipWith3SY :: (a -> b -> c -> d) -> Signal a -> Signal b -> Signal c -> Signal d
- zipWith4SY :: (a -> b -> c -> d -> e) -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e
- zipWithxSY :: (Vector a -> b) -> Vector (Signal a) -> Signal b
- delaySY :: a -> Signal a -> Signal a
- delaynSY :: a -> Int -> Signal a -> Signal a
- scanlSY :: (a -> b -> a) -> a -> Signal b -> Signal a
- scanl2SY :: (a -> b -> c -> a) -> a -> Signal b -> Signal c -> Signal a
- scanl3SY :: (a -> b -> c -> d -> a) -> a -> Signal b -> Signal c -> Signal d -> Signal a
- scanldSY :: (a -> b -> a) -> a -> Signal b -> Signal a
- scanld2SY :: (a -> b -> c -> a) -> a -> Signal b -> Signal c -> Signal a
- scanld3SY :: (a -> b -> c -> d -> a) -> a -> Signal b -> Signal c -> Signal d -> Signal a
- mooreSY :: (a -> b -> a) -> (a -> c) -> a -> Signal b -> Signal c
- moore2SY :: (a -> b -> c -> a) -> (a -> d) -> a -> Signal b -> Signal c -> Signal d
- moore3SY :: (a -> b -> c -> d -> a) -> (a -> e) -> a -> Signal b -> Signal c -> Signal d -> Signal e
- mealySY :: (a -> b -> a) -> (a -> b -> c) -> a -> Signal b -> Signal c
- mealy2SY :: (a -> b -> c -> a) -> (a -> b -> c -> d) -> a -> Signal b -> Signal c -> Signal d
- mealy3SY :: (a -> b -> c -> d -> a) -> (a -> b -> c -> d -> e) -> a -> Signal b -> Signal c -> Signal d -> Signal e
- sourceSY :: (a -> a) -> a -> Signal a
- filterSY :: (a -> Bool) -> Signal a -> Signal (AbstExt a)
- fillSY :: a -> Signal (AbstExt a) -> Signal a
- holdSY :: a -> Signal (AbstExt a) -> Signal a
- whenSY :: Signal (AbstExt a) -> Signal (AbstExt b) -> Signal (AbstExt a)
- zipSY :: Signal a -> Signal b -> Signal (a, b)
- zip3SY :: Signal a -> Signal b -> Signal c -> Signal (a, b, c)
- zip4SY :: Signal a -> Signal b -> Signal c -> Signal d -> Signal (a, b, c, d)
- zip5SY :: Signal a -> Signal b -> Signal c -> Signal d -> Signal e -> Signal (a, b, c, d, e)
- zip6SY :: Signal a -> Signal b -> Signal c -> Signal d -> Signal e -> Signal f -> Signal (a, b, c, d, e, f)
- unzipSY :: Signal (a, b) -> (Signal a, Signal b)
- unzip3SY :: Signal (a, b, c) -> (Signal a, Signal b, Signal c)
- unzip4SY :: Signal (a, b, c, d) -> (Signal a, Signal b, Signal c, Signal d)
- unzip5SY :: Signal (a, b, c, d, e) -> (Signal a, Signal b, Signal c, Signal d, Signal e)
- unzip6SY :: Signal (a, b, c, d, e, f) -> (Signal a, Signal b, Signal c, Signal d, Signal e, Signal f)
- zipxSY :: Vector (Signal a) -> Signal (Vector a)
- unzipxSY :: Signal (Vector a) -> Vector (Signal a)
- mapxSY :: (a -> b) -> Vector (Signal a) -> Vector (Signal b)
- fstSY :: Signal (a, b) -> Signal a
- sndSY :: Signal (a, b) -> Signal b

# Combinational process constructors

Combinational process constructors are used for processes that do not have a state.

mapSY :: (a -> b) -> Signal a -> Signal bSource

The process constructor `mapSY`

takes a combinational function as argument and returns a process with one input signal and one output signal.

zipWithSY :: (a -> b -> c) -> Signal a -> Signal b -> Signal cSource

The process constructor `zipWithSY`

takes a combinational function as argument and returns a process with two input signals and one output signal.

zipWith3SY :: (a -> b -> c -> d) -> Signal a -> Signal b -> Signal c -> Signal dSource

The process constructor `zipWith3SY`

takes a combinational function as argument and returns a process with three input signals and one output signal.

zipWith4SY :: (a -> b -> c -> d -> e) -> Signal a -> Signal b -> Signal c -> Signal d -> Signal eSource

The process constructor `zipWith4SY`

takes a combinational function as argument and returns a process with four input signals and one output signal.

zipWithxSY :: (Vector a -> b) -> Vector (Signal a) -> Signal bSource

The process constructor `zipWithxSY`

works as `zipWithSY`

, but takes a vector of signals as input.

# Sequential process constructors

Sequential process constructors are used for processes that have a state. One of the input parameters is the initial state.

The process constructor `delaySY`

delays the signal one event cycle
by introducing an initial value at the beginning of the output signal.
Note, that this implies that there is one event (the first) at the
output signal that has no corresponding event at the input signal.
One could argue that input and output signals are not fully synchronized,
even though all input events are synchronous with a corresponding output
event. However, this is necessary to initialize feed-back loops.

The process constructor `delaynSY`

delays the signal n events by introducing n identical default values.

:: (a -> b -> a) | Combinational function for next state decoder |

-> a | Initial state |

-> Signal b | Input signal |

-> Signal a | Output signal |

The process constructor `scanlSY`

is used to construct a finite state machine process without output decoder. It takes an initial value and a function for the next state decoder. The process constructor behaves similar to the Haskell prelude function `scanlSY`

and has the value of the new state as its output value as illustrated by the following example.

SynchronousLib> scanldSY (+) 0 (signal [1,2,3,4])

{1,3,6,10} :: Signal Integer

This is in contrast to the function `scanldSY`

, which has its current state as its output value.

:: (a -> b -> a) | Combinational function for next state decoder |

-> a | Initial state |

-> Signal b | Input signal |

-> Signal a | Output signal |

The process constructor `scanldSY`

is used to construct a finite state machine process without output decoder. It takes an initial value and a function for the next state decoder. The process constructor behaves similar to the Haskell prelude function `scanlSY`

. In contrast to the process constructor `scanlSY`

here the output value is the current state and not the one of the next state.

SynchronousLib> scanlSY (+) 0 (signal [1,2,3,4])

{0,1,3,6} :: Signal Integer

:: (a -> b -> a) | Combinational function for next state decoder |

-> (a -> c) | Combinational function for output decoder |

-> a | Initial state |

-> Signal b | Input signal |

-> Signal c | Output signal |

The process constructor `mooreSY`

is used to model state machines of "Moore" type, where the output only depends on the current state. The process constructor is based on the process constructor `scanldSY`

, since it is natural for state machines in hardware, that the output operates on the current state and not on the next state. The process constructors takes a function to calculate the next state, another function to calculate the output and a value for the initial state.

In contrast the output of a process created by the process constructor `mealySY`

depends not only on the state, but also on the input values.

moore3SY :: (a -> b -> c -> d -> a) -> (a -> e) -> a -> Signal b -> Signal c -> Signal d -> Signal eSource

:: (a -> b -> a) | Combinational function for next state decoder |

-> (a -> b -> c) | Combinational function for output decoder |

-> a | Initial state |

-> Signal b | Input signal |

-> Signal c | Output signal |

The process constructor `melaySY`

is used to model state machines of "Mealy" type, where the output only depends on the current state and the input values. The process constructor is based on the process constructor `scanldSY`

, since it is natural for state machines in hardware, that the output operates on the current state and not on the next state. The process constructors takes a function to calculate the next state, another function to calculate the output and a value for the initial state.

In contrast the output of a process created by the process constructor `mooreSY`

depends only on the state, but not on the input values.

mealy3SY :: (a -> b -> c -> d -> a) -> (a -> b -> c -> d -> e) -> a -> Signal b -> Signal c -> Signal d -> Signal eSource

sourceSY :: (a -> a) -> a -> Signal aSource

The process `sourceSY`

takes a function and an initial state and generates an infinite signal starting with the initial state as first output followed by the recursive application of the function on the current state. The state also serves as output value.

The process that has the infinite signal of natural numbers as output is constructed by

SynchronousLib> takeS 5 (sourceSY (+1) 0)

{0,1,2,3,4} :: Signal Integer

filterSY :: (a -> Bool) -> Signal a -> Signal (AbstExt a)Source

The process constructor `filterSY`

discards the values who do not fulfill a predicate given by a predicate function and replaces them with absent events.

# Synchronous Processes

The library contains a few simple processes that are applicable to many cases.

zipSY :: Signal a -> Signal b -> Signal (a, b)Source

The process `zipSY`

"zips" two incoming signals into one signal of tuples.

zip6SY :: Signal a -> Signal b -> Signal c -> Signal d -> Signal e -> Signal f -> Signal (a, b, c, d, e, f)Source

unzipSY :: Signal (a, b) -> (Signal a, Signal b)Source

The process `unzipSY`

"unzips" a signal of tuples into two signals.

unzip6SY :: Signal (a, b, c, d, e, f) -> (Signal a, Signal b, Signal c, Signal d, Signal e, Signal f)Source

zipxSY :: Vector (Signal a) -> Signal (Vector a)Source

The process `zipxSY`

"zips" a signal of vectors into a vector of signals.

unzipxSY :: Signal (Vector a) -> Vector (Signal a)Source

The process `unzipxSY`

"unzips" a vector of signals into a signal of vectors.

mapxSY :: (a -> b) -> Vector (Signal a) -> Vector (Signal b)Source

The process constructor `mapxSY`

creates a process network that maps a function onto all signals in a vector of signals.