OpenCores
URL https://opencores.org/ocsvn/sdhc-sc-core/sdhc-sc-core/trunk

Subversion Repositories sdhc-sc-core

[/] [sdhc-sc-core/] [trunk/] [grpSd/] [unitSdController/] [src/] [SdController-Rtl-a.vhdl] - Diff between revs 102 and 103

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

Rev 102 Rev 103
Line 9... Line 9...
--
--
 
 
architecture Rtl of SdController is
architecture Rtl of SdController is
 
 
        type aSdControllerState is (startup, init, config, idle, invalidCard);
        type aSdControllerState is (startup, init, config, idle, invalidCard);
        type aCmdRegion is (CMD0, CMD8, ACMD41, CMD2, CMD3, SelectCard, CheckBusWidth, SetBusWidth, CheckSpeed);
        type aCmdRegion is (CMD0, CMD8, ACMD41, CMD2, CMD3, SelectCard, CheckBusWidth, SetBusWidth, CheckSpeed, ChangeSpeed);
        type aRegion is (idle, send, response, waitstate, senddata, receivedata, checkbusy, waitstatedata);
        type aRegion is (idle, send, response, waitstate, senddata, receivedata, checkbusy, waitstatedata);
 
 
        constant cDefaultToSdCmd : aSdCmdFromController := (
        constant cDefaultToSdCmd : aSdCmdFromController := (
        (id       => (others        => '0'),
        (id       => (others        => '0'),
        arg       => (others        => '0')),
        arg       => (others        => '0')),
Line 253... Line 253...
                                                                        NextState     := config;
                                                                        NextState     := config;
                                                                        NextCmdRegion := SelectCard;
                                                                        NextCmdRegion := SelectCard;
                                                                        NextRegion    := send;
                                                                        NextRegion    := send;
 
 
                                                        when others =>
                                                        when others =>
                                                                report "SdController: Unhandled state" severity error;
                                                                report "SdController: Unhandled region" severity error;
                                                end case;
                                                end case;
 
 
                                        when others =>
                                        when others =>
                                                report "SdController: Unhandled state" severity error;
                                                report "SdController: Unhandled CmdRegion" severity error;
                                end case;
                                end case;
 
 
                        when config =>
                        when config =>
                                oLedBank(3) <= cActivated;
                                oLedBank(3) <= cActivated;
 
 
Line 328... Line 328...
                                                                        elsif (Timeout = cActivated) then
                                                                        elsif (Timeout = cActivated) then
                                                                                NextR.State <= invalidCard;
                                                                                NextR.State <= invalidCard;
                                                                        end if;
                                                                        end if;
 
 
                                                                when receivedata =>
                                                                when receivedata =>
                                                                        if (iSdData.Err = cActivated) then
                                                                        null;
                                                                                NextR.State <= init;
 
 
 
                                                                        elsif (iSdData.Valid = cActivated) then
 
                                                                                NextR.Region <= waitstatedata;
 
 
 
                                                                        elsif (Timeout = cActivated) then
 
                                                                                NextR.State <= invalidCard;
 
                                                                        end if;
 
 
 
                                                                when waitstatedata =>
                                                                when waitstatedata =>
                                                                                NextRegion := send;
                                                                                NextRegion := send;
 
 
                                                                                if (NextCmdTimeout = cActivated) then
                                                                                if (NextCmdTimeout = cActivated) then
Line 358... Line 350...
                                                                        report "Unhandled region" severity error;
                                                                        report "Unhandled region" severity error;
                                                        end case;
                                                        end case;
                                                end if;
                                                end if;
 
 
                                        when SetBusWidth =>
                                        when SetBusWidth =>
                                                oLedBank(4) <= cActivated;
 
 
 
                                                if (R.SendCMD55 = cInactivated) then
                                                if (R.SendCMD55 = cInactivated) then
                                                        case R.Region is
                                                        case R.Region is
                                                                when send =>
                                                                when send =>
                                                                        NextR.ToSdCmd.Content.id              <= cSdCmdSetBusWidth;
                                                                        NextR.ToSdCmd.Content.id              <= cSdCmdSetBusWidth;
                                                                        NextR.ToSdCmd.Content.arg(1 downto 0) <= cSdWideBusWidth;
                                                                        NextR.ToSdCmd.Content.arg(1 downto 0) <= cSdWideBusWidth;
Line 391... Line 381...
                                                                        report "Unhandled region" severity error;
                                                                        report "Unhandled region" severity error;
                                                        end case;
                                                        end case;
                                                end if;
                                                end if;
 
 
                                        when CheckSpeed =>
                                        when CheckSpeed =>
                                                NextR.State <= idle;
                                                oLedBank(4) <= cActivated;
 
                                                NextR.ToSdData.DataMode <= widewidth;
 
                                                NextR.ToSdData.ExpectBits <= SwitchFunctionBits;
 
 
 
                                                case R.Region is
 
                                                        when send =>
 
                                                                NextR.ToSdCmd.Content.id <= cSdCmdSwitchFunction;
 
                                                                NextR.ToSdCmd.Content.arg <= cSdCmdCheckSpeedSupport;
 
                                                                NextRegion := response;
 
 
 
                                                        when response =>
 
                                                                if (iSdCmd.Valid = cActivated) then
 
                                                                        if (iSdCmd.Content.id = cSdCmdSwitchFunction) then
 
                                                                                NextR.CardStatus <= iSdCmd.Content.arg;
 
                                                                                NextR.Region <= receivedata;
 
 
 
                                                                        else
 
                                                                                NextR.State <= invalidCard;
 
                                                                        end if;
 
                                                                elsif (Timeout = cActivated) then
 
                                                                        NextR.State <= invalidCard;
 
                                                                end if;
 
 
 
                                                        when receivedata =>
 
                                                                null;
 
 
 
                                                        when waitstatedata =>
 
                                                                NextRegion := send;
 
 
 
                                                                if (NextCmdTimeout = cActivated) then
 
                                                                        if (iSdData.DataBlock(cSdHighSpeedFunctionSupportBit) = cActivated and
 
                                                                        iSdData.DataBlock(cSdHighSpeedFunctionGroupLow+3 downto cSdHighSpeedFunctionGroupLow) = X"1") then
 
                                                                                NextCmdRegion := ChangeSpeed;
 
                                                                                NextRegion := idle;
 
 
 
                                                                        else
 
                                                                                NextState := idle;
 
                                                                        end if;
 
                                                                end if;
 
 
 
 
 
                                                        when others =>
 
                                                                report "Unhandled region";
 
                                                end case;
 
 
 
                                        when ChangeSpeed =>
 
                                                oLedBank(1) <= cActivated;
 
 
                                        when others =>
                                        when others =>
                                                report "Unhandled CmdRegion" severity error;
                                                report "Unhandled CmdRegion" severity error;
                                end case;
                                end case;
 
 
Line 468... Line 504...
                                null;
                                null;
 
 
                        when receivedata =>
                        when receivedata =>
                                TimeoutEnable <= cActivated;
                                TimeoutEnable <= cActivated;
 
 
 
                                if (iSdData.Err = cActivated) then
 
                                        NextR.State <= init;
 
 
 
                                elsif (iSdData.Valid = cActivated) then
 
                                        NextR.Region <= waitstatedata;
 
 
 
                                elsif (Timeout = cActivated) then
 
                                        NextR.State <= invalidCard;
 
                                end if;
 
 
 
 
                        when waitstatedata =>
                        when waitstatedata =>
                                NextCmdTimeoutEnable <= cActivated;
                                NextCmdTimeoutEnable <= cActivated;
 
 
                                if (NextCmdTimeout = cActivated) then
                                if (NextCmdTimeout = cActivated) then
                                        NextCmdTimeoutEnable <= cInactivated;
                                        NextCmdTimeoutEnable <= cInactivated;
Line 486... Line 533...
        end process Comb;
        end process Comb;
 
 
        TimeoutGenerator_inst: entity work.TimeoutGenerator
        TimeoutGenerator_inst: entity work.TimeoutGenerator
        generic map (
        generic map (
                gClkFrequency => 25E6,
                gClkFrequency => 25E6,
                gTimeoutTime  => 100 ms
                gTimeoutTime  => 10 ms
        )
        )
        port map (
        port map (
                iClk => iClk,
                iClk => iClk,
                inResetAsync => inResetAsync,
                inResetAsync => inResetAsync,
                iEnable => TimeoutEnable,
                iEnable => TimeoutEnable,

powered by: WebSVN 2.1.0

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