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 101 to Rev 102
- ↔ Reverse comparison
Rev 101 → Rev 102
/unitSdCardModel/src/SdCardModel.sv
104,16 → 104,8
voltageresponse = new(recvcmd.arg); |
voltageresponse.send(ICmd); |
|
// expect CMD55 with default RCA |
recv(); |
assert(recvcmd.id == cSdCmdNextIsACMD); |
assert(recvcmd.arg == 0); |
state.recvCMD55(); |
recvCMD55(0); |
|
// respond with R1 |
response = new(cSdCmdNextIsACMD, state); |
response.send(ICmd); |
|
// expect ACMD41 with HCS = 1 |
recv(); |
assert(recvcmd.id == cSdCmdACMD41); |
124,16 → 116,8
acmd41response = new(ocr); |
acmd41response.send(ICmd); |
|
// expect CMD55 with default RCA |
recv(); |
assert(recvcmd.id == cSdCmdNextIsACMD); |
assert(recvcmd.arg == 0); |
state.recvCMD55(); |
recvCMD55(0); |
|
// respond with R1 |
response = new(cSdCmdNextIsACMD, state); |
response.send(ICmd); |
|
// expect ACMD41 with HCS = 1 |
recv(); |
assert(recvcmd.id == cSdCmdACMD41); |
171,17 → 155,8
response = new(cSdCmdSelCard, state); |
response.send(ICmd); |
|
// expect CMD55 |
recv(); |
assert(recvcmd.id == cSdCmdNextIsACMD); |
assert(recvcmd.arg[31:16] == rca); |
state.recvCMD55(); |
|
// respond with R1 |
response = new(cSdCmdNextIsACMD, state); |
response.send(ICmd); |
|
// expect ACMD51 |
recvCMD55(rca); |
recv(); |
assert(recvcmd.id == cSdCmdSendSCR); |
|
201,9 → 176,32
sddata = new(standard, widewidth); |
sddata.send(ICmd, data); |
|
// expect ACMD6 |
recvCMD55(rca); |
recv(); |
assert(recvcmd.id == cSdCmdSetBusWidth); |
assert(recvcmd.arg == 'h00000002); |
|
response = new(cSdCmdSetBusWidth, state); |
response.send(ICmd); |
|
-> InitDone; |
|
endtask |
|
task recvCMD55(RCA_t rca); |
SDCommandR1 response; |
|
// expect CMD55 |
recv(); |
assert(recvcmd.id == cSdCmdNextIsACMD); |
assert(recvcmd.arg[31:16] == rca); |
state.recvCMD55(); |
|
// respond with R1 |
response = new(cSdCmdNextIsACMD, state); |
response.send(ICmd); |
endtask |
|
function automatic SDCommandToken getCmd(); |
return recvcmd; |
/unitSdCardModel/src/SdCommand.sv
24,7 → 24,8
|
typedef enum { |
cSdCmdACMD41 = 41, |
cSdCmdSendSCR = 51 |
cSdCmdSendSCR = 51, |
cSdCmdSetBusWidth = 6 |
} SDAppCommandId; |
|
const SDCommandArg cSdArgACMD41HCS = 'b01000000111111111000000000000000; |
/pkgSd/src/Sd-p.vhdl
104,6 → 104,8
subtype aSdRCA is std_ulogic_vector(15 downto 0); |
constant cDefaultRCA : aSdRCA := (others => '0'); |
|
constant cSdWideModeBit : natural := 50; |
|
-- Data types |
constant cBlocklen : natural := 512 * 8; -- 512 bytes |
subtype aSdDataBlock is std_ulogic_vector(cBlocklen - 1 downto 0); |
235,6 → 237,9
|
constant cSdCmdACMD41 : aSdCmdId := std_ulogic_vector(to_unsigned(41, cSdCmdIdHigh)); |
constant cSdCmdSendSCR : aSdCmdId := std_ulogic_vector(to_unsigned(51, cSdCmdIdHigh)); |
constant cSdCmdSetBusWidth : aSdCmdId := std_ulogic_vector(to_unsigned(6, cSdCmdIdHigh)); -- [31:2] stuff, [1:0] bus width |
constant cSdWideBusWidth : std_ulogic_vector(1 downto 0) := "10"; |
constant cSdStandardBusWidth : std_ulogic_vector(1 downto 0) := "00"; |
|
end package Sd; |
|
/unitSdController/src/SdController-Rtl-a.vhdl
11,7 → 11,7
architecture Rtl of SdController is |
|
type aSdControllerState is (startup, init, config, idle, invalidCard); |
type aCmdRegion is (CMD0, CMD8, ACMD41, CMD2, CMD3, SelectCard, CheckBusWidth); |
type aCmdRegion is (CMD0, CMD8, ACMD41, CMD2, CMD3, SelectCard, CheckBusWidth, SetBusWidth, CheckSpeed); |
type aRegion is (idle, send, response, waitstate, senddata, receivedata, checkbusy, waitstatedata); |
|
constant cDefaultToSdCmd : aSdCmdFromController := ( |
89,7 → 89,12
NextState := R.State; |
|
-- Status |
oLedBank <= (others => cInactivated); |
oLedBank <= (others => cInactivated); |
if (R.ToSdData.Mode = wide) then |
oLedBank(5) <= cActivated; |
else |
oLedBank(5) <= cInactivated; |
end if; |
|
case R.State is |
when startup => |
198,8 → 203,6
end if; |
|
when CMD2 => |
oLedBank(3) <= cActivated; |
|
case R.Region is |
when send => |
NextR.ToSdCmd.Content.id <= cSdCmdAllSendCID; |
230,8 → 233,6
end case; |
|
when CMD3 => |
oLedBank(4) <= cActivated; |
|
case R.Region is |
when send => |
NextR.ToSdCmd.Content.id <= cSdCmdSendRelAdr; |
262,7 → 263,7
end case; |
|
when config => |
oLedBank(5) <= cActivated; |
oLedBank(3) <= cActivated; |
|
case R.CmdRegion is |
when SelectCard => |
331,18 → 332,69
when receivedata => |
if (iSdData.Err = cActivated) then |
NextR.State <= init; |
|
elsif (iSdData.Valid = cActivated) then |
-- check for 4 bit mode |
NextR.State <= idle; |
NextR.Region <= waitstatedata; |
|
elsif (Timeout = cActivated) then |
NextR.State <= invalidCard; |
end if; |
|
when waitstatedata => |
NextRegion := send; |
|
if (NextCmdTimeout = cActivated) then |
if (iSdData.DataBlock(cSdWideModeBit) = cActivated) then |
NextCmdRegion := SetBusWidth; |
NextR.SendCMD55 <= cActivated; |
|
else |
NextCmdRegion := CheckSpeed; |
end if; |
end if; |
|
|
when others => |
report "Unhandled region" severity error; |
end case; |
end if; |
|
when SetBusWidth => |
oLedBank(4) <= cActivated; |
|
if (R.SendCMD55 = cInactivated) then |
case R.Region is |
when send => |
NextR.ToSdCmd.Content.id <= cSdCmdSetBusWidth; |
NextR.ToSdCmd.Content.arg(1 downto 0) <= cSdWideBusWidth; |
NextRegion := response; |
|
when response => |
if (iSdCmd.Valid = cActivated) then |
if (iSdCmd.Content.id = cSdCmdSetBusWidth) then |
NextR.CardStatus <= iSdCmd.Content.arg; |
NextR.Region <= waitstate; |
|
else |
NextR.State <= invalidCard; |
end if; |
elsif (Timeout = cActivated) then |
NextR.State <= invalidCard; |
end if; |
|
when waitstate => |
NextRegion := send; |
NextCmdRegion := CheckSpeed; |
NextR.ToSdData.Mode <= wide; |
|
when others => |
report "Unhandled region" severity error; |
end case; |
end if; |
|
when CheckSpeed => |
NextR.State <= idle; |
|
when others => |
report "Unhandled CmdRegion" severity error; |
end case; |