OpenCores
URL https://opencores.org/ocsvn/sdhc-sc-core/sdhc-sc-core/trunk

Subversion Repositories sdhc-sc-core

[/] [sdhc-sc-core/] [trunk/] [grpSdVerification/] [unitSdCoreTransactionBFM/] [src/] [SdCoreTransactionBFM.sv] - Blame information for rev 185

Details | Compare with Previous | View Log

Line No. Rev Author Line
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        : SdCoreTransactionBFM.sv
30
// Owner       : Rainer Kastl
31
// Description :
32
// Links       :
33
//
34
 
35 151 rkastl
`ifndef SDCORETRANSACTIONBFM_SV
36
`define SDCORETRANSACTIONBFM_SV
37
 
38 153 rkastl
`include "SdCoreTransaction.sv";
39
`include "WbTransaction.sv";
40 156 rkastl
`include "WbTransactionReadSingleBlock.sv";
41 158 rkastl
`include "WbTransactionWriteSingleBlock.sv";
42 153 rkastl
 
43 151 rkastl
class SdCoreTransactionBFM;
44
 
45 153 rkastl
        SdCoreTransSeqMb SdTransInMb;
46
        SdCoreTransSeqMb SdTransOutMb;
47
        WbTransMb WbTransOutMb;
48
        WbTransMb WbTransInMb;
49 154 rkastl
 
50
        Logger Log = new();
51
        int StopAfter = -1;
52 153 rkastl
 
53 154 rkastl
        task start();
54
                fork
55
                        this.run();
56
                join_none;
57
        endtask
58 153 rkastl
 
59 154 rkastl
        task run();
60
                while (StopAfter != 0) begin
61
                        SdCoreTransaction trans;
62 156 rkastl
                        WbTransactionSequence seq;
63 154 rkastl
 
64
                        SdTransInMb.get(trans);
65
 
66 156 rkastl
                        case (trans.kind)
67
                                SdCoreTransaction::readSingleBlock:
68
                                        begin
69 159 rkastl
                                                int j = 0;
70 156 rkastl
                                                WbTransactionSequenceReadSingleBlock tmp = new(trans.startAddr, trans.endAddr);
71 157 rkastl
                                                assert (tmp.randomize()) else Log.error("Randomizing WbTransactionSequence seq failed.");
72 156 rkastl
                                                seq = tmp;
73 158 rkastl
 
74 159 rkastl
                                                trans.data = new[1];
75
 
76 158 rkastl
                                                foreach(seq.transactions[i]) begin
77
                                                        WbTransaction tr;
78
 
79
                                                        WbTransOutMb.put(seq.transactions[i]);
80
                                                        WbTransInMb.get(tr);
81
 
82 159 rkastl
                                                        // receive read data
83 158 rkastl
                                                        if (tr.Kind == WbTransaction::Read && tr.Addr == cReadDataAddr) begin
84 160 rkastl
                                                                trans.data[0][j++] = tr.Data[7:0];
85
                                                                trans.data[0][j++] = tr.Data[15:8];
86
                                                                trans.data[0][j++] = tr.Data[23:16];
87 159 rkastl
                                                                trans.data[0][j++] = tr.Data[31:24];
88 158 rkastl
                                                        end
89
                                                end
90
 
91
                                                SdTransOutMb.put(trans);
92 156 rkastl
                                        end
93 158 rkastl
 
94
                                SdCoreTransaction::writeSingleBlock:
95
                                        begin
96
                                                WbTransactionSequenceWriteSingleBlock tmp = new(trans.startAddr, trans.endAddr, trans.data[0]);
97
                                                assert (tmp.randomize()) else Log.error("Randomizing WbTransactionSequence seq failed.");
98
                                                seq = tmp;
99
 
100
                                                foreach(seq.transactions[i]) begin
101
                                                        WbTransaction tr;
102
                                                        WbTransOutMb.put(seq.transactions[i]);
103
                                                        WbTransInMb.get(tr);
104
                                                end
105
 
106
                                                SdTransOutMb.put(trans);
107
                                        end
108 156 rkastl
                                default:
109
                                        begin
110
                                                string msg;
111
                                                $swrite(msg, "Transaction kind %s not handled.", trans.kind.name());
112
                                                Log.error(msg);
113
                                        end
114
                        endcase
115 158 rkastl
 
116 156 rkastl
 
117 154 rkastl
                        if (StopAfter > 0) StopAfter--;
118
                end
119
        endtask
120
 
121 151 rkastl
endclass
122
 
123
`endif

powered by: WebSVN 2.1.0

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