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 15

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
        typedef hmc_packet hmc_request_queue[$];
56
        typedef bit [127:0] flit_t;
57
        hmc_request_queue axi4_np_requests[*];
58
        hmc_packet axi4_2_hmc[$];
59 15 juko
        hmc_packet hmc_response[$];
60
        hmc_packet axi4_response[$];
61 12 juko
 
62 15 juko
 
63 12 juko
        int valid_cycle = 0;
64
 
65
        //--check tags
66
        int tag_count = 512;
67
        bit [512:0]used_tags;
68
 
69
 
70
        //-- analysis imports
71
        //-- HMC Interface
72
    `uvm_analysis_imp_decl(_hmc_req)
73
    uvm_analysis_imp_hmc_req #(hmc_packet, hmc_module_scb) hmc_req_port;
74
    `uvm_analysis_imp_decl(_hmc_rsp)
75
    uvm_analysis_imp_hmc_rsp #(hmc_packet, hmc_module_scb) hmc_rsp_port;
76
 
77
        //-- Host Interface
78
    `uvm_analysis_imp_decl(_axi4_hmc_req)
79
    uvm_analysis_imp_axi4_hmc_req #(hmc_packet, hmc_module_scb  ) axi4_hmc_req;
80
    `uvm_analysis_imp_decl(_axi4_hmc_rsp)
81
    uvm_analysis_imp_axi4_hmc_rsp #(hmc_packet, hmc_module_scb  ) axi4_hmc_rsp;
82
 
83
 
84
        `uvm_component_utils(hmc_module_scb )
85
 
86
        function new (string name="hmc_module_scb", uvm_component parent);
87
                super.new(name, parent);
88
                axi4_hmc_req = new("axi4_hmc_req",this);
89
                axi4_hmc_rsp = new("axi4_hmc_rsp",this);
90
                hmc_req_port = new("hmc_req_port",this);
91
                hmc_rsp_port = new("hmc_rsp_port",this);
92
        endfunction : new
93
 
94
        //-- compare the received response packets and check with the previous sent request packet
95 15 juko
        function void response_compare(input hmc_packet expected, input hmc_packet packet);
96 12 juko
                int i;
97
                hmc_packet request;
98
 
99
                if (packet.command != HMC_ERROR_RESPONSE) begin //-- HMC_ERROR_RESPONSE has no label
100
                        //-- Check the packet against the request stored in the axi4_np_requests map
101
                        label : assert (axi4_np_requests.exists(packet.tag))
102 15 juko
                                else `uvm_fatal(get_type_name(),$psprintf("response_compare: Unexpected Response with tag %0x \n%s", packet.tag, packet.sprint()));
103 12 juko
 
104
                        //-- delete the previous sent request packet
105
                        request = axi4_np_requests[packet.tag].pop_front();
106
                        if (axi4_np_requests[packet.tag].size() == 0)
107
                                axi4_np_requests.delete(packet.tag);
108
                end
109
                //-- check the hmc_packet
110
                if (packet.command == HMC_WRITE_RESPONSE
111
                                && request.get_command_type() != HMC_WRITE_TYPE
112
                                && request.get_command_type() != HMC_MISC_WRITE_TYPE)
113 15 juko
                        `uvm_fatal(get_type_name(),$psprintf("response_compare: Write Response received with tag %0x for request %s\n%s", packet.tag, request.command.name(), packet.sprint()))
114 12 juko
 
115
                if (packet.command == HMC_READ_RESPONSE && request.get_command_type() != HMC_READ_TYPE && request.get_command_type() != HMC_MODE_READ_TYPE )
116 15 juko
                        `uvm_fatal(get_type_name(),$psprintf("response_compare: Read Response received with tag %0x for request %s\n%s", packet.tag, request.command.name(), packet.sprint()))
117 12 juko
 
118
                if (packet.command == HMC_READ_RESPONSE) begin
119
                        int expected_count;
