A right panel in tabs, Pins list, bulk editing, transistor breakdown, Settings dialog
- Right panel tabs: Selection, Circuit, Pins, Test. Display and sound
preferences move to a Settings dialog (gear in the top bar).
- Pins tab: every input and output in pin order with live values; rename in
place (Enter goes to the next), number a whole side from a pattern, flag
duplicate names, centre the canvas on a part.
- Several selected parts: narrow by type, swap all, rename all from a
pattern, set switches to 0/1 or flip, shared colour/frequency/size, align
and spread.
- Transistors on every part (NAND 4, switches and lamps 0), NAND 4T in the
palette, and a per-part breakdown of the circuit. Test: the count equals
4 x the gates the simulator builds, for every example and wide gate.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 07:29:55 +00:00
< script setup lang = "ts" >
import { TRANSISTORS _PER _NAND } from '~/lib/logic/analyze'
import { transistorBreakdown } from '~/lib/logic/bulk'
import { chipPins } from '~/lib/logic/geometry'
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
import { unusedComponents } from '~/lib/logic/check'
A right panel in tabs, Pins list, bulk editing, transistor breakdown, Settings dialog
- Right panel tabs: Selection, Circuit, Pins, Test. Display and sound
preferences move to a Settings dialog (gear in the top bar).
- Pins tab: every input and output in pin order with live values; rename in
place (Enter goes to the next), number a whole side from a pattern, flag
duplicate names, centre the canvas on a part.
- Several selected parts: narrow by type, swap all, rename all from a
pattern, set switches to 0/1 or flip, shared colour/frequency/size, align
and spread.
- Transistors on every part (NAND 4, switches and lamps 0), NAND 4T in the
palette, and a per-part breakdown of the circuit. Test: the count equals
4 x the gates the simulator builds, for every example and wide gate.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 07:29:55 +00:00
import { usages } from '~/lib/logic/ops'
import type { SymbolKind } from '~/lib/logic/types'
const ed = useEditor ( )
const def = ed . def
const SYMBOLS : { value : SymbolKind ; label : string } [ ] = [
{ value : 'box' , label : 'Box with name' } ,
{ value : 'and' , label : 'AND gate' } ,
{ value : 'or' , label : 'OR gate' } ,
{ value : 'xor' , label : 'XOR gate' } ,
{ value : 'not' , label : 'NOT gate' } ,
{ value : 'buf' , label : 'Buffer' } ,
{ value : 'nand' , label : 'NAND gate' } ,
{ value : 'nor' , label : 'NOR gate' } ,
{ value : 'xnor' , label : 'XNOR gate' } ,
]
const nameInput = ref < HTMLInputElement > ( )
watch (
( ) => ed . labelFocus . value ,
( ) =>
nextTick ( ( ) => {
if ( ed . selection . value . length ) return
nameInput . value ? . focus ( )
nameInput . value ? . select ( )
} ) ,
)
const pins = computed ( ( ) => chipPins ( def . value ) )
const users = computed ( ( ) => usages ( ed . project . value , def . value . id ) )
const groupNames = computed ( ( ) => [ ... new Set ( ed . project . value . components . map ( d => d . group ) . filter ( Boolean ) ) ] )
const hasFace = computed ( ( ) => def . value . nodes . some ( n => n . kind === 'lamp' || n . kind === 'hex' || n . kind === 'pixel' ) )
const total = computed ( ( ) => ed . transistors ( def . value . id ) )
const breakdown = computed ( ( ) => transistorBreakdown ( def . value , ed . nands . value , ed . getDef . value ) )
const showBreakdown = ref ( true )
function toggleFace ( e : Event ) {
def . value . face = ( e . target as HTMLInputElement ) . checked
ed . commit ( false )
}
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
// ── Problems ────────────────────────────────────────────────────────
const LEVEL _ICON = { error : 'lucide:circle-x' , warn : 'lucide:triangle-alert' , info : 'lucide:info' } as const
const showInfo = ref ( false )
const shownIssues = computed ( ( ) => ed . issues . value . filter ( i => showInfo . value || i . level !== 'info' ) )
const infoCount = computed ( ( ) => ed . issues . value . filter ( i => i . level === 'info' ) . length )
const unused = computed ( ( ) => unusedComponents ( ed . project . value ) . filter ( d => d . id !== def . value . id ) )
const showUnused = ref ( false )
const confirmRemove = ref < string | null > ( null )
A right panel in tabs, Pins list, bulk editing, transistor breakdown, Settings dialog
- Right panel tabs: Selection, Circuit, Pins, Test. Display and sound
preferences move to a Settings dialog (gear in the top bar).
- Pins tab: every input and output in pin order with live values; rename in
place (Enter goes to the next), number a whole side from a pattern, flag
duplicate names, centre the canvas on a part.
- Several selected parts: narrow by type, swap all, rename all from a
pattern, set switches to 0/1 or flip, shared colour/frequency/size, align
and spread.
- Transistors on every part (NAND 4, switches and lamps 0), NAND 4T in the
palette, and a per-part breakdown of the circuit. Test: the count equals
4 x the gates the simulator builds, for every example and wide gate.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 07:29:55 +00:00
const confirmDelete = ref ( false )
watch ( ( ) => def . value . id , ( ) => ( confirmDelete . value = false ) )
< / script >
< template >
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
< section class = "problems" >
< div class = "problems-head" >
< h3 > Check < / h3 >
< span v-if ="!shownIssues.length" class="ok" > < Icon name = "lucide:circle-check" class = "size-4" / > { { infoCount ? 'No problems' : 'All good' } } < / span >
< label v-if ="infoCount" class="check ml-auto" > < input v -model = " showInfo " type = "checkbox" / > Notes ( { { infoCount } } ) < / label >
< / div >
< ul v-if ="shownIssues.length" class="issue-list" >
< li v-for ="(i, k) in shownIssues.slice(0, 40)" :key ="k" >
< button class = "issue" :class ="i.level" :disabled ="!i.nodes.length" @click ="ed.showIssue(i.nodes)" >
< Icon :name ="LEVEL_ICON[i.level]" class = "issue-icon size-4 shrink-0" / >
< span > { { i . text } } < / span >
< / button >
< / li >
< / ul >
< p v-if ="shownIssues.length > 40" class="hint" > and {{ shownIssues.length - 40 }} more < / p >
< template v-if ="unused.length" >
< button class = "section-toggle mt-2" @ click = "showUnused = !showUnused" >
< Icon : name = "showUnused ? 'lucide:chevron-down' : 'lucide:chevron-right'" class = "size-4" / >
Not used in another circuit ( { { unused . length } } )
< / button >
< template v-if ="showUnused" >
< p class = "hint" > Circuits you work in directly show up here too . Delete only what you don ' t need . < / p >
< ul class = "issue-list" >
< li v-for ="d in unused" :key="d.id" class="unused-row" >
< a href = "#" class = "grow truncate" @click.prevent ="ed.open(d.id)" > { { d . name } } < / a >
< template v-if ="confirmRemove === d.id" >
< button class = "btn-sm danger" @ click = "ed.removeComponent(d.id), (confirmRemove = null)" > Delete < / button >
< button class = "btn-sm" @ click = "confirmRemove = null" > Keep < / button >
< / template >
< button v -else class = "icon-btn" title = "Delete this component" @ click = "confirmRemove = d.id" > < Icon name = "lucide:trash-2" class = "size-3.5" / > < / button >
< / li >
< / ul >
< / template >
< / template >
< / section >
A right panel in tabs, Pins list, bulk editing, transistor breakdown, Settings dialog
- Right panel tabs: Selection, Circuit, Pins, Test. Display and sound
preferences move to a Settings dialog (gear in the top bar).
- Pins tab: every input and output in pin order with live values; rename in
place (Enter goes to the next), number a whole side from a pattern, flag
duplicate names, centre the canvas on a part.
- Several selected parts: narrow by type, swap all, rename all from a
pattern, set switches to 0/1 or flip, shared colour/frequency/size, align
and spread.
- Transistors on every part (NAND 4, switches and lamps 0), NAND 4T in the
palette, and a per-part breakdown of the circuit. Test: the count equals
4 x the gates the simulator builds, for every example and wide gate.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 07:29:55 +00:00
< section >
< h3 > This circuit < / h3 >
< label class = "field" >
< span > Name < / span >
< input ref = "nameInput" v -model = " def.name " @change ="ed.commit(false)" @ keydown.enter = " ( $ event.target as HTMLInputElement ) .blur ( ) " / >
< / label >
< label class = "field" >
< span > Description < / span >
< textarea v -model = " def.description " rows = "2" placeholder = "What does it do?" @change ="ed.commit(false)" / >
< / label >
< div class = "grid grid-cols-2 gap-2" >
< label class = "field" >
< span > Drawn as < / span >
< select v-model ="def.symbol" @change="ed.commit(false)" >
< option v-for ="s in SYMBOLS" :key="s.value" :value="s.value" > {{ s.label }} < / option >
< / select >
< / label >
< label class = "field" >
< span > Group < / span >
< input v -model = " def.group " list = "groups" placeholder = "My components" @change ="ed.commit(false)" / >
< datalist id = "groups" >
< option v -for = " g in groupNames " :key ="g" :value ="g" / >
< / datalist >
< / label >
< / div >
< label v-if ="hasFace" class="check" >
< input type = "checkbox" : checked = "def.face !== false" @change ="toggleFace" / >
Show its lamps and displays on the component box
< / label >
< dl class = "stats" >
< dt > Pins < / dt >
< dd >
< a href = "#" title = "List and rename them" @ click.prevent = " ed.rightTab.value = ' pins ' " > { { pins . inputs . length } } in , { { pins . outputs . length } } out < / a >
< / dd >
< dt > NAND gates < / dt >
< dd > { { ed . circuitStats . value . nands . toLocaleString ( ) } } < / dd >
< dt > Transistors < / dt >
< dd > { { total . toLocaleString ( ) } } < / dd >
< dt > { { ed . circuitStats . value . sequential ? 'Memory' : 'Delay' } } < / dt >
< dd > { { ed . circuitStats . value . sequential ? 'yes (feedback loops)' : ` ${ ed . circuitStats . value . delay } gates ` } } < / dd >
< / dl >
< p v-for ="err in ed.errors.value" :key="err" class="result fail" >
< Icon name = "lucide:triangle-alert" class = "size-4 shrink-0" / > { { err } }
< / p >
< p v-if ="users.length" class="hint" >
Used in
< template v-for ="(u, i) in users" :key="u.id" >
< a href = "#" @click.prevent ="ed.open(u.id)" > { { u . name } } < / a > < template v-if ="i < users.length - 1" > , < / template >
< / template >
< / p >
< / section >
BF input panels are component inputs, cable ends plug in more reliably; A merge panels, hex pass-through, design a component's box
- Inside a component, the switch and button rows of its input panels are now input pins (in order with the other inputs, named after the rows); "Rows are component inputs" can be turned off per panel to keep the old fixed switches
- Select input panels, Merge: one panel with all rows, spacing and wires kept; circuits that place this one keep their wires
- Cable ends plug in more often: bundling orders the wires by the part a side runs to, an end with only some wires on a part still plugs, an end placed by hand next to the pins plugs, and dragging an end near its part shows green rings and plugs it on drop
- Hex displays pass their four bits on (outputs on the right), so they can sit in the middle of a bus
- Design the box: move lamps, displays, the screen and the name on a component's box, draw lines, boxes, circles and text in six colours, size it, leave things off; every placed copy shows it
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:49:29 +00:00
< section >
< h3 > Its box < / h3 >
< p class = "hint" > How it looks when placed : { { def . design ? 'drawn by hand' : 'laid out automatically' } } . < / p >
< button class = "btn w-full" title = "Move lamps, displays and the name, draw lines, boxes and text, size the box" @click ="ed.designFace(def.id)" >
< Icon name = "lucide:pen-tool" class = "size-4" / > Design the box
< / button >
< / section >
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
< section >
< h3 > Sheet < / h3 >
< p class = "hint" > The circuit as a wiring sheet with a title block : print it , save it as PDF , or keep it as an SVG . < / p >
< div class = "grid grid-cols-2 gap-2" >
< button class = "btn" :disabled ="!def.nodes.length" title = "On white paper (Ctrl+P); choose Save as PDF in the print dialog" @click ="ed.exportSheet('print')" >
< Icon name = "lucide:printer" class = "size-4" / > Print / PDF
< / button >
< button class = "btn" :disabled ="!def.nodes.length" title = "As on screen, to open in a browser or drawing program" @click ="ed.exportSheet('svg')" >
< Icon name = "lucide:file-image" class = "size-4" / > SVG file
< / button >
< / div >
< / section >
A right panel in tabs, Pins list, bulk editing, transistor breakdown, Settings dialog
- Right panel tabs: Selection, Circuit, Pins, Test. Display and sound
preferences move to a Settings dialog (gear in the top bar).
- Pins tab: every input and output in pin order with live values; rename in
place (Enter goes to the next), number a whole side from a pattern, flag
duplicate names, centre the canvas on a part.
- Several selected parts: narrow by type, swap all, rename all from a
pattern, set switches to 0/1 or flip, shared colour/frequency/size, align
and spread.
- Transistors on every part (NAND 4, switches and lamps 0), NAND 4T in the
palette, and a per-part breakdown of the circuit. Test: the count equals
4 x the gates the simulator builds, for every example and wide gate.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 07:29:55 +00:00
< section >
< button class = "section-toggle" @ click = "showBreakdown = !showBreakdown" >
< Icon : name = "showBreakdown ? 'lucide:chevron-down' : 'lucide:chevron-right'" class = "size-4" / >
Where the transistors are
< / button >
< template v-if ="showBreakdown" >
< p v-if ="!breakdown.length" class="hint mt-2" > No gates here yet. Switches , lamps , displays and cables need no transistors. < / p >
< table v -else class = "cost" >
< tbody >
< tr v-for ="l in breakdown" :key="l.key" title="Select these parts" @click="ed.selectOnly(l.ids)" >
< td class = "what" > { { l . count } } × { { l . name } } < / td >
< td class = "num" > { { l . each . toLocaleString ( ) } } each < / td >
< td class = "num strong" > { { l . total . toLocaleString ( ) } } < / td >
< / tr >
< / tbody >
< tfoot >
< tr >
< td > Total < / td >
< td class = "num" > { { ( total / TRANSISTORS _PER _NAND ) . toLocaleString ( ) } } NAND < / td >
< td class = "num strong" > { { total . toLocaleString ( ) } } < / td >
< / tr >
< / tfoot >
< / table >
< p class = "hint mt-2" >
Everything here is built from NAND gates , and a CMOS NAND gate has 4 transistors : 2 in parallel to the supply , 2 in series to
ground . So the count is 4 per NAND inside , at every depth : a NOT costs 4 , an AND 8 , a full adder 60. ( A NOT made directly in
CMOS would need only 2 ; here it is built from a NAND . )
< / p >
< / template >
< / section >
< section >
< div class = "grid gap-2" >
< button class = "btn w-full" title = "Remove hand-placed bends in this circuit and lay out every wire tidily (undo brings them back)" @click ="ed.tidyAll()" >
< Icon name = "lucide:wand-sparkles" class = "size-4" / > Tidy all wires
< / button >
< button
v - if = "!ed.task.value"
class = "btn w-full"
title = "Turn this circuit into a puzzle link: others build the same behaviour, your circuit stays private"
@ click = "ed.dialog.value = 'publish'"
>
< Icon name = "lucide:puzzle" class = "size-4" / > Publish as puzzle
< / button >
< / div >
< / section >
< section class = "actions" >
< button class = "btn btn-ghost" @click ="ed.copyComponent(def.id)" > < Icon name = "lucide:copy" class = "size-4" / > Duplicate < / button >
< button v-if ="!confirmDelete" class="btn btn-ghost" @click="confirmDelete = true" > < Icon name = "lucide:trash-2" class = "size-4" / > Delete < / button >
< button v -else class = "btn btn-danger" @ click = "ed.removeComponent(def.id); confirmDelete = false" > Really delete ? < / button >
< / section >
< / template >