mirror of
https://github.com/antonblanchard/microwatt.git
synced 2026-04-25 12:01:42 +00:00
This adds an SPI flash controller which supports direct memory-mapped access to the flash along with a manual mode to send commands. The direct mode can be set via generic to default to single wire or quad mode. The controller supports normal, dual and quad accesses with configurable commands, clock divider, dummy clocks etc... The SPI clock can be an even divider of sys_clk starting at 2 (so max 50Mhz with our typical Arty designs). A flash offset is carried via generics to syscon to tell SW about which portion of the flash is reserved for the FPGA bitfile. There is currently no plumbing to make the CPU reset past that address (TBD). Note: Operating at 50Mhz has proven unreliable without adding some delay to the sampling of the input data. I'm working in improving this, in the meantime, I'm leaving the default set at 25 Mhz. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
82 lines
1.8 KiB
VHDL
82 lines
1.8 KiB
VHDL
library ieee;
|
|
use ieee.std_logic_1164.all;
|
|
use ieee.numeric_std.all;
|
|
|
|
library work;
|
|
use work.common.all;
|
|
use work.wishbone_types.all;
|
|
|
|
entity core_tb is
|
|
end core_tb;
|
|
|
|
architecture behave of core_tb is
|
|
signal clk, rst: std_logic;
|
|
|
|
-- testbench signals
|
|
constant clk_period : time := 10 ns;
|
|
|
|
-- Dummy DRAM
|
|
signal wb_dram_in : wishbone_master_out;
|
|
signal wb_dram_out : wishbone_slave_out;
|
|
signal wb_dram_ctrl_in : wb_io_master_out;
|
|
signal wb_dram_ctrl_out : wb_io_slave_out;
|
|
|
|
-- Dummy SPI
|
|
signal spi_sdat_i : std_ulogic_vector(0 downto 0);
|
|
begin
|
|
|
|
soc0: entity work.soc
|
|
generic map(
|
|
SIM => true,
|
|
MEMORY_SIZE => (384*1024),
|
|
RAM_INIT_FILE => "main_ram.bin",
|
|
RESET_LOW => false,
|
|
CLK_FREQ => 100000000,
|
|
HAS_SPI_FLASH => false
|
|
)
|
|
port map(
|
|
rst => rst,
|
|
system_clk => clk,
|
|
uart0_rxd => '0',
|
|
uart0_txd => open,
|
|
spi_flash_sck => open,
|
|
spi_flash_cs_n => open,
|
|
spi_flash_sdat_o => open,
|
|
spi_flash_sdat_oe => open,
|
|
spi_flash_sdat_i => spi_sdat_i,
|
|
wb_dram_in => wb_dram_in,
|
|
wb_dram_out => wb_dram_out,
|
|
wb_dram_ctrl_in => wb_dram_ctrl_in,
|
|
wb_dram_ctrl_out => wb_dram_ctrl_out,
|
|
alt_reset => '0'
|
|
);
|
|
spi_sdat_i(0) <= '1';
|
|
|
|
clk_process: process
|
|
begin
|
|
clk <= '0';
|
|
wait for clk_period/2;
|
|
clk <= '1';
|
|
wait for clk_period/2;
|
|
end process;
|
|
|
|
rst_process: process
|
|
begin
|
|
rst <= '1';
|
|
wait for 10*clk_period;
|
|
rst <= '0';
|
|
wait;
|
|
end process;
|
|
|
|
jtag: entity work.sim_jtag;
|
|
|
|
-- Dummy DRAM
|
|
wb_dram_out.ack <= wb_dram_in.cyc and wb_dram_in.stb;
|
|
wb_dram_out.dat <= x"FFFFFFFFFFFFFFFF";
|
|
wb_dram_out.stall <= '0';
|
|
wb_dram_ctrl_out.ack <= wb_dram_ctrl_in.cyc and wb_dram_ctrl_in.stb;
|
|
wb_dram_ctrl_out.dat <= x"FFFFFFFF";
|
|
wb_dram_ctrl_out.stall <= '0';
|
|
|
|
end;
|