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

Subversion Repositories sdhc-sc-core

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /sdhc-sc-core/trunk/src/grpSd
    from Rev 95 to Rev 96
    Reverse comparison

Rev 95 → Rev 96

/unitTbdSd/src/TbdSd-Rtl-ea.vhdl
59,8 → 59,17
DataAvailable : std_ulogic;
end record aReg;
 
signal R, NextR : aReg;
signal ReceivedContent : aSdCmdContent;
constant cDefaultReg : aReg := (
State => id,
Counter => 3,
ReceivedContent => cDefaultSdCmdContent,
ValidContent => cDefaultSdCmdContent,
Data => (others => '0'),
DataAvailable => cInactivated);
 
signal R : aReg := cDefaultReg;
signal NextR : aReg;
signal ReceivedContent : aSdCmdContent;
signal oReceivedContentValid : std_ulogic;
 
begin
76,12 → 85,7
Rs232_Send : process (iClk, inResetAsync)
begin
if (inResetAsync = cnActivated) then
R.State <= id;
R.Counter <= 3;
R.ReceivedContent <= cDefaultSdCmdContent;
R.ValidContent <= cDefaultSdCmdContent;
R.Data <= (others => '0');
R.DataAvailable <= cInactivated;
R <= cDefaultReg;
 
elsif (iClk'event and iClk = cActivated) then
R <= NextR;
/unitSdCardModel/src/SdCardModel.sv
34,10 → 34,11
 
// Receive a command token and handle it
task recv();
ICmd.cb.Cmd <= 'z;
 
repeat(8) @ICmd.cb;
 
recvcmd = new();
ICmd.cb.Cmd <= 'z;
 
wait(ICmd.cb.Cmd == 0);
// Startbit
151,6 → 152,14
rcaresponse = new(rca, state);
rcaresponse.send(ICmd);
 
// expect CMD7
recv();
assert(recvcmd.id == cSdCmdSelCard);
assert(recvcmd.arg[31:16] == rca);
 
// respond with R1b
 
-> InitDone;
 
endtask
/unitSdController/src/SdController-Rtl-a.vhdl
10,7 → 10,7
 
type aSdControllerState is (startup, init, config, idle, invalidCard);
type aCmdRegion is (CMD0, CMD8, CMD55, ACMD41, CMD2, CMD3, SelectCard);
type aRegion is (send, receive, waitstate);
type aRegion is (idle, send, receive, waitstate);
constant cDefaultToSdCmd : aSdCmdFromController := (
(id => (others => '0'),
34,7 → 34,7
constant cDefaultSdControllerReg : aSdControllerReg := (
State => startup,
CmdRegion => CMD0,
Region => send,
Region => idle,
HCS => cActivated,
CCS => cInactivated,
RCA => cDefaultRCA,
65,8 → 65,11
end process Regs;
 
Comb : process (iSdCmd, Timeout, NextCmdTimeout, R)
variable ocr : aSdRegOCR;
variable arg : aSdCmdArg;
variable ocr : aSdRegOCR;
variable arg : aSdCmdArg;
variable NextRegion : aRegion;
variable NextCmdRegion : aCmdRegion;
variable NextState : aSdControllerState;
begin
-- default assignments
NextR <= R;
74,6 → 77,11
TimeoutEnable <= cInactivated;
NextCmdTimeoutEnable <= cInactivated;
 
-- variables
NextRegion := R.Region;
NextCmdRegion := R.CmdRegion;
NextState := R.State;
 
-- Status
oLedBank <= (others => cInactivated);
 
83,7 → 91,8
if (Timeout = cActivated) then
TimeoutEnable <= cInactivated;
NextR.State <= init;
NextR.State <= init;
NextR.Region <= send;
end if;
 
when init =>
92,23 → 101,13
case R.Region is
when send =>
NextR.ToSdCmd.Content.id <= cSdCmdGoIdleState;
NextR.ToSdCmd.Valid <= cActivated;
NextR.CardStatus <= cDefaultSdCardStatus;
NextRegion := waitstate;
 
if (iSdCmd.Ack = cActivated) then
NextR.ToSdCmd.Valid <= cInactivated;
NextR.Region <= waitstate;
NextR.CardStatus <= cDefaultSdCardStatus;
end if;
 
when waitstate =>
NextCmdTimeoutEnable <= cActivated;
NextRegion := send;
NextCmdRegion := CMD8;
 
if (NextCmdTimeout = cActivated) then
NextCmdTimeoutEnable <= cInactivated;
NextR.Region <= send;
NextR.CmdRegion <= CMD8;
end if;
 
when others =>
report "SdController: Unhandled state" severity error;
end case;
118,17 → 117,9
when send =>
NextR.ToSdCmd.Content.id <= cSdCmdSendIfCond;
NextR.ToSdCmd.Content.arg <= cSdArgVoltage;
NextR.ToSdCmd.Valid <= cActivated;
NextRegion := receive;
 
if (iSdCmd.Ack = cActivated) then
NextR.ToSdCmd.Valid <= cInactivated;
NextR.Region <= receive;
end if;
 
when receive =>
oLedBank(0) <= cActivated;
TimeoutEnable <= cActivated;
 
if (iSdCmd.Valid = cActivated) then
if (iSdCmd.Content.id = cSdCmdSendIfCond and iSdCmd.Content.arg = cSdArgVoltage) then
NextR.Region <= waitstate;
144,14 → 135,9
end if;
 
when waitstate =>
NextCmdTimeoutEnable <= cActivated;
NextCmdRegion := CMD55;
NextRegion := send;
 
if (NextCmdTimeout = cActivated) then
NextCmdTimeoutEnable <= cInactivated;
NextR.CmdRegion <= CMD55;
NextR.Region <= send;
end if;
 
when others =>
report "SdController: Unhandled state" severity error;
end case;
163,17 → 149,9
when send =>
NextR.ToSdCmd.Content.id <= cSdNextIsACMD;
NextR.ToSdCmd.Content.arg <= cSdACMDArg;
NextR.ToSdCmd.Valid <= cActivated;
NextRegion := receive;
 
if (iSdCmd.Ack = cActivated) then
NextR.ToSdCmd.Valid <= cInactivated;
NextR.Region <= receive;
end if;
 
when receive =>
oLedBank(0) <= cActivated;
TimeoutEnable <= cActivated;
 
if (iSdCmd.Valid = cActivated) then
if (iSdCmd.Content.id = cSdNextIsACMD) then
NextR.CardStatus <= iSdCmd.Content.arg;
192,13 → 170,9
end if;
 
when waitstate =>
NextCmdTimeoutEnable <= cActivated;
NextCmdRegion := ACMD41;
NextRegion := send;
 
if (NextCmdTimeout = cActivated) then
NextR.CmdRegion <= ACMD41;
NextR.Region <= send;
end if;
 
when others =>
report "SdController: Unhandled state" severity error;
end case;
214,15 → 188,9
NextR.ToSdCmd.Content.id <= cSdCmdACMD41;
NextR.ToSdCmd.Content.arg <= OCRToArg(ocr);
NextR.ToSdCmd.Valid <= cActivated;
if (iSdCmd.Ack = cActivated) then
NextR.ToSdCmd.Valid <= cInactivated;
NextR.Region <= receive;
end if;
NextRegion := receive;
 
when receive =>
oLedBank(0) <= cActivated;
TimeoutEnable <= cActivated;
NextR.ToSdCmd.CheckCrc <= cInactivated;
 
if (iSdCmd.Valid = cActivated) then
247,14 → 215,10
end if;
when waitstate =>
NextCmdTimeoutEnable <= cActivated;
NextCmdRegion := CMD2;
NextRegion := send;
 
if (NextCmdTimeout = cActivated) then
NextR.CmdRegion <= CMD2;
NextR.Region <= send;
end if;
 
 
when others =>
report "SdController: Unhandled state" severity error;
end case;
267,15 → 231,10
NextR.ToSdCmd.Content.id <= cSdCmdAllSendCID;
NextR.ToSdCmd.Valid <= cActivated;
 
if (iSdCmd.Ack = cActivated) then
NextR.ToSdCmd.Valid <= cInactivated;
NextR.Region <= receive;
end if;
NextRegion := receive;
 
when receive =>
oLedBank(0) <= cActivated;
NextR.ToSdCmd.ExpectCID <= cActivated;
TimeoutEnable <= cActivated;
 
if (iSdCmd.Valid = cActivated) then
NextR.State <= invalidCard;
289,12 → 248,9
end if;
when waitstate =>
NextCmdTimeoutEnable <= cActivated;
NextCmdRegion := CMD3;
NextRegion := send;
 
if (NextCmdTimeout = cActivated) then
NextR.CmdRegion <= CMD3;
NextR.Region <= send;
end if;
when others =>
report "SdController: Unhandled state" severity error;
end case;
307,25 → 263,23
NextR.ToSdCmd.Content.id <= cSdCmdSendRelAdr;
NextR.ToSdCmd.Valid <= cActivated;
 
if (iSdCmd.Ack = cActivated) then
NextR.ToSdCmd.Valid <= cInactivated;
NextR.Region <= receive;
end if;
NextRegion := receive;
 
when receive =>
oLedBank(0) <= cActivated;
TimeoutEnable <= cActivated;
 
if (iSdCmd.Valid = cActivated) then
if (iSdCmd.Content.id = cSdCmdSendRelAdr) then
NextR.RCA <= iSdCmd.Content.arg(31 downto 16);
NextR.State <= idle; -- config;
NextR.CmdRegion <= SelectCard;
NextR.RCA <= iSdCmd.Content.arg(31 downto 16);
NextR.Region <= waitstate;
end if;
elsif (Timeout = cActivated) then
NextR.State <= invalidCard;
end if;
 
when waitstate =>
NextState := config;
NextCmdRegion := SelectCard;
NextRegion := send;
 
when others =>
report "SdController: Unhandled state" severity error;
end case;
341,15 → 295,20
when SelectCard =>
case R.Region is
when send =>
NextR.ToSdCmd.Content.id <= cSdCmdSelCard;
NextR.ToSdCmd.Valid <= cActivated;
NextR.ToSdCmd.Content.id <= cSdCmdSelCard;
NextR.ToSdCmd.Content.arg <= R.RCA & X"0000";
 
if (iSdCmd.Ack = cActivated) then
NextR.ToSdCmd.Valid <= cInactivated;
NextR.Region <= receive;
end if;
NextRegion := receive;
 
when receive => -- Response R1b: with busy!
if (iSdCmd.Valid = cActivated) then
if (iSdCmd.Content.id = cSdCmdSelCard) then
NextR.CardStatus <= iSdCmd.Content.arg;
NextR.State <= idle;
end if;
elsif (Timeout = cActivated) then
NextR.State <= invalidCard;
end if;
 
when waitstate =>
 
370,6 → 329,36
when others =>
report "SdController: Unhandled state" severity error;
end case;
 
case R.Region is
when idle => -- do nothing
null;
 
when send =>
NextR.ToSdCmd.Valid <= cActivated;
 
if (iSdCmd.Ack = cActivated) then
NextR.ToSdCmd.Valid <= cInactivated;
NextR.Region <= NextRegion;
end if;
 
when receive =>
oLedBank(0) <= cActivated;
TimeoutEnable <= cActivated;
 
when waitstate =>
NextCmdTimeoutEnable <= cActivated;
 
if (NextCmdTimeout = cActivated) then
NextCmdTimeoutEnable <= cInactivated;
NextR.Region <= NextRegion;
NextR.CmdRegion <= NextCmdRegion;
NextR.State <= NextState;
end if;
 
when others =>
report "Unhandled region" severity error;
end case;
end process Comb;
 
TimeoutGenerator_inst: entity work.TimeoutGenerator
386,7 → 375,7
NextCmdTimeoutGenerator_inst: entity work.TimeoutGenerator
generic map (
gClkFrequency => 25E6,
gTimeoutTime => 1 sec / 25E6 * (8)
gTimeoutTime => 600 us--1 sec / 25E6 * (8)
)
port map (
iClk => iClk,

powered by: WebSVN 2.1.0

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