{"id":15443835,"url":"https://github.com/zanderlewis/hardware-emulators","last_synced_at":"2025-03-28T08:12:15.372Z","repository":{"id":255234338,"uuid":"848939965","full_name":"zanderlewis/hardware-emulators","owner":"zanderlewis","description":"A collection of hardware emulators written in python. This includes CPU and GPU.","archived":false,"fork":false,"pushed_at":"2024-08-28T21:16:06.000Z","size":51,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-29T20:59:24.031Z","etag":null,"topics":[],"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/zanderlewis.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-08-28T17:23:58.000Z","updated_at":"2024-08-28T21:16:10.000Z","dependencies_parsed_at":"2024-12-20T13:11:40.980Z","dependency_job_id":"1100bd99-0717-4bdd-878f-c3f4989abd49","html_url":"https://github.com/zanderlewis/hardware-emulators","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"f526ad8e0d723ed0c56c2756231e5fd531bbb591"},"previous_names":["zanderlewis/hardware-emulators"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zanderlewis%2Fhardware-emulators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zanderlewis%2Fhardware-emulators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zanderlewis%2Fhardware-emulators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zanderlewis%2Fhardware-emulators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zanderlewis","download_url":"https://codeload.github.com/zanderlewis/hardware-emulators/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236772478,"owners_count":19202281,"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-01T19:37:08.465Z","updated_at":"2025-02-02T08:41:50.684Z","avatar_url":"https://github.com/zanderlewis.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hardware Emulators\nThis repository contains emulators for various hardware components. It also contains a motherboard emulator that combines the CPU, GPU, and RAM emulators. This can be run with [computer.py](computer.py) as a virtual computer.\n\n## Table of Contents\n- [Hardware Emulators](#hardware-emulators)\n  - [Table of Contents](#table-of-contents)\n  - [CPU](#cpu)\n  - [GPU](#gpu)\n  - [RAM](#ram)\n  - [Motherboard](#motherboard)\n  - [Sound Card](#sound-card)\n  - [Network Card](#network-card)\n  - [HDD](#hdd)\n  - [SSD](#ssd)\n\n## CPU\n[cpu.py](emulators/cpu.py)\n### Example Program\n```python\n# Program to add two numbers\nprogram = [\n    0x01, 0x00, 0x0A,  # Load 10 into R0\n    0x01, 0x01, 0x05,  # Load 5 into R1\n    0x02, 0x00, 0x01,  # Add R1 to R0\n    0x0D, 0x07,        # Jump to address 0x07 if R0 is zero\n    0xFF               # Halt\n]\n\ncpu = CPU()\ncpu.load_program(program)\ncpu.run()\n\n# Print the sum of the two numbers\nprint(f\"Sum: {cpu.registers[0]}\")\n```\n\n## GPU\n[gpu.py](emulators/gpu.py)\n### Example Program\n```python\n# Program to draw a square outline\nprogram = [\n    # Draw top side of the square\n    0x06, 10, 10, 255, 255, 255,  # Draw white pixel at (10, 10)\n    0x06, 11, 10, 255, 255, 255,  # Draw white pixel at (11, 10)\n    0x06, 12, 10, 255, 255, 255,  # Draw white pixel at (12, 10)\n    0x06, 13, 10, 255, 255, 255,  # Draw white pixel at (13, 10)\n    0x06, 14, 10, 255, 255, 255,  # Draw white pixel at (14, 10)\n\n    # Draw bottom side of the square\n    0x06, 10, 14, 255, 255, 255,  # Draw white pixel at (10, 14)\n    0x06, 11, 14, 255, 255, 255,  # Draw white pixel at (11, 14)\n    0x06, 12, 14, 255, 255, 255,  # Draw white pixel at (12, 14)\n    0x06, 13, 14, 255, 255, 255,  # Draw white pixel at (13, 14)\n    0x06, 14, 14, 255, 255, 255,  # Draw white pixel at (14, 14)\n\n    # Draw left side of the square\n    0x06, 10, 11, 255, 255, 255,  # Draw white pixel at (10, 11)\n    0x06, 10, 12, 255, 255, 255,  # Draw white pixel at (10, 12)\n    0x06, 10, 13, 255, 255, 255,  # Draw white pixel at (10, 13)\n\n    # Draw right side of the square\n    0x06, 14, 11, 255, 255, 255,  # Draw white pixel at (14, 11)\n    0x06, 14, 12, 255, 255, 255,  # Draw white pixel at (14, 12)\n    0x06, 14, 13, 255, 255, 255,  # Draw white pixel at (14, 13)\n\n    0xFF                          # Halt\n]\n\n# Initialize GPU and load program into memory\ngpu = GPU()\ngpu.load_program(program)\n\n# Run the GPU\ngpu.run()\n\n# Display the pixels\nimport matplotlib.pyplot as plt\n\n# Download the image\nplt.imsave(\"gpu_output.png\", gpu.framebuffer)\n```\n\n## RAM\n[ram.py](emulators/ram.py)\n### Example Program\nNOTE: The RAM emulator is not meant to be run as a standalone program. It is meant to be used in conjunction with the CPU emulator.\n\n## Motherboard\n[motherboard.py](emulators/motherboard.py)\n\n### Example Program\n```python\n# Sample program that finds the sum of two numbers\ncpu_program = [\n    0x01, 0x00, 0x0A,  # Load 10 into R0\n    0x01, 0x01, 0x05,  # Load 5 into R1\n    0x02, 0x00, 0x01,  # Add R1 to R0\n    0x0D, 0x07,        # Jump to address 0x07 if R0 is zero\n    0xFF               # Halt\n]\n\nmotherboard = Motherboard()\nmotherboard.load_program(cpu_program)\nmotherboard.run()\n\nprint(\"CPU output:\", motherboard.cpu.registers[0])\n```\n\n## Sound Card\n[sound_card.py](emulators/sound_card.py)\n\n### Example Program\nNOTE: The Sound Card emulator is not meant to be run as a standalone program. It is meant to be used in conjunction with the Motherboard emulator.\n\n## Network Card\n[network_card.py](emulators/network_card.py)\n\n### Example Program\nNOTE: The Network Card emulator is not meant to be run as a standalone program. It is meant to be used in conjunction with the Motherboard emulator.\n\n## HDD\n[hdd.py](emulators/hdd.py)\n\n### Example Program\nNOTE: The HDD emulator is not meant to be run as a standalone program. It is meant to be used in conjunction with the Motherboard emulator.\n\n## SSD\n[ssd.py](emulators/ssd.py)\n\n### Example Program\nNOTE: The SSD emulator is not meant to be run as a standalone program. It is meant to be used in conjunction with the Motherboard emulator.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzanderlewis%2Fhardware-emulators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzanderlewis%2Fhardware-emulators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzanderlewis%2Fhardware-emulators/lists"}