Syscall 2: Firmware, home

BenchChapter 7: Frames and loops

B46GAIN

The task

V1 and V2 make a sine wave from 0.5 to 4.5 volts, but R1 and R2 halve it before P0.

Undo the divider: on CH2, put out the full wave as a PWM duty on P1.

The board

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

Key idea

CH1 shows what P0 reads, half of the source.

Hints

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

Hint 1Show

MUL 2 doubles A.

Hint 2Show

A reading of 45 percent at the top becomes a duty of 90 percent: 4.5 volts.

Solution

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

Double the halved input back to full size.

u1SC-2 standard

IN P0
MUL 2
OUT P1
CYCLES
400
at par
ENERGY
800
at par
NODES
1
at par
INSTRUCTIONS
3
at par