OpenCores
URL https://opencores.org/ocsvn/openhmc/openhmc/trunk

Subversion Repositories openhmc

[/] [openhmc/] [trunk/] [openHMC/] [sim/] [UVC/] [hmc_module/] [sv/] [hmc_module_scb.sv] - Blame information for rev 12

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 juko
/*
2
 *                              .--------------. .----------------. .------------.
3
 *                             | .------------. | .--------------. | .----------. |
4
 *                             | | ____  ____ | | | ____    ____ | | |   ______ | |
5
 *                             | ||_   ||   _|| | ||_   \  /   _|| | | .' ___  || |
6
 *       ___  _ __   ___ _ __  | |  | |__| |  | | |  |   \/   |  | | |/ .'   \_|| |
7
 *      / _ \| '_ \ / _ \ '_ \ | |  |  __  |  | | |  | |\  /| |  | | || |       | |
8
 *       (_) | |_) |  __/ | | || | _| |  | |_ | | | _| |_\/_| |_ | | |\ `.___.'\| |
9
 *      \___/| .__/ \___|_| |_|| ||____||____|| | ||_____||_____|| | | `._____.'| |
10
 *           | |               | |            | | |              | | |          | |
11
 *           |_|               | '------------' | '--------------' | '----------' |
12
 *                              '--------------' '----------------' '------------'
13
 *
14
 *  openHMC - An Open Source Hybrid Memory Cube Controller
15
 *  (C) Copyright 2014 Computer Architecture Group - University of Heidelberg
16
 *  www.ziti.uni-heidelberg.de
17
 *  B6, 26
18
 *  68159 Mannheim
19
 *  Germany
20
 *
21
 *  Contact: openhmc@ziti.uni-heidelberg.de
22
 *  http://ra.ziti.uni-heidelberg.de/openhmc
23
 *
24
 *   This source file is free software: you can redistribute it and/or modify
25
 *   it under the terms of the GNU Lesser General Public License as published by
26
 *   the Free Software Foundation, either version 3 of the License, or
27
 *   (at your option) any later version.
28
 *
29
 *   This source file is distributed in the hope that it will be useful,
30
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
 *   GNU Lesser General Public License for more details.
33
 *
34
 *   You should have received a copy of the GNU Lesser General Public License
35
 *   along with this source file.  If not, see .
36
 *
37
 *
38
 */
39
 
40
`ifndef HMC_SCOREBOARD_SV
41
`define HMC_SCOREBOARD_SV
42
 
43
 
44
class hmc_module_scb  extends uvm_scoreboard;
45
 
46
        protected int hmc_rsp_packet_count = 0;
47
        protected int hmc_req_packet_count = 0;
48
        protected int hmc_error_response_count = 0;
49
        protected int axi4_rsp_packet_count = 0;
50
        protected int axi4_req_packet_count = 0;
51
        protected int axi4_error_response_count = 0;
52
 
53
 
54
 
55
 
56
        typedef hmc_packet hmc_request_queue[$];
57
        typedef bit [127:0] flit_t;
58
        hmc_request_queue axi4_np_requests[*];
59
        hmc_packet axi4_2_hmc[$];
60
        hmc_packet hmc_2_axi4[$];
61
        hmc_packet hmc_2_axi4_axi4_came_first[$];
62
 
63
        int valid_cycle = 0;
64
 
65
        //--check tags
66
        int tag_count = 512;
67
        bit [512:0]used_tags;
68
 
69
 
70
 
71
 
72
        //-- analysis imports
73
        //-- HMC Interface
74
    `uvm_analysis_imp_decl(_hmc_req)
75
    uvm_analysis_imp_hmc_req #(hmc_packet, hmc_module_scb) hmc_req_port;
76
    `uvm_analysis_imp_decl(_hmc_rsp)
77
    uvm_analysis_imp_hmc_rsp #(hmc_packet, hmc_module_scb) hmc_rsp_port;
78
 
79
        //-- Host Interface
80
    `uvm_analysis_imp_decl(_axi4_hmc_req)
81
    uvm_analysis_imp_axi4_hmc_req #(hmc_packet, hmc_module_scb  ) axi4_hmc_req;
82
    `uvm_analysis_imp_decl(_axi4_hmc_rsp)
