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/] [guiCountRegsGroup.java] - Blame information for rev 54

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 54 nyawn
////////////////////////////////////////////////////////////////
2
//
3
// guiCountRegsGroup.java
4
//
5
// Copyright (C) 2010 Nathan Yawn 
6
//                    (nyawn@opencores.org)
7
//
8
// This class holds the GUI elements related to the hardware
9
// counters in the watchpoint unit.
10
//
11
////////////////////////////////////////////////////////////////
12
//
13
// This source file may be used and distributed without
14
// restriction provided that this copyright statement is not
15
// removed from the file and that any derivative work contains
16
// the original copyright notice and the associated disclaimer.
17
// 
18
// This source file is free software; you can redistribute it
19
// and/or modify it under the terms of the GNU General
20
// Public License as published by the Free Software Foundation;
21
// either version 3.0 of the License, or (at your option) any
22
// later version.
23
//
24
// This source is distributed in the hope that it will be
25
// useful, but WITHOUT ANY WARRANTY; without even the implied 
26
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
27
// PURPOSE.  See the GNU Lesser General Public License for more
28
// details.
29
// 
30
// You should have received a copy of the GNU General
31
// Public License along with this source; if not, download it 
32
// from http://www.gnu.org/licenses/gpl.html
33
//
34
////////////////////////////////////////////////////////////////
35 51 nyawn
package advancedWatchpointControl;
36 54 nyawn
 
37 51 nyawn
import org.eclipse.swt.SWT;
38
import org.eclipse.swt.graphics.Color;
39
import org.eclipse.swt.graphics.Device;
40
import org.eclipse.swt.graphics.GC;
41
import org.eclipse.swt.graphics.Image;
42
import org.eclipse.swt.layout.GridData;
43
import org.eclipse.swt.layout.GridLayout;
44
import org.eclipse.swt.widgets.Button;
45
import org.eclipse.swt.widgets.Composite;
46
import org.eclipse.swt.widgets.Group;
47
import org.eclipse.swt.widgets.Label;
48
import org.eclipse.swt.widgets.Spinner;
49
import org.eclipse.swt.widgets.Combo;
50
 
51
 
