{"id":30376505,"url":"https://github.com/georgtree/ngspicetclbridge","last_synced_at":"2026-02-12T14:32:48.448Z","repository":{"id":309220898,"uuid":"1035526331","full_name":"georgtree/NgspiceTclBridge","owner":"georgtree","description":"Tcl extension for usage with dynamically loaded Ngspice simulator","archived":false,"fork":false,"pushed_at":"2025-11-17T23:38:49.000Z","size":718,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-18T01:21:14.032Z","etag":null,"topics":["ngspice","simulation","spice","tcl","tcl-extension"],"latest_commit_sha":null,"homepage":"https://georgtree.github.io/NgspiceTclBridge/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/georgtree.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-10T15:33:19.000Z","updated_at":"2025-11-17T23:38:53.000Z","dependencies_parsed_at":"2025-10-19T21:18:32.416Z","dependency_job_id":"240c3dd4-4864-42d6-8bd5-2d844539f80e","html_url":"https://github.com/georgtree/NgspiceTclBridge","commit_stats":null,"previous_names":["georgtree/ngspicetclbridge"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/georgtree/NgspiceTclBridge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgtree%2FNgspiceTclBridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgtree%2FNgspiceTclBridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgtree%2FNgspiceTclBridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgtree%2FNgspiceTclBridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/georgtree","download_url":"https://codeload.github.com/georgtree/NgspiceTclBridge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgtree%2FNgspiceTclBridge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29368689,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T08:51:36.827Z","status":"ssl_error","status_checked_at":"2026-02-12T08:51:26.849Z","response_time":55,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ngspice","simulation","spice","tcl","tcl-extension"],"created_at":"2025-08-20T14:15:03.620Z","updated_at":"2026-02-12T14:32:48.443Z","avatar_url":"https://github.com/georgtree.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NgspiceTclBridge - drive ngspice (shared library) from Tcl\n\n`ngspicetclbridge` is a Tcl C extension that embeds Ngspice (built as a shared library) and exposes a small, thread-safe\ncommand API for loading circuits, running analyses in the ngspice background thread, and receiving data/messages/events\nback into Tcl.\n\nIt targets Tcl 9.0 and works on Linux/macOS/Windows. Dynamic loading is abstracted via a tiny portability layer.\n\n## What it gives you (at a glance)\n\n- Create one or more ngspice instances inside Tcl.\n- Issue ngspice commands (e.g. bg_run, circbyline ...).\n- Wait for events (send_stat, send_data, etc.) with optional timeouts.\n- Collect messages from ngspice stdout/stderr.\n- Fetch vector metadata and values (both asynchronously collected and on-demand).\n\nAll Ngspice → Tcl crossings are deferred onto Tcl’s event loop, so you stay in the safe thread.\n\n## Building \u0026 requirements\n\nRequirements:\n\n- ngspice built as a shared library (e.g. libngspice.so, libngspice.dylib, or libngspice.dll) with the sharedspice\n  interface (sharedspice.h).\n- Tcl headers/libs (9.0).\n\nTo install, run following commands:\n- `git clone https://github.com/georgtree/NgspiceTclBridge.git`\n- `./configure`\n- `sudo make install`\n\nDuring installation manpages are also installed.\n\nFor test package in place run `make test`.\n\nFor package uninstall run `sudo make uninstall`.\n\n## Documentation\n\nDocumentation could be found [here](https://georgtree.github.io//).\n\n## Notes\n\nThe commands that are subcommand to the simulator command, like `$s1 command bg_run` are considered low level\nand communicate/interact directly with the simulator. On the other side, commands that accept simulator as a\nparameter are considered as \"helper\" commands, built on top of low-level commands.\n\n## Warnings\n\nThis library should be considere semi-stable now. It works well for **single** loading of shared library per process,\nwithout unloading and loading again. It also works with multiple unloadings (destroying) and loadings of the same\nlibrary, but I've encountered a few possible memory corruption cases. I am trying my best to eliminate them, but I am\nnot in full control of Ngspice shared library behaviour.\n\nOne of the instances I've encountered is the running two circuit in sequence, with pattern load circuit-\u003erun-\u003eload\ncircuit-\u003erun, and then try destroying the instance. This could lead to segmentation violation, unless the command\n`remcirc` for unloading previous circuit is issued before loading new circuit. It is done automatically now if you\npreviously loaded the circuit with `circuit` command. But in case you want to load circuit with command `circbyline`,\nyou need to issue `remcirc` command yourself.\n\n## Quick start (synchronous operation)\n\nPackage loading and initialization:\n\n``` tcl\npackage require ngspicetclbridge\n\n# Path to your ngspice shared library\nset ngspiceLibPath /path/to/libngspice.so\n\n# Create a new instance bound to a Tcl command\nset sim [ngspicetclbridge::new $ngspiceLibPath]\n```\n\nTo feed a circuit one line at a time via ngspice’s circbyline:\n\n``` tcl\nset resDivCircuit {\n    Resistor divider\n    v1 in 0 1\n    r1 in out 1e3\n    r2 out 0 2e3\n    .dc v1 0 5 0.1\n    .save all\n    .end\n}\n```\n\nPass resistor divider circuit to Ngspice, and start the run (in background thread), and wait for completion:\n\n``` tcl\n$sim circuit [split $resDivCircuit \\n]\nrun $sim\n```\n\nGet vector data dictionary saved in internal buffer:\n\n``` tcl\n$sim vectors\n```\n\nDestroy instance of simulator (removes instance command, frees internal storages and simulator context)\n\n``` tcl\n$sim destroy\n```\n\nIf you want to continue work with current simulator instance, you need to clear internal messages storage\nwith next commands:\n\n``` tcl\n$s1 messages -clear\n```\n\nVector storage is resetted after run new simulation, so no need to explicitly frees vectors data.\n\n## Troubleshooting\n\n- `waitevent` **always times out**: make sure you actually started the background run (`$sim command bg_run`) and you\n  allow the Tcl event loop to process events (update) between waits when appropriate.\n\n- **Circuit is not loaded**: ensure your circuit issues `.end` directive.\n\n- **Complex data surprises**: if you expected real data but get `{re im}` pairs, your vector is complex per\n  ngspice. Handle both cases in your Tcl code if needed.\n\n- **Multiple runs**: clear old event data between runs if you want pristine event counters and messages buffer:\n  `$sim messages -clear` and  `$sim eventcounts -clear`. Data buffer and saved vectors resetted after run of\n  the new simulation to prevent data mixing.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgtree%2Fngspicetclbridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeorgtree%2Fngspicetclbridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgtree%2Fngspicetclbridge/lists"}