
At its core, this is a hardware-level educational visualization written in Verilog, specifically formatted for the Tiny Tapeout project.
It is not a software program running on an operating system. Instead, it is pure, combinational digital logic that manipulates raw electrons at 25 million times a second (25.175 MHz) to generate native VGA video signals and PWM audio. It belongs to a niche category of engineering called "racing the beam" or "demoscene" programming, where complex visuals are generated entirely through math and logic gates because there is no RAM available for a traditional framebuffer.
The module acts as a self-contained interactive textbook for a fundamental digital logic gate. When synthesized onto a silicon chip (or FPGA) and plugged into a monitor, it does the following in real-time:
Looking at the architecture and the constraints I was working under, the "why" becomes very clear:
1. To make invisible VLSI concepts visible. When working deep in CMOS design, simulation waveforms and data-flow graphs can get incredibly abstract. I built this to bridge the gap between theoretical textbook diagrams and actual silicon behavior. I wanted something that makes the fundamental building block of modern computing—the inverter—tangible and intuitive to look at.
2. To create compelling educational content.
The inclusion of the @electronics-ed watermark and the striking, color-coded visuals point directly to this being designed for an audience. It is notoriously difficult to make digital signal processing and ASIC architecture look "cool" on camera. By forcing the hardware to draw its own animated diagrams, I have created a perfect, eye-catching centerpiece for a YouTube Short or educational reel. It’s a way to teach complex engineering concepts in a highly scannable, visual format.
3. The technical flex. I have built an entire educational platform into what is essentially a sliver of a single silicon tile (~1000 gates). Doing this without memory buffers, using only coordinate math, bit-shifting, and shared clock dividers for audio and video, is a massive demonstration of technical virtuosity. I made it to prove that I could squeeze maximum educational utility out of minimum hardware means.
Here is a detailed architectural and mathematical breakdown of how this CMOS Inverter Visualizer works.
At the heart of the design is the VGA sync generator for a standard 640x480 @ 60Hz display.
hpos): Sweeps from 0 to 799. Pixels 0-639 are visible onscreen. The rest (640-799) form the horizontal blanking interval (front porch, sync pulse, back porch).vpos): Sweeps from 0 to 524 lines. Lines 0-479 are visible.~(hpos >= 656 && hpos < 752) generates the precise active-low negative sync pulse required by VGA monitors to lock onto the signal.To animate anything, you need a sense of time.
always @(posedge clk) begin
if (~rst_n) frame <= 0;
else if (hpos == 0 && vpos == 0) frame <= frame + 1;
end
By incrementing the frame register only when hpos and vpos are both 0 (the exact top-left corner of the screen), this creates a precise 60Hz counter. This 12-bit frame variable acts as the global clock for all animations, waveform scrolling, and logic state changes.
This is where the demoscene magic happens. To make a wave look like it is scrolling across the screen without storing previous states in memory, the code relies on a spatial-temporal phase shift.
time_offset = {frame[7:0], 2'b00} shifts the frame counter left by 2, effectively multiplying it by 4. The wave moves exactly 4 pixels per frame (240 pixels per second).wave_pos = (x - wave_start_x + time_offset)
x) into a moving mathematical phase (wave_pos). As time_offset increases, the whole phase plane shifts to the left.frame[10:8] bits act as a slow state machine that changes the frequency of the input signal over time.
wave_pos (e.g., wave_pos[4] vs wave_pos[7]), the period of the square wave changes from tight (fast toggling) to wide (slow toggling).Because there is no RAM, images are drawn using mathematical bounds checking—essentially hardcoded geometric equations evaluated for every single pixel coordinate (px, py).
pmos_dist = (py < 220) ? (py - 80) : (140 + px - 200);
if ((pmos_dist - anim_frame) & 16) draw_cmos = 3'd4; // Yellow dash
pmos_dist calculates the 1D path length along the 2D wire geometry.anim_frame to make the sequence move. The bitwise & 16 isolates the 5th bit of the resulting distance. Because binary counts up, the 5th bit alternates 0 for 16 pixels, then 1 for 16 pixels. This single operation effortlessly creates the marching dashed lines simulating electron flow.Generating audio usually requires a dedicated clock divider, but this module saves logic cells by piggybacking on the VGA timing.
else if (x == 0) begin // Evaluated once per scanline
if (tone_cnt > tone_limit) begin ...
x == 0 exactly once per horizontal line. With 525 total lines at 60Hz, this triggers at exactly 31.5 kHz (the VGA line rate).tone_cnt uses this 31.5 kHz pulse as its clock.tone_limit = 180), the audio toggles at 31,500 / (180 * 2) ≈ 87.5 Hz. When Low (tone_limit = 300), it toggles at ≈ 52.5 Hz. This creates a distinct dual-tone square wave synced to the logic state.The final block is a massive priority encoder (if / else if cascade). As the beam hits a pixel coordinate, all the drawing functions return their local evaluation simultaneously. The compositor decides which layer "wins" (e.g., text on top, waves in the middle, grid in the back) and assigns the final 2-bit RGB color to the physical output pins.
The Reactive Plasma CMOS Inverter is an educational hardware visualizer that generates a 640x480 @ 60Hz VGA signal entirely in logic gates. It visually illustrates the fundamental physical operation of a classic CMOS NOT gate.
At its core, the logic is driven by an internal frame counter that continuously toggles an "input" signal at varying speeds. The screen displays three main educational components:
Additionally, the chip generates a simple PWM audio tone that dynamically changes pitch based on the high/low state of the input signal.
The demonstration is completely self-driven, meaning you do not need to manually flip switches to see the circuit animate.
clk input (the standard frequency required for 640x480 VGA timing).rst_n) low, then high, to initialize the internal coordinate and frame counters.ena = 1).To fully experience the demo, the following external hardware is recommended:
uo[7:0]) using the standard Tiny Tapeout VGA pin mapping.uio[0]) to hear the dynamic PWM synthesizer.| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | R1 | Audio PWM | |
| 1 | G1 | ||
| 2 | B1 | ||
| 3 | VSync | ||
| 4 | R0 | ||
| 5 | G0 | ||
| 6 | B0 | ||
| 7 | HSync |