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
    /
    from Rev 49 to Rev 50
    Reverse comparison

Rev 49 → Rev 50

/sdhc-sc-core/trunk/src/grpSd/unitSdCardModel/src/SdCardModel.sv
10,6 → 10,7
 
`define cSDArgWith 32
typedef logic[`cSDArgWith-1:0] SDCommandArg;
typedef logic[6:0] aCrc;
 
typedef enum {
cSdCmdGoIdleState = 0,
31,10 → 32,53
class SDCommandToken;
logic startbit;
logic transbit;
SDCommandId id;
logic[5:0] id;
SDCommandArg arg;
logic[6:0] crc7;
aCrc crc7;
logic endbit;
 
 
function void display();
$display("Startbit: %b", startbit);
$display("Transbit: %b", transbit);
$display("ID: %b", id);
$display("Arg: %h", arg);
$display("CRC: %b", crc7);
$display("Endbit: %b" , endbit);
endfunction
 
function void checkStartEnd();
assert(startbit == 0);
assert(endbit == 1);
endfunction
function void checkFromHost();
checkStartEnd();
checkCrc();
assert(transbit == 1);
endfunction
 
function void checkCrc();
assert(crc7 == calcCrc());
endfunction
 
function automatic aCrc calcCrc();
aCrc crc = 0;
logic[39:0] temp;
temp[39] = startbit;
temp[38] = transbit;
temp[37:32] = id;
temp[31:0] = arg;
for(int i = 39; i >= 0; i--) begin
if (((crc[6] & 1)) != temp[i])
crc = (crc << 1) ^ 'b10001001;
else
crc <<= 1;
end
return crc;
endfunction
 
endclass
 
class SDCommandResponse;
42,10 → 86,17
endclass
 
class SDCard;
virtual ISdCmd.Card ICmd;
 
SDCardState state;
SDCommandToken recvcmd;
 
function new();
event CmdReceived;
 
function new(virtual ISdCmd CmdInterface, event CmdReceived);
ICmd = CmdInterface;
state = idle;
this.CmdReceived = CmdReceived;
endfunction
 
task reset();
52,6 → 103,49
state = idle;
endtask
 
task recv();
recvcmd = new();
ICmd.cbCard.Cmd <= 'z;
 
@(ICmd.cbCard.Cmd == 0);
// Startbit
recvcmd.startbit = ICmd.cbCard.Cmd;
 
@ICmd.cbCard;
// Transbit
recvcmd.transbit = ICmd.cbCard.Cmd;
 
// CmdID
for (int i = 5; i >= 0; i--) begin
@ICmd.cbCard;
recvcmd.id[i] = ICmd.cbCard.Cmd;
end
 
// Arg
for (int i = 31; i >= 0; i--) begin
@ICmd.cbCard;
recvcmd.arg[i] = ICmd.cbCard.Cmd;
end
 
// CRC
for (int i = 6; i >= 0; i--) begin
@ICmd.cbCard;
recvcmd.crc7[i] = ICmd.cbCard.Cmd;
end
 
// Endbit
@ICmd.cbCard;
recvcmd.endbit = ICmd.cbCard.Cmd;
 
-> CmdReceived;
endtask
 
function automatic SDCommandToken getCmd();
return recvcmd;
endfunction
 
 
task recvCmd(input SDCommandToken cmd, output SDCommandResponse response);
case (cmd.id)
cSdCmdGoIdleState: reset();
/sdhc-sc-core/trunk/src/grpSd/unitSdVerificationTestbench/src/SdVerificationTestbench.sv
10,6 → 10,10
 
program Test(ISdCmd ICmd);
initial begin
SDCard card = new(ICmd, $root.Testbed.CmdReceived);
SDCommandToken recvCmd;
bit done = 0;
 
ICmd.Clk <= 0;
#10;
ICmd.nResetAsync <= 0;
27,19 → 31,29
begin // monitor
end
 
begin // driver
begin // driver for SdCmd
@$root.Testbed.ApplyCommand;
ICmd.CmdId <= 0;
ICmd.Arg <= 'h00000000;
ICmd.Valid <= 1;
-> $root.Testbed.CardRecv;
end
 
begin // checker (and agent)
begin // driver for SdCardModel
while(done == 0) begin
card.recv();
done = 1;
end
end
 
begin // checker
@$root.Testbed.CmdReceived;
recvCmd = card.getCmd();
recvCmd.checkFromHost();
end
 
join;
 
#1000ns;
$display("%t : Test completed.", $time);
end
endprogram
55,6 → 69,6
 
Test tb(CmdInterface);
 
event ApplyCommand;
event ApplyCommand, CardRecv, CmdReceived;
 
endmodule
/sdhc-sc-core/trunk/src/grpSd/unitSdVerificationTestbench/src/SdCmdInterface.sv
23,8 → 23,11
input Clk, clocking cb
);
 
clocking cbCard @(posedge Clk);
inout Cmd;
endclocking
modport Card (
inout Cmd
clocking cbCard
);
 
modport SdCmd (

powered by: WebSVN 2.1.0

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