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

Subversion Repositories openhmc

[/] [openhmc/] [trunk/] [openHMC/] [sim/] [UVC/] [hmc/] [sv/] [hmc_env.sv] - Blame information for rev 15

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 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
`ifndef HMC_ENV_SV
40
`define HMC_ENV_SV
41
 
42
 
43
 
44
class hmc_env #(parameter NUM_LANES = 16) extends uvm_env;
45
 
46
        hmc_link_config link_config;
47
 
48
        virtual interface hmc_sr_if#(.NUM_LANES(NUM_LANES)) vif;
49
        virtual interface hmc_sr_if#(.NUM_LANES(NUM_LANES)) int_vif;
50
 
51
        hmc_error_injector #(.NUM_LANES(NUM_LANES)) req_inj;
52
        hmc_error_injector #(.NUM_LANES(NUM_LANES)) rsp_inj;
53
 
54
 
55
        hmc_status h_status;
56
        hmc_monitor #(.NUM_LANES(NUM_LANES)) req_mon;
57
        hmc_monitor #(.NUM_LANES(NUM_LANES)) rsp_mon;
58
 
59
 
60
        hmc_transaction_mon req_transaction_mon;
61
        hmc_transaction_mon rsp_transaction_mon;
62
 
63
        hmc_tag_mon tag_mon;
64
 
65
        hmc_requester_agent #(.NUM_LANES(NUM_LANES)) requester;
66
        hmc_responder_agent #(.NUM_LANES(NUM_LANES)) responder;
67
 
68
        `uvm_component_param_utils(hmc_env #(.NUM_LANES(NUM_LANES)))
69
 
70
        function new(string name="hmc_env", uvm_component parent);
71
                super.new(name,parent);
72
                h_status = new("h_status",this);
73
        endfunction : new
74
 
75
        function void build_phase(uvm_phase phase);
76
                super.build_phase(phase);
77
 
78
                if(uvm_config_db#(virtual interface hmc_sr_if#(.NUM_LANES(NUM_LANES)))::get(this, "", "vif",vif) ) begin
79
                        this.vif = vif;
80
 
81
                        uvm_config_db#(virtual interface hmc_sr_if#(.NUM_LANES(NUM_LANES)))::set(this, "req_inj","ext_vif",vif);
82
                        uvm_config_db#(virtual interface hmc_sr_if#(.NUM_LANES(NUM_LANES)))::set(this, "rsp_inj","ext_vif",vif);
83
 
84
                        uvm_config_db#(virtual interface hmc_sr_if#(.NUM_LANES(NUM_LANES)))::set(this, "rsp_mon","vif",vif);
85
                        uvm_config_db#(virtual interface hmc_sr_if#(.NUM_LANES(NUM_LANES)))::set(this, "rsp_mon.cdr","vif",vif);
86
 
87
                        uvm_config_db#(virtual interface hmc_sr_if#(.NUM_LANES(NUM_LANES)))::set(this, "requester","vif",vif);
88
                end else begin
89
                        `uvm_fatal(get_type_name(),"vif is not set")
90
                end
91
 
92
                if(uvm_config_db#(virtual interface hmc_sr_if#(.NUM_LANES(NUM_LANES)))::get(this, "", "int_vif",int_vif) ) begin
93
                        this.int_vif = int_vif;
94
 
95
                        uvm_config_db#(virtual interface hmc_sr_if#(.NUM_LANES(NUM_LANES)))::set(this, "req_inj","int_vif",int_vif);
96
                        uvm_config_db#(virtual interface hmc_sr_if#(.NUM_LANES(NUM_LANES)))::set(this, "rsp_inj","int_vif",int_vif);
97
 
98
                        uvm_config_db#(virtual interface hmc_sr_if#(.NUM_LANES(NUM_LANES)))::set(this, "req_mon","vif",int_vif);
99
                        uvm_config_db#(virtual interface hmc_sr_if#(.NUM_LANES(NUM_LANES)))::set(this, "req_mon.cdr","vif",int_vif);
100
 
101
                        uvm_config_db#(virtual interface hmc_sr_if#(.NUM_LANES(NUM_LANES)))::set(this, "responder","vif",int_vif);
102
                end
103
 
104
                req_inj = hmc_error_injector#(.NUM_LANES(NUM_LANES))::type_id::create("req_inj", this);
105
                req_inj = hmc_error_injector#(.NUM_LANES(NUM_LANES))::type_id::create("rsp_inj", this);
106
 
107
                req_mon = hmc_monitor#(.NUM_LANES(NUM_LANES))::type_id::create("req_mon", this);
108
                rsp_mon = hmc_monitor#(.NUM_LANES(NUM_LANES))::type_id::create("rsp_mon", this);
109
 
110
                uvm_config_db#(hmc_status)::set(this, "requester", "h_status", h_status);
111
                uvm_config_db#(hmc_status)::set(this, "responder", "h_status", h_status);
112
 
113
                uvm_config_db#(hmc_status)::set(this, "req_mon", "status", h_status);
114
                uvm_config_db#(hmc_status)::set(this, "rsp_mon", "status", h_status);
115
 
116
                uvm_config_db#(hmc_link_status)::set(this, "req_inj", "link_status", h_status.Requester_link_status);
117
                uvm_config_db#(hmc_link_status)::set(this, "rsp_inj", "link_status", h_status.Responder_link_status);
118
 
119
        if (uvm_config_db#(hmc_link_config)::get(this, "", "link_config", link_config)) begin
120
                if(link_config.enable_tag_checking)
121
                        tag_mon = hmc_tag_mon::type_id::create("tag_mon", this);
122
 
123
                set_config_int("req_transaction_mon", "enable_tag_checking", link_config.enable_tag_checking);
124
                        set_config_int("rsp_transaction_mon", "enable_tag_checking", link_config.enable_tag_checking);
125
 
126
                        req_transaction_mon = hmc_transaction_mon::type_id::create("req_transaction_mon", this);
127
                        rsp_transaction_mon = hmc_transaction_mon::type_id::create("rsp_transaction_mon", this);
128
 
129
                uvm_config_db#(hmc_link_config)::set(this, "rsp_mon.cdr","link_config",link_config);
130
                uvm_config_db#(hmc_link_config)::set(this, "req_mon.cdr","link_config",link_config);
131
 
132
                        uvm_config_db#(hmc_link_config)::set(this, "req_mon", "link_config", link_config);
133
                uvm_config_db#(hmc_link_config)::set(this, "rsp_mon", "link_config", link_config);
134
 
135
                uvm_config_db#(hmc_local_link_config)::set(this, "req_mon", "local_config", link_config.requester);
136
                uvm_config_db#(hmc_local_link_config)::set(this, "rsp_mon", "local_config", link_config.responder);
137
 
138
                uvm_config_db#(hmc_link_config)::set(this, "req_inj", "link_config", link_config);
139
                uvm_config_db#(hmc_link_config)::set(this, "rsp_inj", "link_config", link_config);
140
 
141
                uvm_config_db#(hmc_local_link_config)::set(this, "req_inj", "local_config", link_config.requester);
142
                uvm_config_db#(hmc_local_link_config)::set(this, "rsp_inj", "local_config", link_config.responder);
143
 
144
                uvm_config_db#(hmc_link_config)::set(this, "requester.driver", "link_config", link_config);
145
                uvm_config_db#(hmc_link_config)::set(this, "responder.driver", "link_config", link_config);
146
        end
147
                else begin
148
                        uvm_report_fatal(get_type_name(), $psprintf("link_config not set via config_db"));
149
                end
150
 
151
                set_config_int("requester", "active_passive", link_config.requester.active);
152
                set_config_int("responder", "active_passive", link_config.responder.active);
153
 
154
                requester = hmc_requester_agent#(.NUM_LANES(NUM_LANES))::type_id::create("requester",this);
155
                responder = hmc_responder_agent#(.NUM_LANES(NUM_LANES))::type_id::create("responder",this);
156
 
157
                requester.monitor = rsp_mon;
158
                responder.monitor = req_mon;
159
 
160
                responder.req_transaction_mon = req_transaction_mon;
161
 
162
                if(link_config.enable_tag_checking == UVM_ACTIVE) begin
163
                        rsp_transaction_mon.tag_mon = tag_mon;
164
                        req_transaction_mon.tag_mon = tag_mon;
165
                end
166
 
167
                req_mon.transaction_mon = rsp_transaction_mon;
168
                rsp_mon.transaction_mon = req_transaction_mon;
169
        endfunction : build_phase
170
 
171
        function void connect_phase(uvm_phase phase);
172
                super.connect_phase(phase);
173
 
174
                req_mon.return_token_port.connect(req_transaction_mon.pkt_import);
175
                rsp_mon.return_token_port.connect(rsp_transaction_mon.pkt_import);
176
 
177
                req_mon.rrp_port.connect(rsp_transaction_mon.rrp_import);
178
                rsp_mon.rrp_port.connect(req_transaction_mon.rrp_import);
179
        endfunction : connect_phase
180
 
181
endclass : hmc_env
182
 
183
`endif // HMC_ENV_SV

powered by: WebSVN 2.1.0

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