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

Subversion Repositories openhmc

[/] [openhmc/] [trunk/] [openHMC/] [sim/] [UVC/] [hmc/] [sv/] [hmc_token_handler.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_TOKEN_HANDLER_SV
40
`define HMC_TOKEN_HANDLER_SV
41
 
42
class hmc_token_handler extends uvm_component;
43
 
44
        `uvm_analysis_imp_decl(_tokens)
45
        uvm_analysis_imp_tokens#(hmc_packet, hmc_token_handler) token_imp;
46
 
47
 
48
        `uvm_component_utils(hmc_token_handler)
49
 
50
        int available_tokens;
51
 
52
        function new(string name="hmc_token_handler", uvm_component parent);
53
                super.new(name,parent);
54
 
55
                token_imp = new ("token_imp",this);
56
                available_tokens = 0;
57
        endfunction : new
58
 
59
        function void reset();
60
                available_tokens = 0;
61
        endfunction : reset
62
 
63
        function void write_tokens(input hmc_packet packet);
64
                //`uvm_info(get_type_name(), $psprintf("write_tokens received %0d available_tokens = %0d", packet.return_token_count, available_tokens), UVM_HIGH)
65
                available_tokens = available_tokens + packet.return_token_count;
66
        endfunction : write_tokens
67
 
68
        function bit tokens_available(input int request);
69
                //`uvm_info(get_type_name(), $psprintf("tokens_available called for %0d available_tokens = %0d", request, available_tokens), UVM_HIGH)
70
                tokens_available = 0;
71
                if (available_tokens >= request) begin
72
                        available_tokens = available_tokens - request;
73
                        tokens_available = 1;
74
                end
75
        endfunction : tokens_available
76
 
77
 
78
endclass : hmc_token_handler
79
 
80
`endif // HMC_TOKEN_HANDLER_SV

powered by: WebSVN 2.1.0

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