~ubuntu-branches/ubuntu/maverick/electric/maverick

« back to all changes in this revision

Viewing changes to com/sun/electric/tool/simulation/test/Signalyzer.java

  • Committer: Bazaar Package Importer
  • Author(s): Onkar Shinde
  • Date: 2010-01-09 16:26:04 UTC
  • mfrom: (1.1.4 upstream) (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100109162604-1ypvmy8ijmlc6oq7
Tags: 8.10-1
* New upstream version.
* debian/control
  - Add libjava3d-java and quilt build dependencies.
  - Update standards version to 3.8.3.
  - Add libjava3d-java as recommends to binary package.
* debian/rules
  - Use quilt patch system instead of simple patchsys.
  - Add java3d related jar files to DEB_JARS.
* debian/patches/*
  - Update as per current upstream source. Convert to quilt.
* debian/ant.properties
  - Do not disable 3D plugin anymore.
  - Use new property to disable compilation of OS X related classes.
* debian/wrappers/electric
  - Add java3d related jar files to runtime classpath.
* debian/README.source
  - Change text to the appropriate one for quilt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package com.sun.electric.tool.simulation.test;
 
2
 
 
3
/**
 
4
 * Driver for the Signalyzer tool, via urjtag (must be installed).
 
5
 *
 
6
 *   http://microcontrollershop.com/product_info.php?products_id=1754
 
7
 *
 
8
 * NOTE THAT THE SIGNALYZER "LITE" DOES NOT HAVE THE SAME PINOUT AS
 
9
 * THE DUAL-CHANNEL SIGNALYZER!!
 
10
 *
 
11
 * The "Lite" version uses the "ARM Standard JTag 20 Pin Connector",
 
12
 * which happens to be the same pinout as on the WHITE Corolis boxes
 
13
 * plus a REQUIRED Vref pin:
 
14
 *
 
15
 *    VREF    1 2  n.c
 
16
 *    TRST_N  3 4  GND
 
17
 *    TDI     5 6  GND
 
18
 *    TMS     7 8  GND
 
19
 *    TCK     9 10 GND
 
20
 *    n.c.   11 12 GND
 
21
 *    TDO    13 14 GND
 
22
 *    SRST_N 15 16 GND
 
23
 *    n.c.   17 18 GND
 
24
 *    n.c.   19 20 GND
 
25
 * 
 
26
 * This is almost exactly the [Corelis] "White Box" connector.  The
 
27
 * only Differences are that pin 1 is VREF instead of "reserved" and
 
28
 * "master clear" is on pin 15 rather than 17.  You must connect VREF.
 
29
 * 
 
30
 * @author Adam Megacz (megacz)
 
31
 * @version 1.0 29.Oct.2009 
 
32
 *
 
33
 * Copyright (c) 2009 by Nuts, Deez.
 
34
 */
 
35
import java.io.*;
 
36
import java.util.*;
 
37
 
 
38
public class Signalyzer extends NetscanGeneric /* even though it's not a NetScan */ {
 
39
 
 
40
    private ExecProcess urjtag;
 
41
    private BufferedReader br;
 
42
    private HashSet<String> defined = new HashSet<String>();
 
43
    private static boolean DEBUG = false;
 
44
 
 
45
    public Signalyzer() { this(8); }
 
46
    public Signalyzer(int irLen) {
 
47
        try {
 
48
            PipedOutputStream pos = new PipedOutputStream();
 
49
            br = new BufferedReader(new InputStreamReader(new PipedInputStream(pos)));
 
50
            urjtag = new ExecProcess("jtag -q", new String[0], new File("."),
 
51
                                     pos,
 
52
                                     new FileOutputStream("urjtag.err"));
 
53
            urjtag.setDaemon(true);
 
54
            urjtag.start();
 
55
            try { Thread.sleep(100); } catch (Exception e) { }
 
56
            writeln("cable Signalyzer");
 
57
            expectStart("Connected to");
 
58
            writeln("detect");
 
59
            expectStart("IR length: "+irLen);
 
60
            expectStart("Chain length: 1");
 
61
            writeln("part 0");
 
62
            writeln("instruction length "+irLen);
 
63
            
 
64
            logicOutput = new LogicSettableArray(1);
 
65
            setLogicOutput(0, true);
 
66
        } catch (Exception e) { throw new RuntimeException(e); }
 
67
    }
 
68
 
 
69
    public void configure(float tapVolt, long kiloHerz) {
 
70
        // tapVolt is not configurable on this device
 
71
        writeln("frequency " + (kiloHerz*1000));
 
72
        expectStart("Setting TCK frequency to");
 
73
    }
 
74
 
 
75
    public void reset() {
 
76
        writeln("reset");
 
77
    }
 
78
 
 
79
    public void tms_reset() {
 
80
        writeln("reset");
 
81
    }
 
82
 
 
83
    public void disconnect() {
 
84
        urjtag.destroyProcess();
 
85
    }
 
86
 
 
87
    public void setLogicOutput(int index, boolean newLevel) {
 
88
        if (index!=0) throw new RuntimeException("we only support one GPIO, pin 15");
 
89
        logicOutput.setLogicState(index, newLevel);
 
90
        writeln("pod RESET="+(newLevel?"1":"0"));
 
91
    }
 
92
 
 
93
    protected int hw_net_scan_ir(int numBits, short[] scanIn, short[] scanOut, int drBits) {
 
94
        if (DEBUG) {
 
95
            System.err.print("hw_net_scan_ir("+numBits+", {");
 
96
            for(int i=0; i<scanIn.length; i++)
 
97
                System.err.print(" "+scanIn[i]+",");
 
98
            System.err.print("}, {");
 
99
            for(int i=0; i<scanOut.length; i++)
 
100
                System.err.print(" "+scanOut[i]+",");
 
101
            System.err.println("})");
 
102
        }
 
103
 
 
104
        if (scanIn.length != 1) throw new RuntimeException("not implemented");
 
105
 
 
106
        StringBuffer sb = new StringBuffer();
 
107
        for(int i=numBits-1; i>=0; i--)
 
108
            sb.append( (scanIn[i/16] & (short)(1<<(i%16)))==0 ? "0" : "1" );
 
109
        String bits = sb.toString();
 
110
        if (!defined.contains(bits)) {
 
111
            defined.add(bits);
 
112
            writeln("register R"+bits+" "+drBits);
 
113
            writeln("instruction I"+bits+" "+bits+" R"+bits);
 
114
        }
 
115
        writeln("instruction I"+bits);
 
116
        writeln("shift ir");
 
117
 
 
118
        scanOut[0] = 1;
 
119
        return 0;
 
120
    }
 
121
 
 
122
    protected int hw_net_scan_dr(int numBits, short[] scanIn, short[] scanOut) {
 
123
        if (DEBUG) {
 
124
            System.err.print("hw_net_scan_dr("+numBits+", {");
 
125
            for(int i=0; i<scanIn.length; i++)
 
126
                System.err.print(" "+scanIn[i]+",");
 
127
            System.err.print("}, {");
 
128
            for(int i=0; i<scanOut.length; i++)
 
129
                System.err.print(" "+scanOut[i]+",");
 
130
            System.err.println("})");
 
131
        }
 
132
 
 
133
        StringBuffer sb = new StringBuffer();
 
134
        for(int i=numBits-1; i>=0; i--)
 
135
            sb.append( (scanIn[i/16] & (short)(1<<(i%16)))==0 ? "0" : "1" );
 
136
        String bits = sb.toString();
 
137
        writeln("dr " + bits);
 
138
        expectStart(bits);
 
139
        writeln("shift dr");
 
140
        writeln("dr");
 
141
        String dr = readln();
 
142
        if (dr.length()==0) throw new RuntimeException();
 
143
        for(int i=0; i<scanOut.length; i++) scanOut[i] = 0;
 
144
        int j = 0;
 
145
        for(int i=Math.min(dr.length(),numBits)-1; i>=0; i--) {
 
146
            switch(dr.charAt(i)) {
 
147
                case '0': j++; break;
 
148
                case '1': scanOut[j/16] |= (short)(1<<(j%16)); j++; break;
 
149
                default: throw new RuntimeException("unexpected char: " +
 
150
                                                    dr.charAt(i) + " = " + ((int)dr.charAt(i)));
 
151
            }
 
152
        }
 
153
        return 0;
 
154
    }
 
155
 
 
156
    private void writeln(String s) {
 
157
        if (DEBUG) System.err.println(s);
 
158
        urjtag.writeln(s);
 
159
    }
 
160
 
 
161
    private String readln() {
 
162
        try {
 
163
            String s;
 
164
            while(true) {
 
165
                s = br.readLine();
 
166
                if (s.startsWith("Device Id: unknown as bit")) continue;
 
167
                break;
 
168
            }
 
169
            if (DEBUG) System.err.println(s);
 
170
            return s;
 
171
        } catch (Exception e) {
 
172
            throw new RuntimeException(e);
 
173
        }
 
174
    }
 
175
 
 
176
    private void expectStart(String x) {
 
177
        String s = readln();
 
178
        if (!s.startsWith(x))
 
179
            throw new RuntimeException("expected a line starting with \""+x+"\" but got \""+s+"\"");
 
180
    }
 
181
 
 
182
}