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
- from Rev 83 to Rev 84
- ↔ Reverse comparison
Rev 83 → Rev 84
/trunk/src/grpSd/unitSdVerificationTestbench/sim/wave.do
1,23 → 1,12
onerror {resume} |
quietly WaveActivateNextPane {} 0 |
add wave -noupdate -format Logic /Testbed/top/iclk |
add wave -noupdate -format Logic /Testbed/top/inresetasync |
add wave -noupdate -format Logic /Testbed/top/iocmd |
add wave -noupdate -format Logic /Testbed/top/osclk |
add wave -noupdate -format Literal /Testbed/top/iodata |
add wave -noupdate -format Literal /Testbed/top/oledbank |
add wave -noupdate -format Literal /Testbed/top/tocontroller |
add wave -noupdate -format Literal /Testbed/top/fromcontroller |
add wave -noupdate -divider controller |
add wave -noupdate -format Logic /Testbed/top/sdcontroller_inst/iclk |
add wave -noupdate -format Logic /Testbed/top/sdcontroller_inst/inresetasync |
add wave -noupdate -format Literal /Testbed/top/sdcontroller_inst/isdcmd |
add wave -noupdate -format Literal /Testbed/top/sdcontroller_inst/osdcmd |
add wave -noupdate -format Literal /Testbed/top/sdcontroller_inst/oledbank |
add wave -noupdate -format Literal /Testbed/top/sdcontroller_inst/reg |
add wave -noupdate -format Literal /Testbed/top/sdcontroller_inst/nextreg |
add wave -noupdate -format Literal /Testbed/top/sdcontroller_inst/state |
add wave -noupdate -format Literal /Testbed/top/sdcontroller_inst/nextstate |
add wave -noupdate -format Literal /Testbed/top/sdcontroller_inst/osdcmd |
add wave -noupdate -format Literal /Testbed/top/sdcontroller_inst/isdcmd |
add wave -noupdate -format Logic /Testbed/top/sdcontroller_inst/inresetasync |
add wave -noupdate -format Logic /Testbed/top/sdcontroller_inst/iclk |
add wave -noupdate -format Literal /Testbed/top/sdcontroller_inst/r |
add wave -noupdate -format Literal /Testbed/top/sdcontroller_inst/nextr |
add wave -noupdate -divider cmd |
add wave -noupdate -format Logic /Testbed/top/sdcmd_inst/iclk |
add wave -noupdate -format Logic /Testbed/top/sdcmd_inst/inresetasync |
32,7 → 21,7
add wave -noupdate -format Literal /Testbed/top/sdcmd_inst/o |
add wave -noupdate -format Literal /Testbed/top/sdcmd_inst/nexto |
TreeUpdate [SetDefaultTree] |
WaveRestoreCursors {{Cursor 1} {1940 ns} 0} |
WaveRestoreCursors {{Cursor 1} {1040 ns} 0} |
configure wave -namecolwidth 150 |
configure wave -valuecolwidth 100 |
configure wave -justifyvalue left |
/trunk/src/grpSd/unitSdController/src/SdController-Rtl-ea.vhdl
28,24 → 28,34
|
architecture Rtl of SdController is |
|
type aSdControllerState is (CMD0, CMD8Ws, CMD8, CMD8Response, CMD55, |
CMD55Response, ACMD41, ACMD41Response, CMD2, CMD2Response, CMD3, |
CMD3Response, idle, invalidCard); |
constant cDefaultControllerState : aSdControllerState := CMD0; |
constant cDefaultoSdCmd : aSdCmdFromController := ((id => (others => '0'), |
arg => (others => '0')), Valid => cInactivated, ExpectCID => cInactivated); |
type aSdControllerState is (init, idle, invalidCard); |
type aCmdRegion is (CMD0, CMD8, CMD55, ACMD41, CMD2, CMD3); |
type aRegion is (send, receive); |
|
constant cDefaultoSdCmd : aSdCmdFromController := ( |
(id => (others => '0'), |
arg => (others => '0')), |
Valid => cInactivated, |
ExpectCID => cInactivated); |
|
type aSdControllerReg is record |
HCS : std_ulogic; |
CCS : std_ulogic; |
RCA : aSdRCA; |
State : aSdControllerState; |
CmdRegion : aCmdRegion; |
Region : aRegion; |
HCS : std_ulogic; |
CCS : std_ulogic; |
RCA : aSdRCA; |
end record aSdControllerReg; |
constant cDefaultSdControllerReg : aSdControllerReg := (cActivated, |
cInactivated, cDefaultRCA); |
|
signal Reg, NextReg : aSdControllerReg; |
constant cDefaultSdControllerReg : aSdControllerReg := ( |
State => init, |
CmdRegion => CMD0, |
Region => send, |
HCS => cActivated, |
CCS => cInactivated, |
RCA => cDefaultRCA); |
|
signal State, NextState : aSdControllerState; |
signal R, NextR : aSdControllerReg; |
|
begin |
|
52,163 → 62,220
Regs : process (iClk, inResetAsync) |
begin |
if (inResetAsync = cnActivated) then |
State <= cDefaultControllerState; |
Reg <= cDefaultSdControllerReg; |
R <= cDefaultSdControllerReg; |
elsif (iClk'event and iClk = cActivated) then |
Reg <= NextReg; |
State <= NextState; |
R <= NextR; |
end if; |
end process Regs; |
|
Comb : process (iSdCmd, State, Reg) |
Comb : process (iSdCmd, R) |
variable ocr : aSdRegOCR; |
variable arg : aSdCmdArg; |
begin |
-- default assignments |
oSdCmd <= cDefaultoSdCmd; |
NextReg <= Reg; |
NextState <= State; |
NextR <= R; |
|
-- Status |
oLedBank <= (others => cInactivated); |
|
case State is |
when idle => |
oLedBank(6) <= cActivated; |
case R.State is |
when init => |
case R.CmdRegion is |
when CMD0 => |
case R.Region is |
when send => |
oSdCmd.Content.id <= cSdCmdGoIdleState; |
oSdCmd.Valid <= cActivated; |
|
when CMD0 => |
oSdCmd.Content.id <= cSdCmdGoIdleState; |
oSdCmd.Valid <= cActivated; |
if (iSdCmd.Ack = cActivated) then |
NextState <= CMD8Ws; |
end if; |
if (iSdCmd.Ack = cActivated) then |
NextR.CmdRegion <= CMD8; |
NextR.Region <= send; |
end if; |
|
when others => |
report "SdController: Unhandled state" severity error; |
end case; |
|
when CMD8Ws => |
if (iSdCmd.Ack = cInactivated) then |
NextState <= CMD8; |
end if; |
when CMD8 => |
case R.Region is |
when send => |
oSdCmd.Content.id <= cSdCmdSendIfCond; |
oSdCmd.Content.arg <= cSdArgVoltage; |
oSdCmd.Valid <= cActivated; |
|
when CMD8 => |
oSdCmd.Content.id <= cSdCmdSendIfCond; |
oSdCmd.Content.arg <= cSdArgVoltage; |
oSdCmd.Valid <= cActivated; |
if (iSdCmd.Ack = cActivated) then |
NextState <= CMD8Response; |
end if; |
if (iSdCmd.Ack = cActivated) then |
NextR.Region <= receive; |
end if; |
|
when CMD8Response => |
oLedBank(0) <= cActivated; |
if (iSdCmd.Valid = cActivated) then |
if (iSdCmd.Content.id = cSdCmdSendIfCond and |
iSdCmd.Content.arg = cSdArgVoltage) then |
NextReg.HCS <= cActivated; |
NextState <= CMD55; |
else |
NextState <= invalidCard; |
end if; |
-- elsif timeout |
end if; |
when receive => |
oLedBank(0) <= cActivated; |
|
when invalidCard => |
oLedBank(7) <= cActivated; |
if (iSdCmd.Valid = cActivated) then |
if (iSdCmd.Content.id = cSdCmdSendIfCond and iSdCmd.Content.arg = cSdArgVoltage) then |
NextR.HCS <= cActivated; |
NextR.CmdRegion <= CMD55; |
NextR.Region <= send; |
|
when CMD55 => |
oLedBank(1) <= cActivated; |
oSdCmd.Content.id <= cSdNextIsACMD; |
oSdCmd.Content.arg <= cSdACMDArg; |
oSdCmd.Valid <= cActivated; |
if (iSdCmd.Ack = cActivated) then |
NextState <= CMD55Response; |
end if; |
else |
NextR.State <= invalidCard; |
end if; |
-- elsif timeout |
end if; |
|
when others => |
report "SdController: Unhandled state" severity error; |
end case; |
|
when CMD55Response => |
oLedBank(1) <= cActivated; |
oLedBank(0) <= cActivated; |
if (iSdCmd.Valid = cActivated) then |
NextState <= invalidCard; |
if (iSdCmd.Content.id = cSdNextIsACMD) then |
if (iSdCmd.Content.arg(cSdArgAppCmdPos) = cActivated) |
then |
NextState <= ACMD41; |
end if; |
end if; |
-- elsif timeout |
end if; |
when CMD55 => |
case R.Region is |
when send => |
oLedBank(1) <= cActivated; |
oSdCmd.Content.id <= cSdNextIsACMD; |
oSdCmd.Content.arg <= cSdACMDArg; |
oSdCmd.Valid <= cActivated; |
|
when ACMD41 => |
oLedBank(2) <= cActivated; |
oSdCmd.Content.id <= cSdCmdACMD41; |
ocr.nBusy := cnActivated; |
ocr.ccs := Reg.HCS; |
ocr.voltagewindow := cVoltageWindow; |
oSdCmd.Content.arg <= OCRToArg(ocr); |
oSdCmd.Valid <= cActivated; |
if (iSdCmd.Ack = cActivated) then |
NextState <= ACMD41Response; |
end if; |
if (iSdCmd.Ack = cActivated) then |
NextR.Region <= receive; |
end if; |
|
when ACMD41Response => |
oLedBank(0) <= cActivated; |
oLedBank(2) <= cActivated; |
if (iSdCmd.Valid = cActivated) then |
NextState <= CMD55; |
if (iSdCmd.Content.id = cSdR3Id) then |
ocr := ArgToOcr(iSdCmd.Content.arg); |
if (ocr.nBusy = cnInactivated) then |
if (ocr.voltagewindow /= cVoltageWindow) then |
NextState <= invalidCard; |
else |
NextReg.CCS <= ocr.ccs; |
NextState <= CMD2; |
end if; |
end if; |
end if; |
end if; |
when receive => |
oLedBank(1) <= cActivated; |
oLedBank(0) <= cActivated; |
|
when CMD2 => |
oLedBank(3) <= cActivated; |
oSdCmd.Content.id <= cSdCmdAllSendCID; |
oSdCmd.Valid <= cActivated; |
if (iSdCmd.Ack = cActivated) then |
NextState <= CMD2Response; |
end if; |
if (iSdCmd.Valid = cActivated) then |
if (iSdCmd.Content.id = cSdNextIsACMD) then |
NextR.CmdRegion <= CMD55; |
|
when CMD2Response => |
oLedBank(3) <= cActivated; |
oLedBank(0) <= cActivated; |
oSdCmd.ExpectCID <= cActivated; |
|
if (iSdCmd.Valid = cActivated) then |
NextState <= invalidCard; |
if (iSdCmd.Content.arg(cSdArgAppCmdPos) = cActivated) then |
NextR.CmdRegion <= ACMD41; |
NextR.Region <= send; |
end if; |
else |
NextR.State <= invalidCard; |
end if; |
-- elsif timeout |
end if; |
|
if (iSdCmd.Content.id = cSdR2Id) then |
NextState <= CMD3; |
end if; |
end if; |
when others => |
report "SdController: Unhandled state" severity error; |
end case; |
|
when CMD3 => |
oLedBank(4) <= cActivated; |
oSdCmd.Content.id <= cSdCmdSendRelAdr; |
oSdCmd.Valid <= cActivated; |
if (iSdCmd.Ack = cActivated) then |
NextState <= CMD3Response; |
end if; |
when ACMD41 => |
oLedBank(2) <= cActivated; |
|
case R.Region is |
when send => |
ocr.nBusy := cnActivated; |
ocr.ccs := R.HCS; |
ocr.voltagewindow := cVoltageWindow; |
|
oSdCmd.Content.id <= cSdCmdACMD41; |
oSdCmd.Content.arg <= OCRToArg(ocr); |
oSdCmd.Valid <= cActivated; |
if (iSdCmd.Ack = cActivated) then |
NextR.Region <= receive; |
end if; |
|
when CMD3Response => |
oLedBank(4) <= cActivated; |
oLedBank(0) <= cActivated; |
if (iSdCmd.Valid = cActivated) then |
if (iSdCmd.Content.id = cSdCmdSendRelAdr) then |
-- todo: check status |
NextReg.RCA <= iSdCmd.Content.arg(31 downto 16); |
NextState <= idle; |
end if; |
end if; |
when receive => |
oLedBank(0) <= cActivated; |
|
if (iSdCmd.Valid = cActivated) then |
NextR.CmdRegion <= CMD55; |
NextR.Region <= send; |
|
if (iSdCmd.Content.id = cSdR3Id) then |
ocr := ArgToOcr(iSdCmd.Content.arg); |
|
if (ocr.nBusy = cnInactivated) then |
if (ocr.voltagewindow /= cVoltageWindow) then |
NextR.State <= invalidCard; |
else |
NextR.CCS <= ocr.ccs; |
NextR.CmdRegion <= CMD2; |
NextR.Region <= send; |
end if; |
end if; |
end if; |
-- elsif timeout |
end if; |
|
when others => |
report "SdController: Unhandled state" severity error; |
end case; |
|
when CMD2 => |
oLedBank(3) <= cActivated; |
|
case R.Region is |
when send => |
oSdCmd.Content.id <= cSdCmdAllSendCID; |
oSdCmd.Valid <= cActivated; |
|
if (iSdCmd.Ack = cActivated) then |
NextR.Region <= receive; |
end if; |
|
when receive => |
oLedBank(0) <= cActivated; |
oSdCmd.ExpectCID <= cActivated; |
|
if (iSdCmd.Valid = cActivated) then |
NextR.State <= invalidCard; |
|
if (iSdCmd.Content.id = cSdR2Id) then |
NextR.State <= init; |
NextR.CmdRegion <= CMD3; |
NextR.Region <= send; |
end if; |
-- elsif timeout |
end if; |
|
when others => |
report "SdController: Unhandled state" severity error; |
end case; |
|
when CMD3 => |
oLedBank(4) <= cActivated; |
|
case R.Region is |
when send => |
oSdCmd.Content.id <= cSdCmdSendRelAdr; |
oSdCmd.Valid <= cActivated; |
|
if (iSdCmd.Ack = cActivated) then |
NextR.Region <= receive; |
end if; |
|
when receive => |
oLedBank(0) <= cActivated; |
|
if (iSdCmd.Valid = cActivated) then |
if (iSdCmd.Content.id = cSdCmdSendRelAdr) then |
-- todo: check status |
NextR.RCA <= iSdCmd.Content.arg(31 downto 16); |
NextR.State <= idle; |
end if; |
--elsif timeout |
end if; |
|
when others => |
report "SdController: Unhandled state" severity error; |
end case; |
|
when others => |
report "SdController: Unhandled state" severity error; |
end case; |
|
when idle => |
oLedBank(6) <= cActivated; |
|
when invalidCard => |
oLedBank(7) <= cActivated; |
|
when others => |
report "SdController: State not handled" severity error; |
report "SdController: Unhandled state" severity error; |
end case; |
end process Comb; |
|
end architecture Rtl; |
|