结论
由提供的SVF文件来编程Xilinx PROM器件是非常简单的。但是,如果用户能够正确分析SVF文件并理解如何确定对器件链中哪个器件进行编程,会更有好处。知道了这些信息,编程者能够更加高效地使用JTAG库。软件小组要对遥远位置的Xilinx JTAG器件进行编程,已有实际应用。利用开发包中的嵌入式JTAG编程软件,并以mcs文件作为输入文件,这是很容易做到的。
附录A
获得器件IDCODE的完整样例IDCODE.SVF文件
// Created using Xilinx iMPACT Software [ISE WebPACK - 5.1i]
TRST OFF;
ENDIR IDLE;
ENDDR IDLE;
STATE RESET IDLE;
TIR 0 ;
HIR 0 ;
TDR 0 ;
HDR 0 ;
// Validating chain...
TIR 0 ;
HIR 0 ;
TDR 0 ;
HDR 0 ;
SIR 13 TDI (1fff) SMASK (1fff) TDO (0021) MASK (1c63) ;
TIR 0 ;
HIR 5 TDI (1f) SMASK (1f) ;
HDR 1 TDI (00) SMASK (01) ;
TDR 0 ;
//Loading device with 'idcode' instruction.
SIR 8 TDI (fe) SMASK (ff) ;
SDR 32 TDI (00000000) SMASK (ffffffff) TDO (05025093) MASK (ffffffff) ;
//Loading device with 'conld' instruction.
SIR 8 TDI (f0) ;
RUNTEST 110000 TCK;
//Check for Read/Write Protect.
SIR 8 TDI (ff) TDO (01) MASK (ff) ;
//Loading device with 'idcode' instruction.
SIR 8 TDI (fe) ;
SDR 32 TDI (00000000) TDO (05025093) ;
//Loading device with 'bypass' instruction.
SIR 8 TDI (ff) ;
TIR 0 ;
HIR 0 ;
TDR 0 ;
HDR 0 ;
SIR 13 TDI (1fff) SMASK (1fff) ;
SDR 2 TDI (00) SMASK (03) ;
附录B
读取单独XILINX器件XC18V02 IDCODE的示例。
NOTES: This sample program will process SVF file with global padding instructions only.
Users need to modify to work with SVF file without global padding.
import java.io.*;
import java.lang.*;
import javax.comm.*;
import com.dalsemi.comm.*;
public final class AppJtag
{
private static jtag myJtag;
// Starting index of data array
static int Offset = 0;
// Number of byte to send within the data array
static int Size = 0;
// Number of bits/byte or bits/integer
static byte NumberOfBits = 8;
// State = true (Instruction); State = false (Data)
static boolean State = true;
// For Xilinc device this variable always false
static boolean Update = false;
// For Instruction header and trailer
static byte HIR = 0 , TIR = 0 ;
// For Data header and trailer
static byte HDR = 0 , TDR = 0;
// For Instruction header and trailer bit value
static byte HeaderBitInstVal = 1, TrailerBitInstVal = 1;
// For Data header and trailer bit value
static byte HeaderBitDatVal = 0, TrailerBitDatVal = 0;
static int Key;
static byte[] myData = new byte[4096];
static String line;
static RandomAccessFile SVFFile;
static File mySVF ;
public static int ProcessSVFLine()
{
int loop;
int OBracket = 0, CBracket = 0 ;
int myKey = 0x0;
StringBuffer buffer;
byte myAdd = (byte)0x0;
// Check the size in bits
myKey = Integer.parseInt(line.substring(line.indexOf(' ')+1,line.indexOf(' ',line.indexOf(' ')+1)));
if (myKey != 0) // myKey != 0
{
// Find value of data in byte format
OBracket = line.indexOf('(');
if ( myKey/8 > line.length())
{
// Copy data string to buffer starting from open bracket to
// end of data line
buffer = new StringBuffer(line.substring(OBracket+1,line.length()));
// Get another line of data and append to buffer
try
{
line = SVFFile.readLine();
while(line != null)
{
// Find close bracket
CBracket = line.indexOf(')',0);
if ( CBracket < 0) //Can not find close bracket
{
buffer.append(line.substring(0,line.length()));
line = SVFFile.readLine();
}
else // Find close bracket
{
buffer.append(line.substring(0,CBracket));
line = null;
}
}
loop = 0;
// Store data into array to send
for (int x = buffer.length(); x > 0; x--)
{
myData[loop] =(byte) Integer.parseInt((buffer.toString()).substring(x-2,x),16);
loop++;
x--;
}
评论
查看更多