Syscall 2: Firmware, home

BenchChapter 11: Capstones

B84RETRIGGER

The task

P0 reads bursts of short pulses on CH1. Sample it on each tick of P2.

Light the LED on P1 while the input is high, and keep it lit until 4 ticks pass with it low.

Every high tick starts the 4 again, so the LED rides through short gaps.

The board

The chip of RETRIGGERChip u1 with 3 ports: P0 digital in, reaching V1, CH1; P1 digital out, reaching R1, D1, CH2; P2 timer 20 cycles.u1CHIP SC-2P0DIGITAL INV1, CH1P1DIGITAL OUTR1, D1, CH2P2TIMER 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 1 V square at 12.5 Hz and V2 2.5 V square at 83.33 Hz
Resistors
R1 330 Ω
LEDs
D1 red
Probes
CH1 and CH2

Key idea

Keep the ticks left in B: a high sample sets it to 4.

Hints

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

Hint 1Show

A low sample counts B down; when it reaches zero, the LED goes out.

Hint 2Show

Once B is zero, a low sample needs no write at all.

Solution

Reveal the Full SolutionThe complete program for RETRIGGER. 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 retriggerable hold of 4 ticks.

u1SC-2 standard

L: IN P2
IN P0
JZ DEC
MOV A, 4
JMP S
DEC: MOV A, B
JZ L
SUB 1
S: MOV B, A
OUT P1
CYCLES
505
at par
ENERGY
1010
at par
NODES
1
at par
INSTRUCTIONS
10
at par