Syscall 2: Firmware, home

BenchChapter 5: Half duplex

B24COINCIDENCE

The task

V1 and V2 send square waves to P0 and P1 at different rates.

Light the LED on P2 only while both inputs are high.

The board

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

Key idea

When P0 reads 0 the answer is 0, whatever P1 says.

Hints

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

Hint 1Show

JZ jumps when A is 0, so it can skip reading P1.

Hint 2Show

Read P0. If it is 0, write that 0. If not, read P1 and write what it says.

Solution

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

The LED lights only while both inputs are high.

u1SC-2 standard

IN P0
JZ W
IN P1
W: OUT P2
CYCLES
400
at par
ENERGY
800
at par
NODES
1
at par
INSTRUCTIONS
4
at par

Another way: Mul

A second program that also passes, by a different road, at a cost on INSTRUCTIONS.

The product of the two readings is 1 only when both are 1.

u1SC-2 standard

IN P0
MOV B, A
IN P1
MUL B
OUT P2
CYCLES
400
at par
ENERGY
800
at par
NODES
1
at par
INSTRUCTIONS
5
over par