Syscall 2: Firmware, home

BenchChapter 5: Half duplex

B23PUSH PULL

The task

V1 drives P0 with a square wave. P1 and P2 each drive an LED.

Light the green LED on P1 while the input is high, and the red LED on P2 while it is low.

A digital output is on for any value but 0, negative values included.

The board

The chip of PUSH PULLChip u1 with 3 ports: P0 digital in, reaching V1, CH1; P1 digital out, reaching R1, D1, CH2; P2 digital out, reaching R2, D2, CH3.u1CHIP SC-2P0DIGITAL INV1, CH1P1DIGITAL OUTR1, D1, CH2P2DIGITAL OUTR2, D2, 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 5 V square at 100 Hz
Resistors
R1 330 Ω and R2 330 Ω
LEDs
D1 green and D2 red
Probes
CH1, CH2, and CH3

Key idea

IN P0 gives 1 or 0. The green LED takes it as it is.

Hints

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

Hint 1Show

SUB 1 turns 1 into 0 and 0 into minus 1.

Hint 2Show

Minus 1 is not 0, so it lights the red LED.

Solution

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

Green follows the input, red shows the opposite.

u1SC-2 standard

IN P0
OUT P1
SUB 1
OUT P2
CYCLES
400
at par
ENERGY
800
at par
NODES
1
at par
INSTRUCTIONS
4
at par