Line 1... |
Line 1... |
/*!
|
/*!
|
Java host software API of ZTEX EZ-USB FX2 SDK
|
Java host software API of ZTEX SDK
|
Copyright (C) 2009-2011 ZTEX GmbH.
|
Copyright (C) 2009-2014 ZTEX GmbH.
|
http://www.ztex.de
|
http://www.ztex.de
|
|
|
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
it under the terms of the GNU General Public License version 3 as
|
it under the terms of the GNU General Public License version 3 as
|
published by the Free Software Foundation.
|
published by the Free Software Foundation.
|
Line 873... |
Line 873... |
}
|
}
|
System.err.println("Warning: Unable to determine bitstream bit order: no signature found");
|
System.err.println("Warning: Unable to determine bitstream bit order: no signature found");
|
return 0;
|
return 0;
|
}
|
}
|
|
|
|
// ******* detectBitstreamStart ************************************************
|
|
private int detectBitstreamStart ( byte[] buf ) {
|
|
int l=0;
|
|
for ( int i=0; i<buf.length-3; i++ ) {
|
|
if ( (l>=4) && ((buf[i+1] & 255)==0x99) && ((buf[i+3] & 255)==0x66) ) {
|
|
if ( ((buf[i] & 255)==0xaa) && ((buf[i+2] & 255)==0x55) )
|
|
return i-l;
|
|
if ( ((buf[i] & 255)==0x55) && ((buf[i+2] & 255)==0xaa) )
|
|
return i-l;
|
|
}
|
|
l = buf[i]==-1 ? l+1 : 0;
|
|
}
|
|
System.err.println("Warning: Unable to determine start of raw bitstream");
|
|
return 0;
|
|
}
|
|
|
// ******* swapBits ************************************************************
|
// ******* swapBits ************************************************************
|
private void swapBits ( byte[][] buf, int size ) {
|
private void swapBits ( byte[][] buf, int size ) {
|
int j=0, k=0;
|
int j=0, k=0;
|
for (int i=0; i<size; i++ ) {
|
for (int i=0; i<size; i++ ) {
|
while ( k >= buf[j].length ) {
|
while ( k >= buf[j].length ) {
|
Line 1609... |
Line 1625... |
" buf=" + (buf[6] & 255)+" "+(buf[7] & 255)+" "+(buf[8] & 255)+" "+(buf[9] & 255)+" "+(buf[10] & 255)+" "+(buf[11] & 255)+" "+(buf[12] & 255)); // +" "+(buf[13] & 255)+" "+(buf[14] & 255)+" "+(buf[15] & 255)+" "+(buf[16] & 255)+" "+(buf[17] & 255));
|
" buf=" + (buf[6] & 255)+" "+(buf[7] & 255)+" "+(buf[8] & 255)+" "+(buf[9] & 255)+" "+(buf[10] & 255)+" "+(buf[11] & 255)+" "+(buf[12] & 255)); // +" "+(buf[13] & 255)+" "+(buf[14] & 255)+" "+(buf[15] & 255)+" "+(buf[16] & 255)+" "+(buf[17] & 255));
|
|
|
return flashEnabled == 1;
|
return flashEnabled == 1;
|
}
|
}
|
|
|
|
|
// ******* flashUploadBitstream ************************************************
|
// ******* flashUploadBitstream ************************************************
|
/*
|
/*
|
Returns configuration time in ms.
|
Returns configuration time in ms.
|
The format of the boot sector (sector 0 of the Flash memory) is
|
The format of the boot sector (sector 0 of the Flash memory) is
|
0..7 ID
|
0..7 ID
|
Line 1674... |
Line 1691... |
|
|
// read the Bitstream file
|
// read the Bitstream file
|
byte[][] buffer = new byte[32768][];
|
byte[][] buffer = new byte[32768][];
|
byte[] buf1 = new byte[flashSectorSize()];
|
byte[] buf1 = new byte[flashSectorSize()];
|
|
|
int i,j,k;
|
int i,j,k,l;
|
try {
|
try {
|
j = bufferSize;
|
j = bufferSize;
|
for ( i=0; i<buffer.length && j==bufferSize; i++ ) {
|
for ( i=0; i<buffer.length && j==bufferSize; i++ ) {
|
buffer[i] = new byte[bufferSize];
|
buffer[i] = new byte[bufferSize];
|
j = 0;
|
j = 0;
|
do {
|
do {
|
k = inputStream.read( buffer[i], j, bufferSize-j );
|
k = inputStream.read( buffer[i], j, bufferSize-j );
|
if ( k < 0 )
|
if ( k < 0 )
|
k = 0;
|
k = 0;
|
j += k;
|
j += k;
|
|
|
|
// remove header because S6 FPGA's does not support bitstream start word detection
|
|
if ( i==0 && j==bufferSize && (l=detectBitstreamStart(buffer[0]))>0 ) {
|
|
for (int m=0; m<bufferSize-l; m++ )
|
|
buffer[0][m]=buffer[0][m+l];
|
|
j-=l;
|
|
}
|
}
|
}
|
while ( j<bufferSize && k>0 );
|
while ( j<bufferSize && k>0 );
|
}
|
}
|
|
|
try {
|
try {
|