{"id":15728856,"url":"https://github.com/mixedmatched/fourbeecpu","last_synced_at":"2026-01-08T08:07:58.387Z","repository":{"id":122763901,"uuid":"603417793","full_name":"MixedMatched/fourbeecpu","owner":"MixedMatched","description":"very simple 4-bit cpu powered by tiny bees","archived":false,"fork":false,"pushed_at":"2023-02-19T17:11:54.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-06T07:15:52.310Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Verilog","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MixedMatched.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":"2023-02-18T12:58:36.000Z","updated_at":"2024-12-09T01:46:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"364ce40e-a022-441b-a18f-4dca80b64c29","html_url":"https://github.com/MixedMatched/fourbeecpu","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"9f0dd703c905c5742c31cda6c91d04fb52c3eabc"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MixedMatched%2Ffourbeecpu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MixedMatched%2Ffourbeecpu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MixedMatched%2Ffourbeecpu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MixedMatched%2Ffourbeecpu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MixedMatched","download_url":"https://codeload.github.com/MixedMatched/fourbeecpu/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246403916,"owners_count":20771530,"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":[],"created_at":"2024-10-03T23:06:59.940Z","updated_at":"2026-01-08T08:07:58.300Z","avatar_url":"https://github.com/MixedMatched.png","language":"Verilog","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fourbee cpu \nthe fourbee cpu is a very simple 4-bit cpu powered by these tiny bees moving electrons around:\n\n![image](https://user-images.githubusercontent.com/30960626/219956219-bd5f3421-aed9-4af6-8dc9-36871252a7ee.png)\n\n## architecture\nthere are two registers on the cpu, which are hard referenced by the instructions. fourbee uses a harvard architecture (the program and instruction memory are split). the cpu can connect to a whopping 16 addresses of 4-bit program memory and 16 addresses of 4-bit instruction memory. \n\nthis cpu uses a custom instruction set architecture defined in the following table. each instruction is a single 4-bit binary word, which is a single hex digit.\n\n| mnemonic | binary | hex | description | assignment |\n| --- | --- | --- | --- | --- |\n| swp | 0000 | 0 | swap the registers | rx \u003c=\u003e ry |\n| add | 0001 | 1 | add the registers | rx = rx + ry |\n| sub | 0010 | 2 | subtract two registers | rx = rx - ry |\n| and | 0011 | 3 | bitwise and two registers | rx = rx \u0026 ry |\n| or | 0100 | 4 | bitwise or two registers | rx = rx | ry |\n| inc | 0101 | 5 | increment one register | rx = rx + 1 |\n| not | 0110 | 6 | bitwise not one register | rx = ~rx |\n| lsl | 0111 | 7 | logical shift left one register | rx = rx \u003c\u003c 1 |\n| lsr | 1000 | 8 | logical shift right one register | rx = rx \u003e\u003e 1 |\n| jmp | 1001 | 9 | jump to address in register | pc = rx |\n| jz | 1010 | A | jump to address in register if zero flag is set | if (z) pc = rx |\n| jnz | 1011 | B | jump to address in register if zero flag is not set | if (!z) pc = rx |\n| jn | 1100 | C | jump to address in register if negative flag is set | if (n) pc = rx |\n| jnn | 1101 | D | jump to address in register if negative flag is not set | if (!n) pc = rx |\n| ld | 1110 | E | load register from memory | rx = mem[ry] |\n| st | 1111 | F | store register to memory | mem[ry] = rx |\n\nthe cpu has two flags, the zero flag and the negative flag. the zero flag is set if the result of the last operation was zero, and the negative flag is set if the result of the last operation was negative.\n\n## program\nyou can turn bee-assembly into instruction hex files using asm/assembler.py. it takes in an `in.asm` and emits an `out.hex`.\n\n## simulating\nto build and simulate the cpu, you'll need to have make, iverilog, and vvp installed. you can compile the cpu with:\n```\nmake compile\n```\nwhich will generate vvp files for each testbench in the target folder. you can simulate these testbenches by doing:\n```\nmake simulate\n```\nwhich will run vvp on each of the compiled files. to do both you can run:\n```\nmake all\n```\n\n## license\n\nCopyright (C) 2022 Alessandra Simmons\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixedmatched%2Ffourbeecpu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmixedmatched%2Ffourbeecpu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixedmatched%2Ffourbeecpu/lists"}