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_sequence extends uvm_sequence #(cag_rgm_transfer);
|
41 |
|
|
|
42 |
|
|
//`uvm_sequence_utils(cag_rgm_sequence, cag_rgm_sequencer)
|
43 |
|
|
`uvm_object_utils(cag_rgm_sequence)
|
44 |
|
|
`uvm_declare_p_sequencer(cag_rgm_sequencer)
|
45 |
|
|
|
46 |
|
|
function new(string name="cag_rgm_sequence");
|
47 |
|
|
super.new(name);
|
48 |
|
|
endfunction : new
|
49 |
|
|
|
50 |
|
|
virtual task pre_body();
|
51 |
|
|
uvm_test_done.raise_objection(p_sequencer);
|
52 |
|
|
endtask : pre_body
|
53 |
|
|
|
54 |
|
|
virtual task post_body();
|
55 |
|
|
uvm_test_done.drop_objection(p_sequencer);
|
56 |
|
|
endtask : post_body
|
57 |
|
|
|
58 |
|
|
function cag_rgm_base get_by_name(string name = "");
|
59 |
|
|
return p_sequencer.get_by_name(name);
|
60 |
|
|
endfunction : get_by_name
|
61 |
|
|
|
62 |
|
|
task write_reg(cag_rgm_base reg_);
|
63 |
|
|
bit bitstream[];
|
64 |
|
|
int bits;
|
65 |
|
|
cag_rgm_transfer trans;
|
66 |
|
|
|
67 |
|
|
uvm_packer packer = new();
|
68 |
|
|
packer.big_endian = 0;
|
69 |
|
|
|
70 |
|
|
bits = reg_.pack(bitstream,packer);
|
71 |
|
|
//reg_.print();
|
72 |
|
|
|
73 |
|
|
`uvm_create(trans)
|
74 |
|
|
trans.command = CAG_RGM_WRITE;
|
75 |
|
|
trans.address = reg_.get_address();
|
76 |
|
|
trans.data = 64'd0;
|
77 |
|
|
//for(int i = 0 , int j = bits-1; i < bits; i++ ,j--)
|
78 |
|
|
// trans.data[i] = bitstream[j];
|
79 |
|
|
|
80 |
|
|
for(int i = 0; i < bits; i++)
|
81 |
|
|
trans.data[i] = bitstream[i];
|
82 |
|
|
//$display("%b",trans.data);
|
83 |
|
|
|
84 |
|
|
//uvm_report_info("DEBUG",$psprintf("write; address: %h, data: %h",trans.address,trans.data),UVM_NONE);
|
85 |
|
|
|
86 |
|
|
`uvm_send(trans)
|
87 |
|
|
//uvm_report_info("DEBUG",$psprintf("write; address: %h, data: %h done",trans.address,trans.data),UVM_NONE);
|
88 |
|
|
endtask : write_reg
|
89 |
|
|
|
90 |
|
|
task read_reg(cag_rgm_base reg_);
|
91 |
|
|
int unsigned source_tag;
|
92 |
|
|
bit bitstream[];
|
93 |
|
|
int bits;
|
94 |
|
|
cag_rgm_transfer trans;
|
95 |
|
|
cag_rgm_transfer response;
|
96 |
|
|
|
97 |
|
|
uvm_packer packer = new();
|
98 |
|
|
packer.big_endian = 0;
|
99 |
|
|
|
100 |
|
|
p_sequencer.m_get_source_tag(source_tag);
|
101 |
|
|
//uvm_report_info("DEBUG",$psprintf("using tag: %0d",source_tag),UVM_NONE);
|
102 |
|
|
|
103 |
|
|
bits = reg_.pack(bitstream,packer);
|
104 |
|
|
|
105 |
|
|
`uvm_create(trans)
|
106 |
|
|
trans.command = CAG_RGM_READ;
|
107 |
|
|
trans.address = reg_.get_address();
|
108 |
|
|
trans.source_tag = source_tag;
|
109 |
|
|
//uvm_report_info("DEBUG",$psprintf("read; address: %h, data: %h",trans.address,trans.data),UVM_NONE);
|
110 |
|
|
`uvm_send(trans)
|
111 |
|
|
|
112 |
|
|
//-- wait for response
|
113 |
|
|
//p_sequencer.responses.get(response);
|
114 |
|
|
//if(response.source_tag != source_tag)
|
115 |
|
|
// p_sequencer.uvm_report_fatal(get_type_name(),$psprintf("got the wrong source tag: %h",response.source_tag));
|
116 |
|
|
p_sequencer.get_response(source_tag, response);
|
117 |
|
|
|
118 |
|
|
for(int i = 0 /*, int j = bits-1*/; i < bits; i++ /*, j--*/)
|
119 |
|
|
bitstream[i] = response.data[i];
|
120 |
|
|
|
121 |
|
|
bits = reg_.unpack(bitstream,packer);
|
122 |
|
|
|
123 |
|
|
p_sequencer.m_release_source_tag(source_tag);
|
124 |
|
|
//uvm_report_info("DEBUG",$psprintf("read; address: %h, data: %h done",response.address,response.data),UVM_NONE);
|
125 |
|
|
endtask : read_reg
|
126 |
|
|
|
127 |
|
|
endclass : cag_rgm_sequence
|
128 |
|
|
|
129 |
|
|
class cag_rgm_write_sequence extends cag_rgm_sequence;
|
130 |
|
|
|
131 |
|
|
rand cag_rgm_base req_;
|
132 |
|
|
|
133 |
|
|
//`uvm_sequence_utils(cag_rgm_write_sequence, cag_rgm_sequencer)
|
134 |
|
|
`uvm_object_utils(cag_rgm_write_sequence)
|
135 |
|
|
|
136 |
|
|
function new(string name="cag_rgm_write_sequence");
|
137 |
|
|
super.new(name);
|
138 |
|
|
endfunction : new
|
139 |
|
|
|
140 |
|
|
task body();
|
141 |
|
|
cag_rgm_base m_req_;
|
142 |
|
|
|
143 |
|
|
//p_sequencer.uvm_report_info(get_type_name(), $psprintf("Write Request:\n%s ",req_.sprint()),UVM_NONE);
|
144 |
|
|
$cast(m_req_,req_.clone());
|
145 |
|
|
|
146 |
|
|
write_reg(m_req_);
|
147 |
|
|
|
148 |
|
|
req_.copy(m_req_);
|
149 |
|
|
endtask : body
|
150 |
|
|
|
151 |
|
|
endclass : cag_rgm_write_sequence
|
152 |
|
|
|
153 |
|
|
class cag_rgm_read_sequence extends cag_rgm_sequence;
|
154 |
|
|
|
155 |
|
|
rand cag_rgm_base req_;
|
156 |
|
|
|
157 |
|
|
`uvm_object_utils(cag_rgm_read_sequence)
|
158 |
|
|
|
159 |
|
|
function new(string name="cag_rgm_read_sequence");
|
160 |
|
|
super.new(name);
|
161 |
|
|
endfunction : new
|
162 |
|
|
|
163 |
|
|
task body();
|
164 |
|
|
cag_rgm_base m_req_;
|
165 |
|
|
cag_rgm_base old_reg;
|
166 |
|
|
|
167 |
|
|
//req_ = cag_rgm_base::type_id::create("m_req");
|
168 |
|
|
//req_.copy(req_);
|
169 |
|
|
$cast(m_req_,req_.clone());
|
170 |
|
|
|
171 |
|
|
if (m_req_.get_check_on_read() == 1) begin//-- checking is enabled, so make a copy to compare afterwards
|
172 |
|
|
$cast(old_reg,m_req_.clone());
|
173 |
|
|
end
|
174 |
|
|
|
175 |
|
|
//if (m_req_.get_check_on_read() == 1)
|
176 |
|
|
// p_sequencer.uvm_report_info(get_type_name(), $psprintf("Read Request:\n%s\n, Saved:\n%s ",m_req_.sprint(),old_reg.sprint()),UVM_NONE);
|
177 |
|
|
read_reg(m_req_);
|
178 |
|
|
|
179 |
|
|
//uvm_report_info(get_type_name(),$psprintf("Compare of:\n%s\n%s",m_req_.sprint(),old_reg.sprint()),UVM_NONE);
|
180 |
|
|
|
181 |
|
|
if (m_req_.get_check_on_read() == 1) begin
|
182 |
|
|
|
183 |
|
|
if (m_req_.compare(old_reg) != 1)
|
184 |
|
|
p_sequencer.uvm_report_fatal(get_type_name(),
|
185 |
|
|
$psprintf("Compare for check_on_read failed for:\n%s\nShould be:\n%s\nMaybe checking on this register has to be turned off. ",m_req_.sprint(), old_reg.sprint()));
|
186 |
|
|
end
|
187 |
|
|
|
188 |
|
|
req_.copy(m_req_);
|
189 |
|
|
endtask : body
|
190 |
|
|
|
191 |
|
|
endclass : cag_rgm_read_sequence
|
192 |
|
|
|
193 |
|
|
/******************************************************************************
|
194 |
|
|
*
|
195 |
|
|
* REVISION HISTORY:
|
196 |
|
|
*
|
197 |
|
|
*******************************************************************************/
|