Syscall 2: Firmware, home

BenchChapter 12: Shared buses

B97FUSE

The task

P0 reads the load current on CH1. P1 switches the lamp through Q1; CH2 is its drain.

Turn the lamp on. Each tick of P2, add (current minus 40) DIV 4 to a heat count, never below 0.

When the heat passes 100, turn the lamp off for good.

The board

The chip of FUSEChip u1 with 3 ports: P0 analog in, reaching V1, CH1; P1 digital out, reaching R1, Q1; P2 timer 20 cycles.u1CHIP SC-2P0ANALOG INV1, CH1P1DIGITAL OUTR1, Q1P2TIMER 20 CYCLES
The chip's ports, each with its kind and the parts its signal reaches. Cyan reads, lemon writes. On a narrow screen, scroll the board sideways to see all of it.
Sources
V1 3.5 V, V2 2 V square at 12.5 Hz, V3 1 V square at 6.25 Hz, and V4 5 V
Resistors
R1 100 Ω and R2 330 Ω
LEDs
D1 yellow
Transistors
Q1, an N channel MOSFET
Probes
CH1 and CH2

Key idea

Keep the heat in B. A sum that is not positive becomes 0.

Hints

Each hint goes a step further than the one before. Open them one at a time.

Hint 1Show

Without the floor at 0, the heat sinks past minus 128 and wraps to a large number.

Hint 2Show

Once tripped, the program must stay put: a loop that jumps to itself does.

Solution

Reveal the Full SolutionThe complete program for FUSE. Open it only when you want the answer.

The reference program

The game's own solution. It passes every test and scores exactly par on every benchmark.

A thermal model with a floor at 0 and a latched trip.

u1SC-2 standard

MOV A, 1
OUT P1
L: IN P2
IN P0
SUB 40
DIV 4
ADD B
JG K
MOV A, 0
K: MOV B, A
SUB 100
JL L
MOV A, 0
OUT P1
S: JMP S
CYCLES
800
at par
ENERGY
1600
at par
NODES
1
at par
INSTRUCTIONS
15
at par