summaryrefslogtreecommitdiffstats
path: root/fpga/xilinx/programmer/bit2svf/templates
diff options
context:
space:
mode:
Diffstat (limited to 'fpga/xilinx/programmer/bit2svf/templates')
-rw-r--r--fpga/xilinx/programmer/bit2svf/templates/.DEVICES~42
-rw-r--r--fpga/xilinx/programmer/bit2svf/templates/.README.en~112
-rw-r--r--fpga/xilinx/programmer/bit2svf/templates/.README.es~237
-rw-r--r--fpga/xilinx/programmer/bit2svf/templates/DEVICES42
-rw-r--r--fpga/xilinx/programmer/bit2svf/templates/README.en115
-rw-r--r--fpga/xilinx/programmer/bit2svf/templates/README.es241
-rw-r--r--fpga/xilinx/programmer/bit2svf/templates/alg_18V.svft192
-rw-r--r--fpga/xilinx/programmer/bit2svf/templates/alg_Spartan_3.svft83
-rw-r--r--fpga/xilinx/programmer/bit2svf/templates/alg_Spartan_II.svft95
-rw-r--r--fpga/xilinx/programmer/bit2svf/templates/alg_Virtex_4.svft111
-rw-r--r--fpga/xilinx/programmer/bit2svf/templates/alg_XCF.svft190
-rw-r--r--fpga/xilinx/programmer/bit2svf/templates/alg_XCFP.svft208
12 files changed, 1668 insertions, 0 deletions
diff --git a/fpga/xilinx/programmer/bit2svf/templates/.DEVICES~ b/fpga/xilinx/programmer/bit2svf/templates/.DEVICES~
new file mode 100644
index 0000000..9219f41
--- /dev/null
+++ b/fpga/xilinx/programmer/bit2svf/templates/.DEVICES~
@@ -0,0 +1,42 @@
+//One device per line
+//NAME | ID | IDMASK | ALG_TPL | BSIZE | MSIZE (last mem pos)
+// XC18V memories
+XC18V256 , f5022093, 0ffeffff, alg_18V , 2048 , 0x1000
+XC18V512 , f5023093, 0ffeffff, alg_18V , 2048 , 0x2000
+XC18V01 , f5024093, 0ffeffff, alg_18V , 2048 , 0x4000
+XC18V01-SO20 , f5024093, 0ffeffff, alg_18V , 2048 , 0x4000
+XC18V02 , f5025093, 0ffeffff, alg_18V , 4096 , 0x4000
+XC18V04 , f5026093, 0ffeffff, alg_18V , 4096 , 0x8000
+
+// XCF memories
+XCF01S , f5044093, 0ffeffff, alg_XCF , 2048 , 0x4000
+XCF02S , f5045093, 0ffeffff, alg_XCF , 4096 , 0x4000
+XCF04S , f5046093, 0ffeffff, alg_XCF , 4096 , 0x8000
+
+// XCFxxP memories
+XCF08P , f5057093, 0fffffff, alg_XCFP ,8192 , 0x100000
+
+// Spartan II family (5 bits IR)
+XC2S15 , f0608093, 0fffffff, alg_Spartan_II, VOID , 0l
+XC2S30 , f060c093, 0fffffff, alg_Spartan_II, VOID , 0l
+XC2S50 , f0610093, 0fffffff, alg_Spartan_II, VOID , 0l
+XC2S100 , f0614093, 0fffffff, alg_Spartan_II, VOID , 0l
+XC2S100-PQ208 , f0614093, 0fffffff, alg_Spartan_II, VOID , 0l
+XC2S150 , f0618093, 0fffffff, alg_Spartan_II, VOID , 0l
+XC2S200 , f061c093, 0fffffff, alg_Spartan_II, VOID , 0l
+
+// Spartan 3 family (6 bits IR)
+XC3S50 , f140D093, 0fffffff, alg_Spartan_3, VOID , 0l
+XC3S200 , f1414093, 0fffffff, alg_Spartan_3, VOID , 0l
+XC3S400 , f141C093, 0fffffff, alg_Spartan_3, VOID , 0l
+XC3S1000, f1428093, 0fffffff, alg_Spartan_3, VOID , 0l
+XC3S1500, f1434093, 0fffffff, alg_Spartan_3, VOID , 0l
+XC3S2000, f1440093, 0fffffff, alg_Spartan_3, VOID , 0l
+XC3S4000, f1448093, 0fffffff, alg_Spartan_3, VOID , 0l
+XC3S5000, f1450093, 0fffffff, alg_Spartan_3, VOID , 0l
+
+// Virtex 4 family (10 bits IR)
+XC4VLX25, f167c093, 0fffffff, alg_Virtex_4, VOID, 0l
+
+//EOF
+
diff --git a/fpga/xilinx/programmer/bit2svf/templates/.README.en~ b/fpga/xilinx/programmer/bit2svf/templates/.README.en~
new file mode 100644
index 0000000..9201290
--- /dev/null
+++ b/fpga/xilinx/programmer/bit2svf/templates/.README.en~
@@ -0,0 +1,112 @@
+Copyright (c) 2005 Juan Pablo D. Borgna <jpborgna en inti gov ar>
+Copyright (c) 2006-2007 Salvador E. Tropea <salvador en inti gov ar>
+Copyright (c) 2005-2007 Instituto Nacional de Tecnología Industrial
+
+Commands and blocks:
+ The template files have block commands and operation
+ commands. The block commands start with two substract
+ signs "--" and the operation are betwin dollar signs "$".
+ The block commands mark the excecution of a block and the
+ end of the block must be identifyed with the instruction
+ "--END".
+
+Internal variables:
+ The next internal variables are provided wich can be used
+ indicating their name betwin dollars signs "$" or modified
+ if a value is assigned using parentesis signs.
+ Ex.: $ADDRESS(0x00)$ asigns this variable the value 0x0000.
+
+$ADDRESS$ :
+ Accumulator useful at the time of incrementing a memory address.
+
+$STEP$ :
+ Value on wich $ADDRESS$ variable will be incremented.
+
+$BSIZEB$ :
+ Amount of bytes of the bitstream file.
+
+$BSIZEB2$ :
+ 2 * amount of bytes of the bitstream file.
+
+$BSIZE$ :
+ Amount of bits of the bitstream file.
+ Note: BSIZE an STEP are related. BSIZE is the size of the cache
+ used to store the data before flashing the device. Each memory
+ address contains some bits that's a word, the STEP is the size of
+ the cache in words. So BSIZE=STEP*word_size.
+ For the XC18V: 32*64=2048 o 32*128=4096.
+
+$MSIZE$ :
+ Taken from the msize field from the device definition in the
+ DEVICES file.
+ It contains the last memory position of a device with memory.
+
+$ID$ :
+ Taken from the id field from the device definition in the DEVICES
+ file.
+ It contains the IDCODE of the selected device.
+
+$IDMASK$ :
+ Taken from the idmask field from the device definition in the
+ DEVICE file.
+ It contains the mask wich be used in the comprobation of the IDCODE
+
+
+Block commands:
+
+--LITERAL START :
+ It indicate that in the output file must be copied the content
+ of this block until the end is found "as is".
+ If an operational command is found inside it is excecuted.
+
+--REPEAT START :
+
+ It indicate that this block will be repeated until the end of
+ the bitfile is reached.
+ This block must have inside some operational command wich
+ reads information from the input bitfile, if not, the end of
+ this will never be reached and the progran will keep
+ repeating this block until there is no more disk space.
+ With each block iteration the variable $ADDRESS$ is
+ incremented by $STEP$.
+
+--REPEAT UNTIL value :
+ It indicates that this block will be repeated until the
+ variable $ADDRESS$ reach the value passed as parameter.
+ With each block iteration the variable $ADDRESS$ is
+ incremented by $STEP$.
+ The value passwd as parameter must be $STEP$ multiplo,
+ or the exit condition will never be reached and the
+ program will keep repeating this block until there is
+ no more disk space.
+ Instead of value you can use a variable:
+ Ej.: --REPEAT UNTIL MSIZE
+
+
+--END :
+ It indicates the end of a LITERAL, REPEAT or REPEAT UNTIL block.
+
+
+Opeation commands:
+ The operation commands may recive as an argment the name of
+ a variable instead of a constant:
+ Ej.: $FILL(0xFF,BSIZE)$
+
+$DATA(ndatabytes)$ :
+ Writes in the output file a ndatabytes amount of bytes
+ from the input bitfile expressed in hex.
+
+$DATA_INV(ndatabytes)$ :
+ Writes in the output fila a ndatabytes amount of bytes
+ from the input bitfile inverting the order, expressed
+ in hex.
+
+$FILL(VAL,TIMES)$ :
+ Writes TIMES times the value VAL expressed in hex in the
+ output file.
+
+$REWIND$ :
+ Rewinds the bitfile to the first stream byte so it can be used in a
+ new block.
+
+
diff --git a/fpga/xilinx/programmer/bit2svf/templates/.README.es~ b/fpga/xilinx/programmer/bit2svf/templates/.README.es~
new file mode 100644
index 0000000..af3560b
--- /dev/null
+++ b/fpga/xilinx/programmer/bit2svf/templates/.README.es~
@@ -0,0 +1,237 @@
+Copyright (c) 2005 Juan Pablo D. Borgna <jpborgna en inti gov ar>
+Copyright (c) 2006-2007 Salvador E. Tropea <salvador en inti gov ar>
+Copyright (c) 2005-2007 Instituto Nacional de Tecnología Industrial
+
+Comandos y bloques:
+ Los archivos de template tienen comandos de bloque y
+ comandos de operacion. Los comandos de bloque comienzan con
+ dos signos menos "--" y los de operacion van encerrados entre
+ signos pesos "$". Los comandos de bloque indican la ejecucion
+ de un bloque y el fin de bloque debe ser indicado con la
+ instruccion "--END".
+
+
+Variables internas:
+ Se proporcionan las siguientes variables internas que pueden
+ ser utilizadas invocando su nombre entre signos pesos "$" o
+ modificados si ademas se les asigna un valor entre
+ parentesis. Ej. $ADDRESS(0x0000)$ le asignara a esta variable
+ el valor 0x0000.
+
+$ADDRESS$ :
+ Acumulador que es util al momento de incrementar la direccion de una
+ memoria, por ejemplo.
+
+$STEP$ :
+ Valor con el cual se incrementara la variable $ADDRESS$.
+
+$SBYTES$ :
+ Cantidad de bytes que posee el bitstream del bitfile.
+
+$SBITES$ :
+ Cantidad de bits que posee el bitstream del bitfile.
+
+$MSIZE$ :
+ Obtenido del campo msize de la definicion del dispositivo en el
+ archivo DEVICES.
+ Expresa la ultima posicion de memoria de un dispositivo con memoria.
+
+$ID$ :
+ Obtenido del campo id de la definicion del dispositivo en el archivo
+ DEVICES.
+ Expresa el IDCODE del dispositivo actual.
+
+$IDMASK$ :
+ Obtenido del campo idmask de la definicion del dispositivo en el
+ archivo DEVICES.
+ Expresa la mascara que se usara en la comprobacion del IDCODE.
+
+$BSIZE$ :
+ Obtenido del campo BSIZE de la definicion del dispositivo en el
+ archivo DEVICES.
+ Es el "block size" (cantidad de bits) a transferir expresando
+ en bits.
+ Nota: El valor BSIZE y el valor STEP no son cosas separadas.
+ BSIZE es el tamaño en bits de la cache que tiene el dispositivo
+ para almacenar los datos antes de transferirlos a la flash.
+ Cada dirección de memoria direcciona una cantidad de bits (64
+ o 128 es lo común), el STEP es el número de posiciones de memoria
+ que entran en la cache, luego BSIZE=STEP*bits_por_dirección.
+ Esto es en las XC18V: 32*64=2048 o 32*128=4096.
+
+$BSIZEB$ :
+ Obtenido del campo BSIZE de la definicion del dispositivo en el
+ archivo DEVICES.
+ Es el "block size" (cantidad de bits) a transferir expresando
+ en bytes.
+
+$BSIZEB2$ :
+ $BSIZEB$ multiplicado por 2.
+
+Comandos de bloque:
+
+
+--LITERAL START :
+ Indica que se debe copiar en el archivo de salida el contenido
+ de este bloque y hasta el final del mismo tal y como esta.
+ Si se encuentra un comando de operacion entre medio este es
+ ejecutado.
+
+--REPEAT START :
+ Indica que se repetira de principio a fin el contenido de este
+ bloque mientras que haya informacion que leer en el bitfile
+ de entrada.
+ Este comando de bloque debe tener en su interior algun comando
+ de operacion que lea informacion del bitfile de entrada, si no
+ este nunca llegara a su fin y el programa se quedara
+ repitiendo el bloque hasta agotar el espacio en disco.
+ Con cada iteracion del bloque se incrementa la variable
+ $ADDRESS$ en $STEP$.
+
+--REPEAT UNTIL valor :
+ Indica que se repetira de principio a fin el contenido de
+ este bloque hasta que la variable $ADDRESS$ tome el valor
+ pasado como parametro. Con cada iteracion del bloque se
+ incrementara la variable $ADDRESS$ en $STEP$.
+ El valor pasado como parametro debe ser multiplo de
+ $STEP$, si no la condicion de salida del bloque nunca se
+ conseguira y el programa se quedara repitiendo el bloque
+ hasta agotar el espacio en disco.
+ En lugar de valor se puede utilizar una variable:
+ Ej.: --REPEAT UNTIL MSIZE
+
+
+--END :
+ Indica el final de un bloque LITERAL, REPEAT o REPEAT UNTIL.
+
+
+Comandos de operacion:
+ Los comandos de operacion pueden recibir como argumento
+ el nombre de una variable en lugar de una constante:
+ Ej.: $FILL(0xFF,BSIZE)$
+
+$DATA(ndatabytes)$ :
+ Escribe en el archivo de salida una cantidad ndatabytes de
+ bytes del bitfile de entrada expresados en hexadecimal.
+
+$DATA_INV(ndatabytes)$ :
+ Escribe en el archivo de salida una cantidad ndatabytes
+ de bytes del bitfile de entrada, invirtiendo el orden
+ de los bits del bloque, expresados en hexadecimal.
+
+$FILL(VAL,TIMES)$ :
+ Escribe TIMES veces el valor VAL expresado en hexadecimal en
+ el archivo de salida.
+
+$REWIND$ :
+ Vuelve a poner el archivo de bits en la posicion del primer byte del
+ stream para poder realizar otra pasada completa con un comando de
+ bloque.
+
+-------------------------------------------------------------------------------
+
+Como crear un template para una FPGA:
+-------------------------------------
+
+Autor: Salvador E. Tropea
+
+A) Crear un .SVF válido para esa FPGA:
+
+1) Obtener un .bit para la FPGA en cuestión.
+2) Abrir el impact:
+$ . /usr/local/ISEWb/settings.sh
+$ impact
+3) Elegir "I want to (*) Create a new project", Ok. (Darle un nombre si se
+quiere).
+4) Elegir "(*) Prepare a boundary-scan file [SVF]", Finish.
+5) Elegir un nombre para el SVF.
+6) Elegir el .bit.
+7) Presionar el botón derecho sobre la FPGA y elegir "Program", Ok.
+8) Salir del impact
+
+Automáticamente es:
+
+setPreference -pref AutoSignature:FALSE
+setPreference -pref KeepSVF:FALSE
+setPreference -pref ConcurrentMode:FALSE
+setPreference -pref UseHighz:FALSE
+setPreference -pref UserLevel:NOVICE
+setPreference -pref svfUseTime:FALSE
+setMode -bs
+setMode -bs
+setCable -port svf -file "salida.svf"
+addDevice -p 1 -file "archivo.bit"
+Program -p 1 -s -defaultVersion 0
+
+B) Crear un nuevo template (ej: alg_Virtex_4.svft)
+
+1) Abrir un template que ya exista para usarlo de guía.
+2) Borrar "FREQUENCY 1E6 HZ;"
+3) Reemplazar: $ID$ y $IDMASK$ en la parte que dice "Loading device with
+'idcode' instruction.". (f167c093)
+4) Reemplazar la megalínea del bitstream por:
+SDR $SBITS$ TDI ($DATA_INV(-1)$) SMASK ($FILL(0xFF,-1)$);
+
+C) Probar su funcionamiento
+
+1) Colocar el nuevo template en /usr/share/bit2svf/
+2) Editar /usr/share/bit2svf/DEVICES agregando el ID de la FPGA y el algoritmo
+a usar:
+
+// Virtex 4 family (10 bits IR)
+XC4VLX25, f167c093, 0fffffff, alg_Virtex_4, VOID, 0l
+
+3) Probar el template:
+
+$ bit2svf display_test_lx25.bit v4-b2s.svf XC4VLX25
+
+Esto genera v4-b2s.svf que debería ser practicamente idéntico al generado por
+impact.
+Nota: En este caso observé que el impact agrega 32 bits en 0 extra al
+bitstream. Esto no parece ser indispensable y sospecho que sirve para
+"limpiar/vaciar" la cadena.
+4) Si todo fue OK se puede probar con el dispositivo:
+
+$ jbit display_test_lx25.bit XC4VLX25
+
+
+-------------------------------------------------------------------------------
+
+Como crear un template para una PROM:
+-------------------------------------
+
+Autor: Salvador E. Tropea
+
+A) Crear un archivo de PROM válido.
+
+1) Obtener un .bit para la FPGA en cuestión.
+2) Abrir el impact:
+$ . /usr/local/ISEWb/settings.sh
+$ impact
+3) Elegir "I want to (*) Prepare a ROM file", Ok. (Darle un nombre si se
+quiere).
+4) Elegir "I want to target a (*) Xilinx PROM", "PROM File name" darle un
+nombre. Next. (Ojo con el path).
+5) Elegir la PROM y Add, luego Next.
+6) Agregar el .bit
+7) Elegir "Generate File ..." dentro de las acciones disponibles (la única).
+8) Esto genera un .MCS con el contenido para la PROM.
+
+B) Crear un .SVF válido para esa PROM. Esto es similar a la FPGA, la única
+diferencia es que le especificamos el .MCS en lugar de un .bit. En este caso
+nos preguntará cual es el dispositivo haciendo un guess de cual se trata. Esto
+es porque el .mcs es un bitstream crudo y no dice para que dispositivo se
+hizo.
+Durante este proceso se pueden elegir opciones como si la PROM se conecta en
+paralelo y si se incluye verificación. Además hay que elegir que primero la
+borre.
+
+B) Crear un nuevo template o usar uno ya hecho. Esto es como con la FPGA.
+
+C) Probar su funcionamiento. Esto es más o menos lo mismo que con la FPGA. La
+principal diferencia con las PROMs es que acá es necesario configurar su tamaño
+y el tamaño de la caché o página donde se guardarán temporalmente los datos:
+
+// XCFxxP memories
+XCF08P , f5057093, 0fffffff, alg_XCFP ,8192 , 0x100000
+
diff --git a/fpga/xilinx/programmer/bit2svf/templates/DEVICES b/fpga/xilinx/programmer/bit2svf/templates/DEVICES
new file mode 100644
index 0000000..86f53a9
--- /dev/null
+++ b/fpga/xilinx/programmer/bit2svf/templates/DEVICES
@@ -0,0 +1,42 @@
+//One device per line
+//NAME | ID | IDMASK | ALG_TPL | BSIZE | MSIZE
+// XC18V memories
+XC18V256 , f5022093, 0ffeffff, alg_18V , 2048 , 0x1000
+XC18V512 , f5023093, 0ffeffff, alg_18V , 2048 , 0x2000
+XC18V01 , f5024093, 0ffeffff, alg_18V , 2048 , 0x4000
+XC18V01-SO20 , f5024093, 0ffeffff, alg_18V , 2048 , 0x4000
+XC18V02 , f5025093, 0ffeffff, alg_18V , 4096 , 0x4000
+XC18V04 , f5026093, 0ffeffff, alg_18V , 4096 , 0x8000
+
+// XCF memories
+XCF01S , f5044093, 0ffeffff, alg_XCF , 2048 , 0x4000
+XCF02S , f5045093, 0ffeffff, alg_XCF , 4096 , 0x4000
+XCF04S , f5046093, 0ffeffff, alg_XCF , 4096 , 0x8000
+
+// XCFxxP memories
+XCF08P , f5057093, 0fffffff, alg_XCFP ,8192 , 0x100000
+
+// Spartan II family (5 bits IR)
+XC2S15 , f0608093, 0fffffff, alg_Spartan_II, VOID , 0l
+XC2S30 , f060c093, 0fffffff, alg_Spartan_II, VOID , 0l
+XC2S50 , f0610093, 0fffffff, alg_Spartan_II, VOID , 0l
+XC2S100 , f0614093, 0fffffff, alg_Spartan_II, VOID , 0l
+XC2S100-PQ208 , f0614093, 0fffffff, alg_Spartan_II, VOID , 0l
+XC2S150 , f0618093, 0fffffff, alg_Spartan_II, VOID , 0l
+XC2S200 , f061c093, 0fffffff, alg_Spartan_II, VOID , 0l
+
+// Spartan 3 family (6 bits IR)
+XC3S50 , f140D093, 0fffffff, alg_Spartan_3, VOID , 0l
+XC3S200 , f1414093, 0fffffff, alg_Spartan_3, VOID , 0l
+XC3S400 , f141C093, 0fffffff, alg_Spartan_3, VOID , 0l
+XC3S1000, f1428093, 0fffffff, alg_Spartan_3, VOID , 0l
+XC3S1500, f1434093, 0fffffff, alg_Spartan_3, VOID , 0l
+XC3S2000, f1440093, 0fffffff, alg_Spartan_3, VOID , 0l
+XC3S4000, f1448093, 0fffffff, alg_Spartan_3, VOID , 0l
+XC3S5000, f1450093, 0fffffff, alg_Spartan_3, VOID , 0l
+
+// Virtex 4 family (10 bits IR)
+XC4VLX25, f167c093, 0fffffff, alg_Virtex_4, VOID, 0l
+
+//EOF
+
diff --git a/fpga/xilinx/programmer/bit2svf/templates/README.en b/fpga/xilinx/programmer/bit2svf/templates/README.en
new file mode 100644
index 0000000..f517b01
--- /dev/null
+++ b/fpga/xilinx/programmer/bit2svf/templates/README.en
@@ -0,0 +1,115 @@
+Copyright (c) 2005 Juan Pablo D. Borgna <jpborgna en inti gov ar>
+Copyright (c) 2006-2007 Salvador E. Tropea <salvador en inti gov ar>
+Copyright (c) 2005-2007 Instituto Nacional de Tecnología Industrial
+
+Commands and blocks:
+ The template files have block commands and operation
+ commands. The block commands start with two substract
+ signs "--" and the operation are betwin dollar signs "$".
+ The block commands mark the excecution of a block and the
+ end of the block must be identifyed with the instruction
+ "--END".
+
+Internal variables:
+ The next internal variables are provided wich can be used
+ indicating their name betwin dollars signs "$" or modified
+ if a value is assigned using parentesis signs.
+ Ex.: $ADDRESS(0x00)$ asigns this variable the value 0x0000.
+
+$ADDRESS$ :
+ Accumulator useful at the time of incrementing a memory address.
+
+$STEP$ :
+ Value on wich $ADDRESS$ variable will be incremented.
+
+$BSIZEB$ :
+ Amount of bytes of the bitstream file.
+
+$BSIZEB2$ :
+ 2 * amount of bytes of the bitstream file.
+
+$BSIZE$ :
+ Amount of bits of the bitstream file.
+ Note: BSIZE an STEP are related. BSIZE is the size of the cache
+ used to store the data before flashing the device. Each memory
+ address contains some bits that's a word, the STEP is the size of
+ the cache in words. So BSIZE=STEP*word_size.
+ For the XC18V: 32*64=2048 o 32*128=4096.
+
+$MSIZE$ :
+ Taken from the msize field from the device definition in the
+ DEVICES file.
+ It contains the last memory position of a device with memory.
+
+$ID$ :
+ Taken from the id field from the device definition in the DEVICES
+ file.
+ It contains the IDCODE of the selected device.
+
+$IDMASK$ :
+ Taken from the idmask field from the device definition in the
+ DEVICE file.
+ It contains the mask wich be used in the comprobation of the IDCODE
+
+
+Block commands:
+
+--LITERAL START :
+ It indicate that in the output file must be copied the content
+ of this block until the end is found "as is".
+ If an operational command is found inside it is excecuted.
+
+--REPEAT START :
+
+ It indicate that this block will be repeated until the end of
+ the bitfile is reached.
+ This block must have inside some operational command wich
+ reads information from the input bitfile, if not, the end of
+ this will never be reached and the progran will keep
+ repeating this block until there is no more disk space.
+ With each block iteration the variable $ADDRESS$ is
+ incremented by $STEP$.
+
+--REPEAT UNTIL value :
+ It indicates that this block will be repeated until the
+ variable $ADDRESS$ reach the value passed as parameter.
+ With each block iteration the variable $ADDRESS$ is
+ incremented by $STEP$.
+ The value passwd as parameter must be $STEP$ multiplo,
+ or the exit condition will never be reached and the
+ program will keep repeating this block until there is
+ no more disk space.
+ Instead of value you can use a variable:
+ Ej.: --REPEAT UNTIL MSIZE
+
+
+--END :
+ It indicates the end of a LITERAL, REPEAT or REPEAT UNTIL block.
+
+
+Opeation commands:
+ The operation commands may recive as an argment the name of
+ a variable instead of a constant:
+ Ej.: $FILL(0xFF,BSIZE)$
+
+$DATA(ndatabytes)$ :
+ Writes in the output file a ndatabytes amount of bytes
+ from the input bitfile expressed in hex.
+
+$DATA_INV(ndatabytes)$ :
+ Writes in the output fila a ndatabytes amount of bytes
+ from the input bitfile inverting the order, expressed
+ in hex.
+
+$FILL(VAL,TIMES)$ :
+ Writes TIMES times the value VAL expressed in hex in the
+ output file.
+
+$REWIND$ :
+ Rewinds the bitfile to the first stream byte so it can be used in a
+ new block.
+
+$CUTLINES(n):
+ Using 0 stops cutting long lines, 1 starts cutting again.
+ Other values: reserved.
+
diff --git a/fpga/xilinx/programmer/bit2svf/templates/README.es b/fpga/xilinx/programmer/bit2svf/templates/README.es
new file mode 100644
index 0000000..58f47b5
--- /dev/null
+++ b/fpga/xilinx/programmer/bit2svf/templates/README.es
@@ -0,0 +1,241 @@
+Copyright (c) 2005 Juan Pablo D. Borgna <jpborgna en inti gov ar>
+Copyright (c) 2006-2007 Salvador E. Tropea <salvador en inti gov ar>
+Copyright (c) 2005-2007 Instituto Nacional de Tecnología Industrial
+
+Comandos y bloques:
+ Los archivos de template tienen comandos de bloque y
+ comandos de operacion. Los comandos de bloque comienzan con
+ dos signos menos "--" y los de operacion van encerrados entre
+ signos pesos "$". Los comandos de bloque indican la ejecucion
+ de un bloque y el fin de bloque debe ser indicado con la
+ instruccion "--END".
+
+
+Variables internas:
+ Se proporcionan las siguientes variables internas que pueden
+ ser utilizadas invocando su nombre entre signos pesos "$" o
+ modificados si ademas se les asigna un valor entre
+ parentesis. Ej. $ADDRESS(0x0000)$ le asignara a esta variable
+ el valor 0x0000.
+
+$ADDRESS$ :
+ Acumulador que es util al momento de incrementar la direccion de una
+ memoria, por ejemplo.
+
+$STEP$ :
+ Valor con el cual se incrementara la variable $ADDRESS$.
+
+$SBYTES$ :
+ Cantidad de bytes que posee el bitstream del bitfile.
+
+$SBITES$ :
+ Cantidad de bits que posee el bitstream del bitfile.
+
+$MSIZE$ :
+ Obtenido del campo msize de la definicion del dispositivo en el
+ archivo DEVICES.
+ Expresa la ultima posicion de memoria de un dispositivo con memoria.
+
+$ID$ :
+ Obtenido del campo id de la definicion del dispositivo en el archivo
+ DEVICES.
+ Expresa el IDCODE del dispositivo actual.
+
+$IDMASK$ :
+ Obtenido del campo idmask de la definicion del dispositivo en el
+ archivo DEVICES.
+ Expresa la mascara que se usara en la comprobacion del IDCODE.
+
+$BSIZE$ :
+ Obtenido del campo BSIZE de la definicion del dispositivo en el
+ archivo DEVICES.
+ Es el "block size" (cantidad de bits) a transferir expresando
+ en bits.
+ Nota: El valor BSIZE y el valor STEP no son cosas separadas.
+ BSIZE es el tamaño en bits de la cache que tiene el dispositivo
+ para almacenar los datos antes de transferirlos a la flash.
+ Cada dirección de memoria direcciona una cantidad de bits (64
+ o 128 es lo común), el STEP es el número de posiciones de memoria
+ que entran en la cache, luego BSIZE=STEP*bits_por_dirección.
+ Esto es en las XC18V: 32*64=2048 o 32*128=4096.
+
+$BSIZEB$ :
+ Obtenido del campo BSIZE de la definicion del dispositivo en el
+ archivo DEVICES.
+ Es el "block size" (cantidad de bits) a transferir expresando
+ en bytes.
+
+$BSIZEB2$ :
+ $BSIZEB$ multiplicado por 2.
+
+Comandos de bloque:
+
+
+--LITERAL START :
+ Indica que se debe copiar en el archivo de salida el contenido
+ de este bloque y hasta el final del mismo tal y como esta.
+ Si se encuentra un comando de operacion entre medio este es
+ ejecutado.
+
+--REPEAT START :
+ Indica que se repetira de principio a fin el contenido de este
+ bloque mientras que haya informacion que leer en el bitfile
+ de entrada.
+ Este comando de bloque debe tener en su interior algun comando
+ de operacion que lea informacion del bitfile de entrada, si no
+ este nunca llegara a su fin y el programa se quedara
+ repitiendo el bloque hasta agotar el espacio en disco.
+ Con cada iteracion del bloque se incrementa la variable
+ $ADDRESS$ en $STEP$.
+
+--REPEAT UNTIL valor :
+ Indica que se repetira de principio a fin el contenido de
+ este bloque hasta que la variable $ADDRESS$ tome el valor
+ pasado como parametro. Con cada iteracion del bloque se
+ incrementara la variable $ADDRESS$ en $STEP$.
+ El valor pasado como parametro debe ser multiplo de
+ $STEP$, si no la condicion de salida del bloque nunca se
+ conseguira y el programa se quedara repitiendo el bloque
+ hasta agotar el espacio en disco.
+ En lugar de valor se puede utilizar una variable:
+ Ej.: --REPEAT UNTIL MSIZE
+
+
+--END :
+ Indica el final de un bloque LITERAL, REPEAT o REPEAT UNTIL.
+
+
+Comandos de operacion:
+ Los comandos de operacion pueden recibir como argumento
+ el nombre de una variable en lugar de una constante:
+ Ej.: $FILL(0xFF,BSIZE)$
+
+$DATA(ndatabytes)$ :
+ Escribe en el archivo de salida una cantidad ndatabytes de
+ bytes del bitfile de entrada expresados en hexadecimal.
+
+$DATA_INV(ndatabytes)$ :
+ Escribe en el archivo de salida una cantidad ndatabytes
+ de bytes del bitfile de entrada, invirtiendo el orden
+ de los bits del bloque, expresados en hexadecimal.
+
+$FILL(VAL,TIMES)$ :
+ Escribe TIMES veces el valor VAL expresado en hexadecimal en
+ el archivo de salida.
+
+$REWIND$ :
+ Vuelve a poner el archivo de bits en la posicion del primer byte del
+ stream para poder realizar otra pasada completa con un comando de
+ bloque.
+
+$CUTLINES(n):
+ Con 0 deja de cortar las líneas largas, con 1 vuelve a cortarlas.
+ Otros valores: reservados.
+
+-------------------------------------------------------------------------------
+
+Como crear un template para una FPGA:
+-------------------------------------
+
+Autor: Salvador E. Tropea
+
+A) Crear un .SVF válido para esa FPGA:
+
+1) Obtener un .bit para la FPGA en cuestión.
+2) Abrir el impact:
+$ . /usr/local/ISEWb/settings.sh
+$ impact
+3) Elegir "I want to (*) Create a new project", Ok. (Darle un nombre si se
+quiere).
+4) Elegir "(*) Prepare a boundary-scan file [SVF]", Finish.
+5) Elegir un nombre para el SVF.
+6) Elegir el .bit.
+7) Presionar el botón derecho sobre la FPGA y elegir "Program", Ok.
+8) Salir del impact
+
+Automáticamente es:
+
+setPreference -pref AutoSignature:FALSE
+setPreference -pref KeepSVF:FALSE
+setPreference -pref ConcurrentMode:FALSE
+setPreference -pref UseHighz:FALSE
+setPreference -pref UserLevel:NOVICE
+setPreference -pref svfUseTime:FALSE
+setMode -bs
+setMode -bs
+setCable -port svf -file "salida.svf"
+addDevice -p 1 -file "archivo.bit"
+Program -p 1 -s -defaultVersion 0
+
+B) Crear un nuevo template (ej: alg_Virtex_4.svft)
+
+1) Abrir un template que ya exista para usarlo de guía.
+2) Borrar "FREQUENCY 1E6 HZ;"
+3) Reemplazar: $ID$ y $IDMASK$ en la parte que dice "Loading device with
+'idcode' instruction.". (f167c093)
+4) Reemplazar la megalínea del bitstream por:
+SDR $SBITS$ TDI ($DATA_INV(-1)$) SMASK ($FILL(0xFF,-1)$);
+
+C) Probar su funcionamiento
+
+1) Colocar el nuevo template en /usr/share/bit2svf/
+2) Editar /usr/share/bit2svf/DEVICES agregando el ID de la FPGA y el algoritmo
+a usar:
+
+// Virtex 4 family (10 bits IR)
+XC4VLX25, f167c093, 0fffffff, alg_Virtex_4, VOID, 0l
+
+3) Probar el template:
+
+$ bit2svf display_test_lx25.bit v4-b2s.svf XC4VLX25
+
+Esto genera v4-b2s.svf que debería ser practicamente idéntico al generado por
+impact.
+Nota: En este caso observé que el impact agrega 32 bits en 0 extra al
+bitstream. Esto no parece ser indispensable y sospecho que sirve para
+"limpiar/vaciar" la cadena.
+4) Si todo fue OK se puede probar con el dispositivo:
+
+$ jbit display_test_lx25.bit XC4VLX25
+
+
+-------------------------------------------------------------------------------
+
+Como crear un template para una PROM:
+-------------------------------------
+
+Autor: Salvador E. Tropea
+
+A) Crear un archivo de PROM válido.
+
+1) Obtener un .bit para la FPGA en cuestión.
+2) Abrir el impact:
+$ . /usr/local/ISEWb/settings.sh
+$ impact
+3) Elegir "I want to (*) Prepare a ROM file", Ok. (Darle un nombre si se
+quiere).
+4) Elegir "I want to target a (*) Xilinx PROM", "PROM File name" darle un
+nombre. Next. (Ojo con el path).
+5) Elegir la PROM y Add, luego Next.
+6) Agregar el .bit
+7) Elegir "Generate File ..." dentro de las acciones disponibles (la única).
+8) Esto genera un .MCS con el contenido para la PROM.
+
+B) Crear un .SVF válido para esa PROM. Esto es similar a la FPGA, la única
+diferencia es que le especificamos el .MCS en lugar de un .bit. En este caso
+nos preguntará cual es el dispositivo haciendo un guess de cual se trata. Esto
+es porque el .mcs es un bitstream crudo y no dice para que dispositivo se
+hizo.
+Durante este proceso se pueden elegir opciones como si la PROM se conecta en
+paralelo y si se incluye verificación. Además hay que elegir que primero la
+borre.
+
+B) Crear un nuevo template o usar uno ya hecho. Esto es como con la FPGA.
+
+C) Probar su funcionamiento. Esto es más o menos lo mismo que con la FPGA. La
+principal diferencia con las PROMs es que acá es necesario configurar su tamaño
+y el tamaño de la caché o página donde se guardarán temporalmente los datos:
+
+// XCFxxP memories
+XCF08P , f5057093, 0fffffff, alg_XCFP ,8192 , 0x100000
+
diff --git a/fpga/xilinx/programmer/bit2svf/templates/alg_18V.svft b/fpga/xilinx/programmer/bit2svf/templates/alg_18V.svft
new file mode 100644
index 0000000..e754da1
--- /dev/null
+++ b/fpga/xilinx/programmer/bit2svf/templates/alg_18V.svft
@@ -0,0 +1,192 @@
+//Info: Sample template for programming XILINX XC18V01 PROMS
+//Info: Created with output from Impact
+
+--LITERAL START
+TRST OFF;
+ENDIR IDLE;
+ENDDR IDLE;
+STATE RESET;
+STATE IDLE;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+//Loading device with 'idcode' instruction.
+SIR 8 TDI (fe) SMASK (ff) ;
+SDR 32 TDI (00000000) SMASK (ffffffff) TDO ($ID$) MASK ($IDMASK$) ;
+//Loading device with 'conld' instruction.
+SIR 8 TDI (f0) ;
+RUNTEST 110000 TCK;
+//Check for Read/Write Protect.
+SIR 8 TDI (ff) TDO (01) MASK (03) ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+STATE RESET;
+// Loading devices with 'ispen' or 'bypass' instruction.
+SIR 8 TDI (e8) ;
+SDR 6 TDI (34) SMASK (3f) ;
+// Loading device with 'faddr' instruction.
+SIR 8 TDI (eb) ;
+SDR 16 TDI (0001) SMASK (ffff) ;
+RUNTEST 1 TCK;
+RUNTEST 1 TCK;
+// Loading device with 'ferase' instruction.
+SIR 8 TDI (ec) ;
+RUNTEST 1 TCK;
+RUNTEST 15000000 TCK;
+// Loading devices with 'conld' or 'bypass' instruction.
+SIR 8 TDI (f0) ;
+RUNTEST 110000 TCK;
+STATE RESET;
+// Loading devices with 'ispen' or 'bypass' instruction.
+SIR 8 TDI (e8) ;
+SDR 6 TDI (34) SMASK (3f) ;
+--END
+
+$ADDRESS(0x0000)$
+$STEP(0x0020)$
+
+
+--REPEAT START
+// Loading device with a 'fdata0' instruction.
+SIR 8 TDI (ed) ;
+SDR $BSIZE$ TDI ($DATA_INV(BSIZEB)$) SMASK ($FILL(0xFF,BSIZEB)$) ;
+ENDIR IDLE;
+RUNTEST 1 TCK;
+RUNTEST 1 TCK;
+// Loading device with a 'faddr' instruction.
+SIR 8 TDI (eb) ;
+SDR 16 TDI ($ADDRESS$) SMASK (ffff) ;
+RUNTEST 1 TCK;
+RUNTEST 1 TCK;
+// Loading device with a 'fpgm' instruction.
+ENDIR IRPAUSE;
+SIR 8 TDI (ea) ;
+RUNTEST 1 TCK;
+RUNTEST 14000 TCK;
+--END
+
+--LITERAL START
+// Loading device with a 'faddr' instruction.
+SIR 8 TDI (eb) ;
+SDR 16 TDI (0001) ;
+ENDIR IDLE;
+RUNTEST 1 TCK;
+// Loading device with 'serase' instruction.
+SIR 8 TDI (0a) ;
+RUNTEST 37000 TCK;
+// Loading devices with 'conld' or 'bypass' instruction.
+SIR 8 TDI (f0) ;
+RUNTEST 110000 TCK;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+//Loading device with 'ispen' instruction.
+SIR 8 TDI (e8) ;
+SDR 6 TDI (34) SMASK (3f) ;
+//Loading device with 'conld' instruction.
+SIR 8 TDI (f0) ;
+RUNTEST 110000 TCK;
+//Loading device with 'ispen' instruction.
+SIR 8 TDI (e8) ;
+SDR 6 TDI (34) ;
+--END
+
+$REWIND$
+$ADDRESS(0x0000)$
+$STEP(0x0040)$
+
+--REPEAT START
+// Loading device with a 'faddr' instruction.
+SIR 8 TDI (eb) ;
+SDR 16 TDI ($ADDRESS$) SMASK (ffff) ;
+RUNTEST 1 TCK;
+RUNTEST 1 TCK;
+// Loading device with a 'fvfy0' instruction.
+SIR 8 TDI (ef) ;
+RUNTEST 1 TCK;
+RUNTEST 50 TCK;
+SDR $BSIZE2$ TDI ($FILL(0x00,BSIZEB2)$) SMASK ($FILL(0xFF,BSIZEB2)$) TDO ($DATA_INV(BSIZEB2)$) MASK ($FILL(0xFF,BSIZEB2)$) ;
+--END
+
+
+--REPEAT UNTIL MSIZE
+// Loading device with a 'faddr' instruction.
+SIR 8 TDI (eb) ;
+SDR 16 TDI ($ADDRESS$) SMASK (ffff) ;
+RUNTEST 1 TCK;
+RUNTEST 1 TCK;
+// Loading device with a 'fvfy0' instruction.
+SIR 8 TDI (ef) ;
+RUNTEST 1 TCK;
+RUNTEST 50 TCK;
+SDR $BSIZE2$ TDI ($FILL(0xFF,BSIZEB2)$) SMASK ($FILL(0xFF,BSIZEB2)$) TDO ($FILL(0xFF,BSIZEB2)$) MASK ($FILL(0xFF,BSIZEB2)$) ;
+--END
+
+--LITERAL START
+//Loading device with 'conld' instruction.
+SIR 8 TDI (f0) ;
+RUNTEST 110000 TCK;
+//Loading device with 'ispen' instruction.
+SIR 8 TDI (e8) ;
+SDR 6 TDI (34) SMASK (3f) ;
+//Loading device with 'ispen' instruction.
+SIR 8 TDI (e8) ;
+SDR 6 TDI (34) ;
+// Loading device with a 'faddr' instruction.
+SIR 8 TDI (eb) TDO (00) MASK (00) ;
+SDR 16 TDI (4000) SMASK (ffff) ;
+RUNTEST 1 TCK;
+RUNTEST 1 TCK;
+// Loading device with a 'fdata3' instruction.
+SIR 8 TDI (f3) TDO (00) ;
+SDR 6 TDI (1f) SMASK (3f) TDO (00) MASK (00) ;
+// Loading device with a 'fpgm' instruction.
+SIR 8 TDI (ea) TDO (00) ;
+RUNTEST 1 TCK;
+RUNTEST 14000 TCK;
+// Loading device with a 'fvfy3' instruction.
+SIR 8 TDI (e2) TDO (00) ;
+RUNTEST 1 TCK;
+RUNTEST 50 TCK;
+SDR 6 TDI (1f) TDO (1f) ;
+//Loading device with 'conld' instruction.
+SIR 8 TDI (f0) ;
+RUNTEST 110000 TCK;
+//Loading device with 'ispen' instruction.
+SIR 8 TDI (e8) ;
+SDR 6 TDI (34) ;
+//Loading device with 'conld' instruction.
+SIR 8 TDI (f0) ;
+RUNTEST 110000 TCK;
+// Loading device with a 'config' instruction.
+SIR 8 TDI (ee) TDO (00) ;
+RUNTEST 50 TCK;
+//Loading device with 'bypass' instruction.
+SIR 8 TDI (ff) ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+SIR 8 TDI (ff) ;
+SDR 1 TDI (00) SMASK (01) ;
+--END
diff --git a/fpga/xilinx/programmer/bit2svf/templates/alg_Spartan_3.svft b/fpga/xilinx/programmer/bit2svf/templates/alg_Spartan_3.svft
new file mode 100644
index 0000000..d2dc978
--- /dev/null
+++ b/fpga/xilinx/programmer/bit2svf/templates/alg_Spartan_3.svft
@@ -0,0 +1,83 @@
+//Info: Sample template for programming XILINX Spartan 3 FPGA
+//Info: Created with output from Impact
+
+--LITERAL START
+TRST OFF;
+ENDIR IDLE;
+ENDDR IDLE;
+STATE RESET;
+STATE IDLE;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+//Loading device with 'idcode' instruction.
+SIR 6 TDI (09) SMASK (3f) ;
+SDR 32 TDI (00000000) SMASK (ffffffff) TDO ($ID$) MASK ($IDMASK$) ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+//Loading device with 'idcode' instruction.
+SIR 6 TDI (09) ;
+SDR 32 TDI (00000000) TDO ($ID$) ;
+//Loading device with 'bypass' instruction.
+SIR 6 TDI (3f) ;
+// Loading device with a `jprogram` instruction.
+SIR 6 TDI (0b) ;
+RUNTEST 1 TCK;
+// Loading device with a `bypass` instruction.
+SIR 6 TDI (3f) ;
+RUNTEST 14000 TCK;
+// Loading device with a `cfg_in` instruction.
+SIR 6 TDI (05) ;
+SDR 192 TDI (0000000000000000e00000008001000c66aa9955ffffffff) SMASK (ffffffffffffffffffffffffffffffffffffffffffffffff) ;
+// Loading device with a `jshutdown` instruction.
+SIR 6 TDI (0d) ;
+RUNTEST 12 TCK;
+STATE RESET;
+// Loading device with a `cfg_in` instruction.
+SIR 6 TDI (05) ;
+SDR 64 TDI (0000000000000000) SMASK (ffffffffffffffff) ;
+SIR 6 TDI (05) TDO (00) MASK (00) ;
+SDR $SBITS$ TDI ($DATA_INV(-1)$) SMASK ($FILL(0xFF,-1)$);
+// Loading device with a `jstart` instruction.
+SIR 6 TDI (0c) ;
+RUNTEST 12 TCK;
+//Loading device with 'bypass' instruction.
+SIR 6 TDI (3f) ;
+//Loading device with 'bypass' instruction.
+SIR 6 TDI (3f) ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+// Loading device with a `jstart` instruction.
+SIR 6 TDI (0c) ;
+RUNTEST 12 TCK;
+//Checking done pin status.
+//Loading device with 'Bypass' instruction.
+SIR 6 TDI (3f) TDO (21) MASK (20) ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+SIR 6 TDI (3f) ;
+SDR 1 TDI (00) SMASK (01) ;
+--END
diff --git a/fpga/xilinx/programmer/bit2svf/templates/alg_Spartan_II.svft b/fpga/xilinx/programmer/bit2svf/templates/alg_Spartan_II.svft
new file mode 100644
index 0000000..8ef16a4
--- /dev/null
+++ b/fpga/xilinx/programmer/bit2svf/templates/alg_Spartan_II.svft
@@ -0,0 +1,95 @@
+//Info: Sample template for programming XILINX SpartanII FPGA
+//Info: Created with output from Impact
+
+--LITERAL START
+TRST OFF;
+ENDIR IDLE;
+ENDDR IDLE;
+STATE RESET;
+STATE IDLE;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+//Loading device with 'idcode' instruction.
+SIR 5 TDI (09) SMASK (1f) ;
+SDR 32 TDI (00000000) SMASK (ffffffff) TDO ($ID$) MASK ($IDMASK$) ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+//Loading device with 'idcode' instruction.
+SIR 5 TDI (09) ;
+SDR 32 TDI (00000000) TDO ($ID$) ;
+//Loading device with 'bypass' instruction.
+SIR 5 TDI (1f) ;
+STATE RESET;
+// Loading device with a `cfg_in` instruction.
+SIR 5 TDI (05) ;
+SDR 288 TDI (00000000e00000008001000ca00000008001000cbcfd05008004800c66aa995500000000) SMASK (ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) ;
+STATE RESET;
+// Loading device with a `jstart` instruction.
+SIR 5 TDI (0c) ;
+SDR 13 TDI (0000) SMASK (1fff) ;
+STATE RESET;
+// Loading device with a `cfg_in` instruction.
+SIR 5 TDI (05) ;
+SDR 352 TDI (00000000e00000008001000ca00000008001000cfffc05008004800c100000008001000c66aa995500000000) SMASK (ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) ;
+STATE RESET;
+// Loading device with a `jstart` instruction.
+SIR 5 TDI (0c) ;
+SDR 13 TDI (0000) SMASK (1fff) ;
+STATE RESET;
+// Loading device with a `cfg_in` instruction.
+SIR 5 TDI (05) ;
+SDR 288 TDI (00000000e00000008001000ca00000008001000cb4fd05008004800c66aa995500000000) SMASK (ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) ;
+STATE RESET;
+// Loading device with a `jstart` instruction.
+SIR 5 TDI (0c) ;
+SDR 13 TDI (0000) SMASK (1fff) ;
+STATE RESET;
+// Loading device with a `cfg_in` instruction.
+SIR 5 TDI (05) ;
+
+SDR $SBITS$ TDI ($DATA_INV(-1)$) SMASK ($FILL(0xFF,-1)$);
+
+STATE RESET;
+// Loading device with a `jstart` instruction.
+SIR 5 TDI (0c) ;
+SDR 13 TDI (0000) SMASK (1fff) ;
+STATE RESET;
+//Loading device with 'bypass' instruction.
+SIR 5 TDI (1f) ;
+//Loading device with 'bypass' instruction.
+SIR 5 TDI (1f) ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+STATE RESET;
+//Checking done pin status.
+//Loading device with 'Bypass' instruction.
+SIR 5 TDI (1f) TDO (05) MASK (04) ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+SIR 5 TDI (1f) ;
+SDR 1 TDI (00) SMASK (01) ;
+--END
diff --git a/fpga/xilinx/programmer/bit2svf/templates/alg_Virtex_4.svft b/fpga/xilinx/programmer/bit2svf/templates/alg_Virtex_4.svft
new file mode 100644
index 0000000..1bd73f4
--- /dev/null
+++ b/fpga/xilinx/programmer/bit2svf/templates/alg_Virtex_4.svft
@@ -0,0 +1,111 @@
+//Info: Sample template for programming XILINX Virtex 4 FPGA
+//Info: Created with output from Impact
+
+--LITERAL START
+TRST OFF;
+ENDIR IDLE;
+ENDDR IDLE;
+STATE RESET;
+STATE IDLE;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+//Loading device with 'idcode' instruction.
+SIR 10 TDI (03c9) SMASK (03ff) ;
+SDR 32 TDI (00000000) SMASK (ffffffff) TDO ($ID$) MASK ($IDMASK$) ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+//Loading device with 'idcode' instruction.
+SIR 10 TDI (03c9) ;
+SDR 32 TDI (00000000) TDO ($ID$) ;
+//Loading device with 'bypass' instruction.
+SIR 10 TDI (03ff) ;
+// Loading device with a `ISC_ENABLE` instruction.
+ENDIR IRPAUSE;
+SIR 10 TDI (03d0) ;
+SDR 5 TDI (15) SMASK (1f) ;
+ENDIR IDLE;
+RUNTEST 12 TCK;
+// Loading device with a `ISC_PROGRAM_SECURITY` instruction.
+ENDIR IRPAUSE;
+SIR 10 TDI (03d2) ;
+SDR 32 TDI (00000000) SMASK (ffffffff) ;
+ENDIR IDLE;
+RUNTEST 9 TCK;
+// Loading device with a `ISC_DISABLE` instruction.
+SIR 10 TDI (03d7) ;
+RUNTEST 12 TCK;
+// Loading device with a `jprogram` instruction.
+SIR 10 TDI (03cb) ;
+RUNTEST 1 TCK;
+// Loading device with a `bypass` instruction.
+SIR 10 TDI (03ff) ;
+RUNTEST 21000 TCK;
+// Loading device with a `cfg_in` instruction.
+SIR 10 TDI (03c5) ;
+RUNTEST 100000 TCK;
+// Check init_complete in ircapture.
+//Loading device with 'Bypass' instruction.
+SIR 10 TDI (03ff) TDO (0010) MASK (0010) ;
+// Loading device with a `jprogram` instruction.
+SIR 10 TDI (03cb) ;
+RUNTEST 1 TCK;
+// Loading device with a `bypass` instruction.
+SIR 10 TDI (03ff) ;
+RUNTEST 21000 TCK;
+// Loading device with a `cfg_in` instruction.
+SIR 10 TDI (03c5) ;
+RUNTEST 100000 TCK;
+// Check init_complete in ircapture.
+//Loading device with 'Bypass' instruction.
+SIR 10 TDI (03ff) TDO (0010) ;
+STATE RESET;
+// Loading device with a `cfg_in` instruction.
+SIR 10 TDI (03c5) TDO (0000) MASK (0000) ;
+SDR $SBITS$ TDI ($DATA_INV(-1)$) SMASK ($FILL(0xFF,-1)$);
+// Loading device with a `jstart` instruction.
+SIR 10 TDI (03cc) ;
+RUNTEST 12 TCK;
+//Loading device with 'bypass' instruction.
+SIR 10 TDI (03ff) ;
+//Loading device with 'bypass' instruction.
+SIR 10 TDI (03ff) ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+// Loading device with a `jstart` instruction.
+SIR 10 TDI (03cc) ;
+RUNTEST 12 TCK;
+// Loading device with a `cfg_in` instruction.
+SIR 10 TDI (03c5) ;
+SDR 224 TDI (0000000000000000200000008001000c0000000466aa9955ffffffff) SMASK (ffffffffffffffffffffffffffffffffffffffffffffffffffffffff) ;
+//Checking done pin status.
+//Loading device with 'Bypass' instruction.
+SIR 10 TDI (03ff) TDO (0021) MASK (0020) ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+SIR 10 TDI (03ff) ;
+SDR 1 TDI (00) SMASK (01) ;
+--END
diff --git a/fpga/xilinx/programmer/bit2svf/templates/alg_XCF.svft b/fpga/xilinx/programmer/bit2svf/templates/alg_XCF.svft
new file mode 100644
index 0000000..73138c3
--- /dev/null
+++ b/fpga/xilinx/programmer/bit2svf/templates/alg_XCF.svft
@@ -0,0 +1,190 @@
+//Info: Sample template for programming XILINX XCFxx PROMS
+//Info: Created with output from Impact
+
+--LITERAL START
+TRST OFF;
+ENDIR IDLE;
+ENDDR IDLE;
+STATE RESET;
+STATE IDLE;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+//Loading device with 'idcode' instruction.
+SIR 8 TDI (fe) SMASK (ff) ;
+SDR 32 TDI (00000000) SMASK (ffffffff) TDO ($ID$) MASK ($IDMASK$) ;
+//Loading device with 'conld' instruction.
+SIR 8 TDI (f0) ;
+RUNTEST 110000 TCK;
+//Check for Read/Write Protect.
+SIR 8 TDI (ff) TDO (01) MASK (07) ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+STATE RESET;
+// Loading devices with 'ispen' or 'bypass' instruction.
+SIR 8 TDI (e8) ;
+SDR 6 TDI (34) SMASK (3f) ;
+// Loading device with 'faddr' instruction.
+SIR 8 TDI (eb) ;
+SDR 16 TDI (0001) SMASK (ffff) ;
+RUNTEST 1 TCK;
+RUNTEST 1 TCK;
+// Loading device with 'ferase' instruction.
+SIR 8 TDI (ec) ;
+RUNTEST 1 TCK;
+RUNTEST 15000000 TCK;
+// Loading devices with 'conld' or 'bypass' instruction.
+SIR 8 TDI (f0) ;
+RUNTEST 110000 TCK;
+STATE RESET;
+// Loading devices with 'ispen' or 'bypass' instruction.
+SIR 8 TDI (e8) ;
+SDR 6 TDI (34) SMASK (3f) ;
+--END
+
+$ADDRESS(0x0000)$
+$STEP(0x0020)$
+
+--REPEAT START
+// Loading device with a 'fdata0' instruction.
+SIR 8 TDI (ed) ;
+SDR $BSIZE$ TDI ($DATA_INV(BSIZEB)$) SMASK ($FILL(0xFF,BSIZEB)$) ;
+ENDIR IDLE;
+RUNTEST 1 TCK;
+RUNTEST 1 TCK;
+// Loading device with a 'faddr' instruction.
+SIR 8 TDI (eb) ;
+SDR 16 TDI ($ADDRESS$) SMASK (ffff) ;
+RUNTEST 1 TCK;
+RUNTEST 1 TCK;
+// Loading device with a 'fpgm' instruction.
+ENDIR IRPAUSE;
+SIR 8 TDI (ea) ;
+RUNTEST 1 TCK;
+RUNTEST 14000 TCK;
+--END
+
+--LITERAL START
+// Loading device with a 'faddr' instruction.
+SIR 8 TDI (eb) ;
+SDR 16 TDI (0001) ;
+ENDIR IDLE;
+RUNTEST 1 TCK;
+// Loading device with 'serase' instruction.
+SIR 8 TDI (0a) ;
+RUNTEST 37000 TCK;
+// Loading devices with 'conld' or 'bypass' instruction.
+SIR 8 TDI (f0) ;
+RUNTEST 110000 TCK;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+//Loading device with 'ispen' instruction.
+SIR 8 TDI (e8) ;
+SDR 6 TDI (34) SMASK (3f) ;
+//Loading device with 'conld' instruction.
+SIR 8 TDI (f0) ;
+RUNTEST 110000 TCK;
+//Loading device with 'ispen' instruction.
+SIR 8 TDI (e8) ;
+SDR 6 TDI (34) ;
+--END
+
+$REWIND$
+$ADDRESS(0x0000)$
+$STEP(0x0040)$
+
+--REPEAT START
+// Loading device with a 'faddr' instruction.
+SIR 8 TDI (eb) ;
+SDR 16 TDI ($ADDRESS$) SMASK (ffff) ;
+RUNTEST 1 TCK;
+RUNTEST 1 TCK;
+// Loading device with a 'fvfy0' instruction.
+SIR 8 TDI (ef) ;
+RUNTEST 1 TCK;
+RUNTEST 50 TCK;
+SDR $BSIZE2$ TDI ($FILL(0x00,BSIZEB2)$) SMASK ($FILL(0xFF,BSIZEB2)$) TDO ($DATA_INV(BSIZEB2)$) MASK ($FILL(0xFF,BSIZEB2)$) ;
+--END
+
+--REPEAT UNTIL MSIZE
+// Loading device with a 'faddr' instruction.
+SIR 8 TDI (eb) ;
+SDR 16 TDI ($ADDRESS$) SMASK (ffff) ;
+RUNTEST 1 TCK;
+RUNTEST 1 TCK;
+// Loading device with a 'fvfy0' instruction.
+SIR 8 TDI (ef) ;
+RUNTEST 1 TCK;
+RUNTEST 50 TCK;
+SDR $BSIZE2$ TDI ($FILL(0xFF,BSIZEB2)$) SMASK ($FILL(0xFF,BSIZEB2)$) TDO ($FILL(0xFF,BSIZEB2)$) MASK ($FILL(0xFF,BSIZEB2)$) ;
+--END
+
+--LITERAL START
+//Loading device with 'conld' instruction.
+SIR 8 TDI (f0) ;
+RUNTEST 110000 TCK;
+//Loading device with 'ispen' instruction.
+SIR 8 TDI (e8) ;
+SDR 6 TDI (34) SMASK (3f) ;
+//Loading device with 'ispen' instruction.
+SIR 8 TDI (e8) ;
+SDR 6 TDI (34) ;
+// Loading device with a 'faddr' instruction.
+SIR 8 TDI (eb) TDO (00) MASK (00) ;
+SDR 16 TDI (8000) SMASK (ffff) ;
+RUNTEST 1 TCK;
+RUNTEST 1 TCK;
+// Loading device with a 'fdata3' instruction.
+SIR 8 TDI (f3) TDO (00) ;
+SDR 3 TDI (07) SMASK (07) TDO (00) MASK (00) ;
+// Loading device with a 'fpgm' instruction.
+SIR 8 TDI (ea) TDO (00) ;
+RUNTEST 1 TCK;
+RUNTEST 14000 TCK;
+// Loading device with a 'fvfy3' instruction.
+SIR 8 TDI (e2) TDO (00) ;
+RUNTEST 1 TCK;
+RUNTEST 50 TCK;
+SDR 3 TDI (07) TDO (07) ;
+//Loading device with 'conld' instruction.
+SIR 8 TDI (f0) ;
+RUNTEST 110000 TCK;
+//Loading device with 'ispen' instruction.
+SIR 8 TDI (e8) ;
+SDR 6 TDI (34) SMASK (3f) ;
+//Loading device with 'conld' instruction.
+SIR 8 TDI (f0) ;
+RUNTEST 110000 TCK;
+// Loading device with a 'config' instruction.
+SIR 8 TDI (ee) TDO (00) ;
+RUNTEST 50 TCK;
+//Loading device with 'bypass' instruction.
+SIR 8 TDI (ff) ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+SIR 8 TDI (ff) ;
+SDR 1 TDI (00) SMASK (01) ;
+--END
diff --git a/fpga/xilinx/programmer/bit2svf/templates/alg_XCFP.svft b/fpga/xilinx/programmer/bit2svf/templates/alg_XCFP.svft
new file mode 100644
index 0000000..214fa4a
--- /dev/null
+++ b/fpga/xilinx/programmer/bit2svf/templates/alg_XCFP.svft
@@ -0,0 +1,208 @@
+//Info: Sample template for programming XILINX XCFxxP PROMS
+//Info: Created with output from Impact
+
+--LITERAL START
+TRST OFF;
+ENDIR IDLE;
+ENDDR IDLE;
+STATE RESET;
+STATE IDLE;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+//Loading device with 'ispen' instruction.
+SIR 16 TDI (00e8) SMASK (ffff) ;
+SDR 8 TDI (03) SMASK (ff) ;
+//Loading device with 'idcode' instruction.
+SIR 16 TDI (00fe) ;
+SDR 32 TDI (00000000) SMASK (ffffffff) TDO ($ID$) MASK ($IDMASK$) ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+STATE RESET;
+// Loading devices with 'ispen' or 'bypass' instruction.
+SIR 16 TDI (00e8) ;
+SDR 8 TDI (d0) SMASK (ff) ;
+// Loading device with a 'XSC_UNLOCK' instruction.
+SIR 16 TDI (aa55) ;
+SDR 24 TDI (00003f) SMASK (ffffff) ;
+// Loading device witha 'ISC_ERASE' instruction.
+ENDIR IRPAUSE;
+SIR 16 TDI (00ec) ;
+SDR 24 TDI (00003f) ;
+ENDIR IDLE;
+RUNTEST 140000000 TCK;
+// Loading devices with 'conld' or 'bypass' instruction.
+SIR 16 TDI (00f0) ;
+RUNTEST 50 TCK;
+STATE RESET;
+// Loading devices with 'ispen' or 'bypass' instruction.
+SIR 16 TDI (00e8) ;
+SDR 8 TDI (d0) SMASK (ff) ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+//Loading device with 'ispen' instruction.
+SIR 16 TDI (00e8) ;
+SDR 8 TDI (03) ;
+// Loading device with 'XSC_DATA_BTC' instruction.
+SIR 16 TDI (00f2) ;
+SDR 32 TDI (ffffffe0) SMASK (ffffffff) TDO (00000000) MASK (00000000) ;
+// Loading device with a 'ISC_PROGRAM' instruction.
+SIR 16 TDI (00ea) ;
+RUNTEST 120 TCK;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+STATE RESET;
+// Loading devices with 'ispen' or 'bypass' instruction.
+SIR 16 TDI (00e8) ;
+SDR 8 TDI (d0) SMASK (ff) ;
+--END
+
+$CUTLINES(0)$
+
+--LITERAL START
+// Loading device with a 'ISC_DATA_SHIFT' instruction.
+SIR 16 TDI (00ed) ;
+SDR 256 TDI ($DATA_INV(32)$) SMASK ($FILL(0xFF,32)$) ;
+// Loading device with a 'ISC_ADDRESS_SHIFT' instruction.
+SIR 16 TDI (00eb) ;
+SDR 24 TDI (000000) SMASK (ffffff) ;
+// Loading device with a 'ISC_PROGRAM' instruction.
+SIR 16 TDI (00ea) ;
+RUNTEST 1000 TCK;
+// Loading device with a 'ISC_DATA_SHIFT' instruction.
+SIR 16 TDI (00ed) ;
+SDR 256 TDI ($DATA_INV(32)$) SMASK ($FILL(0xFF,32)$) ;
+// Loading device with a 'ISC_PROGRAM' instruction.
+SIR 16 TDI (00ea) ;
+RUNTEST 1000 TCK;
+--END
+
+--REPEAT START
+// Loading device with a 'ISC_DATA_SHIFT' instruction.
+SIR 16 TDI (00ed) ;
+SDR 256 TDI ($DATA_INV(32)$) ;
+// Loading device with a 'ISC_PROGRAM' instruction.
+SIR 16 TDI (00ea) ;
+RUNTEST 1000 TCK;
+--END
+
+$CUTLINES(1)$
+
+--LITERAL START
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+//Loading device with 'ispen' instruction.
+SIR 16 TDI (00e8) ;
+SDR 8 TDI (03) SMASK (ff) ;
+// Loading device with a 'XSC_DATA_SUCR' instruction.
+SIR 16 TDI (000e) ;
+SDR 16 TDI (fffc) SMASK (ffff) TDO (0000) MASK (0000) ;
+// Loading device with a 'ISC_PROGRAM' instruction.
+SIR 16 TDI (00ea) ;
+RUNTEST 60 TCK;
+//Loading device with 'ispen' instruction.
+SIR 16 TDI (00e8) ;
+SDR 8 TDI (03) SMASK (ff) ;
+//Loading device with 'ispen' instruction.
+SIR 16 TDI (00e8) ;
+SDR 8 TDI (03) ;
+// Loading device witha 'XSC_DATA_CCB' instruction.
+SIR 16 TDI (000c) ;
+SDR 16 TDI (fff9) SMASK (ffff) TDO (0000) MASK (0000) ;
+// Loading device with a 'ISC_PROGRAM' instruction.
+SIR 16 TDI (00ea) ;
+RUNTEST 60 TCK;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+// Loading devices with 'conld' or 'bypass' instruction.
+SIR 16 TDI (00f0) ;
+RUNTEST 50 TCK;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+//Loading device with 'ispen' instruction.
+SIR 16 TDI (00e8) ;
+SDR 8 TDI (03) SMASK (ff) ;
+// Loading device with 'XSC_DATA_DONE' instruction.
+SIR 16 TDI (0009) ;
+SDR 8 TDI (ce) TDO (00) MASK (00) ;
+// Loading device with a 'ISC_PROGRAM' instruction.
+SIR 16 TDI (00ea) ;
+RUNTEST 60 TCK;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+//Loading device with 'ispen' instruction.
+SIR 16 TDI (00e8) ;
+SDR 8 TDI (03) ;
+--END
+
+$REWIND$
+$ADDRESS(0x0000)$
+$STEP(0x0400)$
+
+--REPEAT START
+// Loading device with a 'ISC_ADDRESS_SHIFT' instruction.
+SIR 16 TDI (00eb) ;
+SDR 24 TDI ($ADDRESS$) SMASK (ffffff) ;
+// Loading device with a 'XSC_READ' instruction.
+SIR 16 TDI (00ef) ;
+RUNTEST 15 TCK;
+SDR $BSIZE$ TDI ($FILL(0x00,BSIZEB)$) SMASK ($FILL(0xFF,BSIZEB)$) TDO ($DATA_INV(BSIZEB)$) MASK ($FILL(0xFF,BSIZEB)$) ;
+--END
+
+--LITERAL START
+// Check Device status.
+SIR 16 TDI (00e3) ;
+SDR 8 TDI (00) SMASK (ff) TDO (36) MASK (7f) ;
+//Loading device with 'conld' instruction.
+SIR 16 TDI (00f0) ;
+RUNTEST 50 TCK;
+//Loading device with 'ispen' instruction.
+SIR 16 TDI (00e8) ;
+SDR 8 TDI (03) ;
+//Loading device with 'conld' instruction.
+SIR 16 TDI (00f0) ;
+RUNTEST 50 TCK;
+// Loading device with a 'config' instruction.
+SIR 16 TDI (00ee) TDO (0000) MASK (0000) ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+TIR 0 ;
+HIR 0 ;
+HDR 0 ;
+TDR 0 ;
+TIR 0 ;
+HIR 0 ;
+TDR 0 ;
+HDR 0 ;
+SIR 16 TDI (ffff) ;
+SDR 1 TDI (00) SMASK (01) ;
+--END