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

Subversion Repositories adv_debug_sys

[/] [adv_debug_sys/] [trunk/] [Software/] [AdvancedWatchpointControl/] [src/] [advancedWatchpointControl/] [guiDCRGroup.java] - Blame information for rev 51

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 51 nyawn
package advancedWatchpointControl;
2
import org.eclipse.swt.SWT;
3
import org.eclipse.swt.graphics.Color;
4
import org.eclipse.swt.graphics.Device;
5
import org.eclipse.swt.graphics.GC;
6
import org.eclipse.swt.graphics.Image;
7
import org.eclipse.swt.layout.GridLayout;
8
import org.eclipse.swt.widgets.Button;
9
import org.eclipse.swt.widgets.Combo;
10
import org.eclipse.swt.widgets.Composite;
11
import org.eclipse.swt.widgets.Group;
12
import org.eclipse.swt.widgets.Label;
13
import org.eclipse.swt.widgets.Text;
14
 
15
 
16
 
17
public class guiDCRGroup implements RegisterObserver {
18
 
19
        public Group dcrRegsGroup = null;
20
        private Group dcrGroup[]  = {null, null, null, null, null, null, null, null};
21
        private Button dcrBPCheckbox[]  = {null, null, null, null, null, null, null, null};
22
        private Label dcrBPcbLabel[]  = {null, null, null, null, null, null, null, null};
23
        // The Spinner only uses a signed int as its max, so we use a Text element instead
24
        private Text dvrValText[]  = {null, null, null, null, null, null, null, null};
25
        private Button dcrSignedCheckBox[]  = {null, null, null, null, null, null, null, null};
26
        private Label dcrSignedCheckboxLabel[]  = {null, null, null, null, null, null, null, null};
27
        private Combo dcrCmpSource[]  = {null, null, null, null, null, null, null, null};
28
        private Combo dcrCmpType[]  = {null, null, null, null, null, null, null, null};
29
        private Combo dcrChainCombo[]  = {null, null, null, null, null, null, null, null};
30
        private Combo dcrCountLinkCombo[]  = {null, null, null, null, null, null, null, null};
31
        private Label dcrBPActiveLabel[]  = {null, null, null, null, null, null, null, null};
32
        private registerInterpreter regSet = null;
33
        private Image activeImage = null;
34
        private Image inactiveImage = null;
35
 
36
        public guiDCRGroup(Composite parent, Device display, mainControl mCtrl) {
37
 
38
                // Wrap the register set with an interpreter that knows the bit meanings
39
                regSet = new registerInterpreter(mCtrl.getRegSet());
40
 
41
                // Register with main control for register set updates
42
                mCtrl.registerForRegsetUpdates(this);
43
 
44
                // Create images for active interrupt indicators
45
                activeImage = new Image (display, 16, 16);
46
                Color color = display.getSystemColor (SWT.COLOR_RED);
47
                GC gc = new GC (activeImage);
48
                gc.setBackground (color);
49
                gc.fillRectangle (activeImage.getBounds ());
50
                gc.dispose ();
51
 
52
                inactiveImage = new Image (display, 16, 16);
53
                color = display.getSystemColor (SWT.COLOR_DARK_GRAY);
54
                gc = new GC (inactiveImage);
55
                gc.setBackground (color);
56
                gc.fillRectangle (inactiveImage.getBounds ());
57
                gc.dispose ();
58
 
59
                // Create Watchpoint GUI elements
60
                dcrRegsGroup = new Group(parent, SWT.NONE);
61
                dcrRegsGroup.setText("Watchpoints");
62
 
63
                GridLayout gridLayout = new GridLayout();
64
                gridLayout.numColumns = 1;
65
                dcrRegsGroup.setLayout(gridLayout);
66
 
67
                for (int i = 7; i >= 0; i--) {
68
                        createDcrGroup(i);
69
                }
70
        }
71
 
72
        private void createDcrGroup(int groupnum) {
73
                GridLayout gridLayout = new GridLayout();
74
                gridLayout.numColumns = 10;
75
                dcrGroup[groupnum] = new Group(dcrRegsGroup, SWT.NONE);
76
                dcrGroup[groupnum].setLayout(gridLayout);
77
                String dcrLabel = "Watchpoint " + groupnum + ": ";
78
                dcrGroup[groupnum].setText(dcrLabel);
79
 
80
                dcrBPActiveLabel[groupnum] = new Label(dcrGroup[groupnum], SWT.NONE);
81
                dcrBPActiveLabel[groupnum].setImage(inactiveImage);
82
                dcrBPCheckbox[groupnum] = new Button(dcrGroup[groupnum], SWT.CHECK);
83
                dcrBPcbLabel[groupnum] = new Label(dcrGroup[groupnum], SWT.NONE);
84
                dcrBPcbLabel[groupnum].setText("Break on");
85
                createDcrCmpSource(groupnum);
86
                createDcrCmpType(groupnum);
87
                dvrValText[groupnum] = new Text(dcrGroup[groupnum], SWT.BORDER);
88
                dvrValText[groupnum].setTextLimit(10);
89
                dcrSignedCheckBox[groupnum] = new Button(dcrGroup[groupnum], SWT.CHECK);
90
                dcrSignedCheckboxLabel[groupnum] = new Label(dcrGroup[groupnum], SWT.NONE);
91
                dcrSignedCheckboxLabel[groupnum].setText("Signed");
92
                createDcrChainCombo(groupnum);
93
                createDcrCountLinkCombo(groupnum);
94
        }
95
 
96
        /**
97
         * This method initializes dcrCmpSource
98
         *
99
         */
100
        private void createDcrCmpSource(int groupnum) {
101
                dcrCmpSource[groupnum] = new Combo(dcrGroup[groupnum], SWT.DROP_DOWN|SWT.READ_ONLY);
102
                dcrCmpSource[groupnum].add("Disabled", 0);
103
                dcrCmpSource[groupnum].add("Instruction Fetch Addr", 1);
104
                dcrCmpSource[groupnum].add("Load Addr", 2);
105
                dcrCmpSource[groupnum].add("Store Addr", 3);
106
                dcrCmpSource[groupnum].add("Load Data Value", 4);
107
                dcrCmpSource[groupnum].add("Store Data Value", 5);
108
                dcrCmpSource[groupnum].add("Load or Store Addr", 6);
109
                dcrCmpSource[groupnum].add("Load or Store Data", 7);
110
                dcrCmpSource[groupnum].select(0);
111
        }
112
 
113
        /**
114
         * This method initializes drcCmpType
115
         *
116
         */
117
        private void createDcrCmpType(int groupnum) {
118
                dcrCmpType[groupnum] = new Combo(dcrGroup[groupnum], SWT.DROP_DOWN|SWT.READ_ONLY);
119
                dcrCmpType[groupnum].add("(disabled)", 0);
120
                dcrCmpType[groupnum].add("==", 1);
121
                dcrCmpType[groupnum].add("<", 2);
122
                dcrCmpType[groupnum].add("<=", 3);
123
                dcrCmpType[groupnum].add(">", 4);
124
                dcrCmpType[groupnum].add(">=", 5);
125
                dcrCmpType[groupnum].add("!=", 6);
126
                dcrCmpType[groupnum].select(0);
127
        }
128
 
129
        private void createDcrChainCombo(int groupnum) {
130
                dcrChainCombo[groupnum] = new Combo(dcrGroup[groupnum], SWT.DROP_DOWN|SWT.READ_ONLY);
131
                dcrChainCombo[groupnum].add("No chain", 0);
132
                String andStr;
133
                if(groupnum == 0) {
134
                        andStr = "AND EXT";
135
                } else {
136
                        andStr = "AND WP" + (groupnum-1);
137
                }
138
                dcrChainCombo[groupnum].add(andStr, 1);
139
                String orStr;
140
                if(groupnum == 0) {
141
                        orStr = "OR EXT";
142
                } else {
143
                        orStr = "OR WP" + (groupnum-1);
144
                }
145
                dcrChainCombo[groupnum].add(orStr, 2);
146
                dcrChainCombo[groupnum].select(0);
147
        }
148
 
149
        private void createDcrCountLinkCombo(int groupnum) {
150
                dcrCountLinkCombo[groupnum] = new Combo(dcrGroup[groupnum], SWT.DROP_DOWN|SWT.READ_ONLY);
151
                dcrCountLinkCombo[groupnum].add("counter 0", 0);
152
                dcrCountLinkCombo[groupnum].add("counter 1", 1);
153
                dcrCountLinkCombo[groupnum].select(0);
154
        }
155
 
156
 
157
        public void notifyRegisterUpdate(updateDirection dir) throws NumberFormatException {
158
 
159
                if(dir == RegisterObserver.updateDirection.REGS_TO_GUI) {
160
                        // We do this in descending order so that absent DCR/DVR pairs can
161
                        // correctly disable the chain on the previous 
162
                        for(int i = 7; i >= 0; i--) {
163
                                // Go left-to-right, updating UI elements
164
 
165
                                // If this DCR/DVR isn't implemented, disable all controls for this WP
166
                                if(!regSet.isWPImplemented(i)) {  // disable everything
167
                                        dcrBPActiveLabel[i].setImage(inactiveImage);
168
                                        dcrBPcbLabel[i].setText("Not Implemented");
169
                                        // TODO *** Resize so the entire "Not Implemented" text is visible
170
                                        dcrBPCheckbox[i].setVisible(false);
171
                                        dcrCmpSource[i].setVisible(false);
172
                                        dcrCmpType[i].setVisible(false);
173
                                        dvrValText[i].setVisible(false);
174
                                        dcrSignedCheckBox[i].setVisible(false);
175
                                        dcrChainCombo[i].setVisible(false);
176
                                        if(i < 7) {                     // Disable the next chain type too
177
                                                dcrChainCombo[i+1].setVisible(false);
178
                                        }
179
                                        dcrCountLinkCombo[i].setVisible(false);
180
                                        dcrSignedCheckboxLabel[i].setVisible(false);
181
                                        continue;
182
                                } else {  // enable everything
183
                                        dcrBPcbLabel[i].setText("Break on");
184
                                        dcrBPCheckbox[i].setVisible(true);
185
                                        dcrCmpSource[i].setVisible(true);
186
                                        dcrCmpType[i].setVisible(true);
187
                                        dvrValText[i].setVisible(true);
188
                                        dcrSignedCheckBox[i].setVisible(true);
189
                                        dcrChainCombo[i].setVisible(true);
190
                                        dcrCountLinkCombo[i].setVisible(true);
191
                                        dcrSignedCheckboxLabel[i].setVisible(true);
192
                                }
193
 
194
 
195
                                // 'caused break' indicator
196
                                if(regSet.didWPCauseBreak(i)) {
197
                                        dcrBPActiveLabel[i].setImage(activeImage);
198
                                } else {
199
                                        dcrBPActiveLabel[i].setImage(inactiveImage);
200
                                }
201
 
202
                                // 'break enabled' indicator
203
                                if(regSet.getWPBreakEnabled(i)) {
204
                                        dcrBPCheckbox[i].setSelection(true);
205
                                } else {
206
                                        dcrBPCheckbox[i].setSelection(false);
207
                                }
208
 
209
                                // compare source
210
                                switch(regSet.getWPCompareSource(i)) {
211
                                case DISABLED:
212
                                        dcrCmpSource[i].select(0);
213
                                        break;
214
                                case INSTR_FETCH_ADDR:
215
                                        dcrCmpSource[i].select(1);
216
                                        break;
217
                                case LOAD_ADDR:
218
                                        dcrCmpSource[i].select(2);
219
                                        break;
220
                                case STORE_ADDR:
221
                                        dcrCmpSource[i].select(3);
222
                                        break;
223
                                case LOAD_DATA:
224
                                        dcrCmpSource[i].select(4);
225
                                        break;
226
                                case STORE_DATA:
227
                                        dcrCmpSource[i].select(5);
228
                                        break;
229
                                case LOAD_STORE_ADDR:
230
                                        dcrCmpSource[i].select(6);
231
                                        break;
232
                                case LOAD_STORE_DATA:
233
                                        dcrCmpSource[i].select(7);
234
                                        break;
235
                                }
236
 
237
                                // compare type
238
                                switch(regSet.getWPCompareType(i)) {
239
                                case MASKED:
240
                                        dcrCmpType[i].select(0);
241
                                        break;
242
                                case EQ:
243
                                        dcrCmpType[i].select(1);
244
                                        break;
245
                                case LT:
246
                                        dcrCmpType[i].select(2);
247
                                        break;
248
                                case LE:
249
                                        dcrCmpType[i].select(3);
250
                                        break;
251
                                case GT:
252
                                        dcrCmpType[i].select(4);
253
                                        break;
254
                                case GE:
255
                                        dcrCmpType[i].select(5);
256
                                        break;
257
                                case NE:
258
                                        dcrCmpType[i].select(6);
259
                                        break;
260
                                }
261
 
262
                                // compare value
263
                                dvrValText[i].setText("0x" + Long.toHexString(regSet.getDVR(i)));
264
 
265
                                // signed indicator
266
                                if(regSet.getWPSignedCompare(i)) {
267
                                        dcrSignedCheckBox[i].setSelection(true);
268
                                } else {
269
                                        dcrSignedCheckBox[i].setSelection(false);
270
                                }
271
 
272
                                // chain type
273
                                switch(regSet.getWPChainType(i)) {
274
                                case NONE:
275
                                        dcrChainCombo[i].select(0);
276
                                        break;
277
                                case AND:
278
                                        dcrChainCombo[i].select(1);
279
                                        break;
280
                                case OR:
281
                                        dcrChainCombo[i].select(2);
282
                                        break;
283
                                }
284
 
285
                                // counter assignment
286
                                if(regSet.getWPCounterAssign(i) == 0) {
287
                                        dcrCountLinkCombo[i].select(0);
288
                                } else {
289
                                        dcrCountLinkCombo[i].select(1);
290
                                }
291
                        }  // for each DCR
292
                }
293
                else {  // dir == GUI_TO_REGS
294
 
295
                        for(int i = 0; i < 8; i++) {
296
 
297
                                // Don't bother to set values for un-implemented DVR/DCR pairs.
298
                                if(!regSet.isWPImplemented(i)) {
299
                                        continue;
300
                                }
301
 
302
                                // Go left-to-right, putting value into the regSet
303
                                // Break enabled
304
                                regSet.setWPBreakEnabled(i, dcrBPCheckbox[i].getSelection());
305
 
306
                                // Compare Source
307
                                switch(dcrCmpSource[i].getSelectionIndex()) {
308
                                case 0:
309
                                        regSet.setWPCompareSource(i, registerInterpreter.compareSource.DISABLED);
310
                                        break;
311
                                case 1:
312
                                        regSet.setWPCompareSource(i, registerInterpreter.compareSource.INSTR_FETCH_ADDR);
313
                                        break;
314
                                case 2:
315
                                        regSet.setWPCompareSource(i, registerInterpreter.compareSource.LOAD_ADDR);
316
                                        break;
317
                                case  3:
318
                                        regSet.setWPCompareSource(i, registerInterpreter.compareSource.STORE_ADDR);
319
                                        break;
320
                                case  4:
321
                                        regSet.setWPCompareSource(i, registerInterpreter.compareSource.LOAD_DATA);
322
                                        break;
323
                                case  5:
324
                                        regSet.setWPCompareSource(i, registerInterpreter.compareSource.STORE_DATA);
325
                                        break;
326
                                case  6:
327
                                        regSet.setWPCompareSource(i, registerInterpreter.compareSource.LOAD_STORE_ADDR);
328
                                        break;
329
                                case  7:
330
                                        regSet.setWPCompareSource(i, registerInterpreter.compareSource.LOAD_STORE_DATA);
331
                                        break;
332
                                }
333
 
334
                                // Compare Type
335
                                switch(dcrCmpType[i].getSelectionIndex()) {
336
                                case 0:
337
                                        regSet.setWPCompareType(i, registerInterpreter.compareType.MASKED);
338
                                        break;
339
                                case 1:
340
                                        regSet.setWPCompareType(i, registerInterpreter.compareType.EQ);
341
                                        break;
342
                                case 2:
343
                                        regSet.setWPCompareType(i, registerInterpreter.compareType.LT);
344
                                        break;
345
                                case  3:
346
                                        regSet.setWPCompareType(i, registerInterpreter.compareType.LE);
347
                                        break;
348
                                case  4:
349
                                        regSet.setWPCompareType(i, registerInterpreter.compareType.GT);
350
                                        break;
351
                                case  5:
352
                                        regSet.setWPCompareType(i, registerInterpreter.compareType.GE);
353
                                        break;
354
                                case  6:
355
                                        regSet.setWPCompareType(i, registerInterpreter.compareType.NE);
356
                                        break;
357
                                }
358
 
359
                                // Compare Value
360
                                //try {
361
                                        long cval;
362
                                        String str = dvrValText[i].getText();
363
                                        if(str.startsWith("0x") || str.startsWith("0X")) {
364
                                                cval = Long.parseLong(str.substring(2), 16);  // substr(2) skips the "0x"
365
                                        }
366
                                        else {
367
                                                cval = Long.parseLong(str);
368
                                        }
369
 
370
                                        regSet.setDVR(i, cval);
371
 
372
                                //} catch(NumberFormatException e) {
373
                                //      return false;
374
                                //}
375
 
376
 
377
                                // Signed indicator
378
                                regSet.setWPSignedCompare(i, dcrSignedCheckBox[i].getSelection());
379
 
380
                                // Chain type
381
                                switch(dcrChainCombo[i].getSelectionIndex()) {
382
                                case 0:
383
                                        regSet.setWPChainType(i, registerInterpreter.chainType.NONE);
384
                                        break;
385
                                case 1:
386
                                        regSet.setWPChainType(i, registerInterpreter.chainType.AND);
387
                                        break;
388
                                case 2:
389
                                        regSet.setWPChainType(i, registerInterpreter.chainType.OR);
390
                                        break;
391
                                }
392
 
393
                                // Counter assignment
394
                                if(dcrCountLinkCombo[i].getSelectionIndex() == 0) {
395
                                        regSet.setWPCounterAssign(i, 0);
396
                                } else {
397
                                        regSet.setWPCounterAssign(i, 1);
398
                                }
399
                        }
400
                }  // else dir == GUI_TO_REGS
401
        }  // notifyRegisterUpdate()
402
 
403
}

powered by: WebSVN 2.1.0

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