{"id":27308489,"url":"https://github.com/alonmell/build-a-computer","last_synced_at":"2025-08-31T10:39:20.704Z","repository":{"id":286828090,"uuid":"913315484","full_name":"AlonMell/build-a-computer","owner":"AlonMell","description":"Implementation of a modern computer system from first principles. Starting with basic NAND gates and progressively building a CPU","archived":false,"fork":false,"pushed_at":"2025-04-08T14:36:15.000Z","size":63,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T04:59:47.109Z","etag":null,"topics":["assembler","computer-architecture","computer-science","cpu-design","digital-logic","hardware-design"],"latest_commit_sha":null,"homepage":"","language":"Hack","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/AlonMell.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}},"created_at":"2025-01-07T12:56:40.000Z","updated_at":"2025-04-08T15:07:47.000Z","dependencies_parsed_at":"2025-04-08T15:39:32.920Z","dependency_job_id":"5d1b00f9-670a-49dc-86b2-0dcd7b92a436","html_url":"https://github.com/AlonMell/build-a-computer","commit_stats":null,"previous_names":["alonmell/build-a-computer"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/AlonMell/build-a-computer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlonMell%2Fbuild-a-computer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlonMell%2Fbuild-a-computer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlonMell%2Fbuild-a-computer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlonMell%2Fbuild-a-computer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlonMell","download_url":"https://codeload.github.com/AlonMell/build-a-computer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlonMell%2Fbuild-a-computer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272971416,"owners_count":25024093,"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-31T02:00:09.071Z","response_time":79,"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":["assembler","computer-architecture","computer-science","cpu-design","digital-logic","hardware-design"],"created_at":"2025-04-12T04:59:46.356Z","updated_at":"2025-08-31T10:39:20.668Z","avatar_url":"https://github.com/AlonMell.png","language":"Hack","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nand2Tetris Project Implementation\n\nThis repository contains a comprehensive implementation of projects from the [Nand2Tetris](https://www.nand2tetris.org/) course, based on the book \"The Elements of Computing Systems\" by Noam Nisan and Shimon Schocken. The course guides students through building a modern computer system from first principles - starting with basic logic gates (NAND) and eventually creating a full hardware platform and software hierarchy.\n\n## Repository Structure\n\nThe repository is organized into separate projects, each representing a different layer in the computer architecture:\n\n```\nnand2tetris/\n├── project1/  # Boolean Logic\n├── project2/  # Boolean Arithmetic\n├── project3/  # Sequential Logic\n├── project4/  # Machine Language\n├── project5/  # Computer Architecture\n└── project6/  # Assembler\n```\n\n## Project Descriptions\n\n### Project 1: Boolean Logic\nImplementation of elementary logic gates using NAND gates as the primitive building block:\n\n* **And.hdl** - AND gate implementation using NAND\n* **And16.hdl** - 16-bit AND gate\n* **DMux.hdl** - Demultiplexor\n* **DMux4Way.hdl** - 4-way demultiplexor\n* **DMux8Way.hdl** - 8-way demultiplexor\n* **Mux.hdl** - Multiplexor\n* **Mux16.hdl** - 16-bit multiplexor\n* **Mux4Way16.hdl** - 4-way 16-bit multiplexor\n* **Mux8Way16.hdl** - 8-way 16-bit multiplexor\n* **Not.hdl** - NOT gate implementation using NAND\n* **Not16.hdl** - 16-bit NOT gate\n* **Or.hdl** - OR gate implementation using NAND\n* **Or16.hdl** - 16-bit OR gate\n* **Or8Way.hdl** - 8-way OR gate\n* **Xor.hdl** - XOR gate implementation\n\n### Project 2: Boolean Arithmetic\nImplementation of arithmetic logic units (ALU) and arithmetic operations:\n\n* **ALU.hdl** - The Arithmetic Logic Unit\n* **Add16.hdl** - 16-bit adder\n* **FullAdder.hdl** - Full adder (adds 3 bits)\n* **HalfAdder.hdl** - Half adder (adds 2 bits)\n* **Inc16.hdl** - 16-bit incrementer\n\n### Project 3: Sequential Logic\nImplementation of memory components using D flip-flops:\n\n* **Bit.hdl** - 1-bit register\n* **PC.hdl** - Program Counter\n* **RAM16K.hdl** - 16K RAM\n* **RAM4K.hdl** - 4K RAM\n* **RAM512.hdl** - 512 RAM\n* **RAM64.hdl** - 64 RAM\n* **RAM8.hdl** - 8 RAM\n* **Register.hdl** - 16-bit register\n\n### Project 4: Machine Language\nAssembly language programs written for the Hack platform:\n\n* **Fill.asm** - Program that fills the screen when a key is pressed\n* **Mult.asm** - Program that multiplies two numbers\n* **Mult_for.asm** - Alternative implementation of multiplication\n\n### Project 5: Computer Architecture\nImplementation of the Hack computer CPU and memory system:\n\n* **CPU.hdl** - Central Processing Unit\n* **Computer.hdl** - The Hack computer\n* **Memory.hdl** - Memory system including RAM and memory-mapped I/O\n\n### Project 6: Assembler\nA Python implementation of an assembler for the Hack platform that translates assembly language to binary machine code:\n\n* **hack_assembler.py** - Main assembler implementation\n* **tables.py** - Lookup tables for instruction translation\n* **test_hack_assembler.py** - Test suite for the assembler\n* **requirements.txt** - Python dependencies\n\n## Hack Computer Architecture\n\nThe Hack computer is a 16-bit von Neumann platform with:\n- A 16-bit instruction set\n- Separate instruction memory (ROM) and data memory (RAM)\n- Memory-mapped I/O for screen and keyboard\n- Two types of instructions:\n  - A-instruction: `@value` (loads a value into the A register)\n  - C-instruction: `dest=comp;jump` (computation followed by optional storage and jump)\n\n## Assembler Usage\n\nThe assembler in project6 translates Hack assembly language (.asm files) into binary machine code (.hack files):\n\n```bash\ncd project6\npip install -r requirements.txt\npython hack_assembler.py input_file.asm [-o output_file.hack] [-p]\n```\n\n### Options:\n- `-o, --outFile`: Specify the output file path\n- `-p, --profiling`: Enable profiling (outputs performance metrics to `results.prof`)\n\n### Testing:\n```bash\ncd project6\npytest\n```\n\n## Implementation Details\n\n### Hardware Description Language (HDL)\nThe hardware components in projects 1-5 are implemented using a custom Hardware Description Language. Each .hdl file specifies:\n\n1. The chip interface (inputs and outputs)\n2. The internal implementation using other, previously built chips\n\n### Hack Assembly Language\nThe assembly language has several key features:\n- Symbol support (variables and labels)\n- Two instruction types (A and C)\n- Built-in symbols for registers (R0-R15), screen, keyboard, etc.\n- Comment support using `//`\n\n## Resources\n\n- [Nand2Tetris Official Website](https://www.nand2tetris.org/)\n- [The Elements of Computing Systems Book](https://mitpress.mit.edu/books/elements-computing-systems)\n- [Nand2Tetris Software Suite](https://www.nand2tetris.org/software)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falonmell%2Fbuild-a-computer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falonmell%2Fbuild-a-computer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falonmell%2Fbuild-a-computer/lists"}