Terminal Commands & Interactive Controls
The FPGA soft-processor (brainfuck_uP) is pure hardware. It doesn't have a USB stack, an operating system, or a serial terminal interface. If you ran the FPGA standalone, you would need an external programmer to burn ROM chips, a function generator to pump clock signals, and a logic analyzer just to see your program's output.
To make the system user-friendly, the Brainfuino includes an STM32F072 ARM Cortex-M0 coprocessor. The STM32 acts as the FPGA's dedicated digital butler: synthesizing precision clock frequencies, managing USB Virtual COM communication, writing programs to Flash, and translating parallel FPGA pulses into serial terminal characters.
Runtime Hotkeys & Clock Control
While a Brainfuck program is executing in standard Run Mode, the coprocessor listens for real-time control hotkeys:
Dynamic Clock Speed Stepping
You can adjust the FPGA master clock dynamically while code is actively computing:
PageUp: Step clock speed up to the next higher frequency.PageDown: Step clock speed down to the next lower frequency.- Alternative Hotkey Modes: Configurable via the Configuration Menu to use
Up/DownArrow keys or+/-keys instead.
The coprocessor provides 25 precision hardware clock speeds spanning 6 orders of magnitude (from 10 Hz for human-speed register observation up to 12.0 MHz maximum parallel ROM speed):
| Idx | Frequency | Generator / Prescaler | Period | Application / Timing Margin |
|---|---|---|---|---|
1 |
10 Hz | TIM1 PWM (PSC: 47999, ARR: 99) | 100.0 ms | Human-speed instruction stepping, visually tracking register LEDs |
2 |
25 Hz | TIM1 PWM (PSC: 47999, ARR: 39) | 40.0 ms | Ultra-slow execution, oscilloscope & visual debugging |
3 |
50 Hz | TIM1 PWM (PSC: 47999, ARR: 19) | 20.0 ms | Very slow pacing |
4 |
100 Hz | TIM1 PWM (PSC: 47999, ARR: 9) | 10.0 ms | Slow step-by-step program inspection |
5 |
250 Hz | TIM1 PWM (PSC: 47999, ARR: 3) | 4.0 ms | Smooth slow-motion execution |
6 |
500 Hz | TIM1 PWM (PSC: 47999, ARR: 1) | 2.0 ms | Low frequency inspection |
7 |
1 kHz | TIM1 PWM (PSC: 479, ARR: 99) | 1.0 ms | 1 kHz clock baseline |
8 |
2 kHz | TIM1 PWM (PSC: 479, ARR: 49) | 500.0 µs | Audio-frequency experimentation |
9 |
5 kHz | TIM1 PWM (PSC: 479, ARR: 19) | 200.0 µs | Moderate low-speed execution |
10 |
10 kHz | TIM1 PWM (PSC: 479, ARR: 9) | 100.0 µs | Logic analyzer trace verification |
11 |
25 kHz | TIM1 PWM (PSC: 479, ARR: 3) | 40.0 µs | High PWM speed |
12 |
50 kHz | TIM1 PWM (PSC: 479, ARR: 1) | 20.0 µs | Maximum hardware PWM speed (+19.9 µs ROM margin) |
13 |
62.5 kHz | MCO HSI (8 MHz) / 128 | 16.0 µs | Ultra-slow MCO stepping |
14 |
125 kHz | MCO HSI (8 MHz) / 64 | 8.0 µs | Slow visual stepping, watching I/O operations |
15 |
250 kHz | MCO HSI (8 MHz) / 32 | 4.0 µs | Stepping and interactive algorithm inspection |
16 |
500 kHz | MCO HSI (8 MHz) / 16 | 2.0 µs | Default safe clock, balanced speed for general programs |
17 |
750 kHz | MCO HSI48 (48 MHz) / 64 | 1.33 µs | Intermediate speed |
18 |
1 MHz | MCO HSI (8 MHz) / 8 | 1.0 µs | 1 MHz baseline |
19 |
1.5 MHz | MCO HSI48 (48 MHz) / 32 | 666.7 ns | Intermediate speed |
20 |
2 MHz | MCO HSI (8 MHz) / 4 | 500.0 ns | Smooth intermediate speed |
21 |
3 MHz | MCO HSI48 (48 MHz) / 16 | 333.3 ns | Moderate speed |
22 |
4 MHz | MCO HSI (8 MHz) / 2 | 250.0 ns | Fast execution |
23 |
6 MHz | MCO HSI48 (48 MHz) / 8 | 166.7 ns | High speed |
24 |
8 MHz | MCO HSI (8 MHz) / 1 | 125.0 ns | High speed execution |
25 |
12 MHz | MCO HSI48 (48 MHz) / 4 | 83.3 ns | Maximum safe speed (+28 ns margin above 55 ns ROM limit) |
System Commands (Prefix !)
You can send commands directly over the serial connection (via the Web Terminal command bar or any serial console) at any time:
Core Hardware Controls
| Command | Action | Description |
|---|---|---|
!RESET or !RST |
Soft Reset FPGA | Pulses the FPGA soft-processor reset line (BF_RST) and restarts execution from address 0. |
!PRGM or !PROG |
Dedicated Program Mode | Holds FPGA soft-processor in reset and arms companion MCU for incoming Brainfuck stream (up to 256 kB). |
!MENU or !CONFIG |
Configuration Menu | Enters the interactive multi-page VT100 configuration menu. |
!CLK+ / !CLOCK+ |
Clock Step Up | Steps the FPGA clock up one frequency tier silently. |
!CLK- / !CLOCK- |
Clock Step Down | Steps the FPGA clock down one frequency tier silently. |
!CLK / !CLOCK |
Clock Speed Query | Prints the active clock frequency (e.g. [Clock: 12.0 MHz]). |
!DUMP |
Dump Program ROM | Streams the raw Brainfuck program currently stored in parallel Flash ROM over USB serial in non-blocking 64-byte chunks. |
!DFU! |
Software DFU Reboot | Reboots the STM32 into its built-in USB DFU Bootloader mode for firmware updates without touching hardware jumpers. |
Scriptable Program Library Commands
The onboard Program Library can also be queried and controlled directly via commands:
| Command | Action | Description |
|---|---|---|
!LIB* or !LIB:LIST |
Query Library | Outputs the list of all installed programs, slots, and Flash memory usage. |
!LIB:RUN:<slot> |
Run Program | Loads the program from the specified slot (e.g. !LIB:RUN:1) into parallel Flash and auto-executes. |
!LIB:DUMP:<slot> |
Dump Program | Streams the raw Brainfuck code of the specified library slot over serial. |
!LIB:ADD:<name> |
Add Program | Enters library upload mode with 10-second FPGA execution verification before committing to Flash. |
!LIB:ADD_NOVERIFY:<name> |
Direct Add | Uploads code directly to the library without verification countdown. |
!LIB:DEL:<slot> |
Delete Program | Deletes the program at the specified slot using zero-erase tombstone marking. |
!COMMIT |
Early Commit | Commits an uploaded library program immediately during verification. |
!CANCEL |
Abort Add | Cancels library program upload and restores normal run state. |
Manual Stepping Mode (Single-Stepping & Burst Stepping)
When Manual Stepping Mode is enabled via the Configuration Menu, the FPGA master clock remains frozen until triggered by the configured keyboard shortcut:
- Configurable Trigger Key: Spacebar, Tab, or Enter.
- Configurable Step Multiplier: 1, 10, 100, 1,000, 10,000, or 100,000 clock ticks per keypress.
- Burst Accumulation: Keystroke bursts accumulate in an internal queue and drain cleanly without dropping ticks, allowing frame-by-frame observation of Brainfuck execution.
When the FPGA is "Too Fast": The Serial Bottleneck
High Clock Speeds & Missed Characters
The Lattice MachXO2 FPGA soft-processor executes instructions with extreme speed in silicon. However, serial transmission over USB is fundamentally serialized.
When executing write-intensive programs—programs that spam the . output command in tight loops (such as Mandelbrot fractals, large ASCII art dumps, or matrix calculations)—the FPGA can produce parallel bytes on its output bus faster than the STM32 can packetize and transmit them over USB CDC.
- Zero Dropped Characters: The firmware includes Smart Hardware Clock-Pausing (read architecture details). The STM32 automatically freezes the FPGA master clock in 1 CPU instruction upon output strobe assertion, samples data with zero race conditions, and applies hardware backpressure if the USB buffer nears capacity.
- Operating Speeds: Supported across all 25 clock frequencies from 10 Hz up to 12 MHz with 100% character fidelity.
Interactive Program Input (, Command)
Brainfuck can take live input from your keyboard using the , command:
When your Brainfuck program reaches a , instruction:
- The FPGA pauses execution and asserts a read request (
portRD). - The STM32 places the ASCII key you type into the FPGA's 8-bit input port (
inPort[7:0]) and asserts theBF_INCMGflag. - The FPGA accepts the byte and saves it directly into the memory tape cell pointed to by
p. - Automatic Newline Translation: The STM32 translates Windows
\r\npairs into standard\n(0x0A), ensuring consistent behavior across Windows, Linux, and macOS.
Hardware Button Hold Thresholds
The physical button on the Brainfuino uses a 35 ms hardware debounce filter. The coprocessor measures the steady hold duration to provide intuitive 4-tier control:
| Action | Duration | Red LED Feedback | Result |
|---|---|---|---|
| Short Tap (Run Mode) | < 1 second | 70 ms Blip | Resets the running FPGA soft-processor (BF_RST pulse) and restarts execution. |
| Short Tap (Config Mode) | < 1 second | Turns OFF | Exits configuration menu, saves settings, and resumes execution. |
| Short Tap (Program Mode) | < 1 second | Turns OFF | Exits Program Mode and executes the program currently in ROM. |
| Program Mode Hold | 1 – 3 seconds | Solid ON | Enters Dedicated Program Mode (ready for Brainfuck code paste). |
| Config Menu Hold | 3 – 8 seconds | Smooth Breathing / Pulse | Enters Configuration Menu (STATE_CONFIG) for tuning clock, hotkeys, and features. |
| Factory Demo Restore | ≥ 8 seconds | Rapid Strobe (50 ms) | Erases parallel ROM, restores official Brainfuino ASCII logo demo, and auto-launches it! |