| 1 |
164 |
rkastl |
// SDHC-SC-Core
|
| 2 |
|
|
// Secure Digital High Capacity Self Configuring Core
|
| 3 |
|
|
//
|
| 4 |
170 |
rkastl |
// (C) Copyright 2010, Rainer Kastl
|
| 5 |
|
|
// All rights reserved.
|
| 6 |
164 |
rkastl |
//
|
| 7 |
170 |
rkastl |
// Redistribution and use in source and binary forms, with or without
|
| 8 |
|
|
// modification, are permitted provided that the following conditions are met:
|
| 9 |
|
|
// * Redistributions of source code must retain the above copyright
|
| 10 |
|
|
// notice, this list of conditions and the following disclaimer.
|
| 11 |
|
|
// * Redistributions in binary form must reproduce the above copyright
|
| 12 |
|
|
// notice, this list of conditions and the following disclaimer in the
|
| 13 |
|
|
// documentation and/or other materials provided with the distribution.
|
| 14 |
|
|
// * Neither the name of the nor the
|
| 15 |
|
|
// names of its contributors may be used to endorse or promote products
|
| 16 |
|
|
// derived from this software without specific prior written permission.
|
| 17 |
164 |
rkastl |
//
|
| 18 |
170 |
rkastl |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
| 19 |
|
|
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
| 20 |
|
|
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 21 |
|
|
// DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
|
| 22 |
|
|
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
| 23 |
|
|
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
| 24 |
|
|
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 25 |
|
|
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 26 |
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
| 27 |
|
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 28 |
164 |
rkastl |
//
|
| 29 |
|
|
// File : SdCoreChecker.sv
|
| 30 |
|
|
// Owner : Rainer Kastl
|
| 31 |
|
|
// Description : Checker for SdCoreTransactions
|
| 32 |
|
|
// Links :
|
| 33 |
|
|
//
|
| 34 |
|
|
|
| 35 |
151 |
rkastl |
`ifndef SDCORECHECKER_SV
|
| 36 |
|
|
`define SDCORECHECKER_SV
|
| 37 |
|
|
|
| 38 |
153 |
rkastl |
`include "SdCoreTransaction.sv";
|
| 39 |
|
|
`include "RamAction.sv";
|
| 40 |
|
|
`include "ExpectedResult.sv";
|
| 41 |
158 |
rkastl |
`include "Logger.sv";
|
| 42 |
153 |
rkastl |
|
| 43 |
151 |
rkastl |
class SdCoreChecker;
|
| 44 |
|
|
|
| 45 |
153 |
rkastl |
SdCoreTransSeqMb SdTransInMb;
|
| 46 |
|
|
RamActionMb RamActionInMb;
|
| 47 |
|
|
ExpectedResultMb ExpectedResultInMb;
|
| 48 |
158 |
rkastl |
Logger Log = new();
|
| 49 |
|
|
|
| 50 |
|
|
local SdCoreTransaction trans;
|
| 51 |
153 |
rkastl |
|
| 52 |
158 |
rkastl |
covergroup SdCoreTransactions;
|
| 53 |
|
|
coverpoint trans.kind {
|
| 54 |
|
|
bins types[] = {SdCoreTransaction::readSingleBlock,
|
| 55 |
|
|
SdCoreTransaction::writeSingleBlock,
|
| 56 |
|
|
SdCoreTransaction::readMultipleBlock,
|
| 57 |
|
|
SdCoreTransaction::writeMultipleBlocks,
|
| 58 |
|
|
SdCoreTransaction::erase,
|
| 59 |
|
|
SdCoreTransaction::readSdCardStatus};
|
| 60 |
|
|
bins transitions[] = (SdCoreTransaction::readSingleBlock,
|
| 61 |
|
|
SdCoreTransaction::writeSingleBlock,
|
| 62 |
|
|
SdCoreTransaction::readMultipleBlock,
|
| 63 |
|
|
SdCoreTransaction::writeMultipleBlocks,
|
| 64 |
|
|
SdCoreTransaction::erase,
|
| 65 |
|
|
SdCoreTransaction::readSdCardStatus =>
|
| 66 |
|
|
SdCoreTransaction::readSingleBlock,
|
| 67 |
|
|
SdCoreTransaction::writeSingleBlock,
|
| 68 |
|
|
SdCoreTransaction::readMultipleBlock,
|
| 69 |
|
|
SdCoreTransaction::writeMultipleBlocks,
|
| 70 |
|
|
SdCoreTransaction::erase,
|
| 71 |
|
|
SdCoreTransaction::readSdCardStatus);
|
| 72 |
|
|
}
|
| 73 |
|
|
|
| 74 |
|
|
singleblock: coverpoint trans.kind {
|
| 75 |
|
|
bins types[] = {SdCoreTransaction::readSingleBlock,
|
| 76 |
|
|
SdCoreTransaction::writeSingleBlock};
|
| 77 |
|
|
}
|
| 78 |
|
|
|
| 79 |
|
|
multiblock: coverpoint trans.kind {
|
| 80 |
|
|
bins types[] = {SdCoreTransaction::readMultipleBlock,
|
| 81 |
|
|
SdCoreTransaction::writeMultipleBlocks,
|
| 82 |
|
|
SdCoreTransaction::erase};
|
| 83 |
|
|
}
|
| 84 |
|
|
|
| 85 |
|
|
startAddr: coverpoint trans.startAddr {
|
| 86 |
|
|
bins legal = {[0:1000]};
|
| 87 |
|
|
illegal_bins ill = default;
|
| 88 |
|
|
}
|
| 89 |
|
|
|
| 90 |
|
|
endAddr: coverpoint trans.endAddr {
|
| 91 |
|
|
bins legal = {[0:1000]};
|
| 92 |
|
|
illegal_bins ill = default;
|
| 93 |
|
|
}
|
| 94 |
|
|
|
| 95 |
|
|
addressrange: coverpoint (trans.endAddr - trans.startAddr) {
|
| 96 |
|
|
bins valid = {[1:$]};
|
| 97 |
|
|
bins zero = {0};
|
| 98 |
|
|
bins invalid = {[$:-1]};
|
| 99 |
|
|
}
|
| 100 |
|
|
|
| 101 |
|
|
cross singleblock, startAddr;
|
| 102 |
|
|
cross multiblock, startAddr, endAddr;
|
| 103 |
|
|
cross multiblock, addressrange;
|
| 104 |
|
|
endgroup
|
| 105 |
|
|
|
| 106 |
|
|
int StopAfter = -1;
|
| 107 |
|
|
|
| 108 |
|
|
function new();
|
| 109 |
|
|
SdCoreTransactions = new();
|
| 110 |
153 |
rkastl |
endfunction
|
| 111 |
|
|
|
| 112 |
158 |
rkastl |
task start();
|
| 113 |
|
|
fork
|
| 114 |
|
|
run();
|
| 115 |
|
|
join_none
|
| 116 |
|
|
endtask
|
| 117 |
|
|
|
| 118 |
160 |
rkastl |
function void checkRamAction(RamAction actual, RamAction expected, DataBlock block);
|
| 119 |
|
|
if (expected.Kind == RamAction::Write) begin
|
| 120 |
|
|
if (actual.Kind != expected.Kind ||
|
| 121 |
|
|
actual.Addr != expected.Addr ||
|
| 122 |
|
|
actual.Data != expected.Data) begin
|
| 123 |
|
|
|
| 124 |
|
|
string msg;
|
| 125 |
|
|
$swrite(msg, "RamActions differ: %s%p%s%p%s%d%s%d%s%p%s%p",
|
| 126 |
|
|
"\nactual kind ", actual.Kind, ", expected kind ", expected.Kind,
|
| 127 |
|
|
"\nactual addr ", actual.Addr, ", expected addr ", expected.Addr,
|
| 128 |
|
|
"\nactual data ", actual.Data, ", expected data ", expected.Data);
|
| 129 |
|
|
Log.error(msg);
|
| 130 |
|
|
|
| 131 |
|
|
end
|
| 132 |
|
|
end else begin
|
| 133 |
|
|
if (actual.Kind != expected.Kind ||
|
| 134 |
|
|
actual.Addr != expected.Addr ||
|
| 135 |
|
|
actual.Data != block) begin
|
| 136 |
|
|
|
| 137 |
|
|
string msg;
|
| 138 |
|
|
$swrite(msg, "RamActions differ: %s%p%s%p%s%d%s%d%s%p%s%p",
|
| 139 |
|
|
"\nactual kind ", actual.Kind, ", expected kind ", expected.Kind,
|
| 140 |
|
|
"\nactual addr ", actual.Addr, ", expected addr ", expected.Addr,
|
| 141 |
|
|
"\nactual data ", actual.Data, ", expected data ", block);
|
| 142 |
|
|
Log.error(msg);
|
| 143 |
|
|
|
| 144 |
|
|
end
|
| 145 |
|
|
end
|
| 146 |
|
|
endfunction
|
| 147 |
|
|
|
| 148 |
158 |
rkastl |
task run();
|
| 149 |
|
|
while (StopAfter != 0) begin
|
| 150 |
|
|
ExpectedResult res;
|
| 151 |
160 |
rkastl |
RamAction ram[];
|
| 152 |
158 |
rkastl |
|
| 153 |
160 |
rkastl |
// get transactions
|
| 154 |
158 |
rkastl |
ExpectedResultInMb.get(res);
|
| 155 |
160 |
rkastl |
ram = new[res.RamActions.size()];
|
| 156 |
|
|
foreach(ram[i]) RamActionInMb.get(ram[i]);
|
| 157 |
158 |
rkastl |
SdTransInMb.get(trans);
|
| 158 |
|
|
|
| 159 |
|
|
// update functional coverage
|
| 160 |
|
|
SdCoreTransactions.sample();
|
| 161 |
|
|
|
| 162 |
160 |
rkastl |
// check transaction
|
| 163 |
158 |
rkastl |
if (res.trans.compare(trans) == 1) begin
|
| 164 |
159 |
rkastl |
string msg;
|
| 165 |
158 |
rkastl |
Log.note("Checker: Transaction successful");
|
| 166 |
159 |
rkastl |
$swrite(msg, "%s", trans.toString());
|
| 167 |
|
|
Log.note(msg);
|
| 168 |
158 |
rkastl |
end
|
| 169 |
|
|
else begin
|
| 170 |
|
|
string msg;
|
| 171 |
|
|
$swrite(msg, "Actual: %s, Expected: %s", trans.toString(), res.trans.toString());
|
| 172 |
|
|
Log.error(msg);
|
| 173 |
|
|
end
|
| 174 |
|
|
|
| 175 |
160 |
rkastl |
// check data
|
| 176 |
|
|
foreach(ram[i]) begin
|
| 177 |
|
|
checkRamAction(ram[i], res.RamActions[i], trans.data[i]);
|
| 178 |
|
|
end
|
| 179 |
|
|
|
| 180 |
158 |
rkastl |
if (StopAfter > 0) StopAfter--;
|
| 181 |
|
|
end
|
| 182 |
|
|
|
| 183 |
|
|
endtask
|
| 184 |
|
|
|
| 185 |
151 |
rkastl |
endclass
|
| 186 |
|
|
|
| 187 |
|
|
`endif
|