Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
Defines the basic operations for reading and writing through ports.
Each core has four ports connecting it to its neighbors. The cores around the edges have ports connected to IO devices. A Channel is just a type containing the four ports that you can write to or read from.
Documentation
A channel representing the four communication directions a core may use. In practice, these will either be hooked up to other cores or to IO. Nothing represents no message; if there is a word, execution will block.
emptyChannel :: Channel Source
An empty channel has no reads or writes and doesn't block execution.
:: F18Word | The address to write to. Only bits 5–8 are considered. |
-> F18Word | The word to write to the channel. |
-> Channel | The resulting channel, with any unused ports empty. |
Write to the ports specified by the given memory address. This will clear all the channels not being written to (by setting them to Nothing).
The ports to use are specified by bits 5–8 of the address. These bits correspond respectively to up, left, down and right. Bits 5 and 7 are inverted—0 turns the channel *on*.
readPort :: F18Word -> Channel -> Maybe F18Word Source
Read the inputs from the ports specified by the given
address. The address is handled the same way as in
. Returns writePort
Nothing
if blocked on the read.
If more than one of the read ports has data, this currently just chooses the first one based on the right, down, left, up order. I don't know if this is the correct behavior—perhaps I should just xor them together or something?