83
    uvm_analysis_imp_axi4_hmc_rsp #(hmc_packet, hmc_module_scb  ) axi4_hmc_rsp;
84
 
85
 
86
        `uvm_component_utils(hmc_module_scb )
87
 
88
        function new (string name="hmc_module_scb", uvm_component parent);
89
                super.new(name, parent);
90
                axi4_hmc_req = new("axi4_hmc_req",this);
91
                axi4_hmc_rsp = new("axi4_hmc_rsp",this);
92
                hmc_req_port = new("hmc_req_port",this);
93
                hmc_rsp_port = new("hmc_rsp_port",this);
94
        endfunction : new
95
 
96
        //-- compare the received response packets and check with the previous sent request packet
97
        function void hmc_2_axi4_compare(input hmc_packet expected, input hmc_packet packet);
98
                int i;
99
                hmc_packet request;
100
 
101
                if (packet.command != HMC_ERROR_RESPONSE) begin //-- HMC_ERROR_RESPONSE has no label
102
                        //-- Check the packet against the request stored in the axi4_np_requests map
103
                        label : assert (axi4_np_requests.exists(packet.tag))
104
                                else `uvm_fatal(get_type_name(),$psprintf("hmc_2_axi4_compare: Unexpected Response with tag %0x \n%s", packet.tag, packet.sprint()));
105
 
106
                        //-- delete the previous sent request packet
107
                        request = axi4_np_requests[packet.tag].pop_front();
108
                        if (axi4_np_requests[packet.tag].size() == 0)
109
                                axi4_np_requests.delete(packet.tag);
110
                end
111
                //-- check the hmc_packet
112
                if (packet.command == HMC_WRITE_RESPONSE
113
                                && request.get_command_type() != HMC_WRITE_TYPE
114
                                && request.get_command_type() != HMC_MISC_WRITE_TYPE)
115
                        `uvm_fatal(get_type_name(),$psprintf("hmc_2_axi4_compare: Write Response received with tag %0x for request %s\n%s", packet.tag, request.command.name(), packet.sprint()))
116
 
117
                if (packet.command == HMC_READ_RESPONSE && request.get_command_type() != HMC_READ_TYPE && request.get_command_type() != HMC_MODE_READ_TYPE )
118
                        `uvm_fatal(get_type_name(),$psprintf("hmc_2_axi4_compare: Read Response received with tag %0x for request %s\n%s", packet.tag, request.command.name(), packet.sprint()))
119
 
120
                if (packet.command == HMC_READ_RESPONSE) begin
121
                        int expected_count;
122
                        case (request.command)
123
                                HMC_MODE_READ: expected_count = 1;
124
                                HMC_READ_16:   expected_count = 1;
125
                                HMC_READ_32:   expected_count = 2;
126
                                HMC_READ_48:   expected_count = 3;
127
                                HMC_READ_64:   expected_count = 4;
128
                                HMC_READ_80:   expected_count = 5;
129
                                HMC_READ_96:   expected_count = 6;
130
                                HMC_READ_112:  expected_count = 7;
131
                                HMC_READ_128:  expected_count = 8;
132
                                default:      expected_count = 0;
133
                        endcase
134
                        if (expected_count != packet.payload.size())
135
                                `uvm_fatal(get_type_name(),$psprintf("hmc_2_axi4_compare: Read Response received with tag %0x and wrong size req=%0s rsp payload size=%0x\n", packet.tag, request.command.name(), packet.payload.size()))
136
                end
137
 
138
                //-- Check that the HMC command matches the HTOC item
139
                if (packet.get_command_type() != HMC_RESPONSE_TYPE)
140
                        `uvm_fatal(get_type_name(),$psprintf("hmc_2_axi4_compare: Unexpected Packet \n%s", packet.sprint()))
141
 
142
                if (expected.command != packet.command)
143
                        `uvm_fatal(get_type_name(),$psprintf("hmc_2_axi4_compare: Expected %s, got %s", expected.command.name(), packet.command.name()))
144
 
145
                if (expected.tag != packet.tag) begin
146
                        `uvm_info(get_type_name(), $psprintf("Expected: %s. got: %s", expected.sprint(), packet.sprint() ), UVM_NONE)
