Syscall 2: Firmware, home

ShuffleChapter 11: Capstones

S43STILL LIFE

The task

The sample and hold, swapped about. Swap it back.

On each rising edge of the clock on P1, sample P0.

Hold the sample on P2 until the next edge.

The board

The chip of STILL LIFEChip u1 with 3 ports: P0 analog in, reaching V2, CH1; P1 digital in, reaching V3, CH2; P2 pwm out, reaching R1, C1, CH3.u1CHIP SC-2P0ANALOG INV2, CH1P1DIGITAL INV3, CH2P2PWM OUTR1, C1, CH3
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 2.5 V, V2 2 V sine at 25 Hz, and V3 5 V square at 125 Hz
Resistors
R1 1 kΩ
Capacitors
C1 1 µF
Probes
CH1, CH2, and CH3

Key idea

Par is 6 swaps. Core u1 needs 3 instruction swaps and 3 operand swaps. 3 of them trade two tiles that hold each other's places; look for those first, since one swap mends both.

Hints

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

Hint 1Show

A rising edge is a 1 read after a 0: wait for the high, then for the low.

Hint 2Show

JZ loops while the clock is low, and JNZ loops while it is high.

Hint 3Show

Read P0 once, right after the edge, and write it to P2 as it is.

Solution

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

The board as dealt

This is the arrangement the game deals. Framed tiles are the ones out of place.

u1SC-2 standard

L: JZ H
IN L
JNZ P1
IN P0
H: IN P1
OUT P2

6 swaps back

Make these swaps in order. Lines are numbered from 1 in each core.

  1. In core u1, swap the operand H on line 1 with P1 on line 3.
  2. In core u1, swap the operand H on line 3 with P0 on line 4.
  3. In core u1, swap the operand H on line 4 with P2 on line 6.
  4. In core u1, swap the instruction JZ on line 1 with IN on line 2.
  5. In core u1, swap the instruction JNZ on line 3 with IN on line 4.
  6. In core u1, swap the instruction JNZ on line 4 with OUT on line 6.

The finished program

Every tile back in place: the reference solution, which scores exactly par on every benchmark.

u1SC-2 standard

L: IN P1
JZ L
IN P0
OUT P2
H: IN P1
JNZ H
CYCLES
800
at par
ENERGY
1600
at par
NODES
1
at par
INSTRUCTIONS
6
at par
SWAPS
6
at par