{"id":34775958,"url":"https://github.com/msinger/dmg-sim","last_synced_at":"2026-03-16T12:02:17.716Z","repository":{"id":176192548,"uuid":"357352227","full_name":"msinger/dmg-sim","owner":"msinger","description":"SystemVerilog files for simulating a complete Game Boy system with DMG-CPU B chip","archived":false,"fork":false,"pushed_at":"2025-11-29T01:11:54.000Z","size":813,"stargazers_count":7,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-30T23:30:43.172Z","etag":null,"topics":["asic","chip","dmg-001","dmg-cpu","electronics","game-boy","gameboy","icarus-verilog","nintendo","simulation","systemverilog","verilog"],"latest_commit_sha":null,"homepage":"","language":"SystemVerilog","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc-by-sa-4.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msinger.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-04-12T22:08:44.000Z","updated_at":"2025-11-29T21:00:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"e8999bc3-b401-42cd-ba89-e28a108a1f05","html_url":"https://github.com/msinger/dmg-sim","commit_stats":null,"previous_names":["msinger/dmg-sim"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/msinger/dmg-sim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msinger%2Fdmg-sim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msinger%2Fdmg-sim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msinger%2Fdmg-sim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msinger%2Fdmg-sim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msinger","download_url":"https://codeload.github.com/msinger/dmg-sim/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msinger%2Fdmg-sim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28024483,"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-12-25T02:00:05.988Z","response_time":58,"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":["asic","chip","dmg-001","dmg-cpu","electronics","game-boy","gameboy","icarus-verilog","nintendo","simulation","systemverilog","verilog"],"created_at":"2025-12-25T08:16:55.486Z","updated_at":"2026-03-16T12:02:17.710Z","avatar_url":"https://github.com/msinger.png","language":"SystemVerilog","funding_links":[],"categories":[],"sub_categories":[],"readme":"DMG Sim\n=======\n\nSystemVerilog code for simulating a Game Boy system with Icarus Verilog.\nMost of the code is generated from the netlist files in\n[msinger/dmg-schematics](https://github.com/msinger/dmg-schematics).\n\n\nFiles in this repo\n------------------\n\n| File(s)                              | Description                                                                         |\n| ------------------------------------ | ----------------------------------------------------------------------------------- |\n| ./dmg\\_cpu\\_b/cells/\\*.sv            | Modules implementing all standard cells of the DMG-CPU B chip.                      |\n| ./dmg\\_cpu\\_b/dmg\\_cpu\\_b.sv         | The DMG-CPU B chip.                                                                 |\n| ./sm83/cells/\\*.sv                   | Modules implementing all cells in the SM83 CPU core.                                |\n| ./sm83/sm83.sv                       | The SM83 CPU core.                                                                  |\n| ./dmg\\_cpu\\_b\\_gameboy.sv            | Top level module that simulates a complete Game Boy system.                         |\n| ./snd\\_dump.sv                       | Code for dumping the APU's sound output to a file.                                  |\n| ./vid\\_dump.sv                       | Code for dumping the PPU's video signals to a file.                                 |\n| ./mkvid/mkimgs.c                     | C code for extracting raw RGB frames from video signal dumps.                       |\n| ./mkvid/mkvid.sh                     | Bash script for combining dumped sound output and extracted RGB frames to a video.  |\n| ./boot/quickboot.s                   | Assembly code for a boot ROM that boots in less than 0.2 seconds.\n\n\nUsage\n-----\n\nThe default make target (sim-gameboy) simulates a complete Game Boy system (dmg\\_cpu\\_b\\_gameboy.sv).\nRun\n```\nmake sim-gameboy\n```\nor just\n```\nmake\n```\nto start the simulation.\n\nThe simulation can produce any of the folowing files:\n\n| File(s)                             | Description                                                                                             |\n| ----------------------------------- | ------------------------------------------------------------------------------------------------------- |\n| ./dmg\\_cpu\\_b\\_gameboy.snd          | The APU's sound output. All four channels mixed into one 16 bit PCM file with 65536 Hz stereo.          |\n| ./dmg\\_cpu\\_b\\_gameboy\\_ch[1-4].snd | One 8 bit PCM file with 65536 Hz mono for each channel. Only if CH\\_DUMP=y is set on make command line. |\n| ./dmg\\_cpu\\_b\\_gameboy.vid          | The PPU's video signal dump. Can be used to extract images for a video.                                 |\n\nTo produce a playable video file from those dumps, run\n```\nmake dmg_cpu_b_gameboy.mkv\n```\n\nBy default all internal signals are dumped in FST format. To dump in VCD, add `DUMP=vcd` to the make command line. `DUMP=`\ndisables dumping of internal signals.\n\n\nRequirements\n------------\n\nOf course you need Icarus Verilog and GNU Make.\n\nIf you want to generate video files, you also need GCC, ImageMagick and FFmpeg.\n\n\nSimulate boot ROM\n-----------------\n\nThe boot ROM is not part of this repo. You need to download it somewhere else (in binary form; 256 bytes).\nPut it in the root directory of this repository and rename it to `DMG_ROM.bin`. You can also build and use\nthe quick boot ROM in the `boot` folder. You need the [SM83 Binutils](https://github.com/msinger/binutils-sm83)\nfor that. To use it you can either move the generated binary to the root of the repository and rename it\nto `DMG_ROM.bin` or add the variable `BOOTROM=boot/quickboot.bin` to the `make` command line.\n\nThen simulate it with:\n```\nmake sim-gameboy\n```\n\nThis simulates the boot ROM without cartridge. You can specify a ROM file and how many seconds you want to\nsimulate:\n```\nmake sim-gameboy ROM=path/to/romfile.gb SECS=10.0\n```\n\nThe simulation takes about 73 minutes per simulated second on a Ryzen 5 3600. If you just want to generate a\nvideo, you can safe some time by disabling the signal dump:\n```\nmake sim-gameboy DUMP=\n```\n\nThen create video file with:\n```\nmake dmg_cpu_b_gameboy.mkv\n```\n\nThis is what the video should look like: [https://youtu.be/kIpV2FVUPKs](https://youtu.be/kIpV2FVUPKs)\n\n\nTests\n-----\n\nResults of Blargg's tests:\n\n| Test          | Result |\n| ------------- | :----: |\n| cpu\\_instrs   |   ✅   |\n| dmg\\_sound    |   ❌   |\n| halt\\_bug     |   ✅   |\n| instr\\_timing |   ✅   |\n| mem\\_timing   |   ✅   |\n| mem\\_timing-2 |   ✅   |\n| oam\\_bug      |   ❌   |\n\nResults of Mooneye GB tests:\n\n| Test                                           | Result |\n| ---------------------------------------------- | :----: |\n| acceptance/add\\_sp\\_e\\_timing                  |   ✅   |\n| acceptance/bits/mem\\_oam                       |   ✅   |\n| acceptance/bits/reg\\_f                         |   ✅   |\n| acceptance/bits/unused\\_hwio-GS                |   ✅   |\n| acceptance/boot\\_div-dmgABCmgb                 |   ✅   |\n| acceptance/boot\\_hwio-dmgABCmgb                |   ✅   |\n| acceptance/boot\\_regs-dmgABC                   |   ✅   |\n| acceptance/call\\_cc\\_timing                    |   ✅   |\n| acceptance/call\\_cc\\_timing2                   |   ✅   |\n| acceptance/call\\_timing                        |   ✅   |\n| acceptance/call\\_timing2                       |   ✅   |\n| acceptance/di\\_timing-GS                       |   ✅   |\n| acceptance/div\\_timing                         |   ✅   |\n| acceptance/ei\\_sequence                        |   ✅   |\n| acceptance/ei\\_timing                          |   ✅   |\n| acceptance/halt\\_ime0\\_ei                      |   ✅   |\n| acceptance/halt\\_ime0\\_nointr\\_timing          |   ✅   |\n| acceptance/halt\\_ime1\\_timing                  |   ✅   |\n| acceptance/halt\\_ime1\\_timing2-GS              |   ✅   |\n| acceptance/if\\_ie\\_registers                   |   ✅   |\n| acceptance/instr/daa                           |   ✅   |\n| acceptance/intr\\_timing                        |   ✅   |\n| acceptance/interrupts/ie\\_push                 |   ✅   |\n| acceptance/jp\\_cc\\_timing                      |   ✅   |\n| acceptance/jp\\_timing                          |   ✅   |\n| acceptance/ld\\_hl\\_sp\\_e\\_timing               |   ✅   |\n| acceptance/oam\\_dma/basic                      |   ✅   |\n| acceptance/oam\\_dma/reg\\_read                  |   ✅   |\n| acceptance/oam\\_dma/sources-dmgABCmgbS         |   ✅   |\n| acceptance/oam\\_dma\\_restart                   |   ✅   |\n| acceptance/oam\\_dma\\_start                     |   ✅   |\n| acceptance/oam\\_dma\\_timing                    |   ✅   |\n| acceptance/pop\\_timing                         |   ✅   |\n| acceptance/ppu/hblank\\_ly\\_scx\\_timing-GS      |   ✅   |\n| acceptance/ppu/intr\\_1\\_2\\_timing-GS           |   ✅   |\n| acceptance/ppu/intr\\_2\\_0\\_timing              |   ✅   |\n| acceptance/ppu/intr\\_2\\_mode0\\_timing          |   ✅   |\n| acceptance/ppu/intr\\_2\\_mode0\\_timing\\_sprites |   ✅   |\n| acceptance/ppu/intr\\_2\\_mode3\\_timing          |   ✅   |\n| acceptance/ppu/intr\\_2\\_oam\\_ok\\_timing        |   ✅   |\n| acceptance/ppu/lcdon\\_timing-dmgABCmgbS        |   ✅   |\n| acceptance/ppu/lcdon\\_write\\_timing-GS         |   ❌   |\n| acceptance/ppu/stat\\_irq\\_blocking             |   ✅   |\n| acceptance/ppu/stat\\_lyc\\_onoff                |   ✅   |\n| acceptance/ppu/vblank\\_stat\\_intr-GS           |   ✅   |\n| acceptance/push\\_timing                        |   ✅   |\n| acceptance/rapid\\_di\\_ei                       |   ✅   |\n| acceptance/ret\\_cc\\_timing                     |   ✅   |\n| acceptance/ret\\_timing                         |   ✅   |\n| acceptance/reti\\_intr\\_timing                  |   ✅   |\n| acceptance/reti\\_timing                        |   ✅   |\n| acceptance/rst\\_timing                         |   ✅   |\n| acceptance/serial/boot\\_sclk\\_align-dmgABCmgb  |   ✅   |\n| acceptance/timer/div\\_write                    |   ✅   |\n| acceptance/timer/rapid\\_toggle                 |   ✅   |\n| acceptance/timer/tim00                         |   ✅   |\n| acceptance/timer/tim00\\_div\\_trigger           |   ✅   |\n| acceptance/timer/tim01                         |   ✅   |\n| acceptance/timer/tim01\\_div\\_trigger           |   ✅   |\n| acceptance/timer/tim10                         |   ✅   |\n| acceptance/timer/tim10\\_div\\_trigger           |   ✅   |\n| acceptance/timer/tim11                         |   ✅   |\n| acceptance/timer/tim11\\_div\\_trigger           |   ✅   |\n| acceptance/timer/tima\\_reload                  |   ✅   |\n| acceptance/timer/tima\\_write\\_reloading        |   ✅   |\n| acceptance/timer/tma\\_write\\_reloading         |   ✅   |\n| madness/mgb\\_oam\\_dma\\_halt\\_sprites           |   ❌   |\n| manual-only/sprite\\_priority                   |   ✅   |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsinger%2Fdmg-sim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsinger%2Fdmg-sim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsinger%2Fdmg-sim/lists"}