Line 1... |
Line 1... |
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
--
|
--
|
-- SD/MMC Bootloader
|
-- SD/MMC Bootloader
|
--
|
--
|
-- $Id: spi_boot.vhd,v 1.4 2005-02-18 06:42:08 arniml Exp $
|
-- $Id: spi_boot.vhd,v 1.5 2005-03-08 22:07:12 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 48... |
Line 48... |
|
|
|
|
entity spi_boot is
|
entity spi_boot is
|
|
|
generic (
|
generic (
|
|
-- width of set selection
|
|
width_set_sel_g : integer := 4;
|
-- width of bit counter: minimum 6, maximum 12
|
-- width of bit counter: minimum 6, maximum 12
|
width_bit_cnt_g : integer := 6;
|
width_bit_cnt_g : integer := 6;
|
-- width of image counter: minimum 0, maximum n
|
-- width of image counter: minimum 0, maximum n
|
width_img_cnt_g : integer := 2;
|
width_img_cnt_g : integer := 2;
|
-- number of bits required to address one image
|
-- number of bits required to address one image
|
Line 67... |
Line 69... |
|
|
port (
|
port (
|
-- System Interface -------------------------------------------------------
|
-- System Interface -------------------------------------------------------
|
clk_i : in std_logic;
|
clk_i : in std_logic;
|
reset_i : in std_logic;
|
reset_i : in std_logic;
|
|
set_sel_n_i : in std_logic_vector(width_set_sel_g-1 downto 0);
|
-- 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;
|
Line 795... |
Line 798... |
transmit: process (ctrl_fsm_q,
|
transmit: process (ctrl_fsm_q,
|
cmd_fsm_q,
|
cmd_fsm_q,
|
bit_cnt_q,
|
bit_cnt_q,
|
img_cnt_s,
|
img_cnt_s,
|
send_cmd12_q,
|
send_cmd12_q,
|
|
set_sel_n_i,
|
upper_bitcnt_zero_s)
|
upper_bitcnt_zero_s)
|
|
|
subtype cmd_r is natural range 47 downto 0;
|
subtype cmd_r is natural range 47 downto 0;
|
subtype cmd_t is std_logic_vector(cmd_r);
|
subtype cmd_t is std_logic_vector(cmd_r);
|
subtype ext_cmd_t is std_logic_vector(63 downto 0);
|
subtype ext_cmd_t is std_logic_vector(63 downto 0);
|
Line 812... |
Line 816... |
constant acmd41_c : cmd_t := "0110100100000000000000000000000000000000-------1";
|
constant acmd41_c : cmd_t := "0110100100000000000000000000000000000000-------1";
|
|
|
variable cmd_v : ext_cmd_t;
|
variable cmd_v : ext_cmd_t;
|
variable tx_v : boolean;
|
variable tx_v : boolean;
|
|
|
|
variable set_sel_v : std_logic_vector(width_set_sel_g-1 downto 0);
|
|
|
begin
|
begin
|
-- default assignments
|
-- default assignments
|
spi_dat_s <= '1';
|
spi_dat_s <= '1';
|
cmd_v := (others => '1');
|
cmd_v := (others => '1');
|
tx_v := false;
|
tx_v := false;
|
|
set_sel_v := not set_sel_n_i;
|
|
|
if cmd_fsm_q = CMD then
|
if cmd_fsm_q = CMD then
|
case ctrl_fsm_q is
|
case ctrl_fsm_q is
|
when CMD0 =>
|
when CMD0 =>
|
cmd_v(cmd_r) := cmd0_c;
|
cmd_v(cmd_r) := cmd0_c;
|
Line 832... |
Line 839... |
cmd_v(cmd_r) := cmd16_c;
|
cmd_v(cmd_r) := cmd16_c;
|
cmd_v(8 + width_bit_cnt_g-3) := '1';
|
cmd_v(8 + width_bit_cnt_g-3) := '1';
|
tx_v := true;
|
tx_v := true;
|
when CMD18 =>
|
when CMD18 =>
|
cmd_v(cmd_r) := cmd18_c;
|
cmd_v(cmd_r) := cmd18_c;
|
cmd_v(8 + num_bits_per_img_g + width_img_cnt_g downto 8 + num_bits_per_img_g)
|
-- insert image counter
|
:= img_cnt_s;
|
cmd_v(8 + num_bits_per_img_g + width_img_cnt_g
|
|
downto 8 + num_bits_per_img_g) := img_cnt_s;
|
|
-- insert set selection
|
|
cmd_v(8 + num_bits_per_img_g + width_img_cnt_g + width_set_sel_g-1
|
|
downto 8 + num_bits_per_img_g + width_img_cnt_g) := set_sel_v;
|
tx_v := true;
|
tx_v := true;
|
when CMD18_DATA =>
|
when CMD18_DATA =>
|
cmd_v(cmd_r) := cmd12_c;
|
cmd_v(cmd_r) := cmd12_c;
|
|
|
if send_cmd12_q and upper_bitcnt_zero_s then
|
if send_cmd12_q and upper_bitcnt_zero_s then
|
Line 930... |
Line 941... |
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- File History:
|
-- File History:
|
--
|
--
|
-- $Log: not supported by cvs2svn $
|
-- $Log: not supported by cvs2svn $
|
|
-- Revision 1.4 2005/02/18 06:42:08 arniml
|
|
-- clarify wording for images
|
|
--
|
-- Revision 1.3 2005/02/16 18:59:10 arniml
|
-- Revision 1.3 2005/02/16 18:59:10 arniml
|
-- include output enable control for SPI outputs
|
-- include output enable control for SPI outputs
|
--
|
--
|
-- Revision 1.2 2005/02/13 17:25:51 arniml
|
-- Revision 1.2 2005/02/13 17:25:51 arniml
|
-- major update to fix several problems
|
-- major update to fix several problems
|