Skip to content

Commit

Permalink
tm60 fix (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
vossstef authored Dec 1, 2024
1 parent 0203e41 commit b1b750a
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 74 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Enable REU, select c1541 CBM DOS ROM and load the PRG.<br>

## Push Button / DIP Switch utilization
* Nano 20k S2 keep pressed during power-up for FLASH programming of FPGA bitstream<br>
* Mega 60k NEO ```SW1 ON``` ```SW6 ON``` + Press & **Hold** ```RECONFIG``` + Power the Board + connect USB programmer cable + release ```RECONFIG``` and perform programming.
* Mega 60k NEO ```SW1 ON``` ```SW6 ON``` + Unplug 12V Power + Unplug USB Programmer + Disconnect HDMI + Press & **Hold** ```RECONFIG``` + Power the Board + connect USB programmer cable + release ```RECONFIG``` and perform programming. + Reconnect cables.
> [!CAUTION]
A FLASH programm attempt without keeping the board in reset may lead to corruption of the C1541 DOS images stored in FLASH requiring re-programming.
* S1 swap the Joystick Ports if OSD **Swap Joys** is set to Off mode.<br>
Expand Down
3 changes: 3 additions & 0 deletions simulation/sim.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rmdir /s /q sim
if not exist sim\ mkdir sim
vsim -do sim_dualshock.do
47 changes: 34 additions & 13 deletions src/tang_nano_20k_c64_top_138k.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ signal detach_reset_d : std_logic;
signal detach_reset : std_logic;
signal detach : std_logic;
signal coldboot : std_logic;
signal disk_pause : std_logic;

-- 64k core ram 0x000000
-- cartridge RAM banks are mapped to 0x010000
Expand Down Expand Up @@ -595,7 +596,27 @@ gamepad_p2: entity work.dualshock2
end if;
end process;

disk_reset <= c1541_osd_reset or not reset_n or c1541_reset or not flash_lock;
-- delay disk start to keep loader at power-up intact
process(clk32, por)
variable pause_cnt : integer range 0 to 2147483647;
begin
if por = '1' then
disk_pause <= '1';
pause_cnt := 34000000;
elsif rising_edge(clk32) then
if pause_cnt /= 0 then
pause_cnt := pause_cnt - 1;
end if;
end if;

if pause_cnt = 0 then
disk_pause <= '0';
else
disk_pause <= '1';
end if;
end process;

disk_reset <= '1' when disk_pause or c1541_osd_reset or not reset_n or por or c1541_reset else '0';

-- rising edge sd_change triggers detection of new disk
process(clk32, pll_locked)
Expand Down Expand Up @@ -645,7 +666,7 @@ port map
(
clk32 => clk32,
reset => disk_reset,
pause => c64_pause or loader_busy,
pause => loader_busy,
ce => '0',

disk_num => (others =>'0'),
Expand Down Expand Up @@ -685,9 +706,9 @@ port map
c1541rom_data => c1541rom_data
);

sd_lba <= loader_lba when loader_busy = '1' else loader_lba when img_present = '0' else disk_lba;
sd_rd(0) <= c1541_sd_rd when img_present = '1' else '0';
sd_wr(0) <= c1541_sd_wr when img_present = '1' else '0';
sd_lba <= loader_lba when loader_busy = '1' else disk_lba;
sd_rd(0) <= c1541_sd_rd;
sd_wr(0) <= c1541_sd_wr;
ext_en <= '1' when dos_sel(0) = '0' else '0'; -- dolphindos, speeddos
sdc_iack <= int_ack(3);

Expand Down Expand Up @@ -833,7 +854,7 @@ clk_switch_2: DCS
CLKOUT => clk64 -- switched clock
);

pll_locked <= pll_locked_pal and pll_locked_ntsc;
pll_locked <= pll_locked_pal and pll_locked_ntsc and flash_lock;
dcsclksel <= "0001" when ntscMode = '0' else "0010";

clk_switch_1: DCS
Expand Down Expand Up @@ -984,28 +1005,28 @@ pot4 <= pd2 when joyswap = '1' else pd4;

