Line 1... |
Line 1... |
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
--
|
--
|
-- SD/MMC Bootloader
|
-- SD/MMC Bootloader
|
--
|
--
|
-- $Id: spi_boot.vhd,v 1.2 2005-02-13 17:25:51 arniml Exp $
|
-- $Id: spi_boot.vhd,v 1.3 2005-02-16 18:59:10 arniml Exp $
|
--
|
--
|
-- Copyright (c) 2005, Arnim Laeuger (arniml@opencores.org)
|
-- Copyright (c) 2005, Arnim Laeuger (arniml@opencores.org)
|
--
|
--
|
-- All rights reserved, see COPYING.
|
-- All rights reserved, see COPYING.
|
--
|
--
|
Line 72... |
Line 72... |
-- Card Interface ---------------------------------------------------------
|
-- Card Interface ---------------------------------------------------------
|
spi_clk_o : out std_logic;
|
spi_clk_o : out std_logic;
|
spi_cs_n_o : out std_logic;
|
spi_cs_n_o : out std_logic;
|
spi_data_in_i : in std_logic;
|
spi_data_in_i : in std_logic;
|
spi_data_out_o : out std_logic;
|
spi_data_out_o : out std_logic;
|
|
spi_en_outs_o : out std_logic;
|
-- FPGA Configuration Interface -------------------------------------------
|
-- FPGA Configuration Interface -------------------------------------------
|
start_i : in std_logic;
|
start_i : in std_logic;
|
mode_i : in std_logic;
|
mode_i : in std_logic;
|
config_n_o : out std_logic;
|
config_n_o : out std_logic;
|
cfg_init_n_i : in std_logic;
|
cfg_init_n_i : in std_logic;
|
Line 168... |
Line 169... |
|
|
signal r1_result_q : std_logic;
|
signal r1_result_q : std_logic;
|
signal done_q,
|
signal done_q,
|
send_cmd12_q : boolean;
|
send_cmd12_q : boolean;
|
|
|
|
signal en_outs_s,
|
|
en_outs_q : boolean;
|
|
|
signal true_s : boolean;
|
signal true_s : boolean;
|
|
|
begin
|
begin
|
|
|
true_s <= true;
|
true_s <= true;
|
Line 198... |
Line 202... |
done_q <= false;
|
done_q <= false;
|
send_cmd12_q <= false;
|
send_cmd12_q <= false;
|
ctrl_fsm_q <= POWER_UP1;
|
ctrl_fsm_q <= POWER_UP1;
|
cmd_fsm_q <= CMD;
|
cmd_fsm_q <= CMD;
|
r1_result_q <= '0';
|
r1_result_q <= '0';
|
|
en_outs_q <= true;
|
|
|
elsif clk_i'event and clk_i = '1' then
|
elsif clk_i'event and clk_i = '1' then
|
-- bit counter control
|
-- bit counter control
|
if spi_clk_rising_q then
|
if spi_clk_rising_q then
|
case res_bc_s is
|
case res_bc_s is
|
Line 300... |
Line 305... |
-- an end without interruption or generation of unwanted cfg_clk_q
|
-- an end without interruption or generation of unwanted cfg_clk_q
|
done_q <= false;
|
done_q <= false;
|
send_cmd12_q <= false;
|
send_cmd12_q <= false;
|
end if;
|
end if;
|
|
|
|
-- output enable
|
|
if spi_clk_rising_q then
|
|
en_outs_q <= en_outs_s;
|
|
end if;
|
|
|
end if;
|
end if;
|
|
|
end process seq;
|
end process seq;
|
--
|
--
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
Line 449... |
Line 459... |
ctrl_fsm_s <= POWER_UP1;
|
ctrl_fsm_s <= POWER_UP1;
|
config_n_o <= '1';
|
config_n_o <= '1';
|
cnt_en_set_s <= false;
|
cnt_en_set_s <= false;
|
spi_cs_n_s <= '0';
|
spi_cs_n_s <= '0';
|
mmc_compat_v := false;
|
mmc_compat_v := false;
|
|
en_outs_s <= true;
|
|
|
case ctrl_fsm_q is
|
case ctrl_fsm_q is
|
-- Let card finish power up, step 1 -------------------------------------
|
-- Let card finish power up, step 1 -------------------------------------
|
when POWER_UP1 =>
|
when POWER_UP1 =>
|
mmc_compat_v := true;
|
mmc_compat_v := true;
|
Line 562... |
Line 573... |
ctrl_fsm_s <= CMD18;
|
ctrl_fsm_s <= CMD18;
|
else
|
else
|
ctrl_fsm_s <= WAIT_INIT_LOW;
|
ctrl_fsm_s <= WAIT_INIT_LOW;
|
end if;
|
end if;
|
else
|
else
|
|
en_outs_s <= false;
|
ctrl_fsm_s <= WAIT_START;
|
ctrl_fsm_s <= WAIT_START;
|
end if;
|
end if;
|
else
|
else
|
|
en_outs_s <= false;
|
ctrl_fsm_s <= WAIT_START;
|
ctrl_fsm_s <= WAIT_START;
|
end if;
|
end if;
|
|
|
|
|
-- Wait for INIT to become low ------------------------------------------
|
-- Wait for INIT to become low ------------------------------------------
|
Line 904... |
Line 917... |
-- Output Mapping
|
-- Output Mapping
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
spi_clk_o <= spi_clk_q;
|
spi_clk_o <= spi_clk_q;
|
spi_cs_n_o <= spi_cs_n_q;
|
spi_cs_n_o <= spi_cs_n_q;
|
spi_data_out_o <= spi_dat_q;
|
spi_data_out_o <= spi_dat_q;
|
|
spi_en_outs_o <= '1'
|
|
when en_outs_q else
|
|
'0';
|
cfg_clk_o <= cfg_clk_q;
|
cfg_clk_o <= cfg_clk_q;
|
cfg_dat_o <= cfg_dat_q;
|
cfg_dat_o <= cfg_dat_q;
|
|
|
end rtl;
|
end rtl;
|
|
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- File History:
|
-- File History:
|
--
|
--
|
-- $Log: not supported by cvs2svn $
|
-- $Log: not supported by cvs2svn $
|
|
-- Revision 1.2 2005/02/13 17:25:51 arniml
|
|
-- major update to fix several problems
|
|
-- configuration/data download of multiple sets works now
|
|
--
|
-- Revision 1.1 2005/02/08 20:41:33 arniml
|
-- Revision 1.1 2005/02/08 20:41:33 arniml
|
-- initial check-in
|
-- initial check-in
|
--
|
--
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
|
|
No newline at end of file
|
No newline at end of file
|