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

Subversion Repositories openhmc

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

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
//
41
//
42
// cag rgm rfs monitor OVC monitor
43
//
44
//
45
 
46
`ifndef CAG_RGM_RFS_MONITOR_SV
47
`define CAG_RGM_RFS_MONITOR_SV
48
 
49
class cag_rgm_rfs_monitor #(
50
                parameter ADDR_WIDTH       = 6,
51
                parameter READ_DATA_WIDTH  = 64,
52
                parameter WRITE_DATA_WIDTH = 64
53
        ) extends uvm_monitor;
54
 
55
        uvm_analysis_port #(cag_rgm_transfer) request_port;
56
        uvm_analysis_port #(cag_rgm_transfer) response_port;
57
 
58
        virtual cag_rgm_rfs_if #(
59
                .ADDR_WIDTH(ADDR_WIDTH),
60
                .READ_DATA_WIDTH(READ_DATA_WIDTH),
61
                .WRITE_DATA_WIDTH(WRITE_DATA_WIDTH)
62
        ) rfs_if;
63
 
64
        cag_rgm_transfer collected_request;
65
        cag_rgm_transfer collected_response;
66
 
67
        bit     enable_coverage         = 1;
68
        bit     enable_checks           = 1;
69
 
70
        int     cycles_between_req      = 0;
71
        int     cycles_between_resp     = 0;
72
 
73
        `uvm_component_param_utils_begin(cag_rgm_rfs_monitor #(.ADDR_WIDTH(ADDR_WIDTH), .READ_DATA_WIDTH(READ_DATA_WIDTH), .WRITE_DATA_WIDTH(WRITE_DATA_WIDTH)))
74
                `uvm_field_int(enable_coverage, UVM_ALL_ON)
75
                `uvm_field_int(enable_checks, UVM_ALL_ON)
76
        `uvm_component_utils_end
77
 
78
        function new ( string name="cag_rgm_rfs_monitor", uvm_component parent );
79
                super.new(name, parent);
80
                request_port    = new("request_port", this);
81
                response_port   = new("response_port", this);
82
        endfunction : new
83
 
84
 
85
        function void assign_vi( virtual interface cag_rgm_rfs_if #(.ADDR_WIDTH(ADDR_WIDTH), .READ_DATA_WIDTH(READ_DATA_WIDTH), .WRITE_DATA_WIDTH(WRITE_DATA_WIDTH)) rfs_if );
86
                this.rfs_if     = rfs_if;
87
        endfunction : assign_vi
88
 
89
 
90
        task run();
91
                #1;
92
                do_reset();
93
                fork
94
                        collect_request_transfers();
95
                        collect_response_transfers();
96
                join_none
97
        endtask : run
98
 
99
 
100
        task do_reset();
101
                while (rfs_if.res_n == 0)
102
                        @( posedge rfs_if.clk );
103
        endtask : do_reset
104
 
105
 
106
        task collect_request_transfers();
107
 
108
                forever
109
                begin
110
                        cycles_between_req                              = 0;
111
 
112
                        // wait for write or read enable
113
                        while (!(rfs_if.wen || rfs_if.ren)) begin
114
                                cycles_between_req++;
115
                                @(posedge rfs_if.clk);
116
                        end
117
 
118
                        collected_request                               = cag_rgm_transfer::type_id::create("collected_request", this);
119
                        if(recording_detail == UVM_FULL)
120
                                collected_request.enable_recording({get_full_name(),"_request"});
121
                        void'(collected_request.begin_tr());
122
 
123
                        if (rfs_if.ren)
124
                                collected_request.command       = CAG_RGM_READ;
125
                        else
126
                                collected_request.command       = CAG_RGM_WRITE;
127
 
128
                        collected_request.address               = {{64-3-ADDR_WIDTH {1'b0}}, rfs_if.address,3'b0};
129
                        collected_request.data                  = rfs_if.write_data;
130
                        collected_request.delay                 = cycles_between_req;
131
                        collected_request.error                 = 1'b0;
132
 
133
                        @(posedge rfs_if.clk);
134
 
135
                        if (enable_checks)
136
                                perform_request_checks();
137
                        if (enable_coverage)
138
                                perform_request_coverage();
139
 
140
                        void'(collected_request.end_tr());
141
                        // forward the collected_request to the next higher layer of the verification environment
142
//                      collected_request.print();
143
                        request_port.write(collected_request);
144
                end
145
        endtask : collect_request_transfers
146
 
147
 
148
        task collect_response_transfers();
149
 
150
                forever begin
151
                        cycles_between_resp = 0;
152
 
153
                        while (!(rfs_if.wen || rfs_if.ren)) begin
154
                                @(posedge rfs_if.clk);
155
                        end
156
 
157
                        collected_response = cag_rgm_transfer::type_id::create("collected_response", this);
158
 
159
                        if(rfs_if.wen)
160
                                collected_response.command = CAG_RGM_WRITE_RESPONSE;
161
                        else
162
                                collected_response.command = CAG_RGM_READ_RESPONSE;
163
 
164
                        // wait for write or read enable
165
                        while (!rfs_if.access_done)     begin
166
                                cycles_between_resp++;
167
                                @(posedge rfs_if.clk);
168
                        end
169
 
170
                        if(recording_detail == UVM_FULL)
171
                                collected_response.enable_recording({get_full_name(),"_response"});
172
                        void'(collected_response.begin_tr());
173
 
174
                        collected_response.address = {{64-ADDR_WIDTH {1'b0}}, rfs_if.address}; //-- FIXME? address should be byte aligned? not qw?
175
                        collected_response.data    = rfs_if.read_data;
176
                        collected_response.delay   = cycles_between_req;
177
                        collected_response.error   = rfs_if.invalid_address;
178
 
179
                        @(posedge rfs_if.clk);
180
 
181
                        if (enable_checks)
182
                                perform_response_checks();
183
                        if (enable_coverage)
184
                                perform_response_coverage();
185
 
186
                        void'(collected_response.end_tr());
187
                        // forward the collected_response to the next higher layer of the verification environment
188
//                      collected_response.print();
189
                        response_port.write(collected_response);
190
                end
191
        endtask : collect_response_transfers
192
 
193
 
194
        // checks
195
        function void perform_request_checks();
196
                // perform data checks on collected_packet
197
        endfunction : perform_request_checks
198
 
199
        function void perform_response_checks();
200
                //-- perform data checks on collected_packet
201
                if(collected_response.error)
202
                        uvm_report_fatal(get_type_name(),$psprintf("Invalid access to address 0x%0h",collected_response.address));
203
        endfunction : perform_response_checks
204
 
205
 
206
        // coverage
207
        function void perform_request_coverage();
208
                // perform coverage on collected_packet
209
        endfunction : perform_request_coverage
210
 
211
        function void perform_response_coverage();
212
                // perform coverage on collected_packet
213
        endfunction : perform_response_coverage
214
 
215
endclass : cag_rgm_rfs_monitor
216
 
217
`endif // CAG_RGM_RFS_MONITOR_SV

powered by: WebSVN 2.1.0

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