Script blocks and sources
Logic or a behavioural source written in Python, and a source that plays a pattern of levels and waits.
These run in Coppa’s own Python interpreter, the one the Pico uses, with Python’s usual built-ins and math. It isn’t full Python: there are no classes or exceptions.
Script block#
Write step(inputs, t): inputs holds the inputs in pin order (a bus as a number) and t is the time in seconds. Return a list with a value per output. Name the ports in the inspector, such as A, B, D[3:0]. step() runs whenever an input changes and at every time step.
Choose Signals › Volts and it becomes a behavioural source: inputs read in volts and each output is a voltage, driven through 1 Ω. Coppa takes shorter steps while the output moves quickly.
Script source#
A script source runs its script from the top, like EasyHDL in Proteus: out("Q", 5) sets an output, wait_us(10), wait_ms() and wait() pause it, and loops repeat patterns. Each change lands exactly when its wait ends.
from coppa import out, wait_us
while True:
out("Q", 5); wait_us(10)
out("Q", 0); wait_us(30)
time.sleep() works too. A loop that never waits is stopped after 2 million instructions, with a message, so a run can’t hang.
Applies to Coppa 0.1 Preview 14. Last updated 22 November 2026.