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 |
|
|
|
40 |
|
|
//
|
41 |
|
|
//
|
42 |
|
|
// sleep_mode_test sequence
|
43 |
|
|
//
|
44 |
|
|
//
|
45 |
|
|
|
46 |
|
|
`ifndef sleep_mode_test_SEQ_SV
|
47 |
|
|
`define sleep_mode_test_SEQ_SV
|
48 |
|
|
|
49 |
|
|
class sleep_mode_test_seq extends hmc_base_seq;
|
50 |
|
|
|
51 |
|
|
rand int iterations;
|
52 |
|
|
|
53 |
|
|
constraint iterations_c {
|
54 |
|
|
iterations >= 1;
|
55 |
|
|
iterations <= 10;
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
function new(string name="sleep_mode_test_seq");
|
59 |
|
|
super.new(name);
|
60 |
|
|
endfunction : new
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
openhmc_init_seq init;
|
64 |
|
|
hmc_model_init_seq bfm;
|
65 |
|
|
openhmc_check_seq check;
|
66 |
|
|
hmc_base_pkt_seq work;
|
67 |
|
|
|
68 |
|
|
reg_openhmc_rf_status_general_c status;
|
69 |
|
|
reg_openhmc_rf_control_c control;
|
70 |
|
|
reg_openhmc_rf_sent_np_c sent_np;
|
71 |
|
|
reg_openhmc_rf_rcvd_rsp_c rcvd_rsp;
|
72 |
|
|
|
73 |
|
|
`uvm_object_utils(sleep_mode_test_seq)
|
74 |
|
|
`uvm_declare_p_sequencer(vseqr)
|
75 |
|
|
|
76 |
|
|
hmc_2_axi4_sequence #(.DATA_BYTES(`AXI4BYTES), .TUSER_WIDTH(`AXI4BYTES)) requests;
|
77 |
|
|
int timer;
|
78 |
|
|
|
79 |
|
|
task wait_for_idle ();
|
80 |
|
|
timer = 0;
|
81 |
|
|
p_sequencer.rf_seqr_hmc.read_reg(status);
|
82 |
|
|
p_sequencer.rf_seqr_hmc.read_reg(sent_np);
|
83 |
|
|
p_sequencer.rf_seqr_hmc.read_reg(rcvd_rsp);
|
84 |
|
|
p_sequencer.rf_seqr_hmc.read_reg(control);
|
85 |
|
|
#1us;
|
86 |
|
|
|
87 |
|
|
while( ((sent_np.fields.cnt_ != rcvd_rsp.fields.cnt_) ||
|
88 |
|
|
(status.fields.hmc_tokens_remaining_ != p_sequencer.link_cfg.hmc_tokens) ||
|
89 |
|
|
(status.fields.rx_tokens_remaining_ != p_sequencer.link_cfg.rx_tokens))
|
90 |
|
|
&&
|
91 |
|
|
(timer < 200)) begin
|
92 |
|
|
#1us;
|
93 |
|
|
p_sequencer.rf_seqr_hmc.read_reg(status);
|
94 |
|
|
p_sequencer.rf_seqr_hmc.read_reg(sent_np);
|
95 |
|
|
p_sequencer.rf_seqr_hmc.read_reg(rcvd_rsp);
|
96 |
|
|
`uvm_info(get_type_name(),$psprintf("RX token count in TX_LINK = %0d, should be %0d" , status.fields.rx_tokens_remaining_ , p_sequencer.link_cfg.rx_tokens),UVM_LOW)
|
97 |
|
|
`uvm_info(get_type_name(),$psprintf("HMC token count in TX_LINK = %0d, should be %0d", status.fields.hmc_tokens_remaining_, p_sequencer.link_cfg.hmc_tokens),UVM_LOW)
|
98 |
|
|
`uvm_info(get_type_name(),$psprintf("sent = %0d non-posted packets, received %0d responses", sent_np.fields.cnt_, rcvd_rsp.fields.cnt_),UVM_LOW)
|
99 |
|
|
timer++;
|
100 |
|
|
end
|
101 |
|
|
#3us;
|
102 |
|
|
endtask
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
virtual task body();
|
106 |
|
|
time sleep_time = 10us;
|
107 |
|
|
|
108 |
|
|
`uvm_info(get_type_name(), "starting sleep_mode_test_seq", UVM_NONE)
|
109 |
|
|
|
110 |
|
|
//initiate all the registers
|
111 |
|
|
$cast(status,p_sequencer.rf_seqr_hmc.get_by_name("status_general"));
|
112 |
|
|
status.set_check_on_read(1'b0);
|
113 |
|
|
|
114 |
|
|
$cast(control,p_sequencer.rf_seqr_hmc.get_by_name("control"));
|
115 |
|
|
control.set_check_on_read(1'b0);
|
116 |
|
|
|
117 |
|
|
$cast(sent_np,p_sequencer.rf_seqr_hmc.get_by_name("sent_np"));
|
118 |
|
|
sent_np.set_check_on_read(1'b0);
|
119 |
|
|
|
120 |
|
|
$cast(rcvd_rsp,p_sequencer.rf_seqr_hmc.get_by_name("rcvd_rsp"));
|
121 |
|
|
rcvd_rsp.set_check_on_read(1'b0);
|
122 |
|
|
|
123 |
|
|
//-- write your test here
|
124 |
|
|
`uvm_do(bfm)
|
125 |
|
|
|
126 |
|
|
#1us;
|
127 |
|
|
`uvm_do(init)
|
128 |
|
|
#1us;
|
129 |
|
|
|
130 |
|
|
repeat (iterations) begin
|
131 |
|
|
repeat(5) begin
|
132 |
|
|
randcase
|
133 |
|
|
1 : `uvm_do_with(work, {req_class == NON_POSTED;})
|
134 |
|
|
1 : `uvm_do_with(work, {req_class == POSTED;})
|
135 |
|
|
endcase
|
136 |
|
|
end
|
137 |
|
|
//Sleep Mode entry and exit
|
138 |
|
|
`uvm_info(get_type_name(),$psprintf("SLEEP MODE: WAIT FOR IDLE"),UVM_LOW)
|
139 |
|
|
wait_for_idle();
|
140 |
|
|
`uvm_info(get_type_name(),$psprintf("SLEEP MODE: SET"),UVM_LOW)
|
141 |
|
|
//Set the sleep_mode_test bit within the Register File
|
142 |
|
|
control.fields.set_hmc_sleep_ = 1;
|
143 |
|
|
p_sequencer.rf_seqr_hmc.write_reg(control);
|
144 |
|
|
p_sequencer.rf_seqr_hmc.read_reg(status);
|
145 |
|
|
#1us;
|
146 |
|
|
while(!status.fields.sleep_mode_) begin
|
147 |
|
|
p_sequencer.rf_seqr_hmc.read_reg(status);
|
148 |
|
|
end
|
149 |
|
|
//Stay in Sleep for up to 22 us
|
150 |
|
|
sleep_time_rand_succeeds : assert (std::randomize(sleep_time)
|
151 |
|
|
with {sleep_time >= 2us && sleep_time < 22us;}); //-- should be 1ms in real system
|
152 |
|
|
#(sleep_time);
|
153 |
|
|
`uvm_info(get_type_name(),$psprintf("SLEEP MODE: EXIT"),UVM_LOW)
|
154 |
|
|
//Force openHMC controller to exit sleep mode
|
155 |
|
|
control.fields.set_hmc_sleep_ = 0;
|
156 |
|
|
p_sequencer.rf_seqr_hmc.write_reg(control);
|
157 |
|
|
while(!status.fields.link_up_) begin
|
158 |
|
|
p_sequencer.rf_seqr_hmc.read_reg(status);
|
159 |
|
|
end
|
160 |
|
|
end
|
161 |
|
|
|
162 |
|
|
#1us;
|
163 |
|
|
`uvm_info(get_type_name(), "sleep_mode_test_seq done", UVM_NONE)
|
164 |
|
|
`uvm_do(check)
|
165 |
|
|
|
166 |
|
|
endtask : body
|
167 |
|
|
|
168 |
|
|
endclass : sleep_mode_test_seq
|
169 |
|
|
|
170 |
|
|
`endif // sleep_mode_test_SEQ_SV
|