Export C++

Function name:

Exporting a circuit to C++

This is the export no other browser-based logic simulator offers. Instead of a hardware description, Boolflow can emit your schematic as ordinary C++ — every gate becomes a boolean expression, and the whole circuit becomes a function you can call.

That makes a drawn circuit executable outside the simulator. You can drop the function into a unit test to check a design against expected values, embed it in firmware where a lookup table would be too large, or use it as a fast reference model when validating an HDL implementation. Because the output is plain C++ with no dependencies beyond the standard library, it compiles anywhere: GCC, Clang, MSVC, or an embedded toolchain.

  • Function mode emits a single function taking one bool per input and returning a struct of outputs.
  • Program mode wraps it in a complete main() that prints results, so you can compile and run immediately.
  • The generated code has no allocation and no branching beyond the logic itself — it is trivially inlinable.
What the output looks like
// Generated by BoolFlow
#include <cstdint>

struct half_adder_out {
  bool out_0;
  bool out_1;
};

half_adder_out half_adder(bool in_0, bool in_1) {
  half_adder_out r;
  r.out_0 = in_0 ^ in_1;
  r.out_1 = in_0 && in_1;
  return r;
}

Combinational circuits map cleanly onto expressions. Elements that hold state need somewhere to keep it between calls, so they are handled separately — check the generated code before relying on it for a clocked design.

Read: Boolean algebra basics