{"id":20887318,"url":"https://github.com/werdl/4bit","last_synced_at":"2026-04-21T12:33:27.038Z","repository":{"id":232189371,"uuid":"783700794","full_name":"werdl/4bit","owner":"werdl","description":"a 4 bit TTL computer","archived":false,"fork":false,"pushed_at":"2024-10-01T18:55:52.000Z","size":1148,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-19T11:16:53.268Z","etag":null,"topics":["4bit","4bit-computer","homebrew-computer","ttl","ttl-computer"],"latest_commit_sha":null,"homepage":"","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/werdl.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":"2024-04-08T12:04:53.000Z","updated_at":"2024-10-01T18:55:56.000Z","dependencies_parsed_at":"2024-05-03T14:03:35.813Z","dependency_job_id":"7b7f3752-fd77-4dae-a1f3-3aa1db8de036","html_url":"https://github.com/werdl/4bit","commit_stats":null,"previous_names":["werdl/4bit"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werdl%2F4bit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werdl%2F4bit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werdl%2F4bit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werdl%2F4bit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/werdl","download_url":"https://codeload.github.com/werdl/4bit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243268079,"owners_count":20263803,"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":["4bit","4bit-computer","homebrew-computer","ttl","ttl-computer"],"created_at":"2024-11-18T08:19:44.725Z","updated_at":"2025-12-25T12:30:48.149Z","avatar_url":"https://github.com/werdl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# werdl/4bit\n## Features\n- Custom 4-bit ALU, supporting AND, OR, XOR, NOT, full add and full subtract\n- 256 nibbles of general use memory\n- Four registers, used for I/O to/from the ALU\n- Program counter with jump and jump if zero instructions\n\n## Instruction Set\n| Binary Value | Assembly Mnemonic | `A_ARG` value | `B_ARG` value | Operation Description | Implemented |\n|-             |-                  |-               |-              | -                     | -         |\n|`0000`| `ADD` | None | None | Adds reg 00 to reg 01 and stores in reg 10 | Yes |\n|`0001`| `SUB` | None | None | Subtracts reg 01 from reg 00 and stores in reg 10 | Yes |\n|`0010`| `REG` | 4 bit literal | 2 bit register address | Stores `A_ARG` in reg `B_ARG`| Yes |\n|`0011`| `NOP` | None | None | None | Yes |\n|`0100`| `NOT` | None | None | Logically inverts the contents of reg 00 and stores in reg 10 | Yes |\n|`0101`| `XOR` | None | None | Performs logical XOR on registers 00 and 01 and stores in reg 10 | Yes |\n|`0110`| `OR` | None | None | Performs logical OR on registers 00 and 01 and stores in reg 10 | Yes |\n|`0111`| `AND` | None | None | Performs logical AND on registers 00 and 01 and stores in reg 10 | Yes |\n|`1000`| `SAV` | 8 bit address | 4 bit literal | Saves `B_ARG` to memory address `B_ARG`| Yes |\n|`1001`| `LDA` | 8 bit address | 2 bit register address | Loads memory address `A_ARG` to reg `B_ARG`| Yes |\n|`1010`| `WRIT` | 8 bit address | 2 bit register address | Saves reg `B_ARG` to memory address `A_ARG` | Yes |\n|`1011`| Reserved | - | - | - | No|\n|`1100`| `JMP` | 6 bit address | None | Jumps to PC address `A_ARG`| Yes |\n|`1101`| Reserved | - | - | - | No|\n|`1110`| `JCU` | 6 bit address | 2 bit register address | If register `B_ARG` is equal to register 11, jumps to memory address `A_ARG` | Yes |\n|`1111`| Reserved | - | - | -| No|\n\n### Notes on the instruction set\n- There are 4 \"namespaces\" (bitfields)\n\n| `Binary range` | `Use` | `# uses`\n|-|-| - |\n| `0000` - `0011` | Arithmetic uses | 2 + `NOP`\n| `0100` - `0111` | Logical operations | 4\n| `1000` - `1011` | Memory manipulation operations | 3\n| `1100` - `1111` | Control flow operations | 3 (only 1 implemented)\n\n- I think it is Turing-complete or near to it? I am pretty sure it is with manual instruction entry on the ALU/Memory Unit, but the PC I am less sure of\n\n## Example Programs\n### A simple program that adds 1 to a number in memory address 0x00 and stores it in memory address 0x01\n```asm\nLDA 0x00 00 ; Load the number from memory address 0x00 into reg 00\nREG 1 01 ; Store the literal 1 in reg 01\nADD ; Add reg 00 to reg 01 and store in reg 10\nWRIT 0x01 10 ; Write the result to memory address 0x01\n```\n\n## Circuitry\n\u003e Fully designed in Logisim, using the built in TTL library and also [this library](https://github.com/r0the/logi7400). A few logic gates are included for more obscure ICs, but they will be replaced either with said ICs or with equivalent chips in series.\n\n### ALU/MU\nThe ALU/MU is the heart of the computer, and is where all the computation is done. It is a 4-bit ALU, with 256 nibbles of general use memory. The ALU/MU is connected to the program counter, and is where the instructions are executed. The MU contains the registers and the memory.\n\n### Program Counter\nThe program counter is a simple counter that increments by one each clock cycle. It is connected to the ALU/MU, and is where the instructions are fetched from memory. The CLK input loads the current instruction into the ALU/MU, and the GO input executes the instruction. It is programmable, and can jump to any address in memory, using the `JMP` and `JCU` instructions.\n\n![ALU/MU](images/ALU-MU.png)\n\n![Program Counter](images/PC.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwerdl%2F4bit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwerdl%2F4bit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwerdl%2F4bit/lists"}