Overview
Write digital circuits in TypeScript, simulate them anywhere, and run them on an FPGA
Simten is a digital logic simulator where circuits are TypeScript. Ports are typed, so a miswired circuit is a type error. Circuits run in the browser, in tests, and as Verilog on an FPGA.
The quickest way to try it is the editor, or the game, which starts at one NAND gate and ends with a CPU.
1. Write a circuit
npm install @simten/coreimport { bit, circuit } from '@simten/core'
import { And, Xor } from '@simten/core/std'
export const HalfAdder = circuit('HalfAdder', {
inputs: { a: bit, b: bit },
outputs: { sum: bit, carry: bit },
nodes: { xor: Xor, and: And },
connect: ({ inputs, outputs, nodes: { xor, and } }) => [
inputs.a.to(xor.a, and.a),
inputs.b.to(xor.b, and.b),
xor.out.to(outputs.sum),
and.out.to(outputs.carry),
],
})inputs and outputs are the pins, nodes are the parts inside, and connect is the
wiring. Here it is running. Click the switches:
2. Run it
import { simulate } from '@simten/core'
const sim = simulate(HalfAdder)
sim.set({ a: 1, b: 1 })
sim.read() // { sum: 0, carry: 1 }This works in Node, in the browser, and in any test runner. See the API reference.
3. Show it in React
npm install @simten/reactimport '@simten/react/styles.css'
import { CircuitCanvas, useSimulation } from '@simten/react'
function Demo() {
const sim = useSimulation(HalfAdder)
return <CircuitCanvas simulation={sim} height={300} />
}The circuit's code runs in a sandbox on another domain, never on your page. See Building custom UIs to make your own controls.
4. Or put it on any page
Open the circuit in the editor and use Share → Embed to get an iframe. To drive it from your own code without React, see Using Simten without React.
5. Build circuits with an AI assistant
claude mcp add --scope user simten npx @simten/mcpYour assistant writes circuits as files in your repo, tests them, and draws them in a browser tab. Any MCP client works. See MCP integration.
Export to Verilog
import { exportVerilog } from '@simten/core/verilog'
const { verilog } = exportVerilog(HalfAdder, { target: 'synthesis' })The output is checked against Icarus Verilog. Hardware & FPGA takes it all the way to a ULX3S board, with Snake over HDMI as the example.
Built with Simten
- Gates, adders and ALUs
- Counters, shift registers and state machines
- Snake and Pong, from logic gates with no CPU
- A pipelined RISC-V CPU that runs compiled C
- A TPU systolic array, a CORDIC unit and an Ethernet switch
Packages
| Package | Use it to |
|---|---|
@simten/core | Write and simulate circuits, export Verilog |
@simten/react | Show circuits in a React app |
@simten/sandbox | Run circuits from any web page, without React |
@simten/mcp | Let an AI assistant build circuits |