120
                        case (request.command)
121
                                HMC_MODE_READ: expected_count = 1;
122
                                HMC_READ_16:   expected_count = 1;
123
                                HMC_READ_32:   expected_count = 2;
124
                                HMC_READ_48:   expected_count = 3;
125
                                HMC_READ_64:   expected_count = 4;
126
                                HMC_READ_80:   expected_count = 5;
127
                                HMC_READ_96:   expected_count = 6;
128
                                HMC_READ_112:  expected_count = 7;
129
                                HMC_READ_128:  expected_count = 8;
130
                                default:      expected_count = 0;
131
                        endcase
132
                        if (expected_count != packet.payload.size())
133 15 juko
                                `uvm_fatal(get_type_name(),$psprintf("response_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()))
134 12 juko
                end
135
 
136
                //-- Check that the HMC command matches the HTOC item
137
                if (packet.get_command_type() != HMC_RESPONSE_TYPE)
138 15 juko
                        `uvm_fatal(get_type_name(),$psprintf("response_compare: Unexpected Packet \n%s", packet.sprint()))
139 12 juko
 
140
                if (expected.command != packet.command)
141 15 juko
                        `uvm_fatal(get_type_name(),$psprintf("response_compare: Expected %s, got %s", expected.command.name(), packet.command.name()))
142 12 juko
 
143
                if (expected.tag != packet.tag) begin
144 15 juko
                        `uvm_info(get_type_name(), $psprintf("Expected: %s. got: %s", expected.sprint(), packet.sprint() ), UVM_LOW)
145
                        `uvm_fatal(get_type_name(),$psprintf("response_compare: Packet tag mismatch %0d != %0d ", expected.tag, packet.tag))
146 12 juko
                end
147
 
148
                if (expected.packet_length != packet.packet_length) begin
149 15 juko
                        `uvm_info(get_type_name(), $psprintf("Expected: %s. got: %s", expected.sprint(), packet.sprint() ), UVM_LOW)
150
                        `uvm_fatal(get_type_name(),$psprintf("response_compare: Packet length mismatch %0d != %0d ", expected.packet_length, packet.packet_length))
151 12 juko
                end
152
 
153
                if (expected.payload.size() != packet.payload.size())
154 15 juko
                        `uvm_fatal(get_type_name(),$psprintf("response_compare: Payload size mismatch %0d != %0d", expected.payload.size(), packet.payload.size()))
155 12 juko
 
