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 54

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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