Syscall 2: Firmware, home

BenchChapter 11: Capstones

B86VCO

The task

P0 reads a knob on CH1. On each tick of P2, add the reading DIV 10 to a phase kept in B.

The phase wraps at 100. Light the LED on P1 while the phase is 50 or more.

A higher knob adds more each tick, so the LED blinks faster.

The board

The chip of VCOChip u1 with 3 ports: P0 analog in, reaching V1, CH1; P1 digital out, reaching R1, D1, CH2; P2 timer 20 cycles.u1CHIP SC-2P0ANALOG 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 3.5 V, V2 2 V square at 8.333 Hz, and V3 1 V square at 4.167 Hz
Resistors
R1 330 Ω
LEDs
D1 green
Probes
CH1 and CH2

Key idea

MOD 100 keeps the phase between 0 and 99.

Hints

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

Hint 1Show

The phase DIV 50 is 1 in the top half and 0 in the bottom half.

Hint 2Show

IN P2, IN P0, DIV 10, ADD B, MOD 100, MOV B, A, DIV 50, OUT P1.

Solution

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

u1SC-2 standard

IN P2
IN P0
DIV 10
ADD B
MOD 100
MOV B, A
DIV 50
OUT P1
CYCLES
953
at par
ENERGY
1906
at par
NODES
1
at par
INSTRUCTIONS
8
at par