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

Subversion Repositories openhmc

[/] [openhmc/] [trunk/] [openHMC/] [sim/] [UVC/] [hmc/] [sv/] [hmc_requester_driver.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_REQUESTER_DRIVER_SV
40
`define HMC_REQUESTER_DRIVER_SV
41
 
42
/* Driver is incomplete and not tested */
43
/* Use at your own risk */
44
 
45
 
46
class hmc_requester_driver #(parameter NUM_LANES=16) extends hmc_driver_base#(NUM_LANES);
47
 
48
        `uvm_component_param_utils(hmc_requester_driver#(.NUM_LANES(NUM_LANES)))
49
 
50
        function new(string name="hmc_requester_driver", uvm_component parent);
51
                super.new(name,parent);
52
                hmc_frp_port    = new("hmc_frp_port", this);
53
        endfunction : new
54
 
55
        function void build_phase(uvm_phase phase);
56
                super.build_phase(phase);
57
 
58
                local_config = link_config.requester;
59
        endfunction : build_phase
60
 
61
        task run_phase(uvm_phase phase);
62
                super.run_phase(phase);
63
 
64
                forever begin
65
                        if(vif.P_RST_N !== 1) begin
66
                                next_state = RESET;
67
                        end
68
 
69
                        if (next_state != last_state)
70
                                `uvm_info(get_type_name(),$psprintf("in state %s", next_state.name()), UVM_HIGH)
71
 
72
                        last_state = next_state;
73
 
74
                        fork
75
                                begin
76
                                        case (next_state)
77
                                                RESET: reset();
78
                                                NULL_FLITS: null_flits();
79
                                                TS1: ts1();
80
                                                NULL_FLITS_2: null_flits_2();
81
                                                INITIAL_TRETS: initial_trets();
82
                                                LINK_UP: link_up();
83
                                                START_RETRY_INIT: start_retry_init();
84
                                                CLEAR_RETRY: clear_retry();
85
                                                SEND_RETRY_PACKETS: send_retry_packets();
86
 
87
                                        endcase
88
                                end
89
                                begin
90
                                        @(negedge vif.P_RST_N);
91
 
92
                                end
93
                                begin
94
                                //      get_packets();
95
                                end
96
                        join_any
97
                        disable fork;
98
                end
99
 
100
        endtask : run_phase
101
 
102
        task reset();
103
 
104
                vif.RXP = {NUM_LANES {1'bz}};
105
                vif.RXN = {NUM_LANES {1'bz}};
106
                vif.RXPS = 1'b1;
107
 
108
 
109
                seq_num = 1;
110
                last_rrp = 0;
111
                init_continue = 0;
112
                can_continue = 1;
113
                retry_buffer.reset();
114
 
115
                //wait for reset signal
116
                @(posedge vif.P_RST_N);
117
 
118
                #link_config.tINIT;
119
 
120
                set_init_continue();
121
                `uvm_info(get_type_name(),$psprintf("active = %0d retry prob = %0d", local_config.active, local_config.random_retry_probability), UVM_HIGH)
122
 
123
                vif.RXPS = 1'b1;
124
 
125
                #1us;
126
                reset_timestamp = $time;
127
 
128
                next_state = NULL_FLITS;
129
        endtask : reset
130
 
131
        task null_flits();
132
                int null_time;
133
 
134
                reset_lfsr();
135
 
136
                //wait for Responder to send NULLs
137
                while (!remote_status.get_all_lanes_locked())
138
                        drive_fit({NUM_LANES {1'b0}});
139
 
140
                null_timestamp = $time;
141
 
142
                //wait at most tRESP2
143
                null_time_randomization_succeeds : assert (std::randomize(null_time) with {null_time > 0ns && null_time < link_config.tRESP2;});
144
                for (int i=0; i
145
                        drive_fit({NUM_LANES {1'b0}});
146
                end
147
 
148
                next_state = TS1;
149
        endtask : null_flits
150
 
151
        task ts1();
152
                int ts1_fits = 0;
153
 
154
                // Save the timestamp
155
                ts1_timestamp = $time;
156
 
157
                //wait for Responder to send TS1
158
                while (!remote_status.get_all_lanes_aligned())
159
                        send_ts1(256); // 16 fits per sequence number, 16 sequence numbers
160
 
161
                //Send some (possibly incomplete) TS1 flits
162
                ts1_fits_randomization_succeeds : assert (std::randomize(ts1_fits) with {ts1_fits >= 0 && ts1_fits < 512;});
163
                send_ts1(ts1_fits);
164
 
165
                next_state = NULL_FLITS_2;
166
        endtask : ts1
167
 
168
        task null_flits_2();
169
                int null_flit_count;
170
 
171
                while (!remote_status.get_first_tret_received())
172
                        drive_flit(128'h0);
173
 
174
                null_flit_count_randomization_succeeds : assert (std::randomize(null_flit_count) with {null_flit_count >= 1 && null_flit_count < 512;});
175
 
176
                //send NULL FLITs
177
                for (int i=0; i < null_flit_count; i++)
178
                        drive_flit(128'h0);
179
 
180
                next_state = INITIAL_TRETS;
181
        endtask : null_flits_2
182
 
183
        function void drive_lanes(input bit[NUM_LANES-1:0] new_value);
184
                int i;
185
 
186
                bit[NUM_LANES-1:0] lanes_reordered;
187
 
188
                if (local_config.reverse_lanes) begin
189
                        for (i = 0; i < NUM_LANES; i= i+1) begin
190
                                lanes_reordered[i] = new_value[NUM_LANES-i-1];
191
                        end
192
                end else begin
193
                        lanes_reordered = new_value;
194
                end
195
 
196
                // TODO: wire delays?
197
                for (i = 0; i < local_config.width; i= i+1) begin
198
                        vif.RXP[i] = lanes_reordered[i] ^ local_config.reverse_polarity[i];
199
                        vif.RXN[i] = ~lanes_reordered[i] ^ local_config.reverse_polarity[i];
200
                end
201
        endfunction : drive_lanes
202
 
203
endclass : hmc_requester_driver
204
 
205
`endif // HMC_REQUESTER_DRIVER_SV
206
 

powered by: WebSVN 2.1.0

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