What you learn today
- Check before reading
- Check before writing
- Avoid IncorrectLogicType
Yesterday you asked whether a device is there. Today you ask whether it can do something. A gas sensor has no switch, a wall heater no thermometer. If you read Temperature from a heater, the chip reports IncorrectLogicType and stays on that line.
When that happens
As long as you know every device, the error hardly ever occurs. It shows up when the chip does not know what sits on a pin:
- a universal chip you attach to different devices
- a loop over all pins with
dr0 - a ReferenceId someone else entered
bdnvl: can it read that?
bdnvl device Temperature no_thermo # jumps if not readable
l temp device Temperature
bdnvl stands for branch if device not valid for load: the chip jumps if the device can not read this LogicType. Otherwise it continues on the next line, and reading is safe.
bdnvs: can it write that?
bdnvs device On not_switchable # jumps if not writable
s device On 1
bdnvs (not valid for store) checks writing. A gas sensor cannot write On, a wall heater can.
| Instruction | jumps if |
|---|---|
bdnvl device LogicType target | the device cannot read the LogicType |
bdnvs device LogicType target | the device cannot write the LogicType |
Both take a device like l and s: a pin, db or a register with a ReferenceId. There is no counterpart for lbn. There the chip checks all matching devices before reading and reports IncorrectLogicType as soon as one of them lacks the value.
bdnvl checks the ability, not the presence. If the device is missing entirely, bdnvl reports an error as well (DeviceNotFound). So check with bdns first, then with bdnvl.
The simulator of the IC10 coder has a strict mode. Then only the LogicTypes listed on the device apply, and bdnvl jumps as in the game. Without strict mode the simulator allows every LogicType, and the jump never comes.
Diagram
Exercise
Task
A universal chip: what hangs on the pins is not fixed.
d0: a load. If it is there and can writeOn, it follows the lever “Freigabe” (Open).d1: a measuring device. If it is there and can readTemperature, the display ond2shows the temperature in °C, otherwise −999.- If a device is missing on any pin, there is no error.
Hints
Hint 1
Before every access first bdns, then bdnvs or bdnvl – both jump to the next section.
Hint 2
Set c to NOVALUE before checking the meter. Then −999 is shown when a check jumps.
Hint 3
Check the display on d2 with bdns before writing as well.
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