Skip to content

Commit

Permalink
Tn9k (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
vossstef authored Dec 15, 2024
1 parent cb771bf commit d4ff492
Show file tree
Hide file tree
Showing 21 changed files with 9,082 additions and 27 deletions.
Binary file added .assets/tn9k.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .assets/vic20_tn9k_rework.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2,087 changes: 2,087 additions & 0 deletions .assets/vic20_tn9k_rework.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
561 changes: 561 additions & 0 deletions .assets/vic20_tn9k_top.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions INSTALLATION_WINDOWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ should see following screen:**
| Type | TN20k | TP20k |TP25k | TM138k |TM60k | |
| FPGA bitstream | 0x000000 | 0x000000 | 0x000000 | 0x000000 |0x000000|ROM size |

For the TN9k there might be an older version of the programmer SW be needed.

**shell / command line Programming alternative**

Windows shell and Gowin Programmer<br>
```programmer_cli -r 36 --fsFile a2600nano_tn9k.fs --cable-index 1 --d GW1NR-9C```<br>
```programmer_cli -r 36 --fsFile a2600nano_tn20k.fs --spiaddr 0x000000 --cable-index 1 --d GW2AR-18C```<br>
```programmer_cli -r 36 --fsFile a2600nano_tp20k.fs --spiaddr 0x000000 --cable-index 1 --d GW2A-18C```<br>
```programmer_cli -r 36 --fsFile a2600nano_tp25k.fs --spiaddr 0x000000 --cable-index 1 --d GW5A-25A```<br>
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ The A2600Nano is a port of the [MiSTer](https://github.com/MiSTer-devel/Atari260

| Board | FPGA | support |Note|
| --- | - | - |-|
| [Tang Nano 9k](https://wiki.sipeed.com/hardware/en/tang/Tang-Nano-9K/Nano-9K.html) | [GW1NR](https://www.gowinsemi.com/en/product/detail/38/) |X |micro SD card [HW modification](TANG_NANO_9K.md#hw-modification) needed|
| [Tang Nano 20k](https://wiki.sipeed.com/nano20k) | [GW2AR](https://www.gowinsemi.com/en/product/detail/38/) | X |- |
| [Tang Primer 20K Dock ext Board](https://wiki.sipeed.com/hardware/en/tang/tang-primer-20k/primer-20k.html)| [GW2A](https://www.gowinsemi.com/en/product/detail/46/)| X |double Dualshock |
| [Tang Primer 25K](https://wiki.sipeed.com/hardware/en/tang/tang-primer-25k/primer-25k.html) | [GW5A-25](https://www.gowinsemi.com/en/product/detail/60/) | X |no Dualshock, no retro D9 Joystick |
Expand Down Expand Up @@ -46,6 +47,9 @@ Planned features:
HID interfaces aligned in pinmap and control to match [FPGA-Companion](https://github.com/harbaum/FPGA-Companion).<br> Basically a µC M0S/BL616 / Raspberry Pi Pico RP2040 / ESP32-S2/S3 acts as USB host for USB devices and as an OSD controller using a [SPI communication protocol](https://github.com/harbaum/MiSTeryNano/blob/main/SPI.md).
<br>

## A2600Nano on Tang Nano 9K
See [Tang Nano 9K](TANG_NANO_9K.md)

## A2600Nano on Tang Primer 20K (Dock ext board)
See [Tang Primer 20K](TANG_PRIMER_20K.md)<br>

Expand Down Expand Up @@ -152,8 +156,8 @@ You have first to set the DS2 Sticks into analog mode by pressing the DS2 ANALOG

| LED | function | TN20K | TP20K | TP25K | TM60K |TM138k|
| --- | - | - |- | - | - | - |
| 0 |Cartridge selected| x |- | x | x | x |
| 1 | reserved | x |x | unsup | x |unsup|
| 0 |Cartridge selected| x |x | x | x | x |
| 1 | reserved | x |x | x | x | x |
| 2 | Game unsupported | x |x | - | x | - |
| 3 | Game unsupported | x |x | - | x | - |
| 4 | Game unsupported | x |x | - | x | - |
Expand Down
67 changes: 67 additions & 0 deletions TANG_NANO_9K.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# A2600Nano on Tang Nano 9K

A2600Nano can be used in the [Tang Nano 9k](https://wiki.sipeed.com/hardware/en/tang/Tang-Nano-9K/Nano-9K.html).

The whole setup will look like this:<br>
![A2600Nano on TN9K](./.assets/tn9k.png)


**D9 retro Joystick Interface**

|Bus|Signal| D9 |TN9k pin| FPGA Signal |
| - |------|-------------------|-|-------|
| 0 | Trigger | - |27| Trigger |
| 1 | Down | - |28| Down |
| 2 | Up | - |25| Up |
| 3 | Right | - |26 | Right |
| 4 | Left | - |29 | Left |
| - | GND | - |GND | GND |

**Pinmap Dualshock 2 Controller Interface** <br>
<img src="./.assets/controller-pinout.jpg" alt="image" width="30%" height="auto">
| DS pin | TN9 pin | Signal | DS Function |
| ----------- | --- | -------- | ----- |
| 1 | 54 | MISO | JOYDAT |
| 2 | 53 | MOSI | JOYCMD |
| 3 | n.c. | - | 7V5 |
| 4 | | GND | GND |
| 5 | | 3V3 | 3V3 |
| 6 | 55 | CS | JOYATN|
| 7 | 51 | MCLK | JOYCLK |
| 8 | n.c. | - | JOYIRQ |
| 9 | n.c. | - | JOYACK |

**M0S Dock BL616 µC**

|Bus|M0S Signal|M0S Pin|TN9k pin | Signal |
| - |------ |-------------------|-------------------|--------------------------------------|
| - | +5V | +5V | 5V | 5V |
| - | +3V3 | +3V3 | n.c | don't connect ! |
| - | GND | GND | GND | GND |
| - | GND | GND | GND | GND |
| 5 | - | - | 41 | don't connect |
| 4 | IRQn | GPIO14 | 35 | Interrupt from FPGA to MCU|
| 3 | SCK | GPIO13 | 40 | SPI clock, idle low |
| 2 | CSn | GPIO12 | 34 | SPI select, active low |
| 1 | MOSI | GPIO11 | 33 | SPI data from MCU to FPGA |
| 0 | MISO | GPIO10 | 30 | SPI data from FPGA to MCU |


On the software side the setup is very simuilar to the original Tang Nano 20K based solution. The core needs to be built specifically
for the different FPGA of the Tang Primer using either the [TCL script with the GoWin command line interface](build_tn9k.tcl) or the
[project file for the graphical GoWin IDE](vic20nano_tn9k.gprj). The resulting bitstream is flashed to the TN9K as usual.

You might need to use an older version of the Gowin Programmer [SW](https://dl.sipeed.com/shareURL/TANG/programmer) for the GW1NR device.<br>
```programmer_cli -r 38 --mcuFile 32k.bin --spiaddr 0x000000 --cable-index 1 --d GW1NR-9C```

And also the firmware for the M0S Dock is the [same version as for
the Tang Nano 20K](https://github.com/harbaum/MiSTeryNano/tree/main/firmware/misterynano_fw/).

# HW modification

Mandatory HW modification TN9K needed to fully support micro SD Card in 4bit data transfer mode.<br>
Rework place with Soldering Iron and a Microscope or magnifying glass needed.<br>
- **SD Card Data 1**<br>Wire SD card holder SD_dat1 pin 8 to TN9k FPGA pin 48. SPI LCD interface will be blocked by that.<br>
- **SD Card Data 2**<br>Wire SD card holder SD_dat2 pin 1 to TN9k FPGA pin 49. SPI LCD interface will be blocked by that.<br>

![TN9K rework](./.assets/vic20_tn9k_rework.png)
53 changes: 53 additions & 0 deletions a2600nano_tn9k.gprj
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1" encoding="UTF-8"?>
<!DOCTYPE gowin-fpga-project>
<Project>
<Template>FPGA</Template>
<Version>5</Version>
<Device name="GW1NR-9C" pn="GW1NR-LV9QN88PC6/I5">gw1nr9c-004</Device>
<FileList>
<File path="src/detect2600.sv" type="file.verilog" enable="1"/>
<File path="src/dualshock2.v" type="file.verilog" enable="1"/>
<File path="src/gowin_dpb/gowin_dpb_track_buffer_b.v" type="file.verilog" enable="1"/>
<File path="src/gowin_dpb/sector_dpram.v" type="file.verilog" enable="1"/>
<File path="src/hdmi/audio_clock_regeneration_packet.sv" type="file.verilog" enable="1"/>
<File path="src/hdmi/audio_info_frame.sv" type="file.verilog" enable="1"/>
<File path="src/hdmi/audio_sample_packet.sv" type="file.verilog" enable="1"/>
<File path="src/hdmi/auxiliary_video_information_info_frame.sv" type="file.verilog" enable="1"/>
<File path="src/hdmi/hdmi.sv" type="file.verilog" enable="1"/>
<File path="src/hdmi/packet_assembler.sv" type="file.verilog" enable="1"/>
<File path="src/hdmi/packet_picker.sv" type="file.verilog" enable="1"/>
<File path="src/hdmi/serializer.sv" type="file.verilog" enable="1"/>
<File path="src/hdmi/source_product_description_info_frame.sv" type="file.verilog" enable="1"/>
<File path="src/hdmi/tmds_channel.sv" type="file.verilog" enable="1"/>
<File path="src/loader_sd_card.sv" type="file.verilog" enable="1"/>
<File path="src/misc/hid.v" type="file.verilog" enable="1"/>
<File path="src/misc/mcu_spi.v" type="file.verilog" enable="1"/>
<File path="src/misc/osd_u8g2.v" type="file.verilog" enable="1"/>
<File path="src/misc/scandoubler.v" type="file.verilog" enable="1"/>
<File path="src/misc/sd_card.v" type="file.verilog" enable="1"/>
<File path="src/misc/sd_rw.v" type="file.verilog" enable="1"/>
<File path="src/misc/sdcmd_ctrl.v" type="file.verilog" enable="1"/>
<File path="src/misc/sysctrl.v" type="file.verilog" enable="1"/>
<File path="src/misc/video.v" type="file.verilog" enable="1"/>
<File path="src/misc/video_analyzer.v" type="file.verilog" enable="1"/>
<File path="src/misc/ws2812.v" type="file.verilog" enable="1"/>
<File path="src/video_stabilize.sv" type="file.verilog" enable="1"/>
<File path="src/A2601Core.vhd" type="file.vhdl" enable="1"/>
<File path="src/A2601top.vhd" type="file.vhdl" enable="1"/>
<File path="src/A6507.vhd" type="file.vhdl" enable="1"/>
<File path="src/A6532.vhd" type="file.vhdl" enable="1"/>
<File path="src/TIA/Common.vhd" type="file.vhdl" enable="1"/>
<File path="src/TIA/NTSCLookups.vhd" type="file.vhdl" enable="1"/>
<File path="src/TIA/TIA.vhd" type="file.vhdl" enable="1"/>
<File path="src/TIA/VGAColorTable.vhd" type="file.vhdl" enable="1"/>
<File path="src/TIA/audio_argh2600.vhd" type="file.vhdl" enable="1"/>
<File path="src/a2600_top_tn9k.vhd" type="file.vhdl" enable="1"/>
<File path="src/gowin_sdpb/gowin_sdpb_tn9k.vhd" type="file.vhdl" enable="1"/>
<File path="src/t65/T65.vhd" type="file.vhdl" enable="1"/>
<File path="src/t65/T65_ALU.vhd" type="file.vhdl" enable="1"/>
<File path="src/t65/T65_MCode.vhd" type="file.vhdl" enable="1"/>
<File path="src/t65/T65_Pack.vhd" type="file.vhdl" enable="1"/>
<File path="src/a2600_top_tn9k.cst" type="file.cst" enable="1"/>
<File path="src/a2600_top_tn9k.sdc" type="file.sdc" enable="1"/>
</FileList>
</Project>
32 changes: 32 additions & 0 deletions build_all.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

@echo off
set GWSH=C:\Gowin\Gowin_V1.9.10.03_x64\IDE\bin\gw_sh

echo.
echo ============ build mega138k pro ===============
echo.
%GWSH% build_tm138k_pro.tcl
echo.
echo ============ build mega 60k ===============
echo.
%GWSH% build_tm60k.tcl
echo.
echo ============ build primer 25k ===============
echo.
%GWSH% build_tp25k.tcl
echo.
echo ============ build nano 20k ===============
echo.
%GWSH% build_tn20k.tcl
echo.
echo ============ build primer 20k ===============
echo.
%GWSH% build_tp20k.tcl
echo.
echo ============ build nano 9k ===============
echo.
%GWSH% build_tn9k.tcl

echo "done."
dir impl\pnr\*.fs

10 changes: 10 additions & 0 deletions build_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

rm -f impl/pnr/*.fs

grc --config=gw_sh.grc gw_sh ./build_tm138k_pro.tcl
grc --config=gw_sh.grc gw_sh ./build_tm60k.tcl
grc --config=gw_sh.grc gw_sh ./build_tp25k.tcl
grc --config=gw_sh.grc gw_sh ./build_tn20k.tcl
grc --config=gw_sh.grc gw_sh ./build_tp20k.tcl
grc --config=gw_sh.grc gw_sh ./build_tn9k.tcl
61 changes: 61 additions & 0 deletions build_tn9k.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
set_device GW1NR-LV9QN88PC6/I5 -name GW1NR-9C

add_file src/dualshock2.v
add_file src/gowin_dpb/gowin_dpb_track_buffer_b.v
add_file src/gowin_dpb/sector_dpram.v
add_file src/hdmi/audio_clock_regeneration_packet.sv
add_file src/hdmi/audio_info_frame.sv
add_file src/hdmi/audio_sample_packet.sv
add_file src/hdmi/auxiliary_video_information_info_frame.sv
add_file src/hdmi/hdmi.sv
add_file src/hdmi/packet_assembler.sv
add_file src/hdmi/packet_picker.sv
add_file src/hdmi/serializer.sv
add_file src/hdmi/source_product_description_info_frame.sv
add_file src/hdmi/tmds_channel.sv
add_file src/misc/hid.v
add_file src/misc/mcu_spi.v
add_file src/misc/osd_u8g2.v
add_file src/misc/scandoubler.v
add_file src/misc/sd_card.v
add_file src/misc/sd_rw.v
add_file src/misc/sdcmd_ctrl.v
add_file src/misc/sysctrl.v
add_file src/misc/video.v
add_file src/misc/video_analyzer.v
add_file src/misc/ws2812.v
add_file src/t65/T65.vhd
add_file src/t65/T65_ALU.vhd
add_file src/t65/T65_MCode.vhd
add_file src/t65/T65_Pack.vhd
add_file src/loader_sd_card.sv
add_file src/A2601Core.vhd
add_file src/A2601top.vhd
add_file src/A6507.vhd
add_file src/A6532.vhd
add_file src/TIA/Common.vhd
add_file src/TIA/NTSCLookups.vhd
add_file src/TIA/TIA.vhd
add_file src/TIA/VGAColorTable.vhd
add_file src/TIA/audio_argh2600.vhd
add_file src/gowin_sdpb/gowin_sdpb_tn9k.vhd
add_file src/a2600_top_tn9k.vhd
add_file src/a2600_top_tn9k.cst
add_file src/a2600_top_tn9k.sdc
add_file src/video_stabilize.sv
add_file src/detect2600.sv

set_option -synthesis_tool gowinsynthesis
set_option -output_base_name a2600nano_tn9k
set_option -verilog_std sysv2017
set_option -vhdl_std vhd2008
set_option -top_module A2600_top
set_option -use_mspi_as_gpio 1
set_option -use_sspi_as_gpio 1
set_option -print_all_synthesis_warning 1
set_option -rw_check_on_ram 0
set_option -user_code 00000001
set_option -bit_security 0

#run syn
run all
11 changes: 11 additions & 0 deletions gw_sh.grc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# NOTE lines
regexp=^NOTE.*
colour=green
-
# WARNing lines
regexp=^WARN.*
colour=yellow
-
# ERROR lines
regexp=^ERROR.*
colour=red
92 changes: 92 additions & 0 deletions impl/a2600nano_tn9k_process_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"BACKGROUND_PROGRAMMING" : "off",
"COMPRESS" : false,
"CPU" : false,
"CRC_CHECK" : true,
"Clock_Route_Order" : 0,
"Convert_SDP32_36_to_SDP16_18" : true,
"Correct_Hold_Violation" : true,
"DONE" : true,
"DOWNLOAD_SPEED" : "default",
"Disable_Insert_Pad" : false,
"ENABLE_CTP" : false,
"ENABLE_MERGE_MODE" : false,
"ENCRYPTION_KEY" : false,
"ENCRYPTION_KEY_TEXT" : "00000000000000000000000000000000",
"ERROR_DECTION_AND_CORRECTION" : false,
"ERROR_DECTION_ONLY" : false,
"ERROR_INJECTION" : false,
"EXTERNAL_MASTER_CONFIG_CLOCK" : false,
"Enable_DSRM" : false,
"FORMAT" : "binary",
"FREQUENCY_DIVIDER" : "",
"Generate_Constraint_File_of_Ports" : false,
"Generate_IBIS_File" : false,
"Generate_Plain_Text_Timing_Report" : false,
"Generate_Post_PNR_Simulation_Model_File" : false,
"Generate_Post_Place_File" : false,
"Generate_SDF_File" : false,
"Generate_VHDL_Post_PNR_Simulation_Model_File" : false,
"Global_Freq" : "default",
"GwSyn_Loop_Limit" : 2000,
"HOTBOOT" : false,
"I2C" : false,
"I2C_SLAVE_ADDR" : "00",
"INCREMENTAL_PLACE_AND_ROUTING" : "0",
"INCREMENTAL_PLACE_ONLY" : "0",
"IncludePath" : [

],
"Incremental_Compile" : "",
"Initialize_Primitives" : false,
"JTAG" : false,
"MODE_IO" : false,
"MSPI" : true,
"MSPI_JUMP" : false,
"MULTIBOOT_ADDRESS_WIDTH" : "24",
"MULTIBOOT_MODE" : "Normal",
"MULTIBOOT_SPI_FLASH_ADDRESS" : "00000000",
"MULTIJUMP_ADDRESS_WIDTH" : "24",
"MULTIJUMP_MODE" : "Normal",
"MULTIJUMP_SPI_FLASH_ADDRESS" : "000000",
"Multi_Boot" : false,
"OUTPUT_BASE_NAME" : "a2600nano_tn9k",
"POWER_ON_RESET_MONITOR" : true,
"PRINT_BSRAM_VALUE" : false,
"PROGRAM_DONE_BYPASS" : false,
"PlaceInRegToIob" : true,
"PlaceIoRegToIob" : true,
"PlaceOutRegToIob" : true,
"Place_Option" : "0",
"Process_Configuration_Verion" : "1.0",
"Promote_Physical_Constraint_Warning_to_Error" : true,
"READY" : true,
"RECONFIG_N" : false,
"Ram_RW_Check" : false,
"Replicate_Resources" : false,
"Report_Auto-Placed_Io_Information" : false,
"Route_Maxfan" : 23,
"Route_Option" : "0",
"Run_Timing_Driven" : true,
"SECURE_MODE" : false,
"SECURITY_BIT" : true,
"SEU_HANDLER" : false,
"SEU_HANDLER_CHECKSUM" : false,
"SEU_HANDLER_MODE" : "auto",
"SSPI" : true,
"STOP_SEU_HANDLER" : false,
"Show_All_Warnings" : false,
"Synthesize_tool" : "GowinSyn",
"TclPre" : "",
"TopModule" : "A2600_top",
"USERCODE" : "00000001",
"Unused_Pin" : "As_input_tri_stated_with_pull_up",
"VCC" : "1.2",
"VCCAUX" : 3.3,
"VCCX" : "3.3",
"VHDL_Standard" : "VHDL_Std_2008",
"Verilog_Standard" : "Vlg_Std_Sysv2017",
"WAKE_UP" : "0",
"show_all_warnings" : true,
"turn_off_bg" : false
}
Loading

0 comments on commit d4ff492

Please sign in to comment.