{"id":25866402,"url":"https://github.com/joshiemoore/snakehdl","last_synced_at":"2025-08-01T11:34:29.561Z","repository":{"id":278449431,"uuid":"935677699","full_name":"joshiemoore/snakehdl","owner":"joshiemoore","description":"A simple, purely-functional HDL for Python","archived":false,"fork":false,"pushed_at":"2025-03-09T04:34:33.000Z","size":431,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-13T14:28:10.131Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/joshiemoore.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}},"created_at":"2025-02-19T20:48:36.000Z","updated_at":"2025-03-09T04:34:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"a8b25c74-5c9d-40f8-a9e8-9d0e053ba4b9","html_url":"https://github.com/joshiemoore/snakehdl","commit_stats":null,"previous_names":["joshiemoore/snakehdl"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/joshiemoore/snakehdl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshiemoore%2Fsnakehdl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshiemoore%2Fsnakehdl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshiemoore%2Fsnakehdl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshiemoore%2Fsnakehdl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joshiemoore","download_url":"https://codeload.github.com/joshiemoore/snakehdl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshiemoore%2Fsnakehdl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268215602,"owners_count":24214365,"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","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-03-02T02:33:52.481Z","updated_at":"2025-08-01T11:34:29.494Z","avatar_url":"https://github.com/joshiemoore.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# snakeHDL: A simple, purely-functional HDL for Python\n\nsnakeHDL is a tool for creating digital logic circuits with a focus on simplicity and accessibility.\nThis project is intended to be a fun and easy way for anyone to design real hardware with a few lines of Python.\nCompile your circuit to Verilog, VHDL, or a dill-pickled Python function!\n\nsnakeHDL is Free Software licensed under the terms of the MIT License. The project is still early in development,\nso bugs and general instability may occur.\n\nDEMO VIDEO: [YouTube](https://youtu.be/SjTPqguMc84)\n\nJoin us on [Discord](https://discord.gg/Vc6BrkTW)!\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/joshiemoore/snakehdl/blob/master/HACK_ALU.png\" /\u003e\n\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ci\u003eThe 16-bit HACK ALU from\u003c/i\u003e \"The Elements of Computing Systems\" by Nisan and Schocken \u003ci\u003eimplemented in snakeHDL, compiled to VHDL,\n  and imported to Logisim. See\u003c/i\u003e \u003ca href=\"https://github.com/joshiemoore/snakehdl/blob/master/examples/HACK_ALU.py\"\u003eexamples/HACK_ALU.py\u003c/a\u003e\n\u003c/p\u003e\n\n## Introduction\nsnakeHDL has two main components: an API for expressing abstract trees of boolean logic, and an optimizing compiler that translates\nthese abstract logic trees into logic circuits. The compiler handles hardware-specific concerns, so you can focus purely on your\ncircuit's logic.\n\nIn short, snakeHDL lets you express **what** your circuit should do, instead of **how** it should do it.\n\n```\n  $ pip install snakehdl\n  $ python3\n  \u003e\u003e\u003e from snakehdl import input_bits, output, xor\n  \u003e\u003e\u003e out = output(res=xor(input_bits('a'), input_bits('b')))\n```\n\nThis creates a simple BOp tree representing a circuit with one output named `res` that is the XOR of two 1-bit inputs named `a` and `b`.\n\nBOps are naturally composable into larger circuits because they are lazily evaluated. When you create a tree of BOps, nothing actually happens until you compile it:\n\n```\n  \u003e\u003e\u003e from snakehdl.compilers import VerilogCompiler\n  \u003e\u003e\u003e VerilogCompiler(out, name='xor_ab').compile().save('xor_ab.v')\n```\n\nWe can build composite logical structures like adders, multiplexers,\nand even full ALUs starting from these fundamental BOps. Output bit widths\nare automatically inferred based on the tree structure at compile time.\n\nSince only twelve primitive BOps are specified by snakeHDL, it is straightforward to\ncreate new compiler backends.\n\nWe will use snakeHDL to implement the ALU and control logic for the [Snake Processing Unit](https://github.com/joshiemoore/snakehdl/blob/master/examples/snakepu/design.txt), and then combine\nthis with the necessary sequential elements (registers, stack, RAM) to make the snakePU a mega-fast Python coprocessor chip.\n\n## Boolean Operations (BOps)\nThe following boolean operations are specified by the snakeHDL API and must be implemented in hardware (or simulated hardware) by the compiler backends:\n\n### Combinational Operations\n* AND\n* NAND\n* OR\n* NOR\n* XOR\n* XNOR\n* NOT (unary)\n\n### I/O Operations\n* CONST\n* INPUT\n* OUTPUT\n* BIT\n* JOIN\n\n...and that's it!\nCheck out the [BOp documentation](https://github.com/joshiemoore/snakehdl/blob/master/docs/bops.md) to learn more or look at the [examples](https://github.com/joshiemoore/snakehdl/tree/master/examples) to see BOps in action.\n\n## Compiler Targets\n- [x] Verilog\n- [x] VHDL\n- [x] Python - compile your circuit to a pickled Python function that accepts your named inputs\n    as kwargs and returns the result as a dict of your named outputs. Useful for automated logic testing.\n- [ ] Arduino\n- [ ] Minecraft Redstone\n- [ ] ...\n\n## Optimizations\nThe following is a list of current and planned compiler optimizations:\n- [x] Cached BOp hashing\n- [x] Common Subexpression Elimination\n- [ ] Constant folding (i.e. `A \u0026 0 -\u003e 0`)\n- [ ] Gate pruning (i.e. `AND(A, AND(A, B)) -\u003e AND(A, B)`)\n- [ ] ...\n\n## TODO\n* Improve documentation\n* Add more components to component library\n* Add useful examples demonstrating snakeHDL functionality\n* Optimize compiler output (constant folding, gate pruning, etc.)\n* ***MAKE THE snakePU REAL***\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshiemoore%2Fsnakehdl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoshiemoore%2Fsnakehdl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshiemoore%2Fsnakehdl/lists"}