Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To program SPI Flash and restart FPGA #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions src/a2600_top_tp20k.cst
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,18 @@ IO_LOC "leds_n[0]" C13; // DONE
IO_PORT "leds_n[0]" IO_TYPE=LVCMOS33 PULL_MODE=UP DRIVE=8 BANK_VCCIO=3.3;

// SPI FLASH
//IO_LOC "mspi_clk" L10;
//IO_PORT "mspi_clk" IO_TYPE=LVCMOS33 PULL_MODE=NONE DRIVE=4 BANK_VCCIO=3.3;
//IO_LOC "mspi_cs" M9;
//IO_PORT "mspi_cs" IO_TYPE=LVCMOS33 PULL_MODE=UP DRIVE=4 BANK_VCCIO=3.3;
//IO_LOC "mspi_do" P10;
//IO_PORT "mspi_do" IO_TYPE=LVCMOS33 PULL_MODE=NONE DRIVE=4 BANK_VCCIO=3.3;
IO_LOC "mspi_clk" L10;
IO_PORT "mspi_clk" IO_TYPE=LVCMOS33 PULL_MODE=NONE DRIVE=12 BANK_VCCIO=3.3;
IO_LOC "mspi_cs" M9;
IO_PORT "mspi_cs" IO_TYPE=LVCMOS33 PULL_MODE=UP DRIVE=12 BANK_VCCIO=3.3;
IO_LOC "mspi_do" P10;
IO_PORT "mspi_do" IO_TYPE=LVCMOS33 PULL_MODE=NONE BANK_VCCIO=3.3;
//IO_LOC "mspi_wp" P12; // wiring needed ! not mandatory as pull-up available
//IO_PORT "mspi_wp" IO_TYPE=LVCMOS33 PULL_MODE=UP DRIVE=4 BANK_VCCIO=3.3;
//IO_LOC "mspi_hold" F12; // wiring needed ! not mandatory as pull-up available
//IO_PORT "mspi_hold" IO_TYPE=LVCMOS33 PULL_MODE=UP DRIVE=4 BANK_VCCIO=3.3;
//IO_LOC "mspi_di" R10;
//IO_PORT "mspi_di" IO_TYPE=LVCMOS33 PULL_MODE=NONE BANK_VCCIO=3.3;
IO_LOC "mspi_di" R10;
IO_PORT "mspi_di" IO_TYPE=LVCMOS33 PULL_MODE=NONE DRIVE=12 BANK_VCCIO=3.3;

// SDCARD
IO_LOC "sd_dat[3]" N11;
Expand Down Expand Up @@ -182,8 +182,10 @@ IO_PORT "sd_clk" IO_TYPE=LVCMOS33 PULL_MODE=UP DRIVE=4 BANK_VCCIO=3.3;

// PMOD 0
// M0S Dock BL616
//IO_LOC "m0s[5]" P8; // unused
//IO_PORT "m0s[5]" IO_TYPE=LVCMOS33 PULL_MODE=UP BANK_VCCIO=3.3;
IO_LOC "m0s[6]" P9; // reconfig_n
IO_PORT "m0s[6]" IO_TYPE=LVCMOS33 PULL_MODE=UP BANK_VCCIO=3.3;
IO_LOC "m0s[5]" P8; // flash_cs
IO_PORT "m0s[5]" IO_TYPE=LVCMOS33 PULL_MODE=UP BANK_VCCIO=3.3;
IO_LOC "m0s[4]" T8; // IRQn
IO_PORT "m0s[4]" IO_TYPE=LVCMOS33 PULL_MODE=UP DRIVE=8 BANK_VCCIO=3.3;
IO_LOC "m0s[3]" R8; // CLK
Expand Down Expand Up @@ -341,4 +343,7 @@ IO_PORT "user" IO_TYPE=LVCMOS15 PULL_MODE=UP BANK_VCCIO=1.5;
// PMOD pin 4 GND
// PMOD pin 3 GND
// PMOD pin 2 3V3
// PMOD pin 1 3V3
// PMOD pin 1 3V3

IO_LOC "reconfig_n" B10;
IO_PORT "reconfig_n" PULL_MODE=UP IO_TYPE=LVCMOS33;
26 changes: 22 additions & 4 deletions src/a2600_top_tp20k.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ entity A2600_top is
io : in std_logic_vector(4 downto 0);

-- SPI interface Sipeed M0S Dock external BL616 uC
m0s : inout std_logic_vector(4 downto 0);
m0s : inout std_logic_vector(6 downto 0);
--
tmds_clk_n : out std_logic;
tmds_clk_p : out std_logic;
Expand All @@ -31,6 +31,12 @@ entity A2600_top is
sd_dat : inout std_logic_vector(3 downto 0);
ws2812 : out std_logic;

-- spi flash
mspi_cs : out std_logic;
mspi_clk : out std_logic;
mspi_do : in std_logic;
mspi_di : out std_logic;

-- Gamepad Dualshock P1
ds_clk : out std_logic;
ds_mosi : out std_logic;
Expand All @@ -40,7 +46,10 @@ entity A2600_top is
ds2_clk : out std_logic;
ds2_mosi : out std_logic;
ds2_miso : in std_logic;
ds2_cs : out std_logic
ds2_cs : out std_logic;

-- Reconfigure
reconfig_n : out std_logic
);
end;

Expand Down Expand Up @@ -307,7 +316,16 @@ begin
spi_io_din <= m0s(1);
spi_io_ss <= m0s(2);
spi_io_clk <= m0s(3);
m0s(0) <= spi_io_dout; -- M0 Dock
m0s(0) <= spi_io_dout when spi_io_ss = '0' else mspi_do; -- M0 Dock

-- SPI Flash on shared spi bus with its own cs line
mspi_clk <= m0s(3);
mspi_di <= m0s(1);
mspi_cs <= m0s(5);
-- m0s(0) <= mspi_do;

-- Reconfire pin that allows esp32 to restart fpga after loading a core
reconfig_n <= m0s(6);

-- https://store.curiousinventor.com/guides/PS2/
-- https://hackaday.io/project/170365-blueretro/log/186471-playstation-playstation-2-spi-interface
Expand Down Expand Up @@ -641,7 +659,7 @@ begin
when "1000" => joyA <= (others => '0'); -- 8 R #2 D9 PMOD
when "1001" => joyA <= (others => '0'); -- 9 R #2 D9 ALT
when others => joyA <= (others => '0');
end case;
end case;
end if;
end process;

Expand Down