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

Subversion Repositories openhmc

[/] [openhmc/] [trunk/] [openHMC/] [sim/] [tb/] [uvc/] [src/] [hmc_tb.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
 
40
`ifndef hmc_TB_SV
41
`define hmc_TB_SV
42
 
43
class hmc_tb #( parameter AXI4_DATA_BYTES=`AXI4BYTES, parameter AXI4_TUSER_WIDTH=`AXI4BYTES, parameter NUM_LANES=2**`LOG_NUM_LANES) extends uvm_env;
44
        //-- UVCs
45
 
46
        axi4_stream_env #(
47
                .DATA_BYTES(AXI4_DATA_BYTES),
48
                .TUSER_WIDTH(AXI4_TUSER_WIDTH)
49
 
50
        ) axi4_req;
51
 
52
        axi4_stream_env #(
53
                .DATA_BYTES(AXI4_DATA_BYTES),
54
                .TUSER_WIDTH(AXI4_TUSER_WIDTH)
55
 
56
        ) axi4_rsp;
57
 
58
        hmc_env # (.NUM_LANES(NUM_LANES))hmc;
59
 
60
        hmc_module_env  hmc_module;
61
 
62
        axi4_stream_config axi4_rsp_config;
63
        axi4_stream_config axi4_req_config;
64
 
65
        hmc_link_config link_cfg;
66
 
67
        cag_rgm_rfs_env #(
68
                .ADDR_WIDTH(`RFS_OPENHMC_RF_AWIDTH),
69
                .READ_DATA_WIDTH(`RFS_OPENHMC_RF_RWIDTH),
70
                .WRITE_DATA_WIDTH(`RFS_OPENHMC_RF_WWIDTH)
71
        ) rfs_hmc_I;
72
 
73
        rf_openhmc_rf_c rf_model_hmc;
74
 
75
        vseqr v_seqr;
76
 
77
        int i = 2;
78
 
79
        `uvm_component_param_utils(hmc_tb #(.AXI4_DATA_BYTES(AXI4_DATA_BYTES), .AXI4_TUSER_WIDTH(AXI4_TUSER_WIDTH), .NUM_LANES(NUM_LANES) ))
80
 
81
        function new (string name="hmc_tb", uvm_component parent=null);
82
                super.new(name,parent);
83
        endfunction : new
84
 
85
        virtual function void build_phase(uvm_phase phase);
86
 
87
                //-- factory overrides
88
 
89
        set_inst_override_by_type("axi4_req.master.sequencer",
90
                        axi4_stream_master_sequencer #( .DATA_BYTES(AXI4_DATA_BYTES), .TUSER_WIDTH(AXI4_TUSER_WIDTH)
91
                                                                                  )::get_type(),
92
                        hmc_2_axi4_sequencer #( .DATA_BYTES(AXI4_DATA_BYTES),
93
                                                                        .TUSER_WIDTH(AXI4_TUSER_WIDTH)
94
                                                                        )::get_type()
95
 
96
                );
97
 
98
                set_inst_override_by_type("hmc_module.axi4_req_mon",
99
                        hmc_module_mon::get_type(),
100
                        axi4_stream_hmc_monitor         #(      .DATA_BYTES(AXI4_DATA_BYTES),
101
                                                                                        .TUSER_WIDTH(AXI4_TUSER_WIDTH))::get_type()
102
 
103
                );
104
                set_inst_override_by_type("hmc_module.axi4_rsp_mon",
105
                        hmc_module_mon::get_type(),
106
                        axi4_stream_hmc_monitor         #(      .DATA_BYTES(AXI4_DATA_BYTES),
107
                                                                                        .TUSER_WIDTH(AXI4_TUSER_WIDTH))::get_type()
108
 
109
                );
110
 
111
                super.build_phase(phase);
112
 
113
                //-- deploy configuration