52
public class guiCountRegsGroup implements RegisterObserver {
53
 
54
        private Combo count1ChainCombo;
55
        private Group countRegGroup = null;
56
        private Group count1Composite;
57
        private Button count1EnableCheckBox;
58
        private Label count1EnableLabel;
59
        private Button count1BPCheckBox;
60
        private Label count1EnableBPLabel;
61
        private Group count2Composite;
62
        private Button count2EnableCheckBox;
63
        private Label count2EnableLabel;
64
        private Button count2BPCheckBox;
65
        private Label count2EnableBPLabel;
66
        private Spinner matchValueEnteredSpinner;
67
        private Group matchValueActualGroup;
68
        private Spinner matchValueActualSpinner;
69
        private Combo count2ChainCombo;
70
        private Group matchValueEnteredGroup2;
71
        private Spinner matchValueEnteredSpinner2;
72
        private Group matchValueActualGroup2;
73
        private Spinner match2ValueActualSpinner;
74
        private registerInterpreter regSet = null;
75
        private Image activeImage = null;
76
        private Image inactiveImage = null;
77
        private Label count1BPActiveLabel = null;
78
        private Label count2BPActiveLabel = null;
79
        private Combo ctrCountLinkCombo[]  = {null, null};
80
 
81
        public guiCountRegsGroup(Composite parent, Device display, mainControl mCtrl) {
82
 
83
                // Create images for active interrupt indicators
84
                activeImage = new Image (display, 16, 16);
85
                Color color = display.getSystemColor (SWT.COLOR_RED);
86
                GC gc = new GC (activeImage);
87
                gc.setBackground (color);
88
                gc.fillRectangle (activeImage.getBounds ());
89
                gc.dispose ();
90
 
91
                inactiveImage = new Image (display, 16, 16);
92
                color = display.getSystemColor (SWT.COLOR_DARK_GRAY);
93
                gc = new GC (inactiveImage);
94
                gc.setBackground (color);
95
                gc.fillRectangle (inactiveImage.getBounds ());
96
                gc.dispose ();
97
 
98
                // Create the Count registers GUI elements
99
                countRegGroup = new Group(parent, SWT.NONE);
100
                countRegGroup.setLayout(new GridLayout());
101
                createCount1Composite();
102
                createCount2Composite();
103
                countRegGroup.setText("Counters");
104
 
105
                // Register with main control for register set updates
106
                mCtrl.registerForRegsetUpdates(this);
107
 
108
                // Wrap the register set with an interpreter that knows the bit meanings
109
                regSet = new registerInterpreter(mCtrl.getRegSet());
110
        }
111
 
112
        private void createCount1Composite() {
113
                GridData gridData4 = new GridData();
114
                gridData4.horizontalAlignment = SWT.FILL;
115
                gridData4.grabExcessHorizontalSpace = true;
116
 
117
                GridLayout gridLayout1 = new GridLayout();
118
                gridLayout1.numColumns = 7;
119
                count1Composite = new Group(countRegGroup, SWT.NONE);
120
                count1Composite.setText("Count 0");
121
 
122
                count1BPActiveLabel = new Label(count1Composite, SWT.NONE);
123
                count1BPActiveLabel.setImage(inactiveImage);
124
                GridData gd = new GridData();
125
                gd.verticalSpan = 2;
126
                count1BPActiveLabel.setLayoutData(gd);
127
 
128
                count1EnableCheckBox = new Button(count1Composite, SWT.CHECK);
129
                count1EnableLabel = new Label(count1Composite, SWT.NONE);
130
                count1EnableLabel.setText("Enable");
131
 
132
                createMatchValue1EnteredGroup();
133
                createMatchValue1ActualGroup();
134
                createCount1ChainCombo();
135
                createCtr1CountLinkCombo();
136
 
137
                count1BPCheckBox = new Button(count1Composite, SWT.CHECK);
138
                count1EnableBPLabel = new Label(count1Composite, SWT.NONE);
139
                count1EnableBPLabel.setText("Break on Match");
140
                count1Composite.setLayout(gridLayout1);
141
                count1Composite.setLayoutData(gridData4);
142
        }
143
 
144
        private void createCount2Composite() {
145
                GridData gridData5 = new GridData();
146
                gridData5.horizontalAlignment = SWT.FILL;
147
                gridData5.grabExcessHorizontalSpace = true;
148
 
149
                GridLayout gridLayout1 = new GridLayout();
150
                gridLayout1.numColumns = 7;
151
                count2Composite = new Group(countRegGroup, SWT.NONE);
152
                count2Composite.setText("Count 1");
153
 
154
                count2BPActiveLabel = new Label(count2Composite, SWT.NONE);
155
                count2BPActiveLabel.setImage(inactiveImage);
156
                GridData gd = new GridData();
157
                gd.verticalSpan = 2;
158
                count2BPActiveLabel.setLayoutData(gd);
159
 
160
                count2EnableCheckBox = new Button(count2Composite, SWT.CHECK);
161
                count2EnableLabel = new Label(count2Composite, SWT.NONE);
162
                count2EnableLabel.setText("Enable");
163
 
164
                createMatchValue2EnteredGroup();
165
                createMatchValue2ActualGroup();
166
                createCount2ChainCombo();
167
                createCtr2CountLinkCombo();
168
 
169
                count2BPCheckBox = new Button(count2Composite, SWT.CHECK);
170
                count2EnableBPLabel = new Label(count2Composite, SWT.NONE);
171
                count2EnableBPLabel.setText("Break on Match");
172
                count2Composite.setLayout(gridLayout1);
173
                count2Composite.setLayoutData(gridData5);
174
        }
175
 
176
        private void createMatchValue1EnteredGroup() {
177
                GridData gridData = new GridData();
178
                gridData.verticalSpan = 2;
179
                gridData.verticalAlignment = GridData.CENTER;
180
                gridData.horizontalAlignment = GridData.CENTER;
181
                Group matchValueEnteredGroup = new Group(count1Composite, SWT.NONE);
182
                matchValueEnteredGroup.setLayout(new GridLayout());
183
                matchValueEnteredGroup.setLayoutData(gridData);
184
                matchValueEnteredGroup.setText("Match Value");
185
                matchValueEnteredSpinner = new Spinner(matchValueEnteredGroup, SWT.BORDER);
186
                matchValueEnteredSpinner.setValues(0, 0, 0xFFFF, 0, 1, 100);
187
        }
188
 
189
        /**
190
         * This method initializes matchValue1ActualGroup
191
         *
192
         */
193
        private void createMatchValue1ActualGroup() {
194
                GridData gridData2 = new GridData();
195
                gridData2.horizontalAlignment = GridData.CENTER;
196
                gridData2.verticalAlignment = GridData.CENTER;
197
                GridData gridData1 = new GridData();
198
                gridData1.verticalSpan = 2;
199
                matchValueActualGroup = new Group(count1Composite, SWT.NONE);
200
                matchValueActualGroup.setLayout(new GridLayout());
201
                matchValueActualGroup.setLayoutData(gridData1);
202
                matchValueActualGroup.setText("Current Count Value");
203
                matchValueActualSpinner = new Spinner(matchValueActualGroup, SWT.NONE);
204
                matchValueActualSpinner.setValues(0, 0, 0xFFFF, 0, 1, 100);
205
                matchValueActualSpinner.setLayoutData(gridData2);
206
        }
207
 
208
        private void createCount1ChainCombo() {
209
                GridData gridData = new GridData();
210
                gridData.verticalSpan = 2;
211
                count1ChainCombo = new Combo(count1Composite, SWT.DROP_DOWN|SWT.READ_ONLY);
212
                count1ChainCombo.setLayoutData(gridData);
213
                count1ChainCombo.add("No chain", 0);
214
                count1ChainCombo.add("AND WP3", 1);
215
                count1ChainCombo.add("OR WP3", 2);
216
                count1ChainCombo.select(0);
217
        }
218
 
219
        private void createMatchValue2EnteredGroup() {
220
                GridData gridData = new GridData();
221
                gridData.verticalSpan = 2;
222
                gridData.verticalAlignment = GridData.CENTER;
223
                gridData.horizontalAlignment = GridData.CENTER;
224
                matchValueEnteredGroup2 = new Group(count2Composite, SWT.NONE);
225
                matchValueEnteredGroup2.setLayout(new GridLayout());
226
                matchValueEnteredGroup2.setLayoutData(gridData);
227
                matchValueEnteredGroup2.setText("Match Value");
228
                matchValueEnteredSpinner2 = new Spinner(matchValueEnteredGroup2, SWT.BORDER);
229
                matchValueEnteredSpinner2.setValues(0, 0, 0xFFFF, 0, 1, 100);
230
        }
231
 
232
        private void createMatchValue2ActualGroup() {
233
                GridData gridData2 = new GridData();
234
                gridData2.horizontalAlignment = GridData.CENTER;
235
                gridData2.verticalSpan = 2;
236
                gridData2.verticalAlignment = GridData.CENTER;
237
                GridData gridData1 = new GridData();
238
                gridData1.verticalSpan = 2;
239
                matchValueActualGroup2 = new Group(count2Composite, SWT.NONE);
240
                matchValueActualGroup2.setLayout(new GridLayout());
241
                matchValueActualGroup2.setLayoutData(gridData2);
242
                matchValueActualGroup2.setText("Current Count Value");
243
                match2ValueActualSpinner = new Spinner(matchValueActualGroup2, SWT.NONE);
244
                match2ValueActualSpinner.setValues(0, 0, 0xFFFF, 0, 1, 100);
245
        }
246
 
247
        private void createCount2ChainCombo() {
248
                GridData gridData = new GridData();
249
                gridData.verticalSpan = 2;
250
                count2ChainCombo = new Combo(count2Composite, SWT.DROP_DOWN|SWT.READ_ONLY);
251
                count2ChainCombo.setLayoutData(gridData);
252
                count2ChainCombo.add("No chain", 0);
253
                count2ChainCombo.add("AND WP7", 1);
254
                count2ChainCombo.add("OR WP7", 2);
255
                count2ChainCombo.select(0);
256
        }
257
 
258
        private void createCtr1CountLinkCombo() {
259
                GridData gridData = new GridData();
260
                gridData.verticalSpan = 2;
261
                ctrCountLinkCombo[0] = new Combo(count1Composite, SWT.DROP_DOWN|SWT.READ_ONLY);
262
                ctrCountLinkCombo[0].setLayoutData(gridData);
263
                ctrCountLinkCombo[0].add("counter 0", 0);
264
                ctrCountLinkCombo[0].add("counter 1", 1);
265
                ctrCountLinkCombo[0].select(0);
266
        }
267
 
268
        private void createCtr2CountLinkCombo() {
269
                GridData gridData = new GridData();
270
                gridData.verticalSpan = 2;
271
                ctrCountLinkCombo[1] = new Combo(count2Composite, SWT.DROP_DOWN|SWT.READ_ONLY);
272
                ctrCountLinkCombo[1].setLayoutData(gridData);
273
                ctrCountLinkCombo[1].add("counter 0", 0);
274
                ctrCountLinkCombo[1].add("counter 1", 1);
275
                ctrCountLinkCombo[1].select(0);
276
        }
277
 
278
        public void notifyRegisterUpdate(updateDirection dir) throws NumberFormatException {
279
 
280
                if(dir == RegisterObserver.updateDirection.REGS_TO_GUI) {
281
                        // Set GUI elements based on values in regSet
282
                        // Counter 0  -- go left-to-right
283
                        // 'caused break' indicator
284
                        if(regSet.didCounterCauseBreak(0)) {
285
                                count1BPActiveLabel.setImage(activeImage);
286
                        } else {
287
                                count1BPActiveLabel.setImage(inactiveImage);
288
                        }
289
 
290
                        // 'enabled' checkbox
291
                        if(regSet.getCounterEnabled(0)) {
292
                                count1EnableCheckBox.setSelection(true);
293
                        } else {
294
                                count1EnableCheckBox.setSelection(false);
295
                        }
296
 
297
                        // 'break on match' checkbox
298
                        if(regSet.getCounterBreakEnabled(0)) {
299
                                count1BPCheckBox.setSelection(true);
300
                        } else {
301
                                count1BPCheckBox.setSelection(false);
302
                        }
303
 
304
                        // Match value
305
                        matchValueEnteredSpinner.setSelection(regSet.getCounterWatchValue(0));
306
 
307
                        // Count value
308
                        matchValueActualSpinner.setSelection(regSet.getCounterCountValue(0));
309
 
310
                        // Chain type
311
                        switch(regSet.getCounterChainType(0)) {
312
                        case NONE:
313
                                count1ChainCombo.select(0);
314
                                break;
315
                        case AND:
316
                                count1ChainCombo.select(1);
317
                                break;
318
                        case OR:
319
                                count1ChainCombo.select(2);
320
                                break;
321
                        }
322
 
323
                        // counter assignment
324
                        if(regSet.getWPCounterAssign(8) == 0) {
325
                                ctrCountLinkCombo[0].select(0);
326
                        } else {
327
                                ctrCountLinkCombo[0].select(1);
328
                        }
329
 
330
                        // Counter 1
331
                        // 'caused break' indicator
332
                        if(regSet.didCounterCauseBreak(1)) {
333
                                count2BPActiveLabel.setImage(activeImage);
334
                        } else {
335
                                count2BPActiveLabel.setImage(inactiveImage);
336
                        }
337
 
338
                        // 'enabled' checkbox
339
                        if(regSet.getCounterEnabled(1)) {
340
                                count2EnableCheckBox.setSelection(true);
341
                        } else {
342
                                count2EnableCheckBox.setSelection(false);
343
                        }
344
 
345
                        // 'break on match' checkbox
346
                        if(regSet.getCounterBreakEnabled(1)) {
347
                                count2BPCheckBox.setSelection(true);
348
                        } else {
349
                                count2BPCheckBox.setSelection(false);
350
                        }
351
 
352
                        // Match value
353
                        matchValueEnteredSpinner2.setSelection(regSet.getCounterWatchValue(1));
354
 
355
                        // Count value
356
                        match2ValueActualSpinner.setSelection(regSet.getCounterCountValue(1));
357
 
358
                        // Chain type
359
                        switch(regSet.getCounterChainType(1)) {
360
                        case NONE:
361
                                count2ChainCombo.select(0);
362
                                break;
363
                        case AND:
364
                                count2ChainCombo.select(1);
365
                                break;
366
                        case OR:
367
                                count2ChainCombo.select(2);
368
                                break;
369
                        }
370
 
371
                        // counter assignment
372
                        if(regSet.getWPCounterAssign(9) == 0) {
373
                                ctrCountLinkCombo[1].select(0);
374
                        } else {
375
                                ctrCountLinkCombo[1].select(1);
376
                        }
377
                }
378
                else { // direction = GUI_TO_REGS
379
                        // Set values in regSet based on GUI elements
380
                        // Counter 0  -- go left-to-right
381
                        // 'enabled' checkbox
382
                        regSet.setCounterEnabled(0, count1EnableCheckBox.getSelection());
383
 
384
                        // 'break on match' checkbox
385
                        regSet.setCounterBreakEnabled(0, count1BPCheckBox.getSelection());
386
 
387
                        // Match value
388
                        regSet.setCounterWatchValue(0, matchValueEnteredSpinner.getSelection());
389
 
390
                        // Count value
391
                        regSet.setCounterCountValue(0, matchValueActualSpinner.getSelection());
392
 
393
                        // Chain type
394
                        switch(count1ChainCombo.getSelectionIndex()) {
395
                        case 0:
396
                                regSet.setCounterChainType(0, registerInterpreter.chainType.NONE);
397
                                break;
398
                        case 1:
399
                                regSet.setCounterChainType(0, registerInterpreter.chainType.AND);
400
                                break;
401
                        case 2:
402
                                regSet.setCounterChainType(0, registerInterpreter.chainType.OR);
403
                                break;
404
                        }
405
 
406
                        // Counter assignment
407
                        if(ctrCountLinkCombo[0].getSelectionIndex() == 0) {
408
                                regSet.setWPCounterAssign(8, 0);
409
                        } else {
410
                                regSet.setWPCounterAssign(8, 1);
411
                        }
412
 
413
                        // Counter 1
414
                        // 'enabled' checkbox
415
                        regSet.setCounterEnabled(1, count2EnableCheckBox.getSelection());
416
 
417
                        // 'break on match' checkbox
418
                        regSet.setCounterBreakEnabled(1, count2BPCheckBox.getSelection());
419
 
420
                        // Match value
421
                        regSet.setCounterWatchValue(1, matchValueEnteredSpinner2.getSelection());
422
 
423
                        // Count value
424
                        regSet.setCounterCountValue(1, match2ValueActualSpinner.getSelection());
425
 
426
                        // Chain type
427
                        switch(count2ChainCombo.getSelectionIndex()) {
428
                        case 0:
429
                                regSet.setCounterChainType(1, registerInterpreter.chainType.NONE);
430
                                break;
431
                        case 1:
432
                                regSet.setCounterChainType(1, registerInterpreter.chainType.AND);
433
                                break;
434
                        case 2:
435
                                regSet.setCounterChainType(1, registerInterpreter.chainType.OR);
436
                                break;
437
                        }
438
 
439
                        // Counter assignment
440
                        if(ctrCountLinkCombo[1].getSelectionIndex() == 0) {
441
                                regSet.setWPCounterAssign(9, 0);
442
                        } else {
443
                                regSet.setWPCounterAssign(9, 1);
444
                        }
445
                }  // else dir == GUI_TO_REGS
446
        }  // notifyRegisterUpdate()
447
 
448
}

powered by: WebSVN 2.1.0

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