Syscall 2: Firmware, home

BenchChapter 4: Stars and hubs

B14SQUARE

The task

P0 drives the base of Q1 through R1. While P0 is high, Q1 pulls CH1 down.

R2 pulls CH1 up to 5 volts while Q1 is off. P1 ticks every 10 cycles.

Make a square: two ticks with P0 high, then two with it low.

The board

The chip of SQUAREChip u1 with 2 ports: P0 digital out, reaching R1, Q1; P1 timer 10 cycles.u1CHIP SC-2P0DIGITAL OUTR1, Q1P1TIMER 10 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 10 kΩ and R2 1 kΩ
Transistors
Q1, an NPN transistor
Probes
CH1

Key idea

Q1 inverts, so a high on P0 is a low on CH1. The band follows CH1.

Hints

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

Hint 1Show

The level holds while you sleep. Two sleeps at one level make two ticks.

Hint 2Show

Sleep, write 1, sleep twice, write 0, sleep twice.

Solution

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

Two ticks high, two ticks low, on the inverter.

u1SC-2 standard

IN P1
MOV A, 1
OUT P0
IN P1
IN P1
MOV A, 0
OUT P0
IN P1
IN P1
CYCLES
36
at par
ENERGY
72
at par
NODES
1
at par
INSTRUCTIONS
9
at par