-- paddle - mouse - GS controller 2nd button and 3rd button
pd1 <= not paddle_1 when port_1_sel = "0110" else
not paddle_1 when port_1_sel = "1011" else
not paddle_3 when port_1_sel = "1011" else
joystick1_x_pos(7 downto 0) when port_1_sel = "0111" else
('0' & std_logic_vector(mouse_x_pos(6 downto 1)) & '0') when port_1_sel = "0101" else
x"ff" when unsigned(port_1_sel) < 5 and joyA(5) = '1' else
x"ff" when unsigned(port_1_sel) = "1010" and joyA(5) = '1' else
x"00";
pd2 <= not paddle_2 when port_1_sel = "0110" else
not paddle_2 when port_1_sel = "1011" else
not paddle_4 when port_1_sel = "1011" else
joystick1_y_pos(7 downto 0) when port_1_sel = "0111" else
('0' & std_logic_vector(mouse_y_pos(6 downto 1)) & '0') when port_1_sel = "0101" else
x"ff" when unsigned(port_1_sel) < 5 and joyA(6) = '1' else
x"ff" when unsigned(port_1_sel) = "1010" and joyA(6) = '1' else
x"00";
pd3 <= not paddle_3 when port_2_sel = "1011" else
not paddle_3 when port_2_sel = "0110" else
not paddle_1 when port_2_sel = "0110" else
joystick2_x_pos(7 downto 0) when port_2_sel = "1000" else
('0' & std_logic_vector(mouse_x_pos(6 downto 1)) & '0') when port_2_sel = "0101" else
x"ff" when unsigned(port_2_sel) < 5 and joyB(5) = '1' else
x"ff" when unsigned(port_2_sel) = "1010" and joyB(5) = '1' else
x"00";
pd4 <= not paddle_4 when port_2_sel = "1011" else
not paddle_4 when port_2_sel = "0110" else
not paddle_2 when port_2_sel = "0110" else
joystick2_y_pos(7 downto 0) when port_2_sel = "1000" else
('0' & std_logic_vector(mouse_y_pos(6 downto 1)) & '0') when port_2_sel = "0101" else
x"ff" when unsigned(port_2_sel) < 5 and joyB(6) = '1' else
Expand Down Expand Up @@ -1186,7 +1207,7 @@ fpga64_sid_iec_inst: entity work.fpga64_sid_iec
port map
(
clk32 => clk32,
reset_n => reset_n and pll_locked and ram_ready,
reset_n => reset_n,
bios => "00",
pause => '0',
pause_out => c64_pause,
Expand Down Expand Up @@ -1435,7 +1456,7 @@ end generate;
crt_inst : entity work.loader_sd_card
port map (
clk => clk32,
system_reset => system_reset,
system_reset => unsigned'(por & por),

sd_lba => loader_lba,
sd_rd => sd_rd(5 downto 1),
Expand All @@ -1456,7 +1477,7 @@ port map (
load_flt => load_flt,
sd_img_size => sd_img_size,
leds => leds(5 downto 1),
img_select => img_select,
img_select => open,

ioctl_download => ioctl_download,
ioctl_addr => ioctl_addr,
Expand Down
50 changes: 21 additions & 29 deletions src/tang_nano_20k_c64_top_25k.cst
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//Copyright (C)2014-2023 Gowin Semiconductor Corporation.
//All rights reserved.
//File Title: Physical Constraints file
//GOWIN Version: 1.9.8.11 Education
//Part Number: GW2AR-LV18QN88C8/I7
//Device: GW2AR-18
//Device Version: C
//Created Time: Wed 10 25 23:26:16 2023

// tang onboard bl616 µc uart
IO_LOC "uart_rx" B3;
Expand Down Expand Up @@ -45,13 +37,13 @@ IO_PORT "mspi_clk" PULL_MODE=NONE IO_TYPE=LVCMOS33;

// M0S PMOD
IO_LOC "m0s[0]" A10;
IO_PORT "m0s[0]" PULL_MODE=NONE IO_TYPE=LVCMOS33;
IO_PORT "m0s[0]" PULL_MODE=UP IO_TYPE=LVCMOS33;
IO_LOC "m0s[1]" A11;
IO_PORT "m0s[1]" PULL_MODE=NONE IO_TYPE=LVCMOS33;
IO_PORT "m0s[1]" PULL_MODE=UP IO_TYPE=LVCMOS33;
IO_LOC "m0s[2]" E10;
IO_PORT "m0s[2]" PULL_MODE=NONE IO_TYPE=LVCMOS33;
IO_PORT "m0s[2]" PULL_MODE=UP IO_TYPE=LVCMOS33;
IO_LOC "m0s[3]" E11;
IO_PORT "m0s[3]" PULL_MODE=NONE IO_TYPE=LVCMOS33;
IO_PORT "m0s[3]" PULL_MODE=UP IO_TYPE=LVCMOS33;
IO_LOC "m0s[4]" L11;
IO_PORT "m0s[4]" PULL_MODE=UP IO_TYPE=LVCMOS33;
//IO_LOC "m0s[5]" K11; // spare
Expand All @@ -73,33 +65,33 @@ IO_PORT "clk" IO_TYPE=LVCMOS33 PULL_MODE=NONE DRIVE=OFF BANK_VCCIO=3.3;

// SDCard sipeed PMOD TFCARD v2 (newer)
IO_LOC "sd_clk" C11;
IO_PORT "sd_clk" PULL_MODE=NONE IO_TYPE=LVCMOS33;
IO_LOC "sd_cmd" D11; // MOSI
IO_PORT "sd_cmd" PULL_MODE=NONE IO_TYPE=LVCMOS33;
IO_LOC "sd_dat[0]" B11; // MISO or SD card DO, needs pull-up
IO_PORT "sd_clk" PULL_MODE=UP IO_TYPE=LVCMOS33;
IO_LOC "sd_cmd" D11;
IO_PORT "sd_cmd" PULL_MODE=UP IO_TYPE=LVCMOS33;
IO_LOC "sd_dat[0]" B11;
IO_PORT "sd_dat[0]" PULL_MODE=UP IO_TYPE=LVCMOS33;
IO_LOC "sd_dat[1]" G10; // 1
IO_PORT "sd_dat[1]" PULL_MODE=NONE IO_TYPE=LVCMOS33;
IO_LOC "sd_dat[2]" D10; // 1
IO_PORT "sd_dat[2]" PULL_MODE=NONE IO_TYPE=LVCMOS33;
IO_LOC "sd_dat[3]" G11; // 1
IO_PORT "sd_dat[3]" PULL_MODE=NONE IO_TYPE=LVCMOS33;
IO_LOC "sd_dat[1]" G10;
IO_PORT "sd_dat[1]" PULL_MODE=UP IO_TYPE=LVCMOS33;
IO_LOC "sd_dat[2]" D10;
IO_PORT "sd_dat[2]" PULL_MODE=UP IO_TYPE=LVCMOS33;
IO_LOC "sd_dat[3]" G11;
IO_PORT "sd_dat[3]" PULL_MODE=UP IO_TYPE=LVCMOS33;

// SDCard Sipeed PMOD TFCARD v1 (old outdated version)
// not working !
//
//IO_LOC "sd_clk" D10;
//IO_PORT "sd_clk" PULL_MODE=NONE IO_TYPE=LVCMOS33;
//IO_LOC "sd_cmd" D11; // MOSI
//IO_PORT "sd_cmd" PULL_MODE=NONE IO_TYPE=LVCMOS33;
//IO_LOC "sd_dat[0]" B11; // MISO or SD card DO, needs pull-up
//IO_PORT "sd_clk" PULL_MODE=UP IO_TYPE=LVCMOS33;
//IO_LOC "sd_cmd" D11;
//IO_PORT "sd_cmd" PULL_MODE=UP IO_TYPE=LVCMOS33;
//IO_LOC "sd_dat[0]" B11;
//IO_PORT "sd_dat[0]" PULL_MODE=UP IO_TYPE=LVCMOS33;
//IO_LOC "sd_dat[1]" C11;
//IO_PORT "sd_dat[1]" PULL_MODE=NONE IO_TYPE=LVCMOS33;
//IO_PORT "sd_dat[1]" PULL_MODE=UP IO_TYPE=LVCMOS33;
//IO_LOC "sd_dat[2]" G11;
//IO_PORT "sd_dat[2]" PULL_MODE=NONE IO_TYPE=LVCMOS33;
//IO_PORT "sd_dat[2]" PULL_MODE=UP IO_TYPE=LVCMOS33;
//IO_LOC "sd_dat[3]" G10;
//IO_PORT "sd_dat[3]" PULL_MODE=NONE IO_TYPE=LVCMOS33;
//IO_PORT "sd_dat[3]" PULL_MODE=UP IO_TYPE=LVCMOS33;

// Mister SDRAM v3.0 connected through 40-pin port
IO_LOC "IO_sdram_dq[0]" K2;
Expand Down
47 changes: 29 additions & 18 deletions src/tang_nano_20k_c64_top_60k.cst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ IO_LOC "reset" Y12;
IO_PORT "reset" IO_TYPE=LVCMOS15 PULL_MODE=UP DRIVE=OFF BANK_VCCIO=1.5;

IO_LOC "ws2812" J16;
IO_PORT "ws2812" PULL_MODE=NONE DRIVE=8 BANK_VCCIO=3.3;
IO_PORT "ws2812" PULL_MODE=NONE BANK_VCCIO=3.3;

//========================== MS5351 ==============================
//For dock board version V31005 or later:
Expand All @@ -37,13 +37,15 @@ IO_PORT "uart_rx" IO_TYPE=LVCMOS33;
IO_LOC "uart_tx" U15;
IO_PORT "uart_tx" IO_TYPE=LVCMOS33;

// USB-A host port
//IO_LOC "usb_dp" H13;
//IO_LOC "usb_dp" B15;
//IO_LOC "usb_dm" G13;
//IO_LOC "usb_dm" B16;
//IO_PORT "usb_dp" IO_TYPE=LVCMOS33 PULL_MODE=NONE;
//IO_PORT "usb_dm" IO_TYPE=LVCMOS33 PULL_MODE=NONE;
//====== USBA ======
//IO_LOC "USB_1_P" M15;
//IO_LOC "USB_1_N" M16;
//IO_LOC "USB_2_P" H13;
//IO_LOC "USB_2_N" G13;
//IO_PORT "USB_1_P" IO_TYPE=LVCMOS33 PULL_MODE=NONE BANK_VCCIO=3.3;
//IO_PORT "USB_1_N" IO_TYPE=LVCMOS33 PULL_MODE=NONE BANK_VCCIO=3.3;
//IO_PORT "USB_2_P" IO_TYPE=LVCMOS33 PULL_MODE=NONE BANK_VCCIO=3.3;
//IO_PORT "USB_2_N" IO_TYPE=LVCMOS33 PULL_MODE=NONE BANK_VCCIO=3.3;

// HDMI
IO_LOC "tmds_clk_p" G15,G16;
Expand All @@ -54,23 +56,32 @@ IO_LOC "tmds_d_p[1]" J15,H15;
IO_PORT "tmds_d_p[1]" PULL_MODE=NONE DRIVE=8 IO_TYPE=LVCMOS33D;
IO_LOC "tmds_d_p[2]" K17,J17
IO_PORT "tmds_d_p[2]" PULL_MODE=NONE DRIVE=8 IO_TYPE=LVCMOS33D;

IO_LOC "hpd_en" K13;
IO_PORT "hpd_en" PULL_MODE=UP DRIVE=12 BANK_VCCIO=3.3;
IO_PORT "hpd_en" PULL_MODE=UP BANK_VCCIO=3.3;

// SDCard
IO_LOC "sd_clk" V15;
IO_PORT "sd_clk" PULL_MODE=NONE DRIVE=8 IO_TYPE=LVCMOS33;
IO_LOC "sd_cmd" Y16; // MOSI
IO_PORT "sd_cmd" PULL_MODE=NONE DRIVE=8 IO_TYPE=LVCMOS33;
IO_LOC "sd_dat[0]" AA15; // MISO or SD card DO, needs pull-up
IO_PORT "sd_dat[0]" PULL_MODE=UP DRIVE=8 IO_TYPE=LVCMOS33;
IO_PORT "sd_clk" IO_TYPE=LVCMOS33 SLEW_RATE=FAST PULL_MODE=UP DRIVE=8 PULL_STRENGTH=STRONG BANK_VCCIO=3.3
IO_LOC "sd_cmd" Y16;
IO_PORT "sd_cmd" IO_TYPE=LVCMOS33 SLEW_RATE=FAST PULL_MODE=UP DRIVE=8 PULL_STRENGTH=STRONG BANK_VCCIO=3.3
IO_LOC "sd_dat[0]" AA15;
IO_PORT "sd_dat[0]" IO_TYPE=LVCMOS33 SLEW_RATE=FAST PULL_MODE=UP DRIVE=8 PULL_STRENGTH=STRONG BANK_VCCIO=3.3;
IO_LOC "sd_dat[1]" AB15;
IO_PORT "sd_dat[1]" PULL_MODE=NONE DRIVE=8 IO_TYPE=LVCMOS33;
IO_PORT "sd_dat[1]" IO_TYPE=LVCMOS33 SLEW_RATE=FAST PULL_MODE=UP DRIVE=8 PULL_STRENGTH=STRONG BANK_VCCIO=3.3
IO_LOC "sd_dat[2]" W14;
IO_PORT "sd_dat[2]" PULL_MODE=NONE DRIVE=8 IO_TYPE=LVCMOS33;
IO_PORT "sd_dat[2]" IO_TYPE=LVCMOS33 SLEW_RATE=FAST PULL_MODE=UP DRIVE=8 PULL_STRENGTH=STRONG BANK_VCCIO=3.3;
IO_LOC "sd_dat[3]" W15;
IO_PORT "sd_dat[3]" PULL_MODE=NONE DRIVE=8 IO_TYPE=LVCMOS33;
IO_PORT "sd_dat[3]" IO_TYPE=LVCMOS33 SLEW_RATE=FAST PULL_MODE=UP DRIVE=8 PULL_STRENGTH=STRONG BANK_VCCIO=3.3

// PMOD mostleft for testing TFcard v2
//IO_LOC "sd_clk" R18;
//IO_LOC "sd_cmd" T21; // MOSI
//IO_LOC "sd_dat[0]" P16; // MISO
//IO_LOC "sd_dat[1]" R19;
//IO_LOC "sd_dat[2]" U21;
//IO_LOC "sd_dat[3]" P19;
// CDn R17;
// WPn T18;

// 128Mbit NOR Flash (MSPI pins)
// W25Q64
Expand Down
Loading

0 comments on commit b1b750a

Please sign in to comment.