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

powered by: WebSVN 2.1.0

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