Syscall 2: Firmware, home

BenchChapter 8: Scarcity

B59HIGH SIDE

The task

Q1 is a PMOS between V1 and the lamp. It conducts while P0 is low and stops while P0 is high.

Every output starts low, so the lamp starts lit. CH1 is the drain, near 5 volts while lit.

P1 ticks every 20 cycles. Keep the lamp dark for two ticks, then lit for one, from the start.

The board

The chip of HIGH SIDEChip u1 with 2 ports: P0 digital out, reaching R1, Q1; P1 timer 20 cycles.u1CHIP SC-2P0DIGITAL OUTR1, Q1P1TIMER 20 CYCLES
The chip's ports, each with its kind and the parts its signal reaches. Cyan reads, lemon writes.
Sources
V1 5 V
Resistors
R1 1 kΩ and R2 330 Ω
LEDs
D1 yellow
Transistors
Q1, a P channel MOSFET
Probes
CH1

Key idea

A PMOS turns on when its gate is well below its source: a low on P0 lights the lamp.

Hints

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

Hint 1Show

Write 1 to P0 before the first sleep, or the lamp glows through the opening ticks.

Hint 2Show

Write 1, sleep twice, write 0, sleep once, and repeat.

Solution

Reveal the Full SolutionThe complete program for HIGH SIDE. 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.

Dark from the start, two ticks dark and one lit.

u1SC-2 standard

MOV A, 1
OUT P0
IN P1
IN P1
MOV A, 0
OUT P0
IN P1
CYCLES
35
at par
ENERGY
70
at par
NODES
1
at par
INSTRUCTIONS
7
at par