What you learn today
- Housing Setting as a mailbox
- Logic memory in between
- Who writes, who reads
One chip measures the weather outside, a second one controls the hangar door inside. The door chip has to know when a storm is coming. Two chips talk to each other by one putting a value down and the other picking it up.
The housing's Setting as a mailbox
Every IC housing has a Setting its chip writes with s db Setting x. Other chips on the same data network read it like any other device:
s db Setting storm # weather chip
lbn storm HOUSING HASH("Wetterchip") Setting Average # door chip
HOUSING is the hash of StructureCircuitHousing. So that the door chip hits the right housing, the weather chip's housing gets a name of its own.
Logic memory in between
Instead of the housing, a logic memory can hold the value as well. That has two advantages: the value stays even while the writing chip is taken out, and a player sees and changes it without code. The weather chip writes into it with sbn, the door chip reads with lbn.
Who writes, who reads
The most important rule: every value has exactly one writer. If two chips write into the same box in turns, whoever came last wins, and the value jumps back and forth.
| Box | written by | read by |
|---|---|---|
| housing “Wetterchip”, Setting | only the weather chip | door chip, displays |
| housing “Torchip”, Setting | only the door chip | weather chip, displays |
If the weather chip needs feedback, such as “door is closed”, the door chip writes it into its own housing. That way every channel has one direction.
If the sender is missing, lbn … Average returns NaN. Decide beforehand what applies then. For a hangar door with a storm risk that means: better closed than open.
A code in the Setting can mean more than 0 and 1: 0 calm, 1 wind, 2 storm. Write the meaning as a define into both chips.
Diagram
Exercise
Task
You write the door chip. The housing “Wetterchip” reports in its Setting: 0 calm, 1 wind, 2 storm.
- Door “Hangartor” follows the lever “Tor”, but only without danger. Danger means: code ≥ 2 or weather chip missing.
- On danger: door closed and
Lock1, otherwiseLock0. - Feedback: write a 1 into your own housing (
db) when the door is closed, otherwise 0.
Hints
Hint 1
Danger: sge danger weather STORM, then or with snan.
Hint 2
Open only if there is no danger and the lever is on.
Hint 3
The feedback is written with s db Setting closed – never into the weather chip's housing.
Quiz
4 questions. You pass from 60 % – the server does the grading.
Complete the day
- Passed the simulator exercise
- Passed the quiz with at least 60 %
Without an account progress is saved in this browser only.
Report a mistake in this lesson
Please sign in to report. Sign in