Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nand2mario/nestang
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.8rc
Choose a base ref
...
head repository: nand2mario/nestang
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 77,952 additions and 9,652 deletions.
  1. +2 −0 .gitignore
  2. +11 −0 CHANGELOG.md
  3. +20 −2 CHANGES.md
  4. +60 −71 README.md
  5. +93 −18 build.tcl
  6. +29 −0 buildall.bat
  7. +39 −0 doc/NESGamepad.md
  8. BIN doc/images/NESGamepad_NES2FamiCom.jpg
  9. BIN doc/images/NESGamepad_wiring.png
  10. BIN doc/images/NESGamepad_wiring_levelShifter.png
  11. BIN doc/images/nano20k_setup.jpg
  12. BIN doc/images/nestang0.8rc.jpg
  13. BIN doc/images/primer25k_setup.jpg
  14. +5 −0 doc/nes2img.md
  15. +17 −0 doc/primer20k.md
  16. +13 −6 doc/usb_gamepad.md
  17. +92 −0 impl/nestang_mega60k_process_config.json
  18. +105 −0 impl/nestang_primer25k_process_config.json
  19. +0 −12 nano20k.tcl
  20. +70 −0 nestang_mega60k.gprj
  21. +36 −20 nestang_nano20k.gprj
  22. +37 −19 nestang_primer25k.gprj
  23. +0 −16 primer25k.tcl
  24. +120 −0 src/EEPROM_24C0x.sv
  25. +0 −2,374 src/MicroCode.v
  26. +1,118 −769 src/apu.v
  27. 0 src/{ → assets}/background.txt
  28. 0 src/{ → assets}/font.vh
  29. +47 −0 src/assets/logo.py
  30. 0 src/{ → assets}/nes_fb_testpattern_palette.txt
  31. +1 −1 src/autofire.v
  32. +1,900 −0 src/cart.sv
  33. +0 −41 src/config.vh
  34. +36 −0 src/controller_ds2.sv
  35. +137 −0 src/controller_snes.v
  36. +0 −361 src/cpu.v
  37. +38 −0 src/dpram.v
  38. +145 −178 src/dualshock_controller.v
  39. +46 −31 src/game_data.v
  40. +273 −91 src/game_loader.v
  41. +0 −22 src/gowin_clkdiv.v
  42. +14 −8 src/hdmi2/audio_clock_regeneration_packet.sv
  43. +12 −9 src/hdmi2/hdmi.sv
  44. +7 −3 src/hdmi2/packet_picker.sv
  45. +2 −0 src/hdmi2/serializer.sv
  46. +0 −41 src/hw_sound.v
  47. +24 −0 src/iosys/gowin_dpb_menu.ipc
  48. +26 −0 src/iosys/gowin_dpb_menu.mod
  49. +130 −0 src/iosys/gowin_dpb_menu.v
  50. +368 −0 src/iosys/iosys.v
  51. +3,048 −0 src/iosys/picorv32.v
  52. +87 −0 src/iosys/simplespimaster.v
  53. +135 −0 src/iosys/simpleuart.v
  54. +239 −0 src/iosys/spi_master.v
  55. +146 −0 src/iosys/spiflash.v
  56. +166 −0 src/iosys/textdisp.v
  57. +744 −0 src/mappers/FDS.sv
  58. +294 −0 src/mappers/JYCompany.sv
  59. +275 −0 src/mappers/MMC1.sv
  60. +323 −0 src/mappers/MMC2.sv
  61. +700 −0 src/mappers/MMC3.sv
  62. +474 −0 src/mappers/MMC5.sv
  63. +426 −0 src/mappers/Namco.sv
  64. +320 −0 src/mappers/Sachen.sv
  65. +576 −0 src/mappers/Sunsoft.sv
  66. +974 −0 src/mappers/VRC.sv
  67. +1,066 −0 src/mappers/generic.sv
  68. +214 −0 src/mappers/iir_filter.v
  69. +2,183 −0 src/mappers/misc.sv
  70. +16 −0 src/mega60k/config.v
  71. +180 −0 src/mega60k/nestang.cst
  72. +0 −146 src/memory_controller.v
  73. +0 −1,760 src/mmu.v
  74. +4 −3 src/{tang_nano_20k/config.sv → nano20k/config.v}
  75. 0 src/{tang_nano_20k → nano20k}/gowin_pll_hdmi.v
  76. +28 −0 src/nano20k/gowin_pll_nes.ipc
  77. +35 −0 src/nano20k/gowin_pll_nes.mod
  78. +66 −0 src/nano20k/gowin_pll_nes.v
  79. 0 src/{tang_nano_20k → nano20k}/gowin_pll_usb.v
  80. +124 −0 src/nano20k/nestang.cst
  81. +16 −0 src/nano20k/nestang.sdc
  82. +348 −91 src/nes.gao
  83. +537 −279 src/nes.v
  84. +313 −252 src/nes2hdmi.sv
  85. +452 −522 src/nestang_top.sv
  86. +873 −602 src/ppu.v
  87. +5 −5 src/{tang_primer_25k/config.sv → primer25k/config.v}
  88. +15 −0 src/primer25k/config_snescontroller.v
  89. +145 −0 src/primer25k/gowin_pll_27.ipc
  90. +51 −0 src/primer25k/gowin_pll_27.mod
  91. +9 −9 src/{tang_primer_25k → primer25k}/gowin_pll_27.v
  92. 0 src/{tang_primer_25k → primer25k}/gowin_pll_hdmi.v
  93. +145 −0 src/primer25k/gowin_pll_nes.ipc
  94. +59 −0 src/primer25k/gowin_pll_nes.mod
  95. +137 −0 src/primer25k/gowin_pll_nes.v
  96. 0 src/{tang_primer_25k → primer25k}/gowin_pll_usb.v
  97. +215 −0 src/primer25k/nestang.cst
  98. +18 −0 src/primer25k/nestang.sdc
  99. +197 −0 src/primer25k/nestang_snescontroller.cst
  100. +24,592 −0 src/roms/helloworld.hex
  101. +28,688 −0 src/roms/nes15.hex
  102. +0 −578 src/sd_file_list_reader.v
  103. +0 −238 src/sd_loader.v
  104. +0 −234 src/sd_reader.sv
  105. +0 −133 src/sdcmd_ctrl.sv
  106. +0 −295 src/sdram.v
  107. +389 −0 src/sdram_nes.v
  108. +2 −0 src/t65/README.md
  109. +679 −0 src/t65/T65.v
  110. +264 −0 src/t65/T65_ALU.v
  111. +1,345 −0 src/t65/T65_MCode.v
  112. +106 −0 src/t65/T65_Pack.v
  113. +0 −103 src/tang_nano_20k/nestang.cst
  114. +0 −15 src/tang_nano_20k/nestang.sdc
  115. +0 −170 src/tang_primer_25k/nestang.cst
  116. +0 −15 src/tang_primer_25k/nestang.sdc
  117. +11 −0 src/verilator/config.sv
  118. +156 −0 src/verilator/sdram_sim.v
  119. +12 −0 tools/nes2hex.sh
  120. +28 −0 tools/pll.py
  121. +28 −12 verilator/Makefile
  122. +1 −2 verilator/README.md
  123. +0 −32 verilator/setup.sh
  124. +200 −63 verilator/sim_main.cpp
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.o
impl
nes.gprj.user

