{"id":22355448,"url":"https://github.com/enapiuz/logic-board","last_synced_at":"2025-03-26T13:12:30.955Z","repository":{"id":82482229,"uuid":"393662174","full_name":"Enapiuz/logic-board","owner":"Enapiuz","description":"Logic circuit simulator","archived":false,"fork":false,"pushed_at":"2021-08-22T23:01:27.000Z","size":157,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-01T02:52:00.860Z","etag":null,"topics":["circuit-simulator","digital-logic","hacktoberfest","hacktoberfest2021","javascript","library","logic-circuit-simulator","logic-gates","simulator","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Enapiuz.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}},"created_at":"2021-08-07T11:16:44.000Z","updated_at":"2021-09-23T14:08:15.000Z","dependencies_parsed_at":"2023-06-18T20:26:31.965Z","dependency_job_id":null,"html_url":"https://github.com/Enapiuz/logic-board","commit_stats":{"total_commits":32,"total_committers":1,"mean_commits":32.0,"dds":0.0,"last_synced_commit":"7af9fac927898fd0909572e84345b330f51b1372"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Enapiuz%2Flogic-board","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Enapiuz%2Flogic-board/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Enapiuz%2Flogic-board/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Enapiuz%2Flogic-board/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Enapiuz","download_url":"https://codeload.github.com/Enapiuz/logic-board/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245659050,"owners_count":20651525,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["circuit-simulator","digital-logic","hacktoberfest","hacktoberfest2021","javascript","library","logic-circuit-simulator","logic-gates","simulator","typescript"],"created_at":"2024-12-04T14:06:32.687Z","updated_at":"2025-03-26T13:12:30.930Z","avatar_url":"https://github.com/Enapiuz.png","language":"TypeScript","readme":"# Logic Board\n\nLogic circuit simulator\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n\n## Installation\n\n`npm install logic-board`\n\n## Usage\n\nSimple half-adder example\n\n```js\nimport {Element, AND, XOR, BUF} from \"logic-board\";\n\n/**\n * Input ports: 0 and 1.\n * Output ports: 0 as summ, 1 as carry.\n */\nexport class HalfAdder extends Element {\n    protected formBoard() {\n        this.addElement(\"input1\", new BUF());\n        this.addElement(\"input2\", new BUF());\n        this.addElement(\"and1\", new AND());\n        this.addElement(\"xor1\", new XOR());\n        this.addConnection(\"input1\", 0, \"and1\", 0);\n        this.addConnection(\"input1\", 0, \"xor1\", 0);\n        this.addConnection(\"input2\", 0, \"and1\", 1);\n        this.addConnection(\"input2\", 0, \"xor1\", 1);\n        this.addInput(0, \"input1\", 0); // input 0\n        this.addInput(1, \"input2\", 0); // input 1\n        this.addOutput(0, \"xor1\", 0); // sum\n        this.addOutput(1, \"and1\", 0); // carry\n    }\n}\n\nconst ha = new HalfAdder();\nconst result = ha.eval(new Map([[0, false], [1, true]]));\n\n// result = Map([[0, true], [1, false]])\n```\n\nFull adder example (using half-adder from previous example):\n\n```js\nimport {Element, BUF, OR} from \"logic-board\";\nimport {HalfAdder} from \"./half_adder\";\n\nexport class Adder extends Element {\n    protected formBoard(): void {\n        // all needed elements\n        this.addElement(\"A\", new BUF());\n        this.addElement(\"B\", new BUF());\n        this.addElement(\"carryIn\", new BUF());\n        this.addElement(\"ha0\", new HalfAdder());\n        this.addElement(\"ha1\", new HalfAdder());\n        this.addElement(\"or0\", new OR());\n\n        // connect external inputs\n        this.addInput(0, \"A\", 0);\n        this.addInput(1, \"B\", 0);\n        this.addInput(2, \"carryIn\", 0);\n\n        // connect internal inputs\n        this.addConnection(\"A\", 0, \"ha0\", 0);\n        this.addConnection(\"B\", 0, \"ha0\", 1);\n        this.addConnection(\"carryIn\", 0, \"ha1\", 0);\n\n        // connect elements\n        this.addConnection(\"ha0\", 0, \"ha1\", 1);\n        this.addConnection(\"ha0\", 1, \"or0\", 1);\n        this.addConnection(\"ha1\", 1, \"or0\", 0);\n\n        // define outputs\n        this.addOutput(0, \"ha1\", 0); // sum\n        this.addOutput(1, \"or0\", 0); // carry out\n    }\n}\n```\n\n## License\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/logic-board.svg\n[npm-url]: https://npmjs.org/package/logic-board\n[downloads-image]: https://img.shields.io/npm/dm/logic-board.svg\n[downloads-url]: https://npmcharts.com/compare/logic-board?minimal=true\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenapiuz%2Flogic-board","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenapiuz%2Flogic-board","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenapiuz%2Flogic-board/lists"}