1
package com.sun.electric.tool.simulation.test;
4
* Driver for the Signalyzer tool, via urjtag (must be installed).
6
* http://microcontrollershop.com/product_info.php?products_id=1754
8
* NOTE THAT THE SIGNALYZER "LITE" DOES NOT HAVE THE SAME PINOUT AS
9
* THE DUAL-CHANNEL SIGNALYZER!!
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:
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.
30
* @author Adam Megacz (megacz)
31
* @version 1.0 29.Oct.2009
33
* Copyright (c) 2009 by Nuts, Deez.
38
public class Signalyzer extends NetscanGeneric /* even though it's not a NetScan */ {
40
private ExecProcess urjtag;
41
private BufferedReader br;
42
private HashSet<String> defined = new HashSet<String>();
43
private static boolean DEBUG = false;
45
public Signalyzer() { this(8); }
46
public Signalyzer(int irLen) {
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("."),
52
new FileOutputStream("urjtag.err"));
53
urjtag.setDaemon(true);
55
try { Thread.sleep(100); } catch (Exception e) { }
56
writeln("cable Signalyzer");
57
expectStart("Connected to");
59
expectStart("IR length: "+irLen);
60
expectStart("Chain length: 1");
62
writeln("instruction length "+irLen);
64
logicOutput = new LogicSettableArray(1);
65
setLogicOutput(0, true);
66
} catch (Exception e) { throw new RuntimeException(e); }
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");
79
public void tms_reset() {
83
public void disconnect() {
84
urjtag.destroyProcess();
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"));
93
protected int hw_net_scan_ir(int numBits, short[] scanIn, short[] scanOut, int drBits) {
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("})");
104
if (scanIn.length != 1) throw new RuntimeException("not implemented");
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)) {
112
writeln("register R"+bits+" "+drBits);
113
writeln("instruction I"+bits+" "+bits+" R"+bits);
115
writeln("instruction I"+bits);
122
protected int hw_net_scan_dr(int numBits, short[] scanIn, short[] scanOut) {
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("})");
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);
141
String dr = readln();
142
if (dr.length()==0) throw new RuntimeException();
143
for(int i=0; i<scanOut.length; i++) scanOut[i] = 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)));
156
private void writeln(String s) {
157
if (DEBUG) System.err.println(s);
161
private String readln() {
166
if (s.startsWith("Device Id: unknown as bit")) continue;
169
if (DEBUG) System.err.println(s);
171
} catch (Exception e) {
172
throw new RuntimeException(e);
176
private void expectStart(String x) {
178
if (!s.startsWith(x))
179
throw new RuntimeException("expected a line starting with \""+x+"\" but got \""+s+"\"");