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

Subversion Repositories openhmc

[/] [openhmc/] [trunk/] [openHMC/] [sim/] [UVC/] [hmc/] [sv/] [hmc_cdr.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_cdr_SV
40
`define hmc_cdr_SV
41
class hmc_cdr #(parameter NUM_LANES = 16) extends uvm_component;
42
 
43
        event int_clk;
44
 
45
        virtual hmc_sr_if#(.NUM_LANES(NUM_LANES)) vif;
46
        hmc_link_config link_config;
47
 
48
        link_type_t link_type = REQUESTER;
49
 
50
        `uvm_component_param_utils_begin(hmc_cdr#(.NUM_LANES(NUM_LANES)))
51
                `uvm_field_enum(link_type_t, link_type, UVM_DEFAULT)
52
        `uvm_component_utils_end
53
 
54
        function new ( string name="hmc_cdr", uvm_component parent );
55
                super.new(name, parent);
56
        endfunction : new
57
 
58
        function void build_phase(uvm_phase phase);
59
                super.build_phase(phase);
60
                if(uvm_config_db#(hmc_link_config )::get(this, "", "link_config",link_config) ) begin
61
                        this.link_config = link_config;
62
                end else begin
63
                        `uvm_fatal(get_type_name(),"link_config is not set")
64
                end
65
                if(uvm_config_db#(virtual interface hmc_sr_if#(.NUM_LANES(NUM_LANES)))::get(this, "", "vif",vif) ) begin
66
                        this.vif = vif;
67
                end else begin
68
                        `uvm_fatal(get_type_name(),"vif is not set")
69
                end
70
        endfunction : build_phase
71
 
72
 
73
        task run_phase(uvm_phase phase);
74
                bit timeout = 0;
75
 
76
                time timeout_length;
77
                time wait_time;
78
 
79
                super.run_phase(phase);
80
 
81
                forever begin
82
 
83
                        @(posedge vif.P_RST_N); //-- wait for leaving reset state
84
                        fork
85
                                begin
86
                                        @(negedge vif.P_RST_N); //-- entering reset state
87
                                end
88
                                begin
89
 
90
                                        timeout_length = link_config.bit_time;
91
 
92
                                        forever begin
93
                                                fork
94
                                                        begin
95
                                                                if(link_type == REQUESTER)
96
                                                                        @(vif.RXP);
97
                                                                else
98
                                                                        @(vif.TXP);
99
                                                        end
100
                                                        begin
101
                                                                #(timeout_length + 1ps);
102
                                                                timeout = 1;
103
                                                        end
104
                                                join_any
105
                                                disable fork;
106
 
107
                                                case (link_config.bit_time)
108
                                                        100ps   : wait_time = 50ps;
109
                                                        80ps    : wait_time = 40ps;
110
                                                        66ps    : wait_time = 30ps;
111
                                                endcase
112
 
113
                                                timeout_length = wait_time;
114
 
115
                                                if(timeout == 1)
116
                                                        wait_time -= 1ps;
117
 
118
                                                #(wait_time);
119
 
120
                                                -> int_clk;
121
 
122
                                                timeout = 0;
123
                                        end
124
                                end
125
                        join_any;
126
                        disable fork;
127
                end
128
        endtask : run_phase
129
 
130
endclass :hmc_cdr
131
 
132
`endif //hmc_cdr_SV

powered by: WebSVN 2.1.0

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