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

Subversion Repositories openhmc

[/] [openhmc/] [trunk/] [openHMC/] [sim/] [tb/] [bfm/] [testlib/] [openhmc_init_seq.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_INIT_SEQ
41
`define HMC_INIT_SEQ
42
 
43
class openhmc_init_seq extends hmc_base_seq;
44
 
45
        function new(string name="openhmc_init_seq");
46
                super.new(name);
47
        endfunction : new
48
 
49
        `uvm_object_utils(openhmc_init_seq)
50
        `uvm_declare_p_sequencer(vseqr)
51
 
52
        bit phy_tx_ready        = 1'b0;
53
        bit phy_rx_ready        = 1'b0;
54
        bit link_up             = 1'b0;
55
        int timeout             = 0;
56
 
57
        task body();
58
 
59
                //------------------------------------------------------- configure the openHMC controller
60
                reg_openhmc_rf_control_c                control;
61
                reg_openhmc_rf_status_general_c status;
62
                reg_openhmc_rf_status_init_c    status_init;
63
                reg_openhmc_rf_counter_reset_c  cnt_reset;
64
 
65
                `uvm_info(get_type_name(), "Running init sequence", UVM_NONE)
66
 
67
                $cast(control,p_sequencer.rf_seqr_hmc.get_by_name("control"));
68
                control.set_check_on_read(1'b0);
69
                p_sequencer.rf_seqr_hmc.read_reg(control);
70
 
71
                control.fields.rx_token_count_          = p_sequencer.link_cfg.rx_tokens;
72
                control.fields.scrambler_disable_       = ~p_sequencer.link_cfg.cfg_scram_enb;
73
                control.fields.bit_slip_time_           = p_sequencer.link_cfg.bit_slip_time;
74
                control.fields.set_hmc_sleep_           = 0;
75
                control.fields.run_length_enable_       = ~p_sequencer.link_cfg.cfg_scram_enb;
76
                control.fields.irtry_to_send_           = p_sequencer.link_cfg.cfg_init_retry_txcnt*4;
77
                control.fields.irtry_received_threshold_ = p_sequencer.link_cfg.cfg_init_retry_rxcnt;
78
 
79
                p_sequencer.rf_seqr_hmc.write_reg(control);
80
 
81
                //Dummy Read to status init
82
                $cast(status_init,p_sequencer.rf_seqr_hmc.get_by_name("status_init"));
83
                status_init.set_check_on_read(1'b0);
84
                p_sequencer.rf_seqr_hmc.read_reg(status_init);
85
 
86
                //Dummy counter reset
87
                $cast(cnt_reset,p_sequencer.rf_seqr_hmc.get_by_name("counter_reset"));
88
                cnt_reset.fields.rreinit_ = 1;
89
                p_sequencer.rf_seqr_hmc.write_reg(cnt_reset);
90
 
91
                //-- Wait until the PHY is out of reset
92
                $cast(status,p_sequencer.rf_seqr_hmc.get_by_name("status_general"));
93
                status.set_check_on_read(1'b0);
94
                while (phy_tx_ready == 1'b0)
95
                begin
96
                        #1us;
97
                        p_sequencer.rf_seqr_hmc.read_reg(status);
98
                        phy_tx_ready = status.fields.phy_tx_ready_;
99
                        `uvm_info(get_type_name(), "Waiting for the PHY TX to get ready", UVM_NONE)
100
                end
101
                `uvm_info(get_type_name(), "Phy TX ready", UVM_NONE)
102
 
103
                //------------------------------------------------------- Set Reset and Init Continue
104
                control.fields.p_rst_n_ = 1;
105
                p_sequencer.rf_seqr_hmc.write_reg(control);
106
                #1us;
107
 
108
                control.fields.hmc_init_cont_set_ = 1;
109
                p_sequencer.rf_seqr_hmc.write_reg(control);
110
                `uvm_info(get_type_name(), "Init cont in RF set", UVM_NONE)
111
 
112
                //------------------------------------------------------- Wait for the PHY to get ready
113
                while (phy_rx_ready == 1'b0)
114
                begin
115
                        #1us;
116
                        p_sequencer.rf_seqr_hmc.read_reg(status);
117
                        phy_rx_ready = status.fields.phy_rx_ready_;
118
                        `uvm_info(get_type_name(), "Waiting for PHY RX to get ready", UVM_NONE)
119
                end
120
                `uvm_info(get_type_name(), "Phy RX is ready", UVM_NONE)
121
 
122
                //-- Poll on link_up to make sure that it comes up.
123
                while (link_up == 1'b0)
124
                begin
125
                        if (timeout == 8000) //-- Try Resetting it.
126
                        begin
127
                                `uvm_fatal(get_type_name(), "The link didn't come up...")
128
                        end
129
                        #4ns;
130
                        p_sequencer.rf_seqr_hmc.read_reg(status);
131
                        link_up = status.fields.link_up_;
132
                        timeout = timeout + 1;
133
                end
134
                `uvm_info(get_type_name(), "Link is UP !", UVM_NONE)
135
 
136
        endtask : body
137
 
138
endclass : openhmc_init_seq
139
 
140
`endif // HMC_INIT_SEQ

powered by: WebSVN 2.1.0

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