*.vcd
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changes

[20.03.2024]
- Add CHANGELOG.md
- Set device in nestang_nano20k.gprj
- Add mapLoopy.v to nestang_nano20k.gprj
- Add mapLoopy.v to nestang_primer25k.gprj
- Add NESGamepad.v to nestang_primer25k.gprj
- Add guards for NESGamepad (only supported by Nano20k)

# ToDo
22 changes: 20 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@

## Version history for NESTang - an NES emulator for Tang Primer 20K

v0.8rc, 10/31/2023 - The Tang Primer 25k release
v0.11, 2/06/20024
- Add a "Select core" menu item to switch between snestang and nestang cores. To enable it, just put the .bin core files in the /cores directory.

v0.10, 23/05/2024
- Support SNES/NES controller, in addition to DS2.

v0.9, 7/04/2024
- This version adds the iosys softcore, which snestang has used for a while.
- Directory support.
- SD cards larger than 32GB with exFAT file system is supported.
- In-game OSD. Press SELECT-RIGHT to activate.
- A transparency effect for OSD.
- One firmware supports both cores. The firmware in snestang repo is updated to recognize the nestang core.
- Support Tang PMOD TFCARD v2, instead of the old TFCARD v1.

v0.8, 1/4/2024
- Supports the Sipeed Tang SDRAM v1.2 modules (v0.8rc was for MiSTer SDRAM 3.0 modules).

