}
catch(IOException a)
{
System.out.println("Cannot read data "+ a);
}
}
else
{
// Line of data is within one line.");
CBracket = line.indexOf(')',OBracket+1);
if (Key <= 3 || Key == 6) // Process header & trailer
{
if (Key != 6)
{
// determine value of header and trailer
if(Integer.parseInt(line.substring(OBracket+1,CBracket).substring(0,2),16)>0)
myAdd = (byte)0x01;
else
myAdd = (byte)0x00;
}
}
else // Process SIR & SDR
{
loop = 0;
for (int s = CBracket - (OBracket+1); s >0 ; s--)
{
myData[loop] =(byte) Integer.parseInt((line.substring(OBracket+1,CBracket)).substring(s-2,s),16);
loop++;
s--;
}
}
}
}
switch(Key)
{
case 0: //System.out.println("TIR & TrailerBitInstVal ");
TIR = (byte)myKey;
TrailerBitInstVal = myAdd;
break;
case 1: //System.out.println("HIR & HeaderBitInstVal ");
HIR = (byte)myKey;
HeaderBitInstVal = myAdd;
break;
case 2: //System.out.println("TDR & TrailerBitDatVal ");
TDR = (byte)myKey;
TrailerBitDatVal = myAdd;
break;
case 3: //System.out.println("HDR & HeaderBitDatVal ");
HDR = (byte)myKey;
HeaderBitDatVal = myAdd;
break;
case 4:
case 5: Size = myKey;
break;
default:
System.out.println("Invalid opcode.");
return 0;
}
return 1;
}
public static void main(String[] args)
{
// The key words of the SVF file include:
// TRST OFF: Ignore
// ENDIR IDLE: Ignore
// ENDDR IDLE: Ignore
// STATE RESET IDLE: Ignore
// TIR 5 TDI (1f): Key word = 0, length, pin, value(Instruction
// trailer)
// HIR 5 TDI (1f): Key word = 1, length, pin, value(Instruction
// header)
// TDR 5 TDI (00): Key word = 2, length, pin, value(Data trailer)
// HDR 5 TDI (00): Key word = 3, length, pin, value(Data header)
// SIR 13 TDI (1fff)): Key word = 4, length, pin,
// value(Instruction)
// SDR 32 TDI (00000000)): Key word = 5, length, pin, value(Data)
// RUNTEST 110000 TCK: Key word = 0, clock pulse, pin (Run clock)
/*
// Command send format for Instruction.
myJtag.sendNrcv(Data,Offset,Size,(byte)NumberOfBits,State,Update,
(byte)HIR,(byte)HeaderBitInstVal,(byte)TIR,(byte)TrailerBitInstVal);
// Command send format for Data
myJtag.sendNrcv(Data,Offset,Size,(byte)NumberOfBits,State,Update,
(byte)HDR,(byte)HeaderBitDatVal,(byte)TDR,(byte)TrailerBitDatVal);
*/
myJtag = new jtag();
if(args.length != 0)
{
for (int x = 0; x < args.length ; x++)
{
mySVF = new File(args[x]);
if (mySVF.exists())
{
if (mySVF.canRead())
{
try
{
SVFFile= new RandomAccessFile(mySVF.getName(), "r");
// Process one line at a time and set all variables
while((line = SVFFile.readLine()) != null)
{
System.out.println(line);
if(line.regionMatches(false,0,"TIR",0,3))
Key = 0;
else if(line.regionMatches(false,0,"HIR",0,3))
Key = 1;
else if(line.regionMatches(false,0,"TDR",0,3))
Key = 2;
else if(line.regionMatches(false,0,"HDR",0,3))
Key = 3;
else if(line.regionMatches(false,0,"SIR",0,3))
Key = 4;
else if(line.regionMatches(false,0,"SDR",0,3))
Key = 5;
else if(line.regionMatches(false,0,"RUNTEST",0,7))
Key = 6;
else if(line.regionMatches(false,0,"STATE",0,5))
Key = 7;
else
{
Key = 8;
//System.out.println(line);
}
评论
查看更多