Reference Example circuits

Example circuits

Every example below lives under examples/ in the repository and runs as-is: hover <file>.hvr compiles it, runs it, and writes simulation_output.csv.

Full-bridge rectifier
Diode/rectifier.hvr
AC to DC conversion, diode commutation, capacitive filtering. Walked through line by line in Your first circuit.
NPN common-emitter amplifier
BJT/npn_amp.hvr
Small-signal amplification around an NPN bias network.
PNP amplifier
BJT/pnp_amp.hvr
The complementary counterpart.
Op-amp from discrete BJTs
BJT/opamp.hvr
A full operational amplifier built out of transistor-level primitives.
Op-amp circuit
OpAmp/op_amp.hvr
Op-amp behaviour at the circuit level.
H-bridge motor drive
DCMotor/h_bridge.hvr
Switching drive into an electromechanical load.
Common-source NMOS amplifier
MOSFET/nmos_amp.hvr
Square-law saturation biasing, linear amplification, and phase inversion.
Common-source PMOS amplifier
MOSFET/pmos_amp.hvr
P-channel polarity and the negative-VTO card convention.
CMOS inverter
MOSFET/cmos_inverter.hvr
Rail-to-rail complementary switching, the bias-dependent Meyer gate capacitances, and crowbar supply current.
Low-side switch, inductive load
MOSFET/nmos_switch.hvr
Triode conduction, the intrinsic body diode catching an inductive turn-off, and the third-quadrant channel swap that shorts it out.
Complementary MOSFET H-bridge
MOSFET/mosfet_h_bridge.hvr
P/N switching into a DC motor with dead-time sequencing, recirculating through the body diodes alone — no external flyback network in the netlist.
DC/AC inverter, 50 Hz from 20 kHz SPWM
MOSFET/h_bridge_inverter.hvr
Sine-triangle PWM, hard switching with dead-time, and LC reconstruction of the fundamental. The largest example in the set.
Single LED
Optoelectronics/leds/redled.hvr
Forward-bias behaviour and the light_out port.
Multiple LEDs
Optoelectronics/leds/multiple_leds.hvr
Several colors sharing a supply.
Optocoupler
Optoelectronics/phototransistor/optocoupler.hvr
LED driving a phototransistor across an isolation barrier.
Discrete PID controller
PIDController/pid_controller.hvr
Regulating an RC plant toward a setpoint — and the tour of native structs: a struct-typed state variable, a named-field literal, and a struct passed by value into a function.

Library-mode drivers

examples/hovercraft/ is different in kind — instead of a circuit, it holds two host programs (driver.py, driver.cpp) that drive a compiled simulation through the C ABI. See Hovercraft — library mode.

Packaging walkthroughs

Two more directories under examples/ are runnable end-to-end demonstrations of the package system rather than circuits: examples/package/ builds a publishable package (hvr-rc) and a consumer project that installs it with no server and no network, and examples/index/ builds a whole package index — including the entry that serves the standard library — and installs through it. See Packages & hpm.

Plotting the output

The repository root ships plot_results.py and plot_results.html, both of which read simulation_output.csv directly — the columns are whatever the source's .save directive named.