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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 54 nyawn
////////////////////////////////////////////////////////////////
2
//
3
// WriteRegisterTransaction.java
4
//
5
// Copyright (C) 2010 Nathan Yawn 
6
//                    (nyawn@opencores.org)
7
//
8
// This class defines a transaction object which is passed to
9
// the RSP coder in order to perform a register write 
10
// transaction.
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
 
37 51 nyawn
package advancedWatchpointControl;
38
 
39
 
40
public class WriteRegisterTransaction implements TargetTransaction {
41
 
42
                private String packetString = null;
43
 
44
        public WriteRegisterTransaction(targetDebugRegisterSet.regType reg, long val) {
45
                packetString = new String("P"); // 'P' is write one register
46
                int regAddr = targetDebugRegisterSet.getRegisterAddress(reg);
47
 
48
                packetString += Integer.toHexString(regAddr);
49
                packetString += "=";
50
 
51
                String valueStr = Long.toHexString(val);
52
 
53
                // There must be 8 bytes of 'value'
54
                if(valueStr.length() > 8) {
55
                        // Use the last 8 bytes, the first 8 may just be a sign extension
56
                        valueStr = valueStr.substring(valueStr.length() - 8, valueStr.length());
57
                }
58
 
59
                int padsize = 8 - valueStr.length();
60
                for(int i = 0; i < padsize; i++) {
61
                        packetString += '0';
62
                }
63
 
64
                packetString += valueStr;
65
        }
66
 
67
        @Override
68
        public String getDataToSend() {
69
                return packetString;
70
        }
71
 
72
        @Override
73
        public boolean receivePacket(String pkt) {
74
 
75
                // Only one valid response from a register write: "OK"
76
                if(pkt.charAt(0) == 'O' && pkt.charAt(1) == 'K') {
77
                        return true;
78
                }
79
 
80
                return false;
81
        }
82
 
83
}

powered by: WebSVN 2.1.0

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