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

Subversion Repositories openhmc

[/] [openhmc/] [trunk/] [openHMC/] [sim/] [UVC/] [cag_rgm/] [sv/] [cag_rgm_base.sv] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 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
class cag_rgm_base extends uvm_object;
41
 
42
        protected CAG_RGM_TYPE m_type = NONE;
43
        protected bit [63:0] address;
44
        protected bit [63:0] offset;
45
        protected int loop = -1;
46
        protected string name;
47
        protected bit check_on_read = 1;
48
 
49
        `uvm_object_utils_begin(cag_rgm_base)
50
        `uvm_field_int(address, UVM_NOCOMPARE | UVM_NOPACK | UVM_DEFAULT)
51
        `uvm_field_int(offset, UVM_NOCOMPARE | UVM_NOPACK | UVM_DEFAULT)
52
        `uvm_field_int(check_on_read, UVM_NOCOMPARE | UVM_NOPACK | UVM_DEFAULT)
53
        `uvm_field_string(name, UVM_NOCOMPARE | UVM_NOPACK | UVM_DEFAULT)
54
        `uvm_object_utils_end
55
 
56
        function new(string name="cag_rgm_base");
57
                super.new(name);
58
        endfunction : new
59
 
60
        function CAG_RGM_TYPE get_rgm_type();
61
                return m_type;
62
        endfunction : get_rgm_type
63
 
64
        function string get_name();
65
                return name;
66
        endfunction : get_name
67
 
68
        function void set_name(string name);
69
                this.name = name;
70
        endfunction : set_name
71
 
72
        virtual function void set_address(bit [63:0] address);
73
                this.address = address;
74
        endfunction : set_address
75
 
76
        virtual function bit [63:0] get_address();
77
                return address + offset;
78
        endfunction : get_address
79
 
80
        virtual function int address_match(bit [63:0] address);
81
                if(get_address() == address)
82
                        return 1;
83
                else
84
                        return -1;
85
        endfunction : address_match
86
 
87
        function void set_offset(bit [63:0] offset);
88
                this.offset = offset;
89
        endfunction : set_offset
90
 
91
        function bit [63:0] get_offset();
92
                return offset;
93
        endfunction : get_offset
94
 
95
        virtual function void set_loop(int loop);
96
                this.loop = loop;
97
        endfunction : set_loop
98
 
99
        function int get_loop();
100
                return loop;
101
        endfunction : get_loop
102
 
103
        function void set_check_on_read(bit check_on_read);
104
                this.check_on_read = check_on_read;
105
        endfunction : set_check_on_read
106
 
107
        function bit get_check_on_read();
108
                return this.check_on_read;
109
        endfunction : get_check_on_read
110
 
111
        function void set_raw(bit [63:0] data, bit endian = 1);
112
                bit bitstream[];
113
                int bits;
114
 
115
                bits = pack(bitstream);
116
                if (endian == 1) begin
117
                        for(int i = 0, int j = bits-1; i < bits; i++, j--)
118
                                bitstream[i] = data[j];
119
                end else begin
120
                        for(int i = 0; i < bits; i++)
121
                                bitstream[i] = data[i];
122
                end
123
                bits = unpack(bitstream);
124
 
125
        endfunction : set_raw
126
 
127
        function bit [63:0] get_raw(bit endian = 1);
128
                uvm_packer packer = new();
129
                int bits;
130
                bit bitstream[];
131
                bit [63:0] data = 0;
132
 
133
                packer.big_endian = endian;
134
 
135
                bits = pack(bitstream,packer);
136
                for(int i = 0; i < bits; i++)
137
                        data[i] = bitstream[i];
138
 
139
                return data;
140
        endfunction
141
 
142
        virtual function void print_rf(string prefix = "");
143
                $display(do_print_rf($psprintf("%stype: %s, name: %s, address: %0h, offset: %0h",prefix,m_type.name,name,address,offset)));
144
        endfunction : print_rf
145
 
146
        virtual function string do_print_rf(string s = "");
147
                return s;
148
        endfunction : do_print_rf
149
 
150
endclass : cag_rgm_base
151
 
152
/******************************************************************************
153
        *
154
        * REVISION HISTORY:
155
        *
156
*******************************************************************************/

powered by: WebSVN 2.1.0

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