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
/
- from Rev 88 to Rev 89
- ↔ Reverse comparison
Rev 88 → Rev 89
/sdhc-sc-core/trunk/src/grpSd/unitTbdSd/src/TbdSd-Rtl-ea.vhdl
13,6 → 13,7
use work.Global.all; |
use work.Ics307Values.all; |
use work.Rs232.all; |
use work.Sd.all; |
|
entity TbdSd is |
|
50,29 → 51,41
|
signal SdCardStatus : std_ulogic_vector(31 downto 0); |
|
type aState is (send, waitforchange); |
type aState is (id, arg, waitforchange); |
type aReg is record |
State : aState; |
SdCardStatus : std_ulogic_vector(31 downto 0); |
Counter : unsigned(1 downto 0); |
Counter : natural; |
ReceivedContent : aSdCmdContent; |
ValidContent : aSdCmdContent; |
Data : std_ulogic_vector(7 downto 0); |
DataAvailable : std_ulogic; |
end record aReg; |
|
signal R, NextR : aReg; |
signal Ledbank : aLedBank; |
signal R, NextR : aReg; |
signal ReceivedContent : aSdCmdContent; |
signal oReceivedContentValid : std_ulogic; |
|
begin |
|
oLedBank(6 downto 0) <= Ledbank(6 downto 0); |
oDigitAdr <= "101"; -- DIGIT_6 |
oTx <= oRs232Tx.Tx; |
|
-- Send SdCardStatus via Rs232 |
iRs232Tx.Transmit <= cActivated; |
iRs232Tx.Data <= R.Data; |
iRs232Tx.DataAvailable <= R.DataAvailable; |
|
-- Send ReceivedContent via Rs232 |
Rs232_Send : process (iClk, inResetAsync) |
begin |
if (inResetAsync = cnActivated) then |
R.State <= send; |
R.State <= id; |
R.SdCardStatus <= (others => '0'); |
R.Counter <= "11"; |
R.Counter <= 3; |
R.ReceivedContent <= cDefaultSdCmdContent; |
R.ValidContent <= cDefaultSdCmdContent; |
R.Data <= (others => '0'); |
R.DataAvailable <= cInactivated; |
|
elsif (iClk'event and iClk = cActivated) then |
R <= NextR; |
80,29 → 93,36
end if; |
end process Rs232_Send; |
|
Rs232_comb : process (oRs232Tx.DataWasRead, SdCardStatus, R) |
Rs232_comb : process (oRs232Tx.DataWasRead, ReceivedContent, oReceivedContentValid, R) |
begin |
NextR <= R; |
iRs232Tx.Transmit <= cInactivated; |
iRs232Tx.Data <= R.SdCardStatus((to_integer(R.Counter) * 8) + 7 downto to_integer(R.Counter) * 8); |
iRs232Tx.DataAvailable <= cInactivated; |
|
case R.State is |
when waitforchange => |
oLedBank(7) <= cActivated; |
if (R.SdCardStatus /= SdCardStatus) then |
NextR.SdCardStatus <= SdCardStatus; |
NextR.State <= send; |
NextR.DataAvailable <= cInactivated; |
|
if (R.ReceivedContent /= R.ValidContent) then |
NextR.ReceivedContent <= R.ValidContent; |
NextR.State <= id; |
end if; |
|
when send => |
oLedBank(7) <= cInactivated; |
iRs232Tx.DataAvailable <= cActivated; |
iRs232Tx.Transmit <= cActivated; |
when id => |
NextR.DataAvailable <= cActivated; |
NextR.Data <= "00" & R.ReceivedContent.id; |
|
if (oRs232Tx.DataWasRead = cActivated) then |
if (R.Counter = "00") then |
NextR.Counter <= "11"; |
NextR.DataAvailable <= cInactivated; |
NextR.State <= arg; |
end if; |
|
when arg => |
NextR.DataAvailable <= cActivated; |
NextR.Data <= R.ReceivedContent.arg(R.Counter * 8 + 7 downto R.Counter * 8); |
|
if (oRs232Tx.DataWasRead = cActivated) then |
NextR.DataAvailable <= cInactivated; |
if (R.Counter = 0) then |
NextR.Counter <= 3; |
NextR.State <= waitforchange; |
else |
NextR.Counter <= R.Counter - 1; |
113,17 → 133,23
report "Unhandled state" severity error; |
end case; |
|
if (oReceivedContentValid = cActivated) then |
NextR.ValidContent <= ReceivedContent; |
end if; |
|
end process Rs232_comb; |
|
SDTop_inst : entity work.SdTop(Rtl) |
port map ( |
iClk => iClk, |
inResetAsync => inResetAsync, |
ioCmd => ioCmd, |
oSclk => oSclk, |
ioData => ioData, |
oSdCardStatus => SdCardStatus, |
oLedBank => LedBank |
iClk => iClk, |
inResetAsync => inResetAsync, |
ioCmd => ioCmd, |
oSclk => oSclk, |
ioData => ioData, |
oSdCardStatus => SdCardStatus, |
oReceivedContent => ReceivedContent, |
oReceivedContentValid => oReceivedContentValid, |
oLedBank => oLedBank |
); |
|
Rs232Tx_inst : entity work.Rs232Tx |
/sdhc-sc-core/trunk/src/grpSd/unitSdCardModel/src/SdCommand.sv
160,7 → 160,25
this.arg = ocr.get(); |
endbit = 1; |
endfunction |
|
task automatic send(virtual ISdCmd.Card ICmd); |
aCrc crc = 0; |
|
data.push_back(startbit); |
data.push_back(transbit); |
for(int i = 5; i >= 0; i--) |
data.push_back(id[i]); |
|
for (int i = 31; i>= 0; i--) |
data.push_back(arg[i]); |
|
for (int i = 6; i >= 0; i--) |
data.push_back(1); |
|
data.push_back(endbit); |
sendData(ICmd); |
endtask |
|
endclass |
|
include "../../unitSdCardModel/src/SDCID.sv"; |
/sdhc-sc-core/trunk/src/grpSd/pkgSd/src/Sd-p.vhdl
105,9 → 105,10
|
-- Types for entities |
type aSdCmdFromController is record |
Content : aSdCmdContent; |
Valid : std_ulogic; |
Content : aSdCmdContent; |
Valid : std_ulogic; |
ExpectCID : std_ulogic; -- gets asserted when next response is R2 |
CheckCrc : std_ulogic; |
end record aSdCmdFromController; |
|
type aSdCmdToController is record |
/sdhc-sc-core/trunk/src/grpSd/unitSdTop/src/SdTop-Rtl-ea.vhdl
22,8 → 22,10
ioData : inout std_logic_vector(3 downto 0); |
|
-- Status |
oSdCardStatus : out aSdCardStatus; |
oLedBank : out aLedBank |
oSdCardStatus : out aSdCardStatus; |
oReceivedContent : out aSdCmdContent; |
oReceivedContentValid : out std_ulogic; |
oLedBank : out aLedBank |
); |
end entity SdTop; |
|
34,9 → 36,11
signal SdRegisters : aSdRegisters; |
|
begin |
ioData <= "ZZZZ"; |
oSclk <= iClk; |
oSdCardStatus <= SdRegisters.CardStatus; |
ioData <= "ZZZZ"; |
oSclk <= iClk; |
oSdCardStatus <= SdRegisters.CardStatus; |
oReceivedContent <= ToController.Content; |
oReceivedContentValid <= ToController.Valid; |
|
SdController_inst: entity work.SdController(Rtl) |
port map ( |
/sdhc-sc-core/trunk/src/grpSd/unitSdVerificationTestbench/sim/wave.do
16,8 → 16,9
add wave -noupdate -format Literal /Testbed/top/ors232tx |
add wave -noupdate -format Literal /Testbed/top/sdcardstatus |
add wave -noupdate -format Literal /Testbed/top/r |
add wave -noupdate -format Literal -expand /Testbed/top/nextr |
add wave -noupdate -format Literal /Testbed/top/ledbank |
add wave -noupdate -format Literal /Testbed/top/nextr |
add wave -noupdate -format Literal /Testbed/top/receivedcontent |
add wave -noupdate -format Logic /Testbed/top/oreceivedcontentvalid |
add wave -noupdate -divider controller |
add wave -noupdate -format Literal /Testbed/top/sdtop_inst/sdcontroller_inst/isdcmd |
add wave -noupdate -format Literal /Testbed/top/sdtop_inst/sdcontroller_inst/osdcmd |
29,7 → 30,7
add wave -noupdate -format Logic /Testbed/top/sdtop_inst/sdcontroller_inst/timeout |
add wave -noupdate -divider cmd |
add wave -noupdate -format Literal /Testbed/top/sdtop_inst/sdcmd_inst/ifromcontroller |
add wave -noupdate -format Literal /Testbed/top/sdtop_inst/sdcmd_inst/otocontroller |
add wave -noupdate -format Literal -expand /Testbed/top/sdtop_inst/sdcmd_inst/otocontroller |
add wave -noupdate -format Logic /Testbed/top/sdtop_inst/sdcmd_inst/iocmd |
add wave -noupdate -format Logic /Testbed/top/sdtop_inst/sdcmd_inst/serialcrc |
add wave -noupdate -format Logic /Testbed/top/sdtop_inst/sdcmd_inst/crccorrect |
39,12 → 40,12
add wave -noupdate -format Literal /Testbed/top/sdtop_inst/sdcmd_inst/o |
add wave -noupdate -format Literal /Testbed/top/sdtop_inst/sdcmd_inst/nexto |
add wave -noupdate -divider rs232 |
add wave -noupdate -format Literal /Testbed/top/rs232tx_inst/r |
add wave -noupdate -format Literal -expand /Testbed/top/rs232tx_inst/r |
add wave -noupdate -format Literal /Testbed/top/rs232tx_inst/nextr |
add wave -noupdate -format Literal /Testbed/top/rs232tx_inst/ors232tx |
add wave -noupdate -format Literal /Testbed/top/rs232tx_inst/irs232tx |
TreeUpdate [SetDefaultTree] |
WaveRestoreCursors {{Cursor 1} {72588 ns} 0} |
WaveRestoreCursors {{Cursor 1} {1006060 ns} 0} |
configure wave -namecolwidth 150 |
configure wave -valuecolwidth 100 |
configure wave -justifyvalue left |
59,4 → 60,4
configure wave -timeline 0 |
configure wave -timelineunits ns |
update |
WaveRestoreZoom {72588 ns} {72843 ns} |
WaveRestoreZoom {0 ns} {2649759 ns} |
/sdhc-sc-core/trunk/src/grpSd/unitSdCmd/src/SdCmd-Rtl-ea.vhdl
238,12 → 238,16
NextR.ReceivedToken.endbit <= ioCmd; |
|
-- check |
if (CrcCorrect = cActivated and R.ReceivedToken.transbit = cSdTransBitSlave) then |
NextO.Controller.Valid <= cActivated; |
if (iFromController.CheckCrc = cActivated) then |
if (CrcCorrect = cActivated and R.ReceivedToken.transbit = cSdTransBitSlave) then |
NextO.Controller.Valid <= cActivated; |
|
else |
NextO.Controller.Err <= cActivated; |
else |
NextO.Controller.Err <= cActivated; |
|
end if; |
else |
NextO.Controller.Valid <= cActivated; |
end if; |
|
NextR.State <= idle; |
/sdhc-sc-core/trunk/src/grpSd/unitSdController/src/SdController-Rtl-ea.vhdl
37,7 → 37,8
(id => (others => '0'), |
arg => (others => '0')), |
Valid => cInactivated, |
ExpectCID => cInactivated); |
ExpectCID => cInactivated, |
CheckCrc => cActivated); |
|
type aSdControllerReg is record |
State : aSdControllerState; |
226,8 → 227,9
end if; |
|
when receive => |
oLedBank(0) <= cActivated; |
TimeoutEnable <= cActivated; |
oLedBank(0) <= cActivated; |
-- TimeoutEnable <= cActivated; |
oSdCmd.CheckCrc <= cInactivated; |
|
if (iSdCmd.Valid = cActivated) then |
NextR.CmdRegion <= CMD55; |
241,16 → 243,24
NextR.State <= invalidCard; |
else |
NextR.CCS <= ocr.ccs; |
NextR.CmdRegion <= CMD2; |
NextR.Region <= send; |
NextR.CmdRegion <= ACMD41; |
NextR.Region <= waitstate; |
end if; |
end if; |
end if; |
elsif (Timeout = cActivated) then |
NextR.CmdRegion <= CMD55; |
NextR.State <= invalidCard; |
end if; |
|
when waitstate => |
TimeoutEnable <= cActivated; |
|
if (Timeout = cActivated) then |
NextR.CmdRegion <= CMD2; |
NextR.Region <= send; |
end if; |
|
|
when others => |
report "SdController: Unhandled state" severity error; |
end case; |
276,12 → 286,18
|
if (iSdCmd.Content.id = cSdR2Id) then |
NextR.State <= init; |
NextR.CmdRegion <= CMD3; |
NextR.Region <= send; |
NextR.Region <= waitstate; |
end if; |
-- elsif timeout |
end if; |
|
when waitstate => |
TimeoutEnable <= cActivated; |
|
if (Timeout = cActivated) then |
NextR.CmdRegion <= CMD3; |
NextR.Region <= send; |
end if; |
when others => |
report "SdController: Unhandled state" severity error; |
end case; |
332,7 → 348,7
TimeoutGenerator_inst: entity work.TimeoutGenerator |
generic map ( |
gClkFrequency => 25E6, |
gTimeoutTime => 100 ms |
gTimeoutTime => 1 ms |
) |
port map ( |
iClk => iClk, |