v0.8rc, 11/12/2023 - The Tang Primer 25k release
- This releases supports the new Tang Primer 25k, along with Tang Nano 20k.
- For primer 25k, set up the memory module, hdmi pmod, dualshock2 pmod and microsd pmod as shown in [here](doc/images/primer25k_setup.jpg).
- The primer 25k build supports the on-board USB-A port for P1, and the dualshock2 ports for P1 and P2.
@@ -46,4 +64,4 @@ v0.1.0, 9/15/2022 - Initial release
* PC-side loader program for game loading and controller input.
* Cycle accurate emulation quality.
* Needs a MiSTer SDRAM module. See [here](https://github.com/nand2mario/nestang/blob/3e79993cb50d348ecec3a7860ad9d4c9c64ea319/doc/wiring.md)
for wiring instructions.
for wiring instructions.
131 changes: 60 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,60 @@
# NESTang - FPGA NES with Sipeed Tang Nano 20K and Primer 20K Boards

<p align="right">
<a title="Releases" href="https://github.com/nand2mario/nestang/releases"><img src="https://img.shields.io/github/commits-since/nand2mario/nestang/latest.svg?longCache=true&style=flat-square&logo=git&logoColor=fff"></a>
</p>

<img src="doc/images/nestang0.5.jpg" width=400>

NESTang is an open source project to recreate the Nintendo Entertainment System (NES) with modern affordable FPGA boards including Sipeed [Tang Nano 20K](https://wiki.sipeed.com/hardware/en/tang/tang-nano-20k/nano-20k.html) and [Primer 20K](https://wiki.sipeed.com/hardware/en/tang/tang-primer-20k/primer-20k.html). The main logic comes from [fpganes](https://github.com/strigeus/fpganes), to which I have added SDRAM/DDR3 and HDMI interfaces, among other features.

Main features,

- HDMI output with a resolution of 720p and sound capabilities.
- Cycle accurate gameplay quality has been achieved since the NES circuits have been almost entirely replicated.
- Game loading via MicroSD cards (for Tang Nano 20K only) or Windows/Linux loader program.
- Playstation 2 controller or USB gamepads (for Tang Nano 20K only) or interfacing with controllers connected through a PC.

## Setup for Tang Nano 20K

The best way to experience NESTang is with the Tang Nano 20K (Retro Game Kit version), which cost $38 last time I checked. The board features FPGA-friendly SDRAM memory. And the kit includes the necessary controller adapters and a pair of controllers. Here's what you need to run NESTang:

* The Tang Nano 20K board.
* Sipeed ps2 controller adapters connected to the board's pin 15-20 on both sides. Releases since 0.6 also support [USB gamepads](doc/usb_gamepad.md).
* Playstation or USB controllers connected to the adapters.
* HDMI cable to connect the board to a monitor.
* Latest NESTang program downloaded from [github](https://github.com/nand2mario/nestang/releases) and transferred to the board using either [openFPGALoader](https://github.com/trabucayre/openFPGALoader) or Gowin programmer.
* A MicroSD card to hold ROMs. For >= 0.7, just format the SD card in FAT32 (the card should be [<=32GB](https://answers.microsoft.com/en-us/windows/forum/all/format-a-sandisk-extreme-64gb-micro-sd-card-to/ff51be64-75b9-435f-9d39-92299b9d006e)) and place all .nes roms in the root dir. You can use [DriveSort](http://www.anerty.net/software/file/DriveSort/?lang=en) or similar tools to sort the files on the card if you want them to show in order.
* For <= 0.6: The `tools/nes2img.py` python program can be used to convert .nes ROM files to an .img file. Ensure that you have Python version 3.7 or higher, and then install the Pillow package using `pip3 install pillow`. You can then use an SD imaging tool such as [Balena Etcher](https://www.balena.io/etcher) to burn the newly created image onto the MicroSD card.
* Insert the MicroSD card and power up the board to start playing your favorite games!

## Setup for Tang Primer 20K

If you own a Tang Primer 20K board, you can also run NESTang. The following components are required:

* Sipeed Tang Primer 20K board
* Muse-Lab HDMI PMod if you got the "lite" version of Tang board. You can purchase it from [aliexpress](https://www.aliexpress.com/item/3256804122775243.html) or [taobao](https://item.taobao.com/item.htm?id=671021594308). The "dock" version of the board already has an HDMI port, so there is no need for this component. The wiring instructions for the "lite" version can be found in the [doc/wiring.md](doc/wiring.md) file.

Follow the instructions below:

* Download [NESTang 0.4](https://github.com/nand2mario/nestang/releases/tag/v0.4) since later versions only support Tang Nano 20K.
* Launch the **Gowin Programmer** application and program either the `nestang-lite.fs` or `nestang-dock.fs` file, depending on your specific board. If your setup is correctly configured, a colorful NES palette should be displayed.
* Connect your game controller/controllers to your PC. I use a pair of old Xbox 360 controllers.
* Use the command `loader.exe -c COM4 games\rom.nes` (replace COM4 with your port number) to load the game `rom.nes`. If the game does not load, install [Microsoft Visual C++ Redistributable package](https://aka.ms/vs/17/release/vc_redist.x64.exe) to resolve any missing DLL errors.
* Press the left button (LB) to open the in-game OSD menu, from where you can load other games located in the `games` directory.
* If the game does not load, run `loader.exe -r game.nes` to generate error messages from the core.

Congratulations! Now you can enjoy all your favorite NES games. For version 0.4, a Linux loader program is also available. See [Linux loader](doc/linux.md) for details.

## Development

If you want to generate the bitstream from source, see [Build Instructions](https://nand2mario.github.io/nestang-doc/dev/build_bitstream/).

[Usb_hid_host](https://github.com/nand2mario/usb_hid_host) was development so NESTang could support USB gamepads. Follow the link if you want to use it for your FPGA projects. It supports keyboards and mice too.

## Next steps

See NESTang [changes.md](CHANGES.md).

Here are what I may work on when I get time. No promise though. Suggestions and pull requests are welcome!
* Cheats support.
* Saves and loads.

## Special Thanks

* [fpganes](https://github.com/strigeus/fpganes) by Ludvig Strigeus.
* [hdl-util/hdmi](https://github.com/hdl-util/hdmi) by Sameer Puri.
* [NES for Tang Nano 9K](https://github.com/hi631/tang-nano-9K) by hi631

nand2mario (`nand2mario at outlook.com`)

Since 2022.9
# NESTang - NES for Sipeed Tang FPGA Boards

<p align="right">
<a title="Releases" href="https://github.com/nand2mario/nestang/releases"><img src="https://img.shields.io/github/commits-since/nand2mario/nestang/latest.svg?longCache=true&style=flat-square&logo=git&logoColor=fff"></a>
</p>

<img src="doc/images/nestang0.8rc.jpg" width=400>

NESTang is an open source project to recreate the Nintendo Entertainment System (NES) with Sipeed Tang FPGA boards, including Sipeed [Tang Primer 25K](https://wiki.sipeed.com/hardware/en/tang/tang-primer-25k/primer-25k.html), [Tang Nano 20K](https://wiki.sipeed.com/hardware/en/tang/tang-nano-20k/nano-20k.html), [Tang Mega 60K](https://wiki.sipeed.com/hardware/en/tang/tang-mega-60k/mega-60k.html) and [Tang Primer 20K](https://wiki.sipeed.com/hardware/en/tang/tang-primer-20k/primer-20k.html).

Main features,

- 720p HDMI output with sound.
- Cycle accurate gameplay quality has been achieved since the NES circuits have been almost entirely replicated.
- Rom loading from MicroSD cards with an easy-to-use menu system, powered by a RISC-V softcore.
- Extensive mapper support including MMC5, Namco and more.
- NES/SNES controllers, or DS2 controllers.

Also check out [SNESTang](https://github.com/nand2mario/snestang) and [GBATang](https://github.com/nand2mario/gbatang).

## Getting the parts

You need either the Sipeed Tang Primer 25K or Tang Nano 20K FPGA board to run the latest NESTang.

* If you choose the Primer 25K, get the [main Primer 25K dock board](https://wiki.sipeed.com/hardware/en/tang/tang-primer-25k/primer-25k.html), [DVI PMod](https://wiki.sipeed.com/hardware/en/tang/tang-PMOD/FPGA_PMOD.html#PMOD_DVI), [TF Card PMod](https://wiki.sipeed.com/hardware/en/tang/tang-PMOD/FPGA_PMOD.html#PMOD_TF-CARD), [DS2x2 PMod](https://wiki.sipeed.com/hardware/en/tang/tang-PMOD/FPGA_PMOD.html#PMOD_DS2x2) and a [Tang SDRAM](https://wiki.sipeed.com/hardware/en/tang/tang-PMOD/FPGA_PMOD.html#TANG-40P-MODULE).
* For the Tang Nano 20K, we suggest the [Tang Nano 20K Retro Gaming Kit](https://www.amazon.com/GW2AR-18-Computer-Debugger-Multiple-Emulator/dp/B0C5XLBQ6C), as it contains the necessary controllers and adapters.

## Installation

A [step-by-step instructions](https://github.com/nand2mario/snestang/blob/main/doc/installation.md) is available. Here are quick instructions for the more experienced,

* Assemble the board and modules: [result for the primer 25k](https://github.com/nand2mario/snestang/raw/main/doc/images/primer25k_setup.jpg), and [nano 20k](https://github.com/nand2mario/snestang/raw/main/doc/images/nano20k_setup.jpg).
* Download a NESTang release from [github](https://github.com/nand2mario/nestang/releases). The bitstream (`nestang_*.fs`) should be written to flash at address 0. The firmware (`firmware.bin`) should be written to 0x500000 (5MB). See this [screenshot](https://github.com/nand2mario/snestang/blob/main/doc/images/programmer_firmware.png) for how to do it.
* Put your ROM files onto a MicroSD Card (exFAT or FAT32 file system). Insert the card, connect an HDMI monitor or TV, and enjoy your games.

Version 0.4 also supports [tang primer 20k](doc/primer20k.md).

## Development

If you want to generate the bitstream from source, see [Build Instructions](https://nand2mario.github.io/nestang-doc/dev/build_bitstream/). Make sure you use the Gowin IDE version 1.9.9 commercial (requires a free license).

[Usb_hid_host](https://github.com/nand2mario/usb_hid_host) was development so NESTang could support USB gamepads. Follow the link if you want to use it for your FPGA projects. It supports keyboards and mice too.

## Next steps

See NESTang [changes.md](CHANGES.md).

Here are what I may work on when I get time. No promise though. Suggestions and pull requests are welcome!
* Cheats support.
* Saves and loads.

## Special Thanks

* [fpganes](https://github.com/strigeus/fpganes) by Ludvig Strigeus.
* [hdl-util/hdmi](https://github.com/hdl-util/hdmi) by Sameer Puri.
* [NES for Tang Nano 9K](https://github.com/hi631/tang-nano-9K) by hi631

nand2mario (`nand2mario at outlook.com`)

Since 2022.9
111 changes: 93 additions & 18 deletions build.tcl
Original file line number Diff line number Diff line change
@@ -1,12 +1,75 @@
if {$argc == 0} {
puts "Usage: $argv0 <device> <controller>"
puts " device: nano20k, primer25k, mega60k"
puts " controller: snes, ds2"
puts "Note: nano20k supports both controllers simultaneously, so build with just: gw_sh build.tcl nano20k"
exit 1
}

set dev [lindex $argv 0]
if {$argc == 2} {
set controller [lindex $argv 1]
} else {
set controller ""
}

# process $dev and $controller
if {$dev eq "nano20k"} {
set_device GW2AR-LV18QN88C8/I7 -device_version C
add_file src/nano20k/config.v
add_file -type cst "src/nano20k/nestang.cst"
add_file -type verilog "src/nano20k/gowin_pll_hdmi.v"
add_file -type verilog "src/nano20k/gowin_pll_nes.v"
add_file -type sdc "src/nano20k/nestang.sdc"
# nano20k supports both controllers simultaneously
set_option -output_base_name nestang_${dev}
} elseif {$dev eq "primer25k"} {
set_device GW5A-LV25MG121NC1/I0 -device_version A
if {$controller eq "snes"} {
add_file src/primer25k/config_snescontroller.v
add_file -type cst "src/primer25k/nestang_snescontroller.cst"
} elseif {$controller eq "ds2"} {
add_file src/primer25k/config.v
add_file -type cst "src/primer25k/nestang.cst"
} else {
error "Unknown controller $controller"
}
add_file -type verilog "src/primer25k/gowin_pll_27.v"
add_file -type verilog "src/primer25k/gowin_pll_hdmi.v"
add_file -type verilog "src/primer25k/gowin_pll_nes.v"
add_file -type sdc "src/primer25k/nestang.sdc"
set_option -output_base_name nestang_${dev}_${controller}
} elseif {$dev eq "mega60k"} {
set_device GW5AT-LV60PG484AC1/I0 -device_version B
if {$controller eq "snes"} {
add_file src/mega60k/config_snescontroller.v
add_file -type cst "src/mega60k/nestang_snescontroller.cst"
} elseif {$controller eq "ds2"} {
add_file src/mega60k/config.v
add_file -type cst "src/mega60k/nestang.cst"
} else {
error "Unknown controller $controller"
}
# mega60k uses the same PLL as primer25k
add_file -type verilog "src/primer25k/gowin_pll_27.v"
add_file -type verilog "src/primer25k/gowin_pll_hdmi.v"
add_file -type verilog "src/primer25k/gowin_pll_nes.v"
add_file -type sdc "src/primer25k/nestang.sdc"
set_option -output_base_name nestang_${dev}_${controller}
} else {
error "Unknown device $dev"
}

add_file -type verilog "src/MicroCode.v"
add_file -type verilog "src/apu.v"
add_file -type verilog "src/autofire.v"
add_file -type verilog "src/cart.sv"
add_file -type verilog "src/compat.v"
add_file -type verilog "src/cpu.v"
add_file -type verilog "src/controller_snes.v"
add_file -type verilog "src/controller_ds2.sv"
add_file -type verilog "src/dpram.v"
add_file -type verilog "src/dualshock_controller.v"
add_file -type verilog "src/EEPROM_24C0x.sv"
add_file -type verilog "src/game_loader.v"
add_file -type verilog "src/gowin_clkdiv.v"
add_file -type verilog "src/hdmi2/audio_clock_regeneration_packet.sv"
add_file -type verilog "src/hdmi2/audio_info_frame.sv"
add_file -type verilog "src/hdmi2/audio_sample_packet.sv"
@@ -17,39 +80,51 @@ add_file -type verilog "src/hdmi2/packet_picker.sv"
add_file -type verilog "src/hdmi2/serializer.sv"
add_file -type verilog "src/hdmi2/source_product_description_info_frame.sv"
add_file -type verilog "src/hdmi2/tmds_channel.sv"
add_file -type verilog "src/hw_sound.v"
add_file -type verilog "src/hw_uart.v"
add_file -type verilog "src/memory_controller.v"
add_file -type verilog "src/mmu.v"
add_file -type verilog "src/iosys/gowin_dpb_menu.v"
add_file -type verilog "src/iosys/iosys.v"
add_file -type verilog "src/iosys/picorv32.v"
add_file -type verilog "src/iosys/simplespimaster.v"
add_file -type verilog "src/iosys/simpleuart.v"
add_file -type verilog "src/iosys/spi_master.v"
add_file -type verilog "src/iosys/spiflash.v"
add_file -type verilog "src/iosys/textdisp.v"
add_file -type verilog "src/mappers/generic.sv"
add_file -type verilog "src/mappers/iir_filter.v"
add_file -type verilog "src/mappers/JYCompany.sv"
add_file -type verilog "src/mappers/misc.sv"
add_file -type verilog "src/mappers/MMC1.sv"
add_file -type verilog "src/mappers/MMC2.sv"
add_file -type verilog "src/mappers/MMC3.sv"
add_file -type verilog "src/mappers/MMC5.sv"
add_file -type verilog "src/mappers/Namco.sv"
add_file -type verilog "src/mappers/Sachen.sv"
add_file -type verilog "src/mappers/Sunsoft.sv"
add_file -type verilog "src/nes.v"
add_file -type verilog "src/nes2hdmi.sv"
add_file -type verilog "src/nestang_top.sv"
add_file -type verilog "src/ppu.v"
add_file -type verilog "src/sd_file_list_reader.v"
add_file -type verilog "src/sd_loader.v"
add_file -type verilog "src/sd_reader.sv"
add_file -type verilog "src/sdcmd_ctrl.sv"
add_file -type verilog "src/sdram.v"
add_file -type verilog "src/sdram_nes.v"
add_file -type verilog "src/t65/T65.v"
add_file -type verilog "src/t65/T65_ALU.v"
add_file -type verilog "src/t65/T65_MCode.v"
add_file -type verilog "src/t65/T65_Pack.v"
add_file -type verilog "src/uart_tx_V2.v"
add_file -type verilog "src/usb_hid_host.v"
add_file -type verilog "src/usb_hid_host_rom.v"

if {$dev eq "nano20k"} {
set_device GW2AR-LV18QN88C8/I7 -device_version C
} elseif {$dev eq "primer25k"} {
set_device GW5A-LV25MG121NC1/I0 -device_version A
}

set_option -synthesis_tool gowinsynthesis
set_option -output_base_name nestang_$dev
set_option -top_module nestang_top
set_option -verilog_std sysv2017
set_option -rw_check_on_ram 1
set_option -place_option 2
set_option -use_mspi_as_gpio 1
set_option -use_ready_as_gpio 1
set_option -use_done_as_gpio 1
set_option -use_i2c_as_gpio 1
set_option -use_cpu_as_gpio 1
set_option -use_sspi_as_gpio 1

set_option -multi_boot 1

run all
29 changes: 29 additions & 0 deletions buildall.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

@echo off
set GWSH=..\..\Gowin_V1.9.9_x64\IDE\bin\gw_sh
set GWSH_NEW=..\..\Gowin_V1.9.10.03_x64\IDE\bin\gw_sh

echo.
echo ============ Building nano20k ===============
echo.
%GWSH% build.tcl nano20k

echo.
echo ============ Building primer25k with snes/nes controller ===============
echo.
%GWSH% build.tcl primer25k snes

echo.
echo ============ Building primer25k with ds2 controller ===============
echo.
%GWSH% build.tcl primer25k ds2

echo.
echo ============ Building mega60k with ds2 controller ===============
echo.
%GWSH_NEW% build.tcl mega60k ds2

dir impl\pnr\*.fs

echo "All done."

Loading