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

Subversion Repositories openhmc

[/] [openhmc/] [trunk/] [openHMC/] [sim/] [tb/] [bfm/] [src/] [hmc_tb.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_TB_SV
41
`define hmc_TB_SV
42
 
43
class hmc_tb #( parameter AXI4_DATA_BYTES=`AXI4BYTES, parameter AXI4_TUSER_WIDTH=`AXI4BYTES) 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
 
59
        hmc_module_env  hmc_module;
60
 
61
        axi4_stream_config axi4_rsp_config;
62
        axi4_stream_config axi4_req_config;
63
 
64
        hmc_link_config link_cfg;
65
 
66
        cag_rgm_rfs_env #(
67
                .ADDR_WIDTH(`RFS_HMC_CONTROLLER_RF_AWIDTH),
68
                .READ_DATA_WIDTH(`RFS_HMC_CONTROLLER_RF_RWIDTH),
69
                .WRITE_DATA_WIDTH(`RFS_HMC_CONTROLLER_RF_WWIDTH)
70
        ) rfs_hmc_I;
71
 
72
        rf_hmc_controller_rf_c rf_model_hmc;
73
 
74
        hmc_vseqr v_seqr;
75
 
76
        int i = 2;
77
 
78
        `uvm_component_param_utils(hmc_tb #(.AXI4_DATA_BYTES(AXI4_DATA_BYTES), .AXI4_TUSER_WIDTH(AXI4_TUSER_WIDTH) ))
79
 
80
        function new (string name="hmc_tb", uvm_component parent=null);
81
                super.new(name,parent);
82
        endfunction : new
83
 
84
        virtual function void build_phase(uvm_phase phase);
85
 
86
                //-- factory overrides
87
 
88
        set_inst_override_by_type("axi4_req.master.sequencer",
89
                        axi4_stream_master_sequencer #( .DATA_BYTES(AXI4_DATA_BYTES), .TUSER_WIDTH(AXI4_TUSER_WIDTH)
90
                                                                                  )::get_type(),
91
                        hmc_2_axi4_sequencer #( .DATA_BYTES(AXI4_DATA_BYTES),
92
                                                                        .TUSER_WIDTH(AXI4_TUSER_WIDTH)
93
                                                                        )::get_type()
94
 
95
                );
96
 
97
                set_inst_override_by_type("hmc_module.axi4_req_mon",
98
                        hmc_module_mon::get_type(),
99
                        axi4_stream_hmc_monitor         #(      .DATA_BYTES(AXI4_DATA_BYTES),
100
                                                                                        .TUSER_WIDTH(AXI4_TUSER_WIDTH))::get_type()
101
 
102
                );
103
                set_inst_override_by_type("hmc_module.axi4_rsp_mon",
104
                        hmc_module_mon::get_type(),
105
                        axi4_stream_hmc_monitor         #(      .DATA_BYTES(AXI4_DATA_BYTES),
106
                                                                                        .TUSER_WIDTH(AXI4_TUSER_WIDTH))::get_type()
107
 
108
                );
109
 
110
                set_inst_override_by_type("hmc_module.hmc_req_mon",hmc_module_mon::get_type(),bfm_2_hmc_mon::get_type());
111
                set_inst_override_by_type("hmc_module.hmc_rsp_mon",hmc_module_mon::get_type(),bfm_2_hmc_mon::get_type());
112
 
113
 
114
                super.build_phase(phase);
115
 
116
 
117
                //-- deploy configuration
118
                if (!uvm_config_db#(axi4_stream_config)::get(this, "", "axi4_req_config", axi4_req_config)) begin
119
                        uvm_report_fatal(get_type_name(), $psprintf("axi4_config not set via config_db"));
120
                end else begin
121
                        uvm_config_db#(axi4_stream_config)::set(this, "axi4_req", "axi4_stream_cfg", axi4_req_config);
122
                end
123
 
124
                if (!uvm_config_db#(axi4_stream_config)::get(this, "", "axi4_rsp_config", axi4_rsp_config)) begin
125
                        uvm_report_fatal(get_type_name(), $psprintf("axi4_config not set via config_db"));
126
                end else begin
127
                        uvm_config_db#(axi4_stream_config)::set(this, "axi4_rsp", "axi4_stream_cfg", axi4_rsp_config);
128
                end
129
 
130
 
131
                if (!uvm_config_db#(hmc_link_config)::get(this, "", "link_cfg", link_cfg)) begin
132
                        uvm_report_fatal(get_type_name(), $psprintf("hmc_link_config not set via config_db"));
133
                end else begin
134
                        uvm_config_db#(hmc_link_config)::set(this, "v_seqr", "link_cfg", link_cfg);
135
 
136
                        uvm_config_db#(hmc_link_config)::set(this, "hmc_module.hmc_req_mon", "link_cfg", link_cfg);
137
                        uvm_config_db#(hmc_link_config)::set(this, "hmc_module.hmc_rsp_mon", "link_cfg", link_cfg);
138
                end
139
 
140
                //-- create instances
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_HMC_CONTROLLER_RF_AWIDTH), .READ_DATA_WIDTH(`RFS_HMC_CONTROLLER_RF_RWIDTH),.WRITE_DATA_WIDTH(`RFS_HMC_CONTROLLER_RF_WWIDTH))::type_id::create("rfs_hmc_I", this);
147
                rf_model_hmc = rf_hmc_controller_rf_c::type_id::create("rf_model_hmc",this);
148
 
149
                v_seqr = hmc_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
                bfm_2_hmc_mon    hmc_rsp_mon;
161
                bfm_2_hmc_mon    hmc_req_mon;
162
 
163
                super.connect_phase(phase);
164
                rfs_hmc_I.assign_vi(tb_top.rfs_hmc_if);
165
                rfs_hmc_I.set_rf(rf_model_hmc);
166
 
167
                //-- cast sequencer
168
                if ( !$cast(axi4_req_seqr, axi4_req.master.sequencer))
169
                `uvm_fatal(get_type_name(), $psprintf("error in seqr cast"));
170
 
171
                //-- cast AXI4 to HMC pkt monitors
172
                if ( !$cast(axi4_hmc_req_mon, hmc_module.axi4_req_mon))
173
                        `uvm_fatal(get_type_name(), $psprintf("error in axi4_req_mon cast"));
174
                if ( !$cast(axi4_hmc_rsp_mon, hmc_module.axi4_rsp_mon))
175
                        `uvm_fatal(get_type_name(), $psprintf("error in axi4_rsp_mon cast"));
176
 
177
                //-- cast BFM to HMC pkt monitors
178
                if ( !$cast(hmc_req_mon, hmc_module.hmc_req_mon))
179
                        `uvm_fatal(get_type_name(), $psprintf("error in hmc_req_mon cast"));
180
                if ( !$cast(hmc_rsp_mon, hmc_module.hmc_rsp_mon))
181
                        `uvm_fatal(get_type_name(), $psprintf("error in hmc_rsp_mon scast"));
182
 
183
                hmc_rsp_mon.in_mb = tb_top.dut_I.hmc_bfm0.hmc_flit_top.mb_err2driver[0];
184
                hmc_req_mon.in_mb = tb_top.dut_I.hmc_bfm0.hmc_flit_top.mb_err2retry[0];
185
 
186
 
187
 
188
                axi4_req.master.sequencer = axi4_req_seqr;
189
 
190
 
191
                //-- connect the AXI4 UVC UVM analysis ports to the corresponding Module UVC monitors
192
                axi4_req.monitor.item_collected_port.connect(axi4_hmc_req_mon.axi4_port);
193
                axi4_rsp.monitor.item_collected_port.connect(axi4_hmc_rsp_mon.axi4_port);
194
 
195
                //-- connect the AXi4 to HMC pkt response monitor to the tag handler
196
                axi4_hmc_rsp_mon.item_collected_port.connect(axi4_req_seqr.handler.hmc_rsp_port);
197
 
198
                //-- virtual sequencer
199
                v_seqr.axi4_req_seqr = axi4_req_seqr;
200
                v_seqr.rf_seqr_hmc   = rfs_hmc_I.sequencer;
201
 
202
 
203
        endfunction : connect_phase
204
 
205
endclass : hmc_tb
206
 
207
`endif // hmc_TB_SV

powered by: WebSVN 2.1.0

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