Wiremod logic gates: how Garry's Mod wiring maps to real logic
Wiremod is an open-source add-on for Garry's Mod (Apache-2.0, on GitHub and the Steam Workshop in Stable and Canary builds) that adds entities which talk to each other over wires, so you can build automatic and user-controlled contraptions: buttons, thrusters, screens, Expression 2 script chips and even a programmable CPU and GPU. Its gate entity has many modes. The logic gates are Not, And, Or, Exclusive Or, Not And, Not Or and Exclusive Not Or, and And and Or take up to eight inputs. Memory gates include a D-Latch, SR-Latch and RS-Latch, an edge-triggered Latch and Toggle, an Up/Down Counter and RAM, and there are bitwise, comparison, arithmetic and selection gates such as a 7 Segment Decoder. Wiremod's gates behave like real ones in most ways, with one big difference underneath.
How Wiremod's gates map to logic
A Wiremod wire carries a number, not a bit. Its source code defines the logic gates on that number: And outputs 1 if all inputs are greater than 0, Or if any is, and Not outputs 0 for an input greater than 0 and 1 otherwise, so 0 and negative values count as false. The D-Latch stores its Data input while Clk is greater than 0, so one latch holds a whole number, and the bitwise gates (And, Or, Xor, Not and shifts) work on the bits of that number. Because one wire is a number, a single Add or Greater Than gate does what takes a whole adder or comparator in hardware, which is what makes Wiremod quick to build with. (digiwleea is an independent project, not affiliated with Wiremod or Facepunch Studios.)
How real logic gates differ
In a chip each wire carries one bit, 0 or 1, and adding two numbers takes a chain of full adders, one per bit; a latch stores one bit, so a register is a row of them. There are no negative values on a wire: signed numbers are a pattern of bits read as two's complement. digiwleea lets you build those layers yourself in the browser, from CMOS transistors to gates, adders, latches, registers, RAM and an 8-bit CPU that runs a stored program, plus the assembly language behind it, with every part checked against its truth table and an AI tutor (Wleea) to help.
| Wiremod | digiwleea | |
|---|---|---|
| What a wire carries | A number; logic gates treat values above 0 as true | One bit: 0 or 1 |
| Logic gates | Not, And, Or, Xor, Nand, Nor, Xnor (And and Or up to 8 inputs) | Built from transistors, then reused as parts |
| Memory | D-Latch, SR-Latch, RS-Latch, Toggle, counters and RAM, each holding a number | Latches and flip-flops that hold one bit each |
| Arithmetic | One gate: Add, Subtract, Greater Than and more | Adders and comparators built from gates |
| Runs in | Garry's Mod (a paid game on Steam), as an add-on | Any modern browser, nothing to install |
Wiremod gates and the real circuits behind them
- Not, And, Or, Xor, Nand, Nor, Xnor. On single bits these are the real gates: NOT, AND, OR, XOR, NAND, NOR and XNOR.
- D-Latch, SR-Latch, Toggle. One bit each in hardware: the D latch, the SR latch and the T flip-flop; a latch for a whole number is a register.
- Up/Down Counter. An up/down counter of flip-flops.
- Add, Subtract, Greater Than. A ripple-carry adder, an adder-subtractor and a magnitude comparator.
- Bitwise gates and shifts. One gate per bit; try them in the bitwise calculator, and shifts in hardware are a barrel shifter.
- 7 Segment Decoder. The BCD to 7-segment decoder.
- RAM and the CPU entity. A register file, and a whole CPU running a program, step by step.
No sign-up is needed to start: open the lab and place your first transistor, or read the free theory course. The account (and the AI tutor) are optional.
More comparisons: Games about logic and computers
See for yourself: build a logic gate from transistors in the simulator, then follow the path from sand to an 8-bit CPU.
Open the digiwleea lab →Frequently asked
What logic gates does Wiremod have?
Its gate entity's logic modes are Not, And, Or, Exclusive Or, Not And, Not Or and Exclusive Not Or, and And and Or accept up to eight inputs. There are also memory gates (latches, a toggle, counters and RAM), bitwise, comparison, arithmetic and selection gates.
How does a Wiremod And gate treat numbers?
Its source code outputs 1 when every connected input is greater than 0, and 0 otherwise. Or outputs 1 when any input is greater than 0, and Not outputs 1 only when its input is 0 or negative.
How do you make memory with Wiremod?
Use a memory gate: the D-Latch stores its Data input while Clk is greater than 0, the SR-Latch and RS-Latch set and reset, and the Toggle flips on a rising edge. In hardware the same latches are gates fed back to each other, holding one bit each.
Is Wiremod like real digital logic?
In spirit. Its wires carry numbers instead of single bits, so one gate can add or compare whole values; in a chip that takes many 1-bit gates wired as adders and comparators. The ideas of gating, latches, counters and clocks carry straight over.