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_transaction_mon_sv
|
40 |
|
|
`define hmc_transaction_mon_sv
|
41 |
|
|
|
42 |
|
|
class hmc_transaction_mon extends uvm_monitor;
|
43 |
|
|
|
44 |
|
|
hmc_packet hmc_buffer[$];
|
45 |
|
|
bit [7:0] last_rrp = 0;
|
46 |
|
|
bit [2:0] next_sequence_num;
|
47 |
|
|
hmc_tag_mon tag_mon;
|
48 |
|
|
|
49 |
|
|
uvm_active_passive_enum enable_tag_checking = UVM_ACTIVE;
|
50 |
|
|
|
51 |
|
|
`uvm_analysis_imp_decl(_hmc_pkt)
|
52 |
|
|
uvm_analysis_imp_hmc_pkt #(hmc_packet, hmc_transaction_mon) pkt_import;
|
53 |
|
|
`uvm_analysis_imp_decl(_hmc_rrp)
|
54 |
|
|
uvm_analysis_imp_hmc_rrp #(int, hmc_transaction_mon) rrp_import;
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
uvm_analysis_port #(hmc_packet) transaction_finished_port;
|
59 |
|
|
|
60 |
|
|
`uvm_component_utils_begin(hmc_transaction_mon)
|
61 |
|
|
`uvm_field_enum(uvm_active_passive_enum, enable_tag_checking, UVM_DEFAULT)
|
62 |
|
|
`uvm_component_utils_end
|
63 |
|
|
|
64 |
|
|
function new ( string name="hmc_transaction_mon", uvm_component parent );
|
65 |
|
|
super.new(name, parent);
|
66 |
|
|
|
67 |
|
|
pkt_import = new("pkt_import",this);
|
68 |
|
|
rrp_import = new("rrp_import",this);
|
69 |
|
|
|
70 |
|
|
transaction_finished_port = new("transaction_finished_port", this);
|
71 |
|
|
|
72 |
|
|
next_sequence_num = 3'b1;
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
hmc_buffer = {};
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
endfunction : new
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
function void build_phase(uvm_phase phase);
|
82 |
|
|
super.build_phase(phase);
|
83 |
|
|
|
84 |
|
|
endfunction : build_phase
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
function void write_hmc_pkt(input hmc_packet collected_packet);
|
88 |
|
|
|
89 |
|
|
if (collected_packet.command != HMC_NULL
|
90 |
|
|
&& collected_packet.command != HMC_IRTRY
|
91 |
|
|
&& collected_packet.command != HMC_PRET
|
92 |
|
|
)
|
93 |
|
|
begin
|
94 |
|
|
`uvm_info(get_type_name(), $psprintf("got packet with command %s and frp %d", collected_packet.command.name(),collected_packet.forward_retry_pointer), UVM_HIGH)
|
95 |
|
|
hmc_buffer.push_back(collected_packet);
|
96 |
|
|
end
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
endfunction : write_hmc_pkt
|
101 |
|
|
|
102 |
|
|
function void tag_handling (hmc_packet packet );
|
103 |
|
|
if (packet.get_command_type() == HMC_WRITE_TYPE ||
|
104 |
|
|
packet.get_command_type() == HMC_MISC_WRITE_TYPE ||
|
105 |
|
|
packet.get_command_type() == HMC_MODE_READ_TYPE ||
|
106 |
|
|
packet.get_command_type() == HMC_READ_TYPE)
|
107 |
|
|
begin
|
108 |
|
|
tag_mon.use_tag(packet.tag);
|
109 |
|
|
end
|
110 |
|
|
|
111 |
|
|
if (packet.get_command_type() == HMC_RESPONSE_TYPE &&
|
112 |
|
|
packet.command != HMC_ERROR_RESPONSE &&
|
113 |
|
|
!packet.poisoned)
|
114 |
|
|
begin
|
115 |
|
|
tag_mon.release_tag(packet.tag);
|
116 |
|
|
end
|
117 |
|
|
|
118 |
|
|
endfunction : tag_handling
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
function void write_hmc_rrp(int rrp);
|
122 |
|
|
if (rrp != last_rrp) begin
|
123 |
|
|
hmc_packet current_packet;
|
124 |
|
|
`uvm_info(get_type_name(),$psprintf("searching packet with FRP %d", rrp),UVM_HIGH)
|
125 |
|
|
if (hmc_buffer.size()>0) begin
|
126 |
|
|
do begin
|
127 |
|
|
if (hmc_buffer.size()>0) begin
|
128 |
|
|
current_packet = hmc_buffer.pop_front();
|
129 |
|
|
|
130 |
|
|
if ((current_packet.command != HMC_TRET) ) begin
|
131 |
|
|
`uvm_info(get_type_name(),$psprintf("send packet with command %s and frp %d", current_packet.command.name(),current_packet.forward_retry_pointer), UVM_HIGH)
|
132 |
|
|
if (current_packet.poisoned)
|
133 |
|
|
`uvm_info(get_type_name(), $psprintf("Packet was poisoned"), UVM_NONE)
|
134 |
|
|
else begin
|
135 |
|
|
if(enable_tag_checking == UVM_ACTIVE)
|
136 |
|
|
tag_handling(current_packet);
|
137 |
|
|
transaction_finished_port.write(current_packet);
|
138 |
|
|
end
|
139 |
|
|
end
|
140 |
|
|
end
|
141 |
|
|
else
|
142 |
|
|
`uvm_fatal(get_type_name(),$psprintf("Cant find RRP %d in retry buffer", rrp))
|
143 |
|
|
end while (current_packet.forward_retry_pointer != rrp);
|
144 |
|
|
end else
|
145 |
|
|
`uvm_info(get_type_name(), $psprintf("retry buffer is empty, can not find matching rrp (%0d)", rrp), UVM_HIGH)
|
146 |
|
|
last_rrp = rrp;
|
147 |
|
|
end
|
148 |
|
|
endfunction : write_hmc_rrp
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
function bit idle_check();
|
152 |
|
|
if (enable_tag_checking == UVM_ACTIVE)
|
153 |
|
|
return hmc_buffer.size()==0 && tag_mon.idle_check();
|
154 |
|
|
else
|
155 |
|
|
return hmc_buffer.size()==0;
|
156 |
|
|
endfunction : idle_check
|
157 |
|
|
|
158 |
|
|
function void check_phase(uvm_phase phase);
|
159 |
|
|
hmc_packet pkt;
|
160 |
|
|
|
161 |
|
|
if (hmc_buffer.size() >0) begin
|
162 |
|
|
`uvm_info(get_type_name(),$psprintf("retry buffer is not empty!"),UVM_NONE)
|
163 |
|
|
while(hmc_buffer.size()>0) begin
|
164 |
|
|
pkt = hmc_buffer.pop_front();
|
165 |
|
|
`uvm_info(get_type_name(),$psprintf("Open FRP: %d", pkt.forward_retry_pointer), UVM_NONE)
|
166 |
|
|
end
|
167 |
|
|
//-- print packet
|
168 |
|
|
`uvm_fatal(get_type_name(),$psprintf("retry buffer is not empty!"))
|
169 |
|
|
end
|
170 |
|
|
|
171 |
|
|
endfunction : check_phase
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
endclass : hmc_transaction_mon
|
176 |
|
|
|
177 |
|
|
`endif // hmc_transaction_mon_sv
|