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

Subversion Repositories openhmc

[/] [openhmc/] [trunk/] [openHMC/] [sim/] [UVC/] [hmc/] [sv/] [hmc_link_status.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
//
41
// hmc link status
42
//
43
//
44
 
45
`ifndef HMC_LINK_STATUS_SV
46
`define HMC_LINK_STATUS_SV
47
 
48
class hmc_link_status extends uvm_component;
49
 
50
        init_state_t current_state;
51
 
52
        int num_lanes = 8;
53
 
54
        // status bits
55
        bit first_null_detected = 0;    //-- first NULL Flit detected after TS1 sequence
56
        bit null_after_ts1_seen = 0;    //-- recceived the mimimum amount of NULL Flits to enter Link UP
57
 
58
        // Lane status signals
59
        bit lanes_locked []     ;
60
        bit lanes_aligned[];
61
        bit [15:0]lanes_polarity;
62
        bit lanes_nonzero[];
63
        bit lane_reversed;
64
 
65
        bit all_lanes_locked;
66
        bit all_lanes_alligned;
67
 
68
        int token_count;
69
        int num_lanes_locked;
70
 
71
        bit power_state;
72
        bit first_tret_received=1'b0;
73
 
74
        bit error_abort_mode=1'b0;
75
        int irtry_StartRetry_packet_count=0;
76
        int irtry_ClearErrorAbort_packet_count=0;
77
 
78
 
79
        int last_successfull_frp;
80
        int last_sequence_number;
81
 
82
        bit relaxed_token_handling=1'b0;
83
 
84
        `uvm_component_utils(hmc_link_status)
85
 
86
        function new ( string name="hmc_link_status", uvm_component parent );
87
                super.new(name, parent);
88
        endfunction : new
89
 
90
        function void reset();//--TODO power down reset?
91
                lanes_locked    = new[num_lanes];
92
                lanes_aligned   = new[num_lanes];
93
                lanes_polarity  = {16{1'b0}};
94
                lanes_nonzero   = new[num_lanes];
95
                for (int i=0; i < num_lanes; i++) begin
96
                        lanes_locked[i]         = 0;
97
                        lanes_aligned[i]        = 0;
98
                        lanes_polarity[i]       = 0;
99
                        lanes_nonzero[i]        = 0;
100
                        lane_reversed           = 0;
101
                end
102
 
103
                num_lanes_locked        = 0;
104
 
105
                first_null_detected = 0;
106
                null_after_ts1_seen = 0;
107
                error_abort_mode        = 0;
108
                irtry_StartRetry_packet_count           = 0;
109
                irtry_ClearErrorAbort_packet_count      = 0;
110
                first_tret_received = 0;
111
                last_sequence_number= 0;
112
 
113
                void'(get_all_lanes_locked());
114
                void'(get_all_lanes_aligned());
115
 
116
        endfunction : reset
117
 
118
        function void set_relaxed_token_handling(input bit relaxed);
119
                relaxed_token_handling = relaxed;
120
        endfunction : set_relaxed_token_handling
121
 
122
        function void set_locked(input int lane);
123
                lanes_locked[lane] = 1'b1;
124
                num_lanes_locked = num_lanes_locked + 1;
125
                void'(get_all_lanes_locked());
126
        endfunction : set_locked
127
 
128
        function bit get_locked(input int lane);
129
                return lanes_locked[lane];
130
        endfunction : get_locked
131
 
132
        function int get_next_sequence_number();
133
                return last_sequence_number + 1;
134
        endfunction : get_next_sequence_number
135
 
136
        function bit get_all_lanes_locked();
137
                all_lanes_locked = num_lanes_locked == num_lanes;
138
                return num_lanes_locked == num_lanes;
139
        endfunction : get_all_lanes_locked
140
 
141
        function void set_aligned(input int lane);
142
                lanes_aligned[lane] = 1'b1;
143
                all_lanes_alligned = lanes_aligned == lanes_locked;
144
        endfunction : set_aligned
145
 
146
        function bit get_aligned(input int lane);
147
                return lanes_aligned[lane];
148
        endfunction : get_aligned
149
 
150
        function bit get_all_lanes_aligned();
151
                all_lanes_alligned = (lanes_aligned == lanes_locked) && (lanes_aligned == {16{1'b1}});
152
                return all_lanes_alligned;
153
        endfunction : get_all_lanes_aligned
154
 
155
        function void set_inverted(input int lane);
156
                lanes_polarity[lane] = 1'b1;
157
        endfunction : set_inverted
158
 
159
        function bit get_inverted(input int lane);
160
                return lanes_polarity[lane];
161
        endfunction : get_inverted
162
 
163
        function void set_nonzero(input int lane);
164
                lanes_nonzero[lane] = 1'b1;
165
                void'(get_all_nonzero());
166
        endfunction : set_nonzero
167
 
168
        function bit get_nonzero(input int lane);
169
                return lanes_nonzero[lane];
170
        endfunction : get_nonzero
171
 
172
        function bit get_all_nonzero();
173
                return lanes_nonzero == lanes_locked;
174
        endfunction : get_all_nonzero
175
 
176
        function void set_null_after_ts1();
177
                null_after_ts1_seen = 1;
178
        endfunction : set_null_after_ts1
179
 
180
        function bit get_null_after_ts1();
181
                return null_after_ts1_seen;
182
        endfunction : get_null_after_ts1
183
 
184
        function bit get_first_tret_received();
185
                return first_tret_received;
186
        endfunction : get_first_tret_received
187
 
188
        function void set_error_abort_mode();
189
                error_abort_mode = 1;
190
        endfunction : set_error_abort_mode
191
 
192
        function bit get_error_abort_mode();
193
                return error_abort_mode;
194
        endfunction : get_error_abort_mode
195
 
196
        function void clear_irtry_packet_counts();
197
                `uvm_info(get_type_name(),$psprintf("clear IRTRY counter"), UVM_HIGH)
198
                irtry_StartRetry_packet_count = 0;
199
                irtry_ClearErrorAbort_packet_count = 0;
200
        endfunction : clear_irtry_packet_counts
201
 
202
        function int get_StartRetry_packet_count();
203
                return irtry_StartRetry_packet_count;
204
        endfunction : get_StartRetry_packet_count
205
 
206
        function int get_ClearErrorAbort_packet_count();
207
                return irtry_ClearErrorAbort_packet_count;
208
        endfunction : get_ClearErrorAbort_packet_count
209
 
210
        function int increment_StartRetry_packet_count();
211
                irtry_StartRetry_packet_count = irtry_StartRetry_packet_count + 1;
212
                return irtry_StartRetry_packet_count;
213
        endfunction : increment_StartRetry_packet_count
214
 
215
        function int increment_ClearErrorAbort_packet_count();
216
                irtry_ClearErrorAbort_packet_count = irtry_ClearErrorAbort_packet_count + 1;
217
                return irtry_ClearErrorAbort_packet_count;
218
        endfunction : increment_ClearErrorAbort_packet_count
219
 
220
        function void signal_power_state(input bit ps);
221
                power_state = ps;
222
        endfunction : signal_power_state
223
 
224
        function void report_phase(uvm_phase phase);
225
                `uvm_info(get_type_name(),$psprintf("Token_count %0d", token_count), UVM_LOW)
226
        endfunction : report_phase
227
 
228
endclass : hmc_link_status
229
 
230
`endif // HMC_LINK_STATUS_SV

powered by: WebSVN 2.1.0

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