156
                for (int i=0; i
157
                        if (packet.payload[i] != expected.payload[i])
158 15 juko
                                `uvm_fatal(get_type_name(),$psprintf("response_compare: Payload mismatch at %0d %0x != %0x", i, packet.payload[i], expected.payload[i]))
159 12 juko
                end
160
 
161 15 juko
        endfunction : response_compare
162 12 juko
 
163
        //-- compare and check 2 Request type packets
164 15 juko
        function void request_compare(input hmc_packet expected, hmc_packet packet);
165 12 juko
 
166
                hmc_command_type packet_type = packet.get_command_type();
167
                if (packet_type == HMC_FLOW_TYPE || packet_type == HMC_RESPONSE_TYPE)
168 15 juko
                        `uvm_fatal(get_type_name(),$psprintf("request_compare: Unexpected Packet \n%s", packet.sprint()))
169 12 juko
 
170
                if (expected.command != packet.command) begin
171 15 juko
                        `uvm_info(get_type_name(), $psprintf("Expected: %s. got: %s", expected.sprint(), packet.sprint() ), UVM_LOW)
172
                        `uvm_fatal(get_type_name(),$psprintf("request_compare: Expected %s, got %s", expected.command.name(), packet.command.name()))
173 12 juko
                end
174
 
175
                if (expected.cube_ID != packet.cube_ID)
176 15 juko
                        `uvm_fatal(get_type_name(),$psprintf("request_compare: cube_ID mismatch %0d != %0d", expected.cube_ID, packet.cube_ID))
177 12 juko
 
178
                if (expected.address != packet.address)
179 15 juko
                        `uvm_fatal(get_type_name(),$psprintf("request_compare: Address mismatch %0d != %0d", expected.address, packet.address))
180 12 juko
 
181
                if (expected.packet_length != packet.packet_length)
182 15 juko
                        `uvm_fatal(get_type_name(),$psprintf("request_compare: Packet length mismatch %0d != %0d", expected.packet_length, packet.packet_length))
183 12 juko
 
184
                if (expected.tag != packet.tag) begin
185 15 juko
                        `uvm_info(get_type_name(), $psprintf("Expected: %s. got: %s", expected.sprint(), packet.sprint() ), UVM_LOW)
186
                        `uvm_fatal(get_type_name(),$psprintf("request_compare: Packet tag mismatch %0d != %0d ", expected.tag, packet.tag))
187 12 juko
                end
188
 
189
                if (expected.payload.size() != packet.payload.size())
190 15 juko
                        `uvm_fatal(get_type_name(),$psprintf("request_compare: Payload size mismatch %0d != %0d", expected.payload.size(), packet.payload.size()))
191 12 juko
 
192
                for (int i=0;i
193
                        if (expected.payload[i] != packet.payload[i])
194 15 juko
                                `uvm_fatal(get_type_name(),$psprintf("request_compare: Payload mismatch at %0d %0x != %0x", i, expected.payload[i], packet.payload[i]))
195 12 juko
                end
196 15 juko
        endfunction : request_compare
197 12 juko
 
198
        function void write_hmc_rsp(input hmc_packet packet);
199
                hmc_packet expected;
200
 
201
                if (packet.command != HMC_ERROR_RESPONSE) begin //TODO cover error response
202
                        hmc_rsp_packet_count++;
203
                        `uvm_info(get_type_name(),$psprintf("hmc_rsp: received packet #%0d %s", hmc_rsp_packet_count, packet.command.name()), UVM_MEDIUM)
204
                        `uvm_info(get_type_name(),$psprintf("hmc_rsp: \n%s", packet.sprint()), UVM_HIGH)
205
                end else begin
206
                        hmc_error_response_count++;
207
                        `uvm_info(get_type_name(),$psprintf("hmc_error_rsp: received error response #%0d %s", hmc_error_response_count, packet.command.name()), UVM_MEDIUM)
208
                        `uvm_info(get_type_name(),$psprintf("hmc_error_rsp: \n%s", packet.sprint()), UVM_HIGH)
209
                end
210
 
211
                //-- check this packet later
212 15 juko
 
213
                //-- the response packet might be delayed due to the packet mon
214
                //-- check if the response packet is already received on the axi link
215
                if (axi4_response.size() == 0)
216
                        hmc_response.push_back(packet);
217
                else begin //-- check the packet
218
                        expected = axi4_response.pop_front();
219
                        response_compare(expected, packet); //TODO
220
 
221
                        if (packet.command != HMC_ERROR_RESPONSE) begin //TODO cover error response
222
                                                                //-- check if open request with tag is available
223
                                if (used_tags[packet.tag] == 1'b1) begin
224
                                        used_tags[packet.tag] =  1'b0;
225
                                end else begin
226
                                        `uvm_fatal(get_type_name(),$psprintf("Packet with Tag %0d was not requested", packet.tag))
227
                                end
228
                        end
229
                end
230 12 juko
        endfunction : write_hmc_rsp
231
 
232
        function void write_hmc_req(input hmc_packet packet);
233
                hmc_packet expected;
234
 
235
                if (packet == null) begin
236
                  `uvm_fatal(get_type_name(), $psprintf("packet is null"))
237
                 end
238
 
239
                hmc_req_packet_count++;
240
 
241
                `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)
242
                `uvm_info(get_type_name(),$psprintf("hmc_req: \n%s", packet.sprint()), UVM_HIGH)
243
 
244
                //-- expect an request packet on the host (AXI4) request queue
245
                if (axi4_2_hmc.size() == 0)
246
                        `uvm_fatal(get_type_name(),$psprintf("write_hmc_req: Unexpected packet (the request queue is empty)\n%s",packet.sprint()))
247
                else
248
                        expected = axi4_2_hmc.pop_front();
249
 
250
                //-- compare and check 2 Request type packets
251 15 juko
                request_compare(expected, packet);
252 12 juko
 
253
                `uvm_info(get_type_name(),$psprintf("hmc_req: checked packet #%0d %s@%0x", hmc_req_packet_count, packet.command.name(), packet.address), UVM_MEDIUM)
254
        endfunction : write_hmc_req
255
 
256
 
257
        function void write_axi4_hmc_rsp(input hmc_packet packet);
258
 
259
                 hmc_packet expected;
260
                 if (packet == null) begin
261
                  `uvm_fatal(get_type_name(), $psprintf("packet is null"))
262
                 end
263 15 juko
 
264
                 if (packet.command != HMC_ERROR_RESPONSE) begin //TODO cover error response
265 12 juko
                        axi4_rsp_packet_count++;
266
                        `uvm_info(get_type_name(),$psprintf("axi4_rsp: received packet #%0d %s", axi4_rsp_packet_count, packet.command.name()), UVM_MEDIUM)
267
                        `uvm_info(get_type_name(),$psprintf("axi4_rsp: \n%s", packet.sprint()), UVM_HIGH)
268
                end else begin
269
                        axi4_error_response_count++;
270
                        `uvm_info(get_type_name(),$psprintf("axi4_error_rsp: received error response #%0d %s", axi4_error_response_count, packet.command.name()), UVM_MEDIUM)
271
                        `uvm_info(get_type_name(),$psprintf("axi4_error_rsp: \n%s", packet.sprint()), UVM_HIGH)
272
                end
273 15 juko
 
274
                //-- the response packet might be delayed due to the transmission mon.
275
                //-- due to this the compare must be executed later
276
 
277
                //-- compare with previous on the HMC side received response packet
278
 
279
                if (hmc_response.size()== 0)
280
                        axi4_response.push_back(packet);
281
                else begin //-- check
282
                        expected = hmc_response.pop_front();
283
                        response_compare(expected, packet); //TODO
284
 
285
                        if (packet.command != HMC_ERROR_RESPONSE) begin //TODO cover error response
286
                                //-- check if open request with tag is available
287
                                if (used_tags[packet.tag] == 1'b1) begin
288
                                        used_tags[packet.tag] =  1'b0;
289
                                end else begin
290
                                        `uvm_fatal(get_type_name(),$psprintf("Packet with Tag %0d was not requested", packet.tag))
291
                                end
292
                        end
293
                end
294 12 juko
        endfunction :write_axi4_hmc_rsp
295
 
296
 
297
        function void write_axi4_hmc_req(input hmc_packet packet);
298
                if (packet == null) begin
299
                  `uvm_fatal(get_type_name(), $psprintf("packet is null"))
300
                end
301
                `uvm_info(get_type_name(),$psprintf("collected a packet %s", packet.command.name()), UVM_HIGH)
302
                `uvm_info(get_type_name(),$psprintf("\n%s", packet.sprint()), UVM_HIGH)
303
 
304
                //-- check packet later
305
                axi4_req_packet_count++;
306
                axi4_2_hmc.push_back(packet);
307
 
308
                //-- check if tag checking is necessary
309
                if (packet.get_command_type() == HMC_WRITE_TYPE
310
                                || packet.get_command_type() == HMC_MISC_WRITE_TYPE
311
                                || packet.get_command_type() == HMC_READ_TYPE
312
                                || packet.get_command_type() == HMC_MODE_READ_TYPE)
313
                begin
314
                        //-- store this packet to check corresponding response packet later
315
                        if (!axi4_np_requests.exists(packet.tag)) begin
316
                                axi4_np_requests[packet.tag] = {};
317
                        end
318
                        else begin
319
                                `uvm_info(get_type_name(),$psprintf("There is already an outstanding axi4 request with tag %0x!", packet.tag), UVM_MEDIUM)
320
                        end
321
                        axi4_np_requests[packet.tag].push_back(packet);
322
 
323
                        if (used_tags[packet.tag] == 1'b0) begin
324
                                used_tags[packet.tag] =  1'b1;
325
                        end else begin
326
                                `uvm_fatal(get_type_name(), $psprintf("tag %0d is already in use", packet.tag))
327
 
328
                        end
329
                end
330
 
331
                `uvm_info(get_type_name(),$psprintf("axi4_req: received packet #%0d %s@%0x", axi4_req_packet_count, packet.command.name(), packet.address), UVM_MEDIUM)
332
                `uvm_info(get_type_name(),$psprintf("axi4_req: \n%s", packet.sprint()), UVM_HIGH)
333
 
334
        endfunction :write_axi4_hmc_req
335
 
336
        function void check_phase(uvm_phase phase);
337
 
338
                if (axi4_rsp_packet_count != hmc_rsp_packet_count)
339
                        `uvm_fatal(get_type_name(),$psprintf("axi4_rsp_packet_count = %0d hmc_rsp_packet_count = %0d!", axi4_rsp_packet_count, hmc_rsp_packet_count))
340
                if (axi4_req_packet_count != hmc_req_packet_count)
341
                        `uvm_fatal(get_type_name(),$psprintf("axi4_req_packet_count = %0d hmc_req_packet_count = %0d!", axi4_req_packet_count, hmc_req_packet_count))
342
 
343
                //-- check for open requests on the host side
344
                if (axi4_np_requests.size() > 0) begin
345
                        for(int i=0;i<512;i++)begin
346
                                if (axi4_np_requests.exists(i))begin
347 15 juko
                                        `uvm_info(get_type_name(),$psprintf("Unanswered Requests: %0d with tag %0d", axi4_np_requests[i].size(), i), UVM_LOW)
348 12 juko
                                end
349
                        end
350
                        `uvm_fatal(get_type_name(),$psprintf("axi4_np_requests.size() = %0d, not all requests have been answered!", axi4_np_requests.size()))
351
                end
352
 
353
                //-- check for open tags
354
                if (used_tags >0) begin
355
                        foreach(used_tags[i]) begin
356
                                if (used_tags[i] == 1'b1)
357 15 juko
                                        `uvm_info(get_type_name(),$psprintf("Tag %0d is in use",  i), UVM_LOW)
358 12 juko
                        end
359
                        `uvm_fatal(get_type_name(),$psprintf("Open Tags!"))
360
                end
361
        endfunction : check_phase
362
 
363
        function void report_phase(uvm_phase phase);
364 15 juko
                `uvm_info(get_type_name(),$psprintf("axi4_req_count %0d", axi4_req_packet_count), UVM_LOW)
365
                `uvm_info(get_type_name(),$psprintf("axi4_rsp_count %0d", axi4_rsp_packet_count), UVM_LOW)
366
                `uvm_info(get_type_name(),$psprintf("hmc_req_count %0d",  hmc_req_packet_count),  UVM_LOW)
367
                `uvm_info(get_type_name(),$psprintf("hmc_rsp_count %0d",  hmc_rsp_packet_count),  UVM_LOW)
368
                `uvm_info(get_type_name(),$psprintf("Error response count %0d", axi4_error_response_count ),  UVM_LOW)
369 12 juko
        endfunction : report_phase
370
 
371
endclass : hmc_module_scb
372
 
373
`endif // HMC_SCOREBOARD_SV

powered by: WebSVN 2.1.0

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