OpenCores
URL https://opencores.org/ocsvn/spi_boot/spi_boot/trunk

Subversion Repositories spi_boot

[/] [spi_boot/] [trunk/] [rtl/] [vhdl/] [spi_boot.vhd] - Diff between revs 60 and 66

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 60 Rev 66
Line 1... Line 1...
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
--
--
-- SD/MMC Bootloader
-- SD/MMC Bootloader
--
--
-- $Id: spi_boot.vhd,v 1.10 2007-08-06 23:31:05 arniml Exp $
-- $Id: spi_boot.vhd,v 1.11 2007-08-08 00:39: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 167... Line 167...
  signal mmc_cnt_ovfl_s : boolean;
  signal mmc_cnt_ovfl_s : boolean;
  signal mmc_compat_s   : boolean;
  signal mmc_compat_s   : boolean;
 
 
  signal cmd_finished_s : boolean;
  signal cmd_finished_s : boolean;
 
 
  signal r1_result_q    : std_logic;
  signal r1_illcmd_q,
 
         r1_idle_q      : std_logic;
  signal done_q,
  signal done_q,
         send_cmd12_q   : boolean;
         send_cmd12_q   : boolean;
 
 
  signal en_outs_s,
  signal en_outs_s,
         en_outs_q      : boolean;
         en_outs_q      : boolean;
Line 210... Line 211...
      start_q      <= '0';
      start_q      <= '0';
      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_illcmd_q  <= '0';
 
      r1_idle_q    <= '0';
      en_outs_q    <= false;
      en_outs_q    <= false;
 
 
    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
Line 270... Line 272...
      -- Extract flags from R1 response
      -- Extract flags from R1 response
      if cmd_fsm_q = R1 then
      if cmd_fsm_q = R1 then
        bit_cnt_v := bit_cnt_q(1 downto 0);
        bit_cnt_v := bit_cnt_q(1 downto 0);
        case bit_cnt_v(1 downto 0) is
        case bit_cnt_v(1 downto 0) is
          when "10" =>
          when "10" =>
            -- always save "Illegal Command" flag
            -- save "Illegal Command" flag
            r1_result_q <= to_X01(spi_data_in_i);
            r1_illcmd_q <= to_X01(spi_data_in_i);
          when "00" =>
          when "00" =>
            -- overwrite with "Idle State" flag when not in CMD55
            -- save "Idle State" flag
            if ctrl_fsm_q /= CMD55 then
            r1_idle_q   <= to_X01(spi_data_in_i);
              r1_result_q <= to_X01(spi_data_in_i);
 
            end if;
 
          when others =>
          when others =>
            null;
            null;
        end case;
        end case;
      end if;
      end if;
 
 
Line 455... Line 455...
  --
  --
  -- Purpose:
  -- Purpose:
  --   Implements the controller FSM.
  --   Implements the controller FSM.
  --
  --
  ctrl_fsm: process (ctrl_fsm_q,
  ctrl_fsm: process (ctrl_fsm_q,
                     cmd_finished_s, r1_result_q,
                     cmd_finished_s, r1_illcmd_q, r1_idle_q,
                     start_i, start_q, mode_i,
                     start_i, start_q, mode_i,
                     cfg_init_n_i)
                     cfg_init_n_i)
 
 
    variable mmc_compat_v : boolean;
    variable mmc_compat_v : boolean;
 
 
Line 513... Line 513...
      when CMD55 =>
      when CMD55 =>
        if sd_init_g = 1 then
        if sd_init_g = 1 then
 
 
          mmc_compat_v   := true;
          mmc_compat_v   := true;
          if cmd_finished_s then
          if cmd_finished_s then
            if r1_result_q = '0' then
            if r1_illcmd_q = '0' then
              -- command accepted, it's an SD card
              -- command accepted, continue with ACMD41
              ctrl_fsm_s <= ACMD41;
              ctrl_fsm_s <= ACMD41;
            else
            else
              -- command rejected, it's an MMC card
              -- command rejected, it's an MMC card
              ctrl_fsm_s <= CMD1;
              ctrl_fsm_s <= CMD1;
            end if;
            end if;
Line 533... Line 533...
      when ACMD41 =>
      when ACMD41 =>
        if sd_init_g = 1 then
        if sd_init_g = 1 then
 
 
          mmc_compat_v   := true;
          mmc_compat_v   := true;
          if cmd_finished_s then
          if cmd_finished_s then
            if r1_result_q = '0' then
            if r1_illcmd_q = '0' then
 
              -- ok, that's an SD card
 
              if r1_idle_q = '0' then
              ctrl_fsm_s <= CMD16;
              ctrl_fsm_s <= CMD16;
            else
            else
              ctrl_fsm_s <= CMD55;
              ctrl_fsm_s <= CMD55;
            end if;
            end if;
 
 
 
            else
 
              -- command rejected, though it accepted CMD55 -> it's an MMC
 
              ctrl_fsm_s   <= CMD1;
 
            end if;
 
 
          else
          else
            ctrl_fsm_s   <= ACMD41;
            ctrl_fsm_s   <= ACMD41;
          end if;
          end if;
 
 
        end if;
        end if;
Line 549... Line 557...
 
 
      -- Issue CMD1: SEND_OP_COND ---------------------------------------------
      -- Issue CMD1: SEND_OP_COND ---------------------------------------------
      when CMD1 =>
      when CMD1 =>
        mmc_compat_v   := true;
        mmc_compat_v   := true;
        if cmd_finished_s then
        if cmd_finished_s then
          if r1_result_q = '0' then
          if r1_idle_q = '0' then
            ctrl_fsm_s <= CMD16;
            ctrl_fsm_s <= CMD16;
          else
          else
            ctrl_fsm_s <= CMD1;
            ctrl_fsm_s <= CMD1;
          end if;
          end if;
        else
        else
Line 945... Line 953...
 
 
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- File History:
-- File History:
--
--
-- $Log: not supported by cvs2svn $
-- $Log: not supported by cvs2svn $
 
-- Revision 1.10  2007/08/06 23:31:05  arniml
 
-- enlarge set_sel_i input to fill all upper bits of the 32 bit address vector
 
--
-- Revision 1.9  2007/02/25 18:24:12  arniml
-- Revision 1.9  2007/02/25 18:24:12  arniml
-- fix type handling of resets
-- fix type handling of resets
--
--
-- Revision 1.8  2006/09/11 23:03:36  arniml
-- Revision 1.8  2006/09/11 23:03:36  arniml
-- disable outputs with reset
-- disable outputs with reset

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.