Syscall 2: Firmware, home

BenchChapter 7: Frames and loops

B49QUANTIZER

The task

P0 reads a triangle wave. Round each reading down to a quarter of the supply,

0, 25, 50, 75, or 100 percent, and put it out on P1, so CH2 climbs and falls in steps.

The board

The chip of QUANTIZERChip u1 with 2 ports: P0 analog in, reaching V1, CH1; P1 pwm out, reaching R1, C1, CH2.u1CHIP SC-2P0ANALOG INV1, CH1P1PWM OUTR1, C1, CH2
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 triangle at 25 Hz and V2 2.5 V
Resistors
R1 1 kΩ
Capacitors
C1 1 µF
Probes
CH1 and CH2

Key idea

DIV 25 throws away the remainder.

Hints

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

Hint 1Show

MUL 25 turns the number of quarters back into a percent.

Hint 2Show

A reading of 60 becomes 2 quarters, and a duty of 50.

Solution

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

Round each reading down to a quarter.

u1SC-2 standard

IN P0
DIV 25
MUL 25
OUT P1
CYCLES
800
at par
ENERGY
1600
at par
NODES
1
at par
INSTRUCTIONS
4
at par