147
                        `uvm_fatal(get_type_name(),$psprintf("hmc_2_axi4_compare: Packet tag mismatch %0d != %0d ", expected.tag, packet.tag))
148
                end
149
 
150
                if (expected.packet_length != packet.packet_length) begin
151
                        `uvm_info(get_type_name(), $psprintf("Expected: %s. got: %s", expected.sprint(), packet.sprint() ), UVM_NONE)
152
                        `uvm_fatal(get_type_name(),$psprintf("hmc_2_axi4_compare: Packet length mismatch %0d != %0d ", expected.packet_length, packet.packet_length))
153
                end
154
 
155
                if (expected.payload.size() != packet.payload.size())
156
                        `uvm_fatal(get_type_name(),$psprintf("hmc_2_axi4_compare: Payload size mismatch %0d != %0d", expected.payload.size(), packet.payload.size()))
157
 
158
                for (int i=0; i
159
                        if (packet.payload[i] != expected.payload[i])
160
                                `uvm_fatal(get_type_name(),$psprintf("hmc_2_axi4_compare: Payload mismatch at %0d %0x != %0x", i, packet.payload[i], expected.payload[i]))
161
                end
162
 
163
        endfunction : hmc_2_axi4_compare
164
 
165
        //-- compare and check 2 Request type packets
166
        function void axi4_2_hmc_compare(input hmc_packet expected, hmc_packet packet);
167
 
168
                hmc_command_type packet_type = packet.get_command_type();
169
                if (packet_type == HMC_FLOW_TYPE || packet_type == HMC_RESPONSE_TYPE)
170
                        `uvm_fatal(get_type_name(),$psprintf("axi4_2_hmc_compare: Unexpected Packet \n%s", packet.sprint()))
171
 
172
                if (expected.command != packet.command) begin
173
                        `uvm_info(get_type_name(), $psprintf("Expected: %s. got: %s", expected.sprint(), packet.sprint() ), UVM_NONE)
174
                        `uvm_fatal(get_type_name(),$psprintf("axi4_2_hmc_compare: Expected %s, got %s", expected.command.name(), packet.command.name()))
175
                end
176
 
177
                if (expected.cube_ID != packet.cube_ID)
178
                        `uvm_fatal(get_type_name(),$psprintf("axi4_2_hmc_compare: cube_ID mismatch %0d != %0d", expected.cube_ID, packet.cube_ID))
179
 
180
                if (expected.address != packet.address)
181
                        `uvm_fatal(get_type_name(),$psprintf("axi4_2_hmc_compare: Address mismatch %0d != %0d", expected.address, packet.address))
182
 
183
                if (expected.packet_length != packet.packet_length)
184
                        `uvm_fatal(get_type_name(),$psprintf("axi4_2_hmc_compare: Packet length mismatch %0d != %0d", expected.packet_length, packet.packet_length))
185
 
186
                if (expected.tag != packet.tag) begin
187
                        `uvm_info(get_type_name(), $psprintf("Expected: %s. got: %s", expected.sprint(), packet.sprint() ), UVM_NONE)
188
                        `uvm_fatal(get_type_name(),$psprintf("axi4_2_hmc_compare: Packet tag mismatch %0d != %0d ", expected.tag, packet.tag))
189
                end
190
 
191
                if (expected.payload.size() != packet.payload.size())
192
                        `uvm_fatal(get_type_name(),$psprintf("axi4_2_hmc_compare: Payload size mismatch %0d != %0d", expected.payload.size(), packet.payload.size()))
193
 
194
                for (int i=0;i
195
                        if (expected.payload[i] != packet.payload[i])
196
                                `uvm_fatal(get_type_name(),$psprintf("axi4_2_hmc_compare: Payload mismatch at %0d %0x != %0x", i, expected.payload[i], packet.payload[i]))
197
                end
198
        endfunction : axi4_2_hmc_compare
199
 
200
        function void write_hmc_rsp(input hmc_packet packet);
201
                hmc_packet expected;
202
 
203
                if (packet.command != HMC_ERROR_RESPONSE) begin //TODO cover error response
204
                        hmc_rsp_packet_count++;
205
                        `uvm_info(get_type_name(),$psprintf("hmc_rsp: received packet #%0d %s", hmc_rsp_packet_count, packet.command.name()), UVM_MEDIUM)
206
                        `uvm_info(get_type_name(),$psprintf("hmc_rsp: \n%s", packet.sprint()), UVM_HIGH)
207
                end else begin
208
                        hmc_error_response_count++;
209
                        `uvm_info(get_type_name(),$psprintf("hmc_error_rsp: received error response #%0d %s", hmc_error_response_count, packet.command.name()), UVM_MEDIUM)
210
                        `uvm_info(get_type_name(),$psprintf("hmc_error_rsp: \n%s", packet.sprint()), UVM_HIGH)
211
                end
212
 
213
                //-- check this packet later
214
                hmc_2_axi4.push_back(packet);
215
        endfunction : write_hmc_rsp
216
 
217
        function void write_hmc_req(input hmc_packet packet);
218
                hmc_packet expected;
219
 
220
                if (packet == null) begin
221
                  `uvm_fatal(get_type_name(), $psprintf("packet is null"))
222
                 end
223
 
224
                hmc_req_packet_count++;
225
 
226
                `uvm_info(get_type_name(),$psprintf("hmc_req: received packet #%0d %s@%0x (tok %0d)", hmc_req_packet_count, packet.command.name(), packet.address, packet.return_token_count), UVM_MEDIUM)
227
                `uvm_info(get_type_name(),$psprintf("hmc_req: \n%s", packet.sprint()), UVM_HIGH)
228
 
229
                //-- expect an request packet on the host (AXI4) request queue
230
                if (axi4_2_hmc.size() == 0)
231
                        `uvm_fatal(get_type_name(),$psprintf("write_hmc_req: Unexpected packet (the request queue is empty)\n%s",packet.sprint()))
232
                else
233
                        expected = axi4_2_hmc.pop_front();
234
 
235
                //-- compare and check 2 Request type packets
236
                axi4_2_hmc_compare(expected, packet);
237
 
238
                `uvm_info(get_type_name(),$psprintf("hmc_req: checked packet #%0d %s@%0x", hmc_req_packet_count, packet.command.name(), packet.address), UVM_MEDIUM)
239
        endfunction : write_hmc_req
240
 
241
 
242
        function void write_axi4_hmc_rsp(input hmc_packet packet);
243
 
244
                 hmc_packet expected;
245
                 if (packet == null) begin
246
                  `uvm_fatal(get_type_name(), $psprintf("packet is null"))
247
                 end
248
 
249
                //-- compare with previous on the HMC side received response packet
250
                expected = hmc_2_axi4.pop_front();
251
                hmc_2_axi4_compare(expected, packet);
252
                if (packet.command != HMC_ERROR_RESPONSE) begin //TODO cover error response
253
                        axi4_rsp_packet_count++;
254
 
255
                        `uvm_info(get_type_name(),$psprintf("axi4_rsp: received packet #%0d %s", axi4_rsp_packet_count, packet.command.name()), UVM_MEDIUM)
256
                        `uvm_info(get_type_name(),$psprintf("axi4_rsp: \n%s", packet.sprint()), UVM_HIGH)
257
                        //-- check if open request with tag is available
258
                        if (used_tags[packet.tag] == 1'b1) begin
259
                                used_tags[packet.tag] =  1'b0;
260
                        end else begin
261
                                `uvm_fatal(get_type_name(),$psprintf("Packet with Tag %0d was not requested", packet.tag))
262
                        end
263
                end else begin
264
                        axi4_error_response_count++;
265
                        `uvm_info(get_type_name(),$psprintf("axi4_error_rsp: received error response #%0d %s", axi4_error_response_count, packet.command.name()), UVM_MEDIUM)
266
                        `uvm_info(get_type_name(),$psprintf("axi4_error_rsp: \n%s", packet.sprint()), UVM_HIGH)
267
                end
268
        endfunction :write_axi4_hmc_rsp
269
 
270
 
271
        function void write_axi4_hmc_req(input hmc_packet packet);
272
                if (packet == null) begin
273
                  `uvm_fatal(get_type_name(), $psprintf("packet is null"))
274
                end
275
                `uvm_info(get_type_name(),$psprintf("collected a packet %s", packet.command.name()), UVM_HIGH)
276
                `uvm_info(get_type_name(),$psprintf("\n%s", packet.sprint()), UVM_HIGH)
277
 
278
                //-- check packet later
279
                axi4_req_packet_count++;
280
                axi4_2_hmc.push_back(packet);
281
 
282
                //-- check if tag checking is necessary
283
                if (packet.get_command_type() == HMC_WRITE_TYPE
284
                                || packet.get_command_type() == HMC_MISC_WRITE_TYPE
285
                                || packet.get_command_type() == HMC_READ_TYPE
286
                                || packet.get_command_type() == HMC_MODE_READ_TYPE)
287
                begin
288
                        //-- store this packet to check corresponding response packet later
289
                        if (!axi4_np_requests.exists(packet.tag)) begin
290
                                axi4_np_requests[packet.tag] = {};
291
                        end
292
                        else begin
293
                                `uvm_info(get_type_name(),$psprintf("There is already an outstanding axi4 request with tag %0x!", packet.tag), UVM_MEDIUM)
294
                        end
295
                        axi4_np_requests[packet.tag].push_back(packet);
296
 
297
                        if (used_tags[packet.tag] == 1'b0) begin
298
                                used_tags[packet.tag] =  1'b1;
299
                        end else begin
300
                                `uvm_fatal(get_type_name(), $psprintf("tag %0d is already in use", packet.tag))
301
 
302
                        end
303
                end
304
 
305
                `uvm_info(get_type_name(),$psprintf("axi4_req: received packet #%0d %s@%0x", axi4_req_packet_count, packet.command.name(), packet.address), UVM_MEDIUM)
306
                `uvm_info(get_type_name(),$psprintf("axi4_req: \n%s", packet.sprint()), UVM_HIGH)
307
 
308
 
309
 
310
 
311
        endfunction :write_axi4_hmc_req
312
 
313
        function void check_phase(uvm_phase phase);
314
 
315
                if (axi4_rsp_packet_count != hmc_rsp_packet_count)
316
                        `uvm_fatal(get_type_name(),$psprintf("axi4_rsp_packet_count = %0d hmc_rsp_packet_count = %0d!", axi4_rsp_packet_count, hmc_rsp_packet_count))
317
                if (axi4_req_packet_count != hmc_req_packet_count)
318
                        `uvm_fatal(get_type_name(),$psprintf("axi4_req_packet_count = %0d hmc_req_packet_count = %0d!", axi4_req_packet_count, hmc_req_packet_count))
319
 
320
                //-- check for open requests on the host side
321
                if (axi4_np_requests.size() > 0) begin
322
                        for(int i=0;i<512;i++)begin
323
                                if (axi4_np_requests.exists(i))begin
324
                                        `uvm_info(get_type_name(),$psprintf("Unanswered Requests: %0d with tag %0d", axi4_np_requests[i].size(), i), UVM_NONE)
325
                                end
326
                        end
327
                        `uvm_fatal(get_type_name(),$psprintf("axi4_np_requests.size() = %0d, not all requests have been answered!", axi4_np_requests.size()))
328
                end
329
 
330
                //-- check for open tags
331
                if (used_tags >0) begin
332
                        foreach(used_tags[i]) begin
333
                                if (used_tags[i] == 1'b1)
334
                                        `uvm_info(get_type_name(),$psprintf("Tag %0d is in use",  i), UVM_NONE)
335
                        end
336
                        `uvm_fatal(get_type_name(),$psprintf("Open Tags!"))
337
                end
338
        endfunction : check_phase
339
 
340
        function void report_phase(uvm_phase phase);
341
                `uvm_info(get_type_name(),$psprintf("axi4_req_count %0d", axi4_req_packet_count), UVM_NONE)
342
                `uvm_info(get_type_name(),$psprintf("axi4_rsp_count %0d", axi4_rsp_packet_count), UVM_NONE)
343
                `uvm_info(get_type_name(),$psprintf("hmc_req_count %0d",  hmc_req_packet_count),  UVM_NONE)
344
                `uvm_info(get_type_name(),$psprintf("hmc_rsp_count %0d",  hmc_rsp_packet_count),  UVM_NONE)
345
                `uvm_info(get_type_name(),$psprintf("Error response count %0d", axi4_error_response_count ),  UVM_NONE)
346
        endfunction : report_phase
347
 
348
endclass : hmc_module_scb
349
 
350
`endif // HMC_SCOREBOARD_SV

powered by: WebSVN 2.1.0

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