Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / api / pli / src / SS_RegCompare.cc
CommitLineData
920dae64
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: SS_RegCompare.cc
4// Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
5// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
6//
7// The above named program is free software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public
9// License version 2 as published by the Free Software Foundation.
10//
11// The above named program is distributed in the hope that it will be
12// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// General Public License for more details.
15//
16// You should have received a copy of the GNU General Public
17// License along with this work; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19//
20// ========== Copyright Header End ============================================
21
22#include "SS_RegCompare.h"
23
24SS_RegCompare::SS_RegCompare( SS_Strand* _strand, SS_PliSocket* _socket )/*{{{*/
25 :
26 dbg_out(0),
27 socket(_socket),
28 strand(_strand),
29 inited(false)
30{
31 cmpr_on();
32}
33/*}}}*/
34
35void SS_RegCompare::initialise()/*{{{*/
36{
37 // the initialise() should be invoked right before the first sstep of each
38 // strand, so that any change (forced by rtl testbench) before that
39 // is not considered as a change made by the first instruction. One
40 // example is HVER, where testbench may do a ASR_WRITE to set a value
41 // before first sstep.
42
43 uint_t id = strand->strand_id();
44
45 strand->gl_save();
46 strand->cwp_save();
47 strand->tl_save();
48
49 for (int gl = 0; gl <= strand->max_gl(); gl++)
50 for (int gi = 0; gi < 8; gi++)
51 grf[gl * 8 + gi] = strand->grf[gl * 8 + gi];
52
53 for (int wp = 0; wp <= strand->max_wp(); wp++)
54 for (int wi = 0; wi < 16; wi++)
55 if (wi >= 8)
56 wrf[wp * 16 + wi] = strand->wrf[wp * 16 + wi - 8];
57 else if (wp == strand->max_wp())
58 wrf[wp * 16 + wi] = strand->wrf[wi + 8];
59 else
60 wrf[wp * 16 + wi] = strand->wrf[wp * 16 + wi + 24];
61
62 for (int fi =0; fi < 64; fi++)
63 frf[fi] = strand->get_frf(SS_Strand::freg_idx2off(fi));
64
65 inited = true;
66}
67/*}}}*/
68void SS_RegCompare::compare()/*{{{*/
69{
70 char cmp[64];
71 uint_t id = strand->strand_id();
72
73 strand->gl_save();
74 strand->cwp_save();
75 strand->tl_save();
76
77 new_delta = false;
78 for (int gl = 0; gl <= strand->max_gl(); gl++)
79 {
80 for (int gi = 0; gi < 8; gi++)
81 {
82 uint64_t old_val = grf[gl * 8 + gi];
83 uint64_t new_val = strand->grf[gl * 8 + gi];
84
85 if (new_val != old_val)
86 {
87 if (cmpr_list[CTR_G])
88 {
89 new_delta = true;
90 sprintf(cmp,"STEP: %d G %d %d %016llx ",id,gl,gi,new_val);
91 socket->write(cmp);
92 }
93 grf[gl * 8 + gi] = new_val;
94 }
95 }
96 }
97
98 for (int wp = 0; wp <= strand->max_wp(); wp++)
99 {
100 for (int wi = 0; wi < 16; wi++)
101 {
102 uint64_t old_val = wrf[wp * 16 + wi];
103 uint64_t new_val;
104
105 // Compare window: 8=o0,..,o7,16=l0,..,l7
106 // Vonk window is: 0=l0,..,l7,8=i0,..,i7,_______,24=o0,..,o7
107
108 if (wi >= 8)
109 new_val = strand->wrf[wp * 16 + wi - 8];
110 else if (wp == strand->max_wp())
111 new_val = strand->wrf[wi + 8];
112 else
113 new_val = strand->wrf[wp * 16 + wi + 24];
114
115 if (new_val != old_val)
116 {
117 if (cmpr_list[CTR_W])
118 {
119 new_delta = true;
120 sprintf(cmp,"STEP: %d W %d %d %016llx ",id,wp,wi + 8,new_val);
121 socket->write(cmp);
122 }
123 wrf[wp * 16 + wi] = new_val;
124 }
125 }
126 }
127
128 for (int fi =0; fi < 64; fi++)
129 {
130 uint32_t old_val = frf[fi];
131 uint32_t new_val = strand->get_frf(SS_Strand::freg_idx2off(fi));
132
133 if (new_val != old_val)
134 {
135 if (cmpr_list[CTR_F])
136 {
137 new_delta = true;
138 sprintf(cmp,"STEP: %d F %d %08x ",id,fi,new_val);
139 socket->write(cmp);
140 }
141 frf[fi] = new_val;
142 }
143 }
144}
145/*}}}*/
146
147void SS_RegCompare::dump_regs()/*{{{*/
148{
149 uint_t id = strand->strand_id();
150
151 strand->gl_save();
152 strand->cwp_save();
153 strand->tl_save();
154
155 fprintf(stdout, "Strand %d:\n", id);
156 fprintf(stdout, "%2s", "");
157 for (int gl = 0; gl <= strand->max_gl(); gl++)
158 fprintf(stdout, " %5s g[%d] %5s ", "", gl, "");
159 fprintf(stdout, "\n");
160 for (int gi = 0; gi < 8; gi++)
161 {
162 fprintf(stdout, "%d ", gi);
163 for (int gl = 0; gl <= strand->max_gl(); gl++)
164 fprintf(stdout, " %016llx ", strand->grf[gl * 8 + gi]);
165 fprintf(stdout,"\n");
166 }
167
168 for (int wp = 0; wp <= strand->max_wp(); wp++)
169 {
170 fprintf(stdout, " %5s o[%d] %5s %5s l[%d] %5s\n", "", wp, "", "", wp, "");
171 for (int wi = 0; wi < 8; wi++)
172 {
173 uint64_t new_val_o;
174 uint64_t new_val_l;
175
176 // Compare window: 8=o0,..,o7,16=l0,..,l7
177 // Vonk window is: 0=l0,..,l7,8=i0,..,i7,_______,24=o0,..,o7
178
179 if (wp == strand->max_wp())
180 new_val_o = strand->wrf[wi + 8];
181 else
182 new_val_o = strand->wrf[wp * 16 + wi + 24];
183 new_val_l = strand->wrf[wp * 16 + wi];
184 fprintf(stdout, "%d %016llx %016llx \n", wi, new_val_o, new_val_l);
185 }
186 }
187
188 for (int fi = 0; fi < 64; fi+=8)
189 {
190 fprintf(stdout, "%2s", "");
191 for (int i = 0; i < 4; i++)
192 if ((fi+i*2) < 10)
193 fprintf(stdout, " %13s f%1d ", "", (fi+i*2));
194 else
195 fprintf(stdout, " %12s f%2d ", "", (fi+i*2));
196 fprintf(stdout, "\n");
197 fprintf(stdout, "%2s", "");
198 for (int i = 0; i < 8; i+=2)
199 {
200 uint32_t new_val1 = strand->get_frf(SS_Strand::freg_idx2off(fi));
201 uint32_t new_val2 = strand->get_frf(SS_Strand::freg_idx2off(fi+1));
202 fprintf(stdout, " %08x%08x ", new_val1, new_val2);
203 }
204 fprintf(stdout, "\n");
205 }
206}
207/*}}}*/
208
209
210
211
212
213