114
                if (!uvm_config_db#(axi4_stream_config)::get(this, "", "axi4_req_config", axi4_req_config)) begin
115
                        uvm_report_fatal(get_type_name(), $psprintf("axi4_config not set via config_db"));
116
                end else begin
117
                        uvm_config_db#(axi4_stream_config)::set(this, "axi4_req", "axi4_stream_cfg", axi4_req_config);
118
                end
119
 
120
                if (!uvm_config_db#(axi4_stream_config)::get(this, "", "axi4_rsp_config", axi4_rsp_config)) begin
121
                        uvm_report_fatal(get_type_name(), $psprintf("axi4_config not set via config_db"));
122
                end else begin
123
                        uvm_config_db#(axi4_stream_config)::set(this, "axi4_rsp", "axi4_stream_cfg", axi4_rsp_config);
124
                end
125
 
126
 
127
                //hmc link uvc
128
                if (!uvm_config_db#(hmc_link_config)::get(this, "", "link_cfg", link_cfg)) begin
129
                        uvm_report_fatal(get_type_name(), $psprintf("hmc_link_uvc_config not set via config_db"));
130
                end else begin
131
                        uvm_config_db#(hmc_link_config)::set(this, "v_seqr", "link_cfg", link_cfg);
132
 
133
                        uvm_config_db#(hmc_link_config)::set(this, "hmc", "link_config", link_cfg);
134
 
135
                end
136
 
137
                //-- create instances
138
                hmc = hmc_env #(.NUM_LANES(NUM_LANES))::type_id::create("hmc",this);
139
 
140
 
141
                axi4_req = axi4_stream_env #(.DATA_BYTES(AXI4_DATA_BYTES),.TUSER_WIDTH(AXI4_TUSER_WIDTH))::type_id::create("axi4_req",this);
142
                axi4_rsp = axi4_stream_env #(.DATA_BYTES(AXI4_DATA_BYTES),.TUSER_WIDTH(AXI4_TUSER_WIDTH))::type_id::create("axi4_rsp",this);
143
 
144
                hmc_module = hmc_module_env::type_id::create("hmc_module",this);
145
 
146
                rfs_hmc_I = cag_rgm_rfs_env #(.ADDR_WIDTH(`RFS_OPENHMC_RF_AWIDTH), .READ_DATA_WIDTH(`RFS_OPENHMC_RF_RWIDTH),.WRITE_DATA_WIDTH(`RFS_OPENHMC_RF_WWIDTH))::type_id::create("rfs_hmc_I", this);
147
                rf_model_hmc = rf_openhmc_rf_c::type_id::create("rf_model_hmc",this);
148
 
149
                v_seqr = vseqr::type_id::create("v_seqr", this);
150
 
151
        endfunction : build_phase
152
 
153
        function void connect_phase(uvm_phase phase);
154
 
155
        hmc_2_axi4_sequencer #(.DATA_BYTES(AXI4_DATA_BYTES),.TUSER_WIDTH(AXI4_TUSER_WIDTH)) axi4_req_seqr;
156
 
157
        axi4_stream_hmc_monitor #(.DATA_BYTES(AXI4_DATA_BYTES), .TUSER_WIDTH(AXI4_TUSER_WIDTH)  )  axi4_hmc_req_mon;
158
        axi4_stream_hmc_monitor #(.DATA_BYTES(AXI4_DATA_BYTES), .TUSER_WIDTH(AXI4_TUSER_WIDTH)  )  axi4_hmc_rsp_mon;
159
 
160
                super.connect_phase(phase);
161
                rfs_hmc_I.assign_vi(tb_top.rfs_hmc_if);
162
                rfs_hmc_I.set_rf(rf_model_hmc);
163
 
164
                //-- cast sequencer
165
                if ( !$cast(axi4_req_seqr, axi4_req.master.sequencer))
166
                `uvm_fatal(get_type_name(), $psprintf("error in seqr cast"));
167
 
168
                //-- cast AXI4 to HMC pkt monitors
169
                if ( !$cast(axi4_hmc_req_mon, hmc_module.axi4_req_mon))
170
                        `uvm_fatal(get_type_name(), $psprintf("error in axi4_req_mon cast"));
171
                if ( !$cast(axi4_hmc_rsp_mon, hmc_module.axi4_rsp_mon))
172
                        `uvm_fatal(get_type_name(), $psprintf("error in axi4_rsp_mon cast"));
173
 
174
                axi4_req.master.sequencer = axi4_req_seqr;
175
 
176
                //-- connect the AXI4 UVC UVM analysis ports to the corresponding Module UVC monitors
177
                axi4_req.monitor.item_collected_port.connect(axi4_hmc_req_mon.axi4_port);
178
                axi4_rsp.monitor.item_collected_port.connect(axi4_hmc_rsp_mon.axi4_port);
179
 
180
                //-- connect the AXi4 to HMC pkt response monitor to the tag handler
181
                axi4_hmc_rsp_mon.item_collected_port.connect(axi4_req_seqr.handler.hmc_rsp_port);
182
 
183
                //-- virtual sequencer
184
                v_seqr.axi4_req_seqr = axi4_req_seqr;
185
                v_seqr.rf_seqr_hmc   = rfs_hmc_I.sequencer;
186
 
187
                 //--hmc monitor to scb
188
                hmc.req_transaction_mon.transaction_finished_port.connect(hmc_module.scb.hmc_req_port); //--direkt
189
                hmc.rsp_transaction_mon.transaction_finished_port.connect(hmc_module.scb.hmc_rsp_port);
190
 
191
 
192
                v_seqr.scb = hmc_module.scb;
193
 
194
        endfunction : connect_phase
195
 
196
        function void extract_phase(uvm_phase phase);
197
                link_cfg.responder.config_cg.sample();
198
        endfunction : extract_phase
199
 
200
endclass : hmc_tb
201
 
202
`endif // hmc_TB_SV

powered by: WebSVN 2.1.0

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