Syscall 2: Firmware, home

BenchChapter 10: Meshes

B78SEQUENCER

The task

P0 reads an enable switch on CH1. P1 powers the core rail on CH2, P2 the IO rail on CH3.

When enable rises, power the core, then the IO rail two ticks of P3 later.

When it falls, drop the IO rail first and the core one tick later.

The board

The chip of SEQUENCERChip u1 with 4 ports: P0 digital in, reaching V1, CH1; P1 digital out, reaching R1, C1, CH2; P2 digital out, reaching R2, C2, CH3; P3 timer 20 cycles.u1CHIP SC-2P0DIGITAL INV1, CH1P1DIGITAL OUTR1, C1, CH2P2DIGITAL OUTR2, C2, CH3P3TIMER 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 5 V and V2 5 V square at 12.5 Hz
Resistors
R1 2.2 kΩ and R2 2.2 kΩ
Capacitors
C1 1 µF and C2 1 µF
Probes
CH1, CH2, and CH3

Key idea

Sample the switch on each tick, so every wait is a whole number of ticks.

Hints

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

Hint 1Show

A digital read of 1 can go straight out to switch a rail on, and a read of 0 to switch it off.

Hint 2Show

Up: core, sleep twice, IO. Down: IO, sleep once, core.

Solution

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

Core before IO going up, IO before core going down.

u1SC-2 standard

W: IN P3
IN P0
JZ W
OUT P1
IN P3
IN P3
MOV A, 1
OUT P2
H: IN P3
IN P0
JNZ H
OUT P2
IN P3
MOV A, 0
OUT P1
CYCLES
253
at par
ENERGY
506
at par
NODES
1
at par
INSTRUCTIONS
15
at par