Syscall 2: Firmware, home

BenchChapter 12: Shared buses

B95LONG DELAY

The task

P0 reads a digital signal on CH1. Sample it on each tick of P2.

Copy it to the LED on P1 exactly 6 ticks late.

For the first 6 ticks the LED stays dark.

The board

The chip of LONG DELAYChip 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 2 V square at 25 Hz and V2 1.2 V square at 62.5 Hz
Resistors
R1 330 Ω
LEDs
D1 blue
Probes
CH1 and CH2

Key idea

Two registers cannot hold six samples, unless each sample is one bit of a number.

Hints

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

Hint 1Show

Double B and add the new sample: older samples move up one bit, and 6 bits stay under 64.

Hint 2Show

Before MOD 64 trims B, the bit pushed out, the value DIV 64, is the sample from 6 ticks ago.

Solution

Reveal the Full SolutionThe complete program for LONG DELAY. 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 six bit shift register in B.

u1SC-2 standard

IN P2
IN P0
ADD B
ADD B
MOV B, A
DIV 64
OUT P1
MOV A, B
MOD 64
MOV B, A
CYCLES
791
at par
ENERGY
1582
at par
NODES
1
at par
INSTRUCTIONS
10
at par