proyecto de ingenierÍ a electrÓnica

73
EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S 1 PROYECTO DE INGENIERÍ A ELECTRÓNICA EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S PARA OBTENER EL TÍ TULO DE : INGENIERIO EN ELECTRÓNICA EN COMPUTACIÓN Asesor : M.I. Oscar Yáñez Suárez. Alumno: Oscar Ruiz de Jesús. 09 de Marzo de 2004.

Upload: others

Post on 25-Jun-2022

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

1

PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

PARA OBTENER EL TÍTULO DE :INGENIERIO EN ELECTRÓNICA EN COMPUTACIÓN

Asesor : M.I. Oscar Yáñez Suárez.

Alumno: Oscar Ruiz de Jesús.

09 de Marzo de 2004.

Page 2: PROYECTO DE INGENIERÍ A ELECTRÓNICA
Page 3: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

2

I N D I C E

& Agradecimientos .................................................................... 3

& Abstract .................................................................................. 4

& CAPITULO 1 MARCO TEÓRICO ..................................... 51.1 Arquitectura FPGA de XILINX .............................................. 6

1.1.1 CLB, Configurable Logic Block ......................................... 71.1.2 IOB, Bloques de Entrada-Salida ...................................... 81.1.3 Bloques de Interconexión ............................................... 9

1.2 Programación FPGA de XILINX ............................................ 111.3 La Memoria PROM (EEPROM SERIAL) ................................. 11

1.3.1 Funcionamiento del protocolo I2 C .................................... 121.3.2 Condiciones de START y STOP ....................................... 121.3.3 Transferencia de Datos .................................................. 13

& CAPITULO 2 IMPLEMENTACION DEL SOFTWARE ........ 142.1 Descripción del Protocolo de Lectura/Escritura AT17LV256 .. 14

2.1.1 Instrucción de Escritura .................................................. 142.1.2 Instrucción de Lectura .................................................... 14

2.2 Información Técnica del programa AT17LV.exe ..................... 152.2.1 Programa Protocolo.c .................................................... 162.2.2 Programa Leearch.c ...................................................... 242.2.3 Programa Graficos.c ..................................................... 282.2.4 Librerí a AT17LIB.H ........................................................ 31

& CAPITULO 3 DISEÑO DE LA TARJETA ............................ 333.1 Componentes de la tarjeta de Lectura/Escritura AT17LV256 . 33

3.2 El circuito para Lectura/Escritura de la memoria AT17LV256. 34

& Conclusiones ........................................................................ 36

& Bibliografí a ............................................................................ 37

& ANEXOS AT17LV

Page 4: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

3

Agradecimientos :

A Esther por estar conmigo incondicionalmente.

A mis padres que permitieron lograr mi objetivo.

A Sebastián, por el cariño que no pude brindarle.

A mis Amigos que siempre me han apoyado.

A mi Asesor de Proyecto :

Oscar Yáñez Suárez, por confiar en mí.

Page 5: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

4

Abstract

La tecnologí a utilizada en el diseño de circuitos para propósitos educativos, ha encontrado en losdispositivos programables tales como los FPGA s de XILIN , una herramienta indispensable para eldesarrollo los circuitos digitales.

Las aplicaciones de los FPGA S van más allá de la simple implementación de lógica digital. LosFPGA S pueden ser utilizados para la implementación de arquitecturas especí ficas para acelerar algúnalgoritmo. Los sistemas basados en FPGA S pueden proporcionan un mejor desempeño que suscorrespondientes implementaciones software.

Reducir el costo que implica el hacer uso de éstos dispositivos, es el objetivo esencial de esteProyecto., Para lograrlo se implementó en lenguaje C++ el Protocolo para la Lectura y Escritura de unamemoria EEPROM SERIAL ATMEL AT17LV256 (262,144 bits), a través del puerto paralelo de unacomputadora personal , estableciendo la interfase entre la PC y la memoria.

La información grabada en la EEPROM SERIAL será la que se utilice en la reprogramaciónprácticamente ilimitada de un FPGA serie XC4005XL de XILINX , permitiendo que los alumnos desarrollencircuitos prototipo.

La EEPROM ATMEL permite que se pueda realizar una configuración de la FPGA en modo Maestro(Master) . La memoria debe ser programada previamente con el archivo .bit. Posteriormente la transferenciade los datos de la memoria al FPGA se realiza de manera serial.

La Configuración del FPGA en modo Master Serial se implementó debido a las siguientes ventajas :

• Compatibilidad con FPGA S Altera, Atmel, Spartan y Spartan II de XILIN .

• La configuración del FPGA en modo Master Serial (utiliza 3 o 4 pines del dispositivo) que, adiferencia del modo Master Parallel, permite el máximo aprovechamiento de lo pines deentrada/salida.

• La transmisión de la información de la computadora a la EEPROM a través del puertoparalelo, nos permite prescindir del grabador de memoria.

• Considerando el costo / beneficio, comparado con otras configuraciones, la Master Serialdestaca por su economí a y sencillez.

El proyecto (Emulador de ROM serial para arranque de FPGA s) servirá para que los futurosIngenieros utilicen éste dispositivo para programar a nivel hardware y así poder desarrollar nuevastecnologí as, haciendo uso del diseño de Software y la Interfase que se describen a continuación:

Page 6: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

5

CAPITULO 1 MARCO TEÓRICOPara entender la necesidad de diseñar un circuito para el arranque de un

FPGA, explicaremos la tecnologí a en que se basan éstos dispositivos programables.

Page 7: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

6

1.1 Arquitectura FPGA de XILINX

Siendo FPGA un arreglo de bloques lógicos programables colocados en unainfraestructura de interconexiones programable; es posible programar la funcionalidad delos bloques lógicos, las interconexiones entre bloques y las conexiones entre entradas ysalidas. Un FPGA es un dispositivo programable a nivel hardware. Así , un FPGAproporciona las ventajas de un procesador de propósito general y un circuitoespecializado que puede reconfigurarse las veces que sea necesario para depurar sufuncionalidad.

La funcionalidad de un FPGA se determina mediante un programa deconfiguración que se almacena en una memoria estática SRAM (aquella que puedealmacenar datos mientras se aplica energí a al circuito).

Dado que es posible efectuar una reprogramación del dispositivo, es unaarquitectura muy adecuada para el diseño de prototipos.

El Plano de base (Floorplan) del FPGA está formado por tres tipos de bloques básicosque se muestran en la figura No. 1:

1. El núcleo del FPGA es una matriz de bloques denominados CLB(Configurable Logic Blocks).

2. Bloques de Entrada/Salida, IOB (Input/Output Blocks). Están situados en laperiferia del circuito integrado, su función es la comunicación con elexterior.

3. Bloques destinados a la interconexión (Programmable Interconnect) deCLBs entre sí y con los bloques IOB.

Figura 1. Bloques que conforman un FPGA

Page 8: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

7

1.1.1- CLB, Configurable Logic Block

En la figura 2 se presenta la estructura básica de un CLB.Puede observarse que elbloque está formado por tres etapas lógicas configurables(LUT) y por dos flip-flops. Laetapa lógica configurable, está formada por 16 celdas de memoria SRAM controladas porcuatro variables de entrada que se aplican a las lí neas de dirección de la memoria (Verfigura 3). La salida de la LUT nos da la función deseada como se puede representar en latabla 1 (los términos de la función deben almacenarse previamente en la memoria), conesta estructura puede programarse: cualquier función de cuatro o cinco variables oalgunas funciones (no todas) de entre seis y nueve variables. Los flip-flops puedencargarse con un dato proveniente de la salida de la etapa lógica configurable o biendirectamente desde una entrada del CLB. Esta estrategia permite que este bloque resulteóptimo tanto para la implementación de máquinas combinacionales y secuenciales comopara la implementación de estructuras regulares tipo registros de desplazamiento.

Fig. 2 CLB serie 4000. Su núcleo lo forman 3 LUT: 2 de cuatro variables y una de 3 variables, quepermiten implementar: Cualquier función de cinco variables, o bien dos funciones de cuatro variables,o algunas funciones (no todas) de entre seis y nueve variables. Tomado del libro The Programmable LogicData Book

Page 9: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

8

figura 3. Configuracion de dos LUT de 16 bits: 2 funciones de cuatrovariables.

Tabla 1. Tabla de verdad de una función de 4 variables

1.1.2 IOB, Bloques de Entrada/Salida

Los IOBs son también bloques configurables. Están situados en la periferia delcircuito. En la figura 4 se presenta la estructura de un IOB; como puede observarseincluye dos flip-flop D que en caso necesario puede realizar funciones de buffer deentrada o de salida. Cada uno de estos bloques puede ser programado como :

• Entrada del circuito. Esta configuración permite almacenar la señal de entrada enun flip-flop D, o ser traspasada directamente a los CLBs.

• Salida del circuito. La señal de salida encuentra en primer lugar una puerta XORque permite invertir la señal de salida. La señal entonces puede ser almacenadaen un flip-flop D o atacar directamente un buffer de salida con control de altaimpedancia.

• Conexión bidireccional, entrada/salida, con control de alta impedancia

Este amplio espectro de posibilidades facilita que el dispositivo sea adaptable a ungran número de aplicaciones.

F1 F2 F3 F4 F(1..4)0 0 0 0 00 0 0 1 00 0 1 0 10 0 1 1 10 1 0 0 00 1 0 1 00 1 1 0 10 1 1 1 11 0 0 0 01 0 0 1 01 0 1 0 11 0 1 1 11 1 0 0 01 1 0 1 01 1 1 0 11 1 1 1 1

Page 10: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

9

figura 4. Estructura de un IOB serie 4000 Xilinx. Tomado del Libro The Programmable Logic Data Book

1.1.3 Bloques de interconexión

La funcionalidad del diseño queda completada por una adecuada interconexión delos CLBs, que se realiza mediante puntos de interconexión programables (PIP).

Tal como puede observarse en el plano de base de la figura 5, las lí neas deinterconexión atraviesan horizontal y verticalmente entre los diversos CLBs. En el planode base ampliado, aparecen tres tipos de recursos de interconexión.

• Conexiones directas entre CLBs vecinos• Conexiones de tipo general.• Conexiones largas para señales crí ticas

Page 11: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

10

figura 5. Interconexión entre CLBs (Direct interconec) , tipo general (utilizadas en switching matrix) yseñales crí ticas (longlines).

Page 12: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

11

1.2 Programación del FPGA de XILINX

La fase de programación consiste en cargar el contenido de la LUT de cada CLB yde toda la memoria de configuración. Como la memoria RAM es volátil, el programa deconfiguración debe cargarse en la memoria interna del FPGA cada vez que se inicia elsistema.

Son posibles varios métodos según las exigencias del sistema:

• El programa puede residir en una memoria EEPROM externa y cargarse en elmomento de arranque del FPGA.

• Alternativamente, el programa puede estar grabado en un disco y cargarse demanera controlada por un microprocesador (puede cargarse en serie o enparalelo).

• Otra solución posible consiste en alimentar continuamente al FPGA con unapequeña pila de litio.

1.3 La Memoria PROM (EEPROM SERIAL)

A diferencia de las memorias EPROM, las EEPROM o memorias eléctricamenteborrables tienen caracterí sticas que las hacen compatibles con los FPGA. A continuaciónse consideran algunas de éstas:

• La programación y el borrado de una EEPROM puede hacerse en el mismocircuito.

• Su memoria es no volátil, por lo que mantendrá todos los datos escritos enella aún después de eliminar el voltaje de alimentación.

• Tiene la capacidad de borrar eléctricamente, bytes individuales en elarreglo de la memoria..

• Una EEPROM completa puede borrarse en un intervalo de tiemporelativamente corto con respecto a las EPROM (30 minutos).

Adicionalmente a las caracterí sticas antes mencionadas, las memorias EEPROMseriales presentan las siguientes ventajas :

• Vienen en capacidades de 32 kbytes, 64 kbytes y 128 kbytes según elmodelo.

• Bajo consumo de energí a.• La lectura y grabación se realiza con 5 o 3.3 V (necesarios para interfase

con el FPGA).• Utilización de 3 pines para su configuración.• Se pueden grabar un total de 100000 veces.• Utilización del protocolo bus serie I2C

Page 13: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

12

1.3.1 Funcionamiento del Protocolo I2C (Inter-Integrated Circuit).

Este protocolo fué inventado por Philips y como su nombre lo indica es utilizadopara la comunicación entre Circuitos Integrados, utiliza dos hilos y permite intercambio dedatos entre periféricos y unidades inteligentes.Las caracterí sticas principales del bus I2C son:

• Se necesitan solamente dos lí neas, la de datos (DATA) y la de reloj (CLOCK).

• El protocolo de transferencia de datos y direcciones posibilita diseñar sistemascompletamente definidos por software.

• Los datos y direcciones se transmiten serialmente en intervalos de 8 bits.

• Se utiliza principalmente para la comunicación entre periféricos cuando la distanciano es muy grande.

Descripción básica de su funcionamiento:

El Master (Maestro) es el dispositivo que inicia la transferencia en el bus y genera la señalde Clock. El Slave (esclavo) es el dispositivo direccionado.

Las lí neas DATA (serial Data) y CLOCK (serial Clock) son bidireccionales,conectadas al positivo de la alimentación a través de resistencias de pull-up.

Cuando el bus está libre, ambas lí neas están en nivel alto. La transmisiónbidireccional serie (8-bits) de datos puede realizarse a 100Kbits/s en el modo standard o400 Kbits/s en el modo rápido. La cantidad de dispositivos que se pueden conectar al busestá limitada, solamente, por la máxima capacitancia permitida: 400 pF.

1.3.2 Condiciones de START Y STOP.

Antes de que se establezca la comunicación entre el circuito Maestro y losEsclavos, el Maestro debe informar el inicio de la transferencia de datos (condición deStart): la lí nea DATA realiza la transición a cero mientras CLOCK permanece en nivelalto. A partir de este momento comienza la transferencia de datos. Una vez terminada lacomunicación se debe informar de esta situación (condición de Stop). La lí nea DATA pasaa nivel alto mientras CLOCK permanece en estado alto. Ver Figura 6.

Page 14: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

13

figura 6 Condicion de Start (inicio) y Stop (fin) del protocolo I2C

1.3.3 Transferencia de Datos

El Maestro genera la condición de INICIO. Por cada byte transmitido, el Maestrolee el estado de la lí nea DATA, si vale 0 (impuesto por el esclavo), el proceso detransferencia continúa. Si vale 1, indica que el esclavo no valida la comunicación,entonces, el Maestro genera un bit de FIN para liberar el bus I2C. Este acuse de recibo sedenomina ACK (Acknowledge) y es una parte importante del protocolo I2C.

El protocolo de comunicación después de enviar la dirección del esclavo se añadeel bit de recepción / transmisión o lectura / escritura (R / W). Si R / W = 0 será unarecepción o lectura y si R / W = 1 será transmisión o escritura. A continuación del bit de R/ W, se enví a el bit de acuse de recibo. Tras todos estos bits, se transmiten los datos, engrupos de 8 bits cada uno, y al finalizar cada octeto se inserta un bit de Acknowledge(ACK), que en este caso puede ser producido por el esclavo o por el maestro (según seael caso de R o W) . Estos datos pueden tener una función especial dentro de la tramasegún el orden que tengan, pero esto depende del formato que tenga esta transmisión, osea, depende de los dispositivos. Para terminar la trama el maestro generará el bit deSTOP. En la figura 7 podemos ver el formato de transmisión explicado.

START DIRECCIÓNBit· 7...Bit· 0 R/W ACK DATO 1

Bit· 7...Bit· 0 ACK ............... DATO NBit· 7...Bit· 0 ACK STOP

Figura 7. formato de trasmisión del protocolo I2C

Al final de la transmisión, el Maestro genera la condición de STOP y libera el busI2C., las lí neas DATA y CLOCK pasan a estado alto.

Page 15: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

14

CAPITULO 2 IMPLEMENTACIÓN DEL SOFTWARE

El diseño de la interfase de nuestro circuito , se compone de tres etapas. Laprimera de ellas es la etapa de lectura de un archivo binario (mismo que es generadoal sintetizar modelos VHDL) que contiene la información para la programación delFPGA. La segunda etapa consiste en la transmisión de los datos del archivo utilizandocomo una Tarjeta como interfase entre el puerto paralelo y una memoria EEPROMserial externa en donde residirá el programa. Y la tercera forma parte de la interfaseentre la memoria y el FPGA; por lo que la elección de la memoria EEPROM esdeterminante para la sencillez del circuito.

Para las dos primeras etapas, se diseño el software para la lectura de un archivobinario extensión .bit, que se almacenará en un buffer cuyo enví o de los datos serealizará de acuerdo al protocolo especificado para las memorias AT17LVXXX.

2.1 Descripción del Protocolo de Lectura/Escritura de la Memoria EEPROMSERIAL AT17LV256

Los detalles del protocolo utilizado por la memoria serial AT17LV256 seencuentran en el ANEXO 1 atmel_prog. Sin embargo se enlistan algunas caracterí sticas:

• Las direcciones de la memoria, incluyendo los bytes de lectura y escritura seenví an invertidos , es decir se enví an primero los bytes más significativos (MSB) ypor último los bytes menos significativos (LSB).

• Los Datos se enví an primero los LSB y posteriormente los MSB.• El BIT para Lectura es Alto , para Escritura es Bajo • Soporta hasta 100,000 veces su grabación

2.1.1 Instrucción de Escritura consiste en :

• Una condición inicial• La dirección del dispositivo con R/W = 0• Un bit ACK proporcionada por la memoria AT17LV256• Enví o del Byte MSB de la dirección de la EEPROM• Un bit ACK proporcionada por la memoria EEPROM AT17LV256• Enví o del Byte LSB de la dirección de la EEPROM• Un bit ACK proporcionada por la memoria AT17LV256• Uno o más Bytes de Datos enviados a la memoria EEPROM AT17LV256• Después de cada Byte de Datos el bit ACK como respuesta de la EEPROM• Una condición final

2.1.2 Instrucción de Lectura consiste en :

• Una condición inicial• La dirección del dispositivo con R/W = 1• Un bit ACK proporcionada por la memoria AT17LV256• Uno o más Bytes de Datos leidos en la memoria EEPROM AT17LV256• Después de cada Byte de Datos el bit ACK como respuesta de la EEPROM• Un condición de terminación por parte del programador

Page 16: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

15

2.2 Información Técnica del Programa AT17LV.exe para la escritura y lecturade la MEMORIA SERIAL AT17LV256

El programa AT17LV.EXE se diseño en lenguaje C++ ya que resulta ideal para elmanejo del puerto paralelo y de archivos binarios, así como el manejo de gráficos.Elcódigo fuente se dividió en 3 programas compilados y ejecutados en turbo c(PROTOCOL.C, LEEARCH.C, GRAFICOS.C ) y una librerí a que contiene informaciónespecí fica de la memoria EEPROM AT17LV256.

Está diseñado para grabar la memoria AT17LV256 de ATMEL, sin embargo en elarchivo AT17LIB.H se pueden modificar los parámetros para grabar las memorias de 8Kbytes, 16 Kbytes, 64 Kbytes y 128 Kbytes.Así como también se pueden modificar ladirección del puerto paralelo y la frecuencia del Reloj (Macros: ALTO, BAJO, RETARDO).

VALORES DEFINIDOS PARA MEMORIA ATMEL AT17LV256

#define T_BYTE 0x40 //Número de BYTES por página HEXADECIMAL#define T_PAGE 0x200 //Número Total de Páginas HEXADECIMAL#define TT_BYTE 32768 //Capacidad en Bytes de la memoria AT17LV256#define T_BUFFER 1024 //Buffer para almacenamiento temporal del archivo fuente#define HABILITA outportb(Control,0x08) // Habilita Lectura/Escritura#define STANDBY outportb(Control,0x04) // En Esperaextern unsigned int PAGE_COUNT; //Contador de Páginas memoria ATLV256extern unsigned int BYTE_COUNT; //Contador de Bytes en progreso

VALOR DE LA DIRECCIÓN POR DEFAULT DEL PUERTO PARALELO

#define Puerto 0x378 // Puerto Paralelo#define Status 0x379 // Puerto Paralelo#define Control 0x37A // Puerto Paralelo

MACRO QUE SINCRONIZA LA LINEA DE DATOS (DATA) Y LA LINEA DERELOJ(CLOCK)

#define ALTO outportb(Puerto,DATA | 0x80); delay(0.003); // Macro de Reloj Alto pin 7 DATOS#define BAJO outportb(Puerto,DATA & 0x7F); delay(0.003);// Macro de Reloj Bajo pin 7 DATOS#define RETRASO outportb(Puerto,DATA & 0x76); delay(0.003);// Retraso de los Datos pin 0

Para el protocolo de comunicación se diseñaron las siguientes funciones, que acontinuación se señalan :

direccion() Función que enví a la dirección de Lectura/Escrituracond_ini() Genera la condición inicialenviardir() Enví a la dirección previamente rotadarotar_byte() Rota los Bytes de direccionesenviar() Enví a los datos por puerto paraleloreconoce() Reconoce la Señal ACK de la memoriacond_fin() Genera la condición finallectura() Lee los datos de la memoria AT17LV256verifica() Verifica la memoria AT17LV256

Page 17: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

16

2.2.1 Programa Protocol.c/***************************************************************************//* *//* U N I V E R S I D A D A U T O N O M A M E T R O P O L I T A N A *//* Unidad Iztapalapa *//* ASESOR DE PROYECTO: Oscar Yañez Suárez *//* ALUMNO: Oscar Ruiz de Jesús *//* MATRICULA: 96219171 *//* Archivo fuente: PROTOCOL.C *//* Archivo de Proyecto ejecutable: AT17LV.exe *//* *//***************************************************************************/

/*********************** LIBRERIAS DE C++ **********************************/

#include "AT17LIB.H"#include <graphics.h>#include <stdio.h>#include <math.h>#include <dos.h>#include <conio.h>#include <stdlib.h>#include <string.h>

/***************** FUNCIONES DE PROTOCOLO: LECTURA/ESCRITURA ****************/

extern void menu(void); //Despliega el Menú de Opcionesextern void cursor(void); //Mantiene la Posición del Cursorextern void ejecutar(int); //Ejecuta la opción escogidaextern void write(void); //Escribe en la memoria AT17LV256extern void read(void); //Lee la memoria AT17LV256extern void verifica(void); //Verfica la memoria AT17LV256extern void direccion(void); //Funci¢n que envía la dirección deLectura/Escrituraextern void cond_ini(void); //Genera la condicion inicialextern void enviardir(unsigned int *); //Envía la dirección previamente rotadaextern void enviar(); //Envia datos por puerto paraleloextern void reconoce(void); //Reconoce la SeñalACK de la memoriaextern void cond_fin(void); //Genera la condicion finalextern void lectura(void); //Lee los datos de la memoria AT17LV256extern unsigned int rotar_byte(unsigned int *); //Rota los Bytes de direccionesunsigned int Direccion=0x00; //Variable de la direcci¢n de la memoria AT17LV256unsigned int BYTE_COUNT; //Cuenta los Bytes por p ginaunsigned int DirMSB; //Byte de Dirección más significativounsigned int DirLSB; //Byte de Dirección menos significativoextern char archivo_bit[30]; //Variable que guarda el Nombre del archivo fuenteunsigned char BUFFER[T_BYTE+1]; //Buffer de almacenamiento auxiliar del Archivode salidaextern FILE *fuente; //Variable del Archivo de EntradaFILE *salida; //Variable del Archivo de Salidaunsigned long int ContData; //Contador de Datos del Archivo de Lecturaint bandera; //Bandera para seleccionar proceso de Lectura/Escriturachar modo; //Modo supervisi¢n o R pido

/********FUNCIONES QUE REALIZAN EL PROTOCOLO DE LECTURA/ESCRITURA***********/

/* Función para el protocolo de Escritura en la memoria AT17LV256 */

void write() //Escribe en la memoria AT17LV256int Pos=0,i=0;unsigned int WRITE=0x65; //Env¡a Byte de Escritura 0xA6 ¡¡¡ INVERTIDO !!!unsigned int READ=0xE5; //Env¡a Byte de Lectura 0xA7 ¡¡¡ INVERTIDO !!!

Page 18: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

17

if (kbhit())

closegraph();fclose(fuente);fclose(salida);exit(1);

for (i=0;i<T_BYTE+1;i++) BUFFER[i]='\0'; //Inicializa BUFFERfseek(fuente,ContData,0L);

do

BUFFER[Pos]=fgetc(fuente); //Carga el BUFFER de entradaPos++;

while(!feof(fuente) && Pos <T_BYTE);setviewport(125,282,502,431,1);setfillstyle(SOLID_FILL,3);floodfill(1,2,1);rectangle(0,0,377,149);settextstyle(2,0,5);setcolor(WHITE);outtextxy(30,6," % TRANSFERENCIA DE DATOS A MEMORIA");outtextxy(30,22,"DIRECCION PAGINA BYTE GRABADO");setcolor(RED);outtextxy(30,52,"PRESIONE CUALQUIER TECLA PARA SUSPENDER");outtextxy(30,68,"EL PROCESO DE ESCRITURA A MEMORIA");setcolor(WHITE);bandera=1;HABILITA; //Pone RESET/OE y CE en 0cond_ini();BYTE_COUNT=0x00;enviardir(&WRITE); //Env¡a la direccion previamente rotadadireccion(); //Funci¢n que env¡a la direcci¢n de Lectura/Escrituracond_ini(); //Genera la condici¢n inicialenviardir(&READ); //Env¡a la direccion previamente rotada

// STANDBY; //Pone RESET/OE y CEDireccion=0;setviewport(0,200,639,479,1);clearviewport();fclose(fuente); //Cierra Archivo Fuentemenu(); // Menú de opciones

/* Funci¢n para el protocolo de Lectura en la memoria AT17LV256 */

void read()

unsigned int MSB, LSB; //Variables locales de Direccionunsigned int WRITE=0x65; //Env¡a Byte de Escritura 0xA6 ¡¡¡ INVERTIDO !!!unsigned int READ=0xE5; //Env¡a Byte de Lectura 0xA7 ¡¡¡ INVERTIDO !!!if(fopen("lectura.bit","w")==NULL)exit(1);salida=fopen("lectura.bit","wb");setviewport(150,140,500,280,8);clearviewport();setviewport(125,262,508,420,1);setfillstyle(SOLID_FILL,3);floodfill(1,2,1);rectangle(0,0,383,157);settextstyle(2,0,5);setcolor(WHITE);outtextxy(8,124,"TECLEE 'S' MODO SUPERVISION O ENTER MODO RADIDO");setcolor(RED);

Page 19: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

18

outtextxy(8,140,"NO OLVIDE RENOMBRAR SU ARCHIVO POR CADA LECTURA");setcolor(WHITE);modo=getch(); //Pantalla de Inspección de las señales del EPP//outtextxy(8,24," pin (15) (10) pin ");outtextxy(8,40," DATA IN ACK ");outtextxy(8,56," pin (2) (9) pin ");outtextxy(8,72," DATOS CLK ");outtextxy(8,88," pin (17) (16) pin ");outtextxy(8,104," RESET/OE: CE ");outtextxy(8,8,"VALOR BYTES DE DATOS LEIDOS EN MEMORIA");setcolor(3);outtextxy(8,124,"TECLEE 'S' MODO SUPERVISION O ENTER MODO RADIDO");outtextxy(8,140,"NO OLVIDE RENOMBRAR SU ARCHIVO POR CADA LECTURA");setcolor(RED);outtextxy(8,124,"PRESIONE CUALQUIER TECLA PARA SUSPENDER LECTURA");bandera=2;HABILITA; //Pone RESET/OE y CE en 0outportb(Puerto,0x00); //Inicializa Puerto paralelooutportb(Status,0x00); //Inicializa Puerto paralelocond_ini(); //Genera condici¢n inicialenviardir(&WRITE); //Env¡a Byte de Escritura 0xA6 !!! INVERTIDO ¡¡¡DirMSB=Direccion & 0xFF00; //Enmascara Direcci¢n AltaDirMSB=DirMSB>>8; //Parte Alta de la Variable Direcci¢nMSB=rotar_byte(&DirMSB); //Rota DirMSB y el resultado se asigna a MSBenviardir(&MSB); //Envia Byte MSB previamente rotadoDirLSB=Direccion & 0xFF; //Enmascara Direcci¢n BajaLSB=rotar_byte(&DirLSB); //Rota DirLSB y el resultado se asigna a LSBenviardir(&LSB); //Envia Byte LSB previamente rotadocond_ini(); //Genera Condici¢n bajaenviardir(&READ); //Env¡a Byte de Lectura 0xA7 INVERTIDOlectura(); //Lee la informaci¢n obtenida de la memoriaSTANDBY; //Pone a RESET/OE y CE en Bajosetviewport(125,262,508,420,1);clearviewport();fclose(salida); //Cierra Archivo Lectura.bit

/* Esta funci¢n rota las direcciones de memoria del protocolo de ESCRITURA */

void direccion()

unsigned int MSB,LSB; //Es el Valor de las direcciones ya rotadasDirMSB=Direccion & 0xFF00; //Enmascara Direccion AltaDirMSB=DirMSB>>8; //Realiza la rotaci¢n de la variableMSB=rotar_byte(&DirMSB); //Rota el Byte MSBenviardir(&MSB); //Envia Byte MSBDirLSB=Direccion & 0xFF; //Enmascara Direcci¢n BajaLSB=rotar_byte(&DirLSB); //Rota Byte LSBenviardir(&LSB); //Envia Byte LSBenviar (); // Carga Archivo de Datoscond_fin(); // Condicion finalSTANDBY; //CE en Alto

/******* Esta función genera condición inicial usando las MACROS ************/

void cond_ini () //Condición necesaria del protocolo de comunicaciónunsigned char DATA;DATA=inportb(Puerto);DATA=DATA|0x01;BAJO;BAJO;BAJO;ALTO;ALTO;ALTO; //Macros ALTO;BAJO en AT17LIBDATA=DATA & 0xFE;

Page 20: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

19

ALTO;ALTO;ALTO;BAJO;BAJO;BAJO;

/************ Se envían las direcciones a la memoria AT17LV256 *************/

void enviardir(unsigned int *puntero) // Envía Direccionesint i;unsigned char DATA;DATA=*puntero;for (i=1;i<=8;i++)

RETRASO;BAJO;BAJO;ALTO;ALTO;ALTO;ALTO;ALTO;ALTO;BAJO;BAJO;RETRASO;DATA= DATA >> 1; //Rota el Byte para enviarlo serial reconoce(); //

/****************** Se envía los Datos cargados en el BUFFER ***************/

void enviar() //Enviar los datos del archivo fuente, almacenados en BUFFER

int i=0,j=0;

unsigned char DATA,BYTE_ENVIADO; while(ContData<TotalData)

do

BYTE_ENVIADO=0; //Variable que visualiza el Byte Enviado ContData++; DATA=BUFFER[j++]; //Hace cada dirección de BUFFER a DATA setviewport(0,440,(639/TotalData)*ContData,441,1); //Genera línea

setfillstyle(LINE_FILL,10); floodfill(1,1,1); gotoxy(20,19); printf("%2.2f\n",(ContData/TotalData)*100); for (i=0;i<=7;i++)

RETRASO;BAJO;BAJO;ALTO;ALTO;ALTO;ALTO;ALTO;ALTO;BAJO;BAJO;RETRASO; //Envia DATA

BYTE_ENVIADO=BYTE_ENVIADO+(DATA&0x01)*pow(2,i);DATA= DATA >> 1; //Desplazamiento de Byte para rotación

BYTE_COUNT++; //Incrementa contador de BYTES por página gotoxy(38,20); printf("%X %X",Direccion,BYTE_ENVIADO); reconoce(); // Reconoce ACK enviado por memoriawhile(BYTE_COUNT<T_BYTE && ContData<TotalData); //Envía Bytes por PáginasDireccion=Direccion+0x40; //Incrementa Dirección

cond_fin(); //Condición Final

/****************** Se Recibe el Byte de Reconocimiento ACK ***************/

void reconoce() //Evalúa si la respuesta de la memoria fue recibida

unsigned char DATA;for (;;) DATA=inportb(Status); //Lee la SeñalACK de la memoriaif (DATA & 0x40 )

//Verifica condici¢n ACK=0

Page 21: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

20

setviewport(125,282,502,412,1); setcolor(RED);

outtextxy (6,115,"Error: No se Recibió ACK"); delay(1000); setcolor(3); outtextxy (6,115,"Error: No se Recibió ACK");

if (inportb(Status)&0x40) exit(1);setcolor(BLUE);

outtextxy (220,115,"ACK ha sido recibido"); delay(1000); setcolor(3); outtextxy (220,115,"ACK ha sido recibido");;

setcolor(WHITE);if (bandera==1) write();if (bandera==2) read();

else

BAJO; BAJO; ALTO; ALTO; DATA= DATA|0x01; //Genera la lectura de ACK BAJO; break;

/******* Esta funci¢n genera condición final usando las MACROS **************/

void cond_fin () //Genera Condición Finalunsigned char DATA;DATA=inportb(Puerto);DATA=DATA & 0xFE;BAJO; BAJO; BAJO;BAJO;BAJO;BAJO;ALTO;ALTO;ALTO;DATA=DATA | 0x01;ALTO;ALTO;ALTO;BAJO;BAJO;BAJO;BAJO;BAJO;BAJO;ALTO;ALTO;ALTO;ALTO;ALTO;ALTO;PAGE_COUNT=PAGE_COUNT++; //Contador de Paginasif(PAGE_COUNT<T_PAGE && ContData<TotalData) write(); //Manda a escribirelse

//Compara con Total de P ginafclose(fuente);setviewport(125,200,502,275,1);setfillstyle(SOLID_FILL,1);floodfill(1,2,1);rectangle(0,0,377,74);settextstyle(2,0,5);outtextxy(55,10,"MEMORIA AT17LV256");outtextxy(55,25,"EL PROCESO DE GRABADO HA CONCLUIDO");settextstyle(2,0,6);setcolor(2);outtextxy(15,42,"Pulse cualquier tecla para continuar");setcolor(WHITE);getch();

/******************* Se Realiza la rotación del Byte ************************/

unsigned int rotar_byte(unsigned int *apuntador) //Rota Byte int i;

Page 22: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

21

unsigned int j,DIR,AUX1=0; //Variable localesDIR=*apuntador;

for (i=0,j=1;i<=7;i++,j=j<<1) if(DIR & j) AUX1=pow(2 ,8-i-1)+AUX1; //Realiza la rotacion de un

Byte return(AUX1);

/*** Lee el puerto de Impresora el Dato Contenido en la memoria AT17LV256 ***/

void lectura()unsigned char BUFFSAL[T_BUFFER];//Buffer almacenamiento auxiliar de Lecturaunsigned char BYTE_LEIDO=0; //Variable de Byte que se leeint i=0,j=0,k=0;unsigned char

DATA=0x7F,PIN15=0,RESET_OE=0,CE_OUT=0,CLK_OUT=0,DATA_OUT=0,ACK_IN=0;//InicializaBYTE_COUNT=0;doif (kbhit()) //Salir de la funci¢n si pulsas cualquier Tecla

closegraph(); fclose(fuente);

fclose(salida); exit(1);

BYTE_COUNT++;BYTE_LEIDO=0; for (i=0;i<=7;i++)

RETRASO;BAJO; if(inportb(Status)&0x08) PIN15=1; else PIN15=0; if(inportb(Status)&0x40) ACK_IN=1; else ACK_IN=0;

if(modo=='S' || modo=='s') //Se inspeccionan la se¤ales gotoxy(32,20); printf("%u %u",PIN15,ACK_IN); if(inportb(Control)&0x08) RESET_OE=0; else RESET_OE=1; if(inportb(Control)&0x04) CE_OUT=1; else CE_OUT=0; gotoxy(32,22); printf("%u %u",DATA_OUT,CLK_OUT); if(inportb(Puerto)&0x80) CLK_OUT=1; else CLK_OUT=0; if(inportb(Puerto)&0x01) DATA_OUT=1; else DATA_OUT=0;gotoxy(32,24);

printf("%u %u",RESET_OE,CE_OUT);

BAJO; ALTO; ALTO; //Macro que genera la condición de lectura ALTO; ALTO; ALTO; ALTO; BAJO; BAJO; RETRASO;BYTE_LEIDO=BYTE_LEIDO+PIN15*pow(2,i);

gotoxy(23,18); printf("%X %u",BYTE_LEIDO,BYTE_COUNT); BUFFSAL[j++]=BYTE_LEIDO; if (j>=T_BUFFER) j=0; fwrite(BUFFSAL,sizeof(BUFFSAL),1,salida);//Escribe archivo Lectura.Bit for (k=0;k<T_BUFFER;k++) BUFFSAL[k]='\0'; //Inicializa BUFFSAL reconoce();while(BYTE_COUNT<TotalData);

Page 23: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

22

fwrite(BUFFSAL,sizeof(BUFFSAL),1,salida); //Escribe archivo Lectura.Bit fclose(salida); //Cierra Archivo de lectura.bit

void verifica() //Verifica los archivos de Entrada y Lectura.bit int Pos=0,i=0,Contador=0; unsigned char BUFF1[T_BUFFER+1]; unsigned char BUFF2[T_BUFFER+1]; if(fopen(archivo_bit,"r")==NULL)

closegraph();exit(1);

if(fopen("lectura.bit","r")==NULL)closegraph();exit(1);

fuente=fopen(archivo_bit,"rb"); //Abre el Archivo de Datos salida=fopen("lectura.bit","rb"); //Abre el Archivo de lectura

while (Contador<=TotalData-1) Pos=0; for (i=0;i<=T_BUFFER;i++) BUFF1[i]='\0'; //Inicializa BUFF1 for (i=0;i<=T_BUFFER;i++) BUFF2[i]='\0'; //Inicializa BUFF2 fseek(fuente,Contador,SEEK_SET); fseek(salida,Contador,SEEK_SET);do BUFF1[Pos]=fgetc(fuente); //Carga el BUFFER de entrada BUFF2[Pos]=fgetc(salida); //Carga el BUFFER de salida if(BUFF1[Pos]!=BUFF2[Pos]) //Compara si los BUFFER son diferentes

setviewport(140,325,515,400,1); setfillstyle(SOLID_FILL,1); floodfill(1,2,1); rectangle(0,0,374,74); settextstyle(2,0,5);

outtextxy(50,25,"LA MEMORIA NO SE GRABO CORRECTAMENTE"); settextstyle(2,0,6); setcolor(2); outtextxy(15,42,"Pulse cualquier tecla para terminar");

setcolor(WHITE); getch(); setviewport(140,325,515,400,1); clearviewport();

fclose(fuente);fclose(salida);

closegraph();exit(1);

Contador++; Pos++; while(!feof(fuente) && !feof(salida) && Pos <T_BUFFER &&Contador<TotalData-1); //Compara hasta terminar de leer los archivos y el Total de Datos de hayaleido fclose(fuente); fclose(salida);

setviewport(140,325,515,400,1); setfillstyle(SOLID_FILL,1); floodfill(1,2,1);

Page 24: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

23

rectangle(0,0,374,74); settextstyle(2,0,5);

outtextxy(50,25,"LA MEMORIA HA SIDO GRABADA CORRECTAMENTE"); settextstyle(2,0,6); setcolor(2); outtextxy(15,42,"Pulse cualquier tecla para continuar");

setcolor(WHITE); getch();

setviewport(140,325,515,400,1); clearviewport();

/***** Función reset para el protocolo de borrado de la memoria AT17LV256 *****//***** Esta función se puede modificar para resetear la memoria *********//**!!! Se puede escribir la memoria sin necesidad de borrarla previamente¡¡¡***//* Si desea borrar memoria utilize el archivo LIMPIA.BIT como archivo fuente*//***** Enviar dudas o comentarios a:[email protected] *********/

/*void reset()bandera=3;unsigned int MSB,LSB; //Variables locales de Direcci¢nunsigned int DirREMSB=0x3F,DirRELSB=0xFF; //Direcci¢n Reset de memoriaunsigned int WRITE=0x65,RESET=0xFF,READ=0xE5;unsigned char DATA;cond_ini();enviardir(&WRITE); //Env¡a de direcci¢n de EscrituraMSB=rotar_byte(&DirREMSB); //Rotaci¢n del Byte 0x3Fenviardir(&MSB); //Env¡a Direcci¢n Alta de RESETLSB=rotar_byte(&DirRELSB); //Rotaci¢n del Byte 0xFFenviardir(&LSB); //Env¡a Direcci¢n Baja de RESETenviardir(&RESET); //Env¡a la Direcci¢n 0xFFcond_fin();DATA=DATA & 0xFE;BAJO;BAJO;BAJO;BAJO;BAJO;BAJO;ALTO;ALTO;ALTO; //Macro env¡o DatosDATA=DATA | 0x01;ALTO;ALTO;ALTO;BAJO;BAJO;BAJO;BAJO;BAJO;BAJO;ALTO;ALTO;ALTO;ALTO;ALTO;ALTO;BAJO;BAJO;BAJO;BAJO;BAJO;BAJO;delay(1000); //Esperar 10 mscond_ini();enviardir(&READ); //Enviar la Direcci¢n 0xA7STANDBY; //CE en altosetviewport(140,275,515,350,1);setfillstyle(SOLID_FILL,1);floodfill(1,2,1);rectangle(0,0,374,74);settextstyle(2,0,5);outtextxy(10,2,"SE HA RESETEADO LA MEMORIA SATISFACTORIAMENTE");settextstyle(2,0,6);setcolor(2);outtextxy(15,42,"Pulse cualquier tecla para continuar");setcolor(WHITE);getch();clearviewport();cursor(); */

Page 25: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

24

2.2.2 Programa Leearch.c/****************************************************************************//* *//* U N I V E R S I D A D A U T O N O M A M E T R O P O L I T A N A *//* Unidad Iztapalapa *//* ASESOR DE PROYECTO: Oscar Yañez Suárez *//* ALUMNO: Oscar Ruiz de Jesús *//* MATRICULA: 96219171 *//* Archivo fuente: LEEARCH.C *//* Archivo Proyecto Ejecutable: AT17LV.exe *//* *//****************************************************************************/

/******************** LIBRERIAS DE C++ **************************************/#include "AT17LIB.H"#include <stdio.h>#include <graphics.h>

/********************* FUNCIONES DE RUTINAS GRAFICAS ************************/

extern void menu(void); //Menú de opcionesextern void ejecutar(int); //Ejecuta la opción escogidaextern void cursor(void); //Pinta la nueva posición del cursorextern void mensaje(int); //Escribe los mensajes de la opción actual del menúextern void write(void); //Escribe en la memoriaextern void read(void); //Lee la memoriaextern void verifica(void); //Verifica los archivos generados

/********************** VARIABLES GLOBALES **********************************/

char archivo_bit[30]; //Variable que guarda el Nombre del archivo de datosFILE *fuente; //Variable de archivo fuentefloat TotalData; //Variable que registra el todal de Datos del Archivo Entradaunsigned int PAGE_COUNT; //Contador de P ginas de la memoria AT17LV256int pos_cursor=0;

/****************************** PRINCIPAL **********************************/

main () int gdriver = DETECT, gmode, errorcode;initgraph(&gdriver, &gmode, "");

errorcode = graphresult(); if (errorcode != grOk)

printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:");getch();

exit(1); /* Salir si existe error en graficos */

menu(); closegraph(); return 0;

/********* EJECUTA LAS OPCIONES SELECCIONADAS DEL CURSOR ********************/

void ejecutar(int pos) char car; switch(pos)

Page 26: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

25

case 0: // Leer archivo setviewport(150,160,500,300,8); clearviewport(); TotalData=0; setviewport(140,275,515,350,1); setfillstyle(SOLID_FILL,1);floodfill(1,2,1);

rectangle(0,0,374,74); settextstyle(2,0,5);outtextxy(40,10,"ESCRIBE EL NOMBRE DE ARCHIVO A LEER");outtextxy(40,25,"EXTENSION BIT");settextstyle(2,0,6);

setcolor(2);outtextxy(15,42,"Pulse cualquier tecla para continuar");setcolor(WHITE);

getch();clearviewport();

cursor(); setviewport(0,460,639,479,1); //va a la ventana de mensajesclearviewport();

setfillstyle(SOLID_FILL,RED);floodfill(1,2,1);

settextstyle(2,0,5); outtextxy(3,5,"INTRODUZCA EL NOMBRE DEL ARCHIVO");settextstyle(2,0,6);

setviewport(20,313,230,343,1); setfillstyle(SOLID_FILL,1); floodfill(1,2,1); rectangle(0,0,210,29); gotoxy(5,21); settextstyle(2,0,5); outtextxy(10,2,"Nombre: "); cprintf(" "); gets(archivo_bit); clearviewport(); setviewport(155,0,639,450,1); clearviewport();mensaje(pos_cursor);cursor();

if(fopen(archivo_bit,"r")!=NULL)

fuente=fopen(archivo_bit,"rb"); //Abre el Archivo de Datosfseek(fuente,0L, SEEK_SET);do

fgetc(fuente); //Carga el BUFFER de entrada TotalData++; //Total de Datos guardados en BUFFER while(!feof(fuente));

TotalData=TotalData-1; //Elimina el fin de Archivo en TotalDatasetviewport(140,325,515,400,1);setfillstyle(SOLID_FILL,1);floodfill(1,2,1);rectangle(0,0,374,74);settextstyle(2,0,5);outtextxy(55,10,"BUSCANDO ARCHIVO ...");outtextxy(55,25,"TAMA¥O DEL ARCHIVO BYTES");if (TotalData<TT_BYTE) gotoxy(44,23); printf("%2.0f",TotalData);

settextstyle(2,0,6); setcolor(2); outtextxy(15,42,"Pulse cualquier tecla para continuar");

Page 27: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

26

setcolor(WHITE); getch(); setviewport(0,325,515,400,1); clearviewport(); cursor();

menu(); gotoxy(44,23);outtextxy(55,40,"EL ARCHIVO DEBE SER MENOR A 32 KBytes");printf("%2.0f",TotalData);settextstyle(2,0,6);setcolor(2);outtextxy(15,48,"Pulse cualquier tecla para terminar");setcolor(WHITE);getch();fclose(fuente);closegraph();exit(1);

else setviewport(140,315,515,390,1); setfillstyle(SOLID_FILL,1); floodfill(1,2,1); rectangle(0,0,374,74); settextstyle(2,0,5);outtextxy(55,10,"BUSCANDO ARCHIVO ...");

outtextxy(55,25,"EL ARCHIVO NO EXISTE"); settextstyle(2,0,6); setcolor(2); outtextxy(15,42,"Pulse cualquier tecla para continuar");setcolor(WHITE);

getch(); setviewport(0,315,515,390,1); clearviewport(); cursor();menu();

break;case 1: //ESCRIBIR EN MEMORIA AT17LV256

setviewport(150,160,500,280,8); clearviewport(); PAGE_COUNT=0x00; //Contador de Pagina en 0

write(); //Función que inicia el protocolo de Escritura menu(); //Regresa al menú de opcionesbreak;case 2: //LEER EN MEMORIA AT17LV256

setviewport(150,160,500,280,8); clearviewport(); read(); //Funcion que inicia el protocolo de Lectura menu(); //Regresa al menú de opcionesbreak;case 3: //VERIFICAR MEMORIA setviewport(150,160,500,280,8); clearviewport(); setviewport(150,160,500,280,8);

setfillstyle(SOLID_FILL,1); floodfill(1,2,1); rectangle(0,0,349,119); settextstyle(2,0,5);

outtextxy(10,3,"PARA VERIFICAR LA MEMORIA ES NECESARIO"); outtextxy(10,20,"EJECUTAR CON EXITO LAS OPCIONES:");

setcolor(RED); outtextxy(10,35,"Carga Archivo"); outtextxy(10,50,"Graba Memoria");

Page 28: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

27

outtextxy(10,65,"Lee Memoria");setcolor(WHITE);

outtextxy(10,85,"PRESIONE ENTER PARA CONFIRMAR VERIFICACION"); outtextxy(10,100,"Esc PARA SALIR DE ESTA OPCION"); if(getcodigo()==ENTER) verifica(); //Inicia el proceso de Verificación

setviewport(150,160,500,280,8); clearviewport(); menu(); //Regresa al menú de opciones

break;case 4: /* acerca */ setviewport(150,160,500,280,8); clearviewport(); setviewport(150,160,500,280,8); setfillstyle(SOLID_FILL,1); floodfill(1,2,1); rectangle(0,0,349,119); settextstyle(2,0,5);

outtextxy(40,3,"UNIVERSIDAD AUTONOMA METROPOLITANA"); outtextxy(10,40,"PROYECTO TERMINAL"); outtextxy(10,55,"PROGRAMA ELABORADO POR: "); outtextxy(10,70,"ASESOR DE PROYECTO:"); settextstyle(2,0,4); setcolor(10); outtextxy(170,42,"MEMORIA SERIAL PARA FPGA"); outtextxy(122,18,"UNIDAD IZTAPALAPA"); outtextxy(200,57,"OSCAR RUIZ DE JESUS"); outtextxy(165,72,"OSCAR YAÑEZ SUAREZ"); setcolor(14); outtextxy(95,100,"MEXICO D.F. MARZO DE 2004");

getch(); clearviewport(); setcolor(WHITE); setviewport(105,0,639,450,1); settextstyle(2,0,6); cursor(); break;case 5: /* salir */ closegraph(); fclose(fuente);

exit(0); break;

Page 29: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

28

2.2.3 Programa Graficos.c/****************************************************************************//* *//* U N I V E R S I D A D A U T O N O M A M E T R O P O L I T A N A *//* Unidad Iztapalapa *//* ASESOR DE PROYECTO: Oscar Yañez Suárez *//* ALUMNO: Oscar Ruiz de Jesús *//* MATRICULA: 96219171 *//* Archivo fuente: GRAFICOS.C *//* Archivo Proyecto Ejecutable: AT17LV.exe *//* *//****************************************************************************/

/*************************** LIBRERIAS DE C++ *******************************/

#include <graphics.h>#include "AT17LIB.H"

/********************* FUNCIONES DE RUTINAS GRAFICAS ************************/

extern void menu (void); //Menú de Opcionesextern int getcodigo(void); //Esperar a que se pulse una teclaextern void ejecutar(int); //Ejecuta la opción escogidaextern void cursor(void); //Pinta la nueva posicióndel cursorextern void borrar_cursor(void); //Borra la posiciónactual del cursorextern void texto(void); //Escribe la opción del menúextern void mensaje(int); //Escribe los mensajes de la opcion actual del menúextern void write(void); //Escribe en la memoriaextern void read(void); //Lee la memoriaextern void verifica(void); //Verifica los archivos generadosextern int pos_cursor;

/******************************** MENU **************************************/

void menu(void) int codigo; outportb(Puerto,0x7F); //Inicializa el Puerto Paralelo outportb(Status,0x00); //Inicializa el Puerto Paralelo outportb(Control,0x04); //Inicializa el Puerto Paralelosetviewport(10,10,145,160,1);

setfillstyle(SOLID_FILL,6); floodfill(10,10,1); setviewport(0,0,135,150,1); setfillstyle(SOLID_FILL,4); floodfill(10,10,1); setcolor(15); setbkcolor(8); settextstyle(2,0,6); outtextxy(3,25,"Graba Memoria"); outtextxy(3,50,"Lee Memoria");outtextxy(3,75,"Verifica");

outtextxy(3,100,"Acerca de ..."); outtextxy(3,125,"Salir"); mensaje(pos_cursor); cursor(); while((codigo=getcodigo())!=27)

switch(codigo)

case up_arrow: /* cursor arriba */

if(pos_cursor>0)

Page 30: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

29

borrar_cursor(); mensaje(--pos_cursor); cursor();

else borrar_cursor(); mensaje(pos_cursor=NUM-1);cursor();

break;

case down_arrow: /* cursor abajo */if(pos_cursor<NUM-1)

borrar_cursor(); mensaje(++pos_cursor); cursor();

else borrar_cursor(); mensaje(pos_cursor=0);cursor();

break;

case ENTER:ejecutar(pos_cursor); /* ejecuta la opción seleccionada */

exit(1);

/************* BORRA LA POSICION ACTUAL DEL CURSOR EN EL MENU **************/

void borrar_cursor() setfillstyle(SOLID_FILL,4);floodfill(2,1,3);

texto();/* borrar_cursor */

/******************** ESCRIBE LA OPCION EN EL MENU *************************/

void texto(void) if(pos_cursor==0)

outtextxy(3,0,"Carga Archivo" ); else if(pos_cursor==1)

outtextxy(3,0,"Graba Memoria"); else if(pos_cursor==2)

outtextxy(3,0,"Lee Memoria"); else if(pos_cursor==3)

outtextxy(3,0,"Verifica"); else if(pos_cursor==4)

outtextxy(3,0,"Acerca de ...");else

outtextxy(3,0,"Salir");/* texto */

/************** PINTA LA NUEVA POSICION DEL CURSOR EN EL MENU ***************/

void cursor(void)

Page 31: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

30

setviewport(0,25*(pos_cursor),135,25*(pos_cursor+1),1);setfillstyle(SOLID_FILL,1);floodfill(1,2,1);

texto();/* cursor */

/******************** ESPERA A QUE SE PULSE UNA TECLA ***********************/

int getcodigo(void) int tecla; while((tecla=getch())!=0)

if(tecla==13 || tecla==27) return(tecla);

return(getch());/* getcodigo */

/************* ESCRIBE EL MENSAJE DE LA OPCION ACTUAL DEL MENU *************/

void mensaje(int pos) setviewport(150,160,500,280,8); setfillstyle(SOLID_FILL,1); floodfill(1,2,1); rectangle(0,0,349,119); settextstyle(4,0,6); setcolor(10); outtextxy(30,0,"U A M - I"); settextstyle(2,0,5); setcolor(YELLOW); outtextxy(40,60,"MEMORIA AT17LV256 PARA INTERFASE FPGA"); setcolor(WHITE);

settextstyle(2,0,5); outtextxy(40,80,"USE LAS FLECHAS PARA SELECION DE MENU"); outtextxy(40,95,"ENTER EJECUTAR OPCION Esc SALIR OPCION");

setviewport(0,460,639,479,1); clearviewport(); setfillstyle(SOLID_FILL,RED); floodfill(1,2,1); settextstyle(2,0,5); if(pos==0)

outtextxy(3,5,"CARGA ARCHIVO DE DATOS DEL FPGA XILINX CONFIGURACION MASTERSERIAL");else if(pos==1)

outtextxy(3,5,"GRABA LA MEMORIA AT17LV256 DE UN ARCHIVO FPGA XILINXCONFIGURACION MASTER SERIAL ");else if(pos==2)

outtextxy(3,5,"LEE MEMORIA AT17LV256 Y LA ESCRIBE EN LECTURA.BIT");else if(pos==3)

outtextxy(3,5,"VERIFICA LOS ARCHIVOS DE ENTRADA Y SALIDA GENERADOS");else if(pos==4)

outtextxy(3,5,"A CERCA DEL PROGRAMA"); else

outtextxy(3,5,"SALIDA DEL PROGRAMA");settextstyle(2,0,6);

Page 32: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

31

2.2.4 Librerí a AT17LIB.H/****************************************************************************//* *//* U N I V E R S I D A D A U T O N O M A M E T R O P O L I T A N A *//* Unidad Iztapalapa *//* ASESOR DE PROYECTO: Oscar Yañez Suárez *//* ALUMNO: Oscar Ruiz de Jesús *//* MATRICULA: 96219171 *//* Archivo fuente: AT17LIB.H *//* Archivo executable: AT17LV.exe *//* *//****************************************************************************/

/******************** LIBRERIAS DE C++ **************************************/#if defined(_STDIO_H)#include <stdio.h>#endif#if defined(_STDLIB_H)#include <stdlib.h>#endif#if defined(_CONIO_H)#include <conio.h>#endif#if defined(_DOS_H)#include <dos.h>#endif#if defined(_MATH_H)#include <math.h>#endif#if defined(_STRING_H)#include <string.h>#endif#if defined(_CTYPE_H)#include <ctype.h>#endif#if defined(_GRAPHICS_H)#include <graphics.h>#endif

/***********DEFINICIONES PARA CONTROLAR EL MENU DE OPCIONES*****************/

#define ENTER 13#define NUM 6 /* número de lineas del menu principal*/#define up_arrow 72 /*desplazamiento en el menú*/#define down_arrow 80

/*********** MACROS Y DEFINICIONES PARA GRABAR LA MEMORIA AT17LV256 *********/

#define Puerto 0x378 // Puerto Paralelo#define Status 0x379 // Puerto Paralelo#define Control 0x37A // Puerto Paralelo#define ALTO outportb(Puerto,DATA | 0x80); delay(0.003); // Macro de Reloj Altopin 7 DATOS#define BAJO outportb(Puerto,DATA & 0x7F); delay(0.003);// Macro de Reloj Bajopin 7 DATOS#define RETRASO outportb(Puerto,DATA & 0x76); delay(0.003);// Retraso de losDatos pin 0#define T_BYTE 0x40 //Número de BYTES por p gina HEXADECIMAL#define T_PAGE 0x200 //Número Total de P ginas HEXADECIMAL#define TT_BYTE 32768 //Capacidad en Bytes de la memoria AT17LV256#define T_BUFFER 1024 //Buffer para almacenamiento temporal del archivo fuente#define HABILITA outportb(Control,0x08) // Habilita Lectura/Escritura#define STANDBY outportb(Control,0x04) // En Espera

Page 33: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

32

/********************** VARIABLES GLOBALES **********************************/

extern int pos_cursor; //Pocisión del cursorextern unsigned long int ContData; //Contador de Bytes del Archivo Bitextern float TotalData; //Total de Bytes almacenados en Archivoextern unsigned int Direccion; //Direccion de la Memoriaextern unsigned int PAGE_COUNT; //Contador de P ginas memoria ATLV256extern unsigned int BYTE_COUNT; //Contador de Bytes en progresoextern int bandera; //Bandera para escoger protocolo LECTURA/ESCRITURA

/*********************** Fin de librería ************************************/

Page 34: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

33

CAPITULO 3 DISEÑO LA TARJETA PARA LECTURA/ESCRITURA DE LA MEMORIA SERIAL AT17LV256

Archivo de EAGLE Layout Editor 4.11 ATLV.brd

3.1 Componentes de la tarjeta de Lectura/Escritura AT17LV256

Los componentes requeridos para la fabricación de la tarjeta son los siguientes:

• 1 Placa de circuito impreso

• 1 Memoria EEPROM SERIALAT17LV256 (32 Kbytes)

• 1 Circuito Integrado 74LS244 buffercon salida en alta impedancia

• 1 Diodo led de color rojo(como indicador de móduloencendido)

• 3 resistencias de 4,7 K (1/4W)

• 1 resistencias de 270 Ohm (1/4W)

• 1 resistencia de 220 Ohm (1/4W)

• 1 Conector DB25 macho

Page 35: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

34

• 2 Capacitor cerámico 0.1 uF

• 1 Zócalo de 4 pines

• 1 Zócalo de 3 Pines

3.2 El Circuito para Lectura/Escritura de la memoria AT17LV256El circuito consta fundamentalmente de un buffer octal con salida en alta

impedancia, ésta caracterí stica se utiliza para forzar a 5v o a 0v dependiendo de lalectura del bit D0 (PIN 2) del puerto paralelo, y para proporcionar un nivel de corrienteque permita la transferencia de datos a la memoria.

Las dos lí neas CLOCK y DATA están conectadas a un rango de 3.3v - 5v, a travésde resistencias cuya misión es asegurar una mí nima carga de la lí nea, necesaria para quela transmisión sea estable ante posibles "ruidos" externos. Otra función que tienen estasresistencias es la de permitir que tanto la lí nea de datos como la de reloj seanbidireccionales. Cuando el bus está inactivo, las dos lí neas deben encontrarse en estadoalto (1 lógico). Por esta razón es importante verificar que el puerto paralelo estéconfigurado en modo EPP.

Cuando el software AT17LV.EXE se ejecuta en la PC, se genera una señal de reloja través del bit D7 del byte de DATOS del puerto paralelo ( PIN 9), enví ando los datos através del bit D0 (PIN 2). Para realizar la lectura de la memoria, se recibe la informacióndel contenido de la memoria a través del bit S3 del byte STATUS del puerto paralelo (PIN15 DATA IN), y la señal de confirmación -ACK- es recibida en el bit S6 (PIN10) STATUS.Las señales de control se enví an a través del byte STATUS siendo éstas: C3 RESET/OE(PIN 17) y C2 CE (PIN 16).

El diseño del circuito se puede consultar en el archivo ATLV.brd generado conEAGLE Layout Editor 4.11 incluido en éste proyecto.

Page 36: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

35

Como lo hemos mencionado, la tercera parte de la interfaz entre la memoria y elFPGA, depende de la elección de la memoria serial. La compatibilidad de la memoria conFPGA s de XILINX, Altera y Atmel hace posible su sencillez y versatilidad.La transferencia de las señales se realiza como lo muestra la gráfica :

Conclusiones

Por todo lo anterior si se logra reducir el costo que implica el hacer uso de éstos dispositivos, losalumnos de Ingenierí a Electrónica podrán realizar sus proyectos y grabar su información en la EEPROMSERIAL para la reprogramación prácticamente ilimitada de un FPGA serie XC4005XL de XILINX , oSpartan II. Al hacerlo, se estará logrando su principal objetivo, y será una pequeña contribución en eldesarrollo de Tecnologí a propia, caracterí stica principal del grado de desarrollo de un Paí s. Razones másque suficientes para considerar que éste proyecto cumplió su objetivo .

Page 37: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA’S

36

Bibliografí a

v The Programmable Logic Data Book2100 Logic DriveSan Jose, California 95124United States of AmericaTelephone: (408) 559-7778Fax: (408) 559-7114

v Programación en Turbo CSchildt SmithEd. Prentice Hall 2da Edición

v Diseño ElectrónicoSavant, Roden y CarpenterEd. Addison Wesley Iberoamericana

v http://www.xilinx.com/

v http://www.atmel.com

v http://www.atmel.com/atmel/products/prod183.htm

Page 38: PROYECTO DE INGENIERÍ A ELECTRÓNICA

1

Programming Specification for Atmel’s AT17 and AT17A Series FPGA

Configuration EEPROMs

The FPGA ConfiguratorThe FPGA Configurator is a ser ialEEPROM memory which can also beused to load programmable devices.This document describes the featuresneeded to program the Configuratorfrom within its programming mode (i.e.,when SER_EN is driven Low).

Reference schematics are supplied forin-system programming applications.

Serial Bus OverviewThe serial bus is a two-wire bus; onewire (CLOCK) functions as a clock andis provided by the programmer, thesecond wire (DATA) is a bidirectionalsignal and is used to provide data andcontrol information.

Information is transmitted on the serialbus in messages. Each MESSAGE ispreceded by a Start Condition and isended with a Stop Condition. The mes-sage consists of an integer number ofbytes, each byte consisting of 8 bits ofdata, followed by a ninth AcknowledgeBit. This Acknowledge Bit is provided bythe recipient of the transmitted byte. Thisis possible because devices may only

drive the DATA line Low. The systemmust provide a small pull-up current(1kΩ equivalent) for the DATA line.

The MESSAGE FORMAT for read andwrite instructions consists of the bytesshown below.

While writing, the programmer is respon-sible for issuing the instruction and data.While reading, the programmer issuesthe instruction and acknowledges thedata from the Configurator as necessary.

Again, the Acknowledge Bit is assertedon the DATA line by the receiving deviceon a byte-by-byte basis.

The factory blanks devices to all zerosbefore shipping. The array cannot other-wise be “initialized” except by explicitlywriting a known value to each locationusing the serial protocol describedherein.

Bit FormatData on the DATA pin may change onlyduring the CLOCK Low time; whereasStart and Stop Conditions are identifiedas transitions during the CLOCK Hightime.

Write Instruction Message Format

Current Address Read (Extended to Sequential Read) Instruction Message Format

ACK BIT (CONFIGURATOR)

DATABYTE n

STOPCONDITION

START CONDITION

DEVICE ADDRESS

MS EEPROM ADDRESS BYTE(512K, 1M ONLY)

(NEXT) EEPROM ADDRESS BYTE

LS EEPROM ADDRESS BYTE

DATA BYTE 1

ACK BIT (CONFIGURATOR)

DATABYTE n

STOPCONDITION

START CONDITION

DEVICE ADDRESS

DATA BYTE 1

ACK BIT (PROGRAMMER)

FPGA Configuration EEPROM Programming Specification

Application Note

Rev. 0437G–07/99

Page 39: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming2

Start and Stop ConditionsThe Start Condition is indicated by a high-to-low transitionof the DATA line when the CLOCK line is High. Similarly,the Stop Condition is generated by a low-to-high transitionof the DATA line when the CLOCK line is High, as shown inFigure 1.

The Start Condition will return the device to the state whereit is waiting for a Device Address (its normal quiescentmode).

The Stop Condition initiates an internally-timed write signalwhose maximum duration is tWR (refer to AC Characteris-t ics table for ac tual va lue). Dur ing this t ime, theConfigurator must remain in programming mode (i.e.,SER_EN is driven Low). DATA and CLOCK lines areignored until the cycle is completed. Since the write cycletypically completes in less than tWR seconds, we recom-mend the use of “polling” as described in later sections.Input levels to all other pins should be held constant untilthe write cycle has been completed.

Figure 1. Start and Stop Conditions

Acknowledge BitThe Acknowledge “ACK” Bit shown in Figure 1 is providedby the Configurator receiving the byte. The receiving Con-figurator can accept the byte by asserting a Low value onthe DATA line, or it can refuse the byte by asserting (allow-ing the signal to be externally pulled up to) a High value onthe DATA line. All bytes from accepted messages must beterminated by either an Acknowledge Bit or a Stop Condi-tion. Following an ACK Bit, when the DATA line is releasedduring an exchange of control between the Configuratorand the Programmer, the DATA line may be pulled Hightemporarily as shown above; due to the open-collector out-put nature of the line. Control of the line must resumebefore the next rising edge of the clock.

Bit Ordering ProtocolThe most significant bit is the first bit of a byte transmittedon the DATA line for the Device Address Byte and theEEPROM Address Bytes. It is followed by the lesser signifi-cant bits until the eighth bit, the least significant bit, istransmitted. However, for Data Bytes (both writing andreading), the first bit transmitted is the least significant bit.This protocol is shown in the diagrams below.

Device Address ByteThe contents of the Device Address Byte are shown below,along with the order in which the bits are clocked into thedevice. The A2 bit is provided to allow multiple Configura-tors to share a common bus. When programming aConfigurator, the A2 pin on the Configurator must be forcedto a logic “0” or “1” level. It is recommended that this pin beconnected to 0V (GND) using a 4.7kΩ pull-down (therebymatching the default setting of Atmel’s programming utility).Thus A2 bit may be used as an Address Bit amongtwo Configurators, or as a chip-enable mechanism forin-system programming employing more than twoConfigurators.

The CE pin cannot be used for device selection in program-ming mode (i.e., when SER_EN is drive Low).Note: For the 512K and 1M Configurators only the A2 input pin

will be pulled to ground via weak internal pull-downs if left floating

8th BIT

STOP Condition

Byte n

CLOCK

DATA

START Condition

t WR

ACK BIT

Page 40: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming

3

.

Where:R/W = 1 Read

= 0 Write

A2 = 1 if A2 pin of target Configuratoris at VCC

= 0 if A2 pin of target Configuratoris at GROUND

EEPROM AddressThe EEPROM Address consists of two bytes on the 64K,128K, and 256K parts, and three bytes on the 512K, 1Mand 2M parts. Each Address Byte is followed by anAcknowledge Bit (provided by the Configurator). Thesebytes define the normal address space of the Configurator,as described below. The order in which each byte isclocked into the Configurator is also indicated. Unused bits

in an Address Byte must be set to “0”. Exceptionsto this are:

1. when setting the reset polarity;

2. when reading Device and Manufacturer Codes; and

3. when enabling/disabling the internal oscillator in the AT17A Series Configurator (512K, 1M, and 2M parts only).

Device Address Byte

MSB LSB

1 0 1 0 A2 1 1 R/W

1st 2nd 3rd 4th 5th 6th 7th 8th

MSB LSB MSB LSB MSB LSB

0 0 0 0 0 0 0 AE16 ACK AE15 AE14 AE13 AE12 AE11 AE10 AE9 AE8 ACK AE7 AE6 AE5 AE4 AE3 AE2 AE1 AE0 ACK

1st 2nd 3rd 4th 5th 6th 7th 8th 1st 2nd 3rd 4th 5th 6th 7th 8th 1st 2nd 3rd 4th 5th 6th 7th 8th

This byte is only used on the 512K, 1M and 2M parts

byte order

512K/1M/2M Page Length

64K/128K/256K Page Length

64K Address Space

128K Address Space

256K Address Space

512K Address Space

1M/2M Address Space

Page 41: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming4

AT17C/LV020(A) Device OrganizationThe memory cell within the 2-megabit device is organized as follows:

Lower Memory 1,048,576 bitsUpper Memory 1,048,576 bits

The lower and upper memories combine to provide 2,097,152 bits of storage. To program or verify, issue write or readinstructions, using the specified addressing bytes in the following recommended sequence:

1. (Optional) Read the Device ID

2. Write the Lower Memory

3. Write the Upper Memory

4. Read the Lower Memory

5. Read the Upper Memory

6. Write Reset Fuse A

7. Write Reset Fuse B

8. (Optional) Write the DCLK Fuse

Device AddressByte Read/Write

Physical AddressFirst Byte - MSB

Physical AddressSecond Byte

Physical AddressThird Byte - LSB

Lower Memory: First page Last page

10100111/1010011010100111/10100110

0000000000000001

0000000011111111

0000000010000000

Upper Memory: First page Last page

10101111/1010111010101111/10101110

0000000000000001

0000000011111111

0000000010000000

Reset Fuse Locations: Fuse A (4 bytes) Fuse B (4 bytes)

10100111/1010011010101111/10101110

0000001000000010

0000000000000000

0000000000000000

Device ID (2 bytes) 10100111 00000100 00000000 00000000

DCLK Fuse (1 byte) 10100111 0011100x xxxxxxxx xxxxxxxx

Page 42: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming

5

Programming Summary: Write to Whole DeviceNotes1. Pull-up resistor required on DATA line

2. Pull-up (AE\h) or pull-down (A6\h) required on A2 pin of EEPROM (CEO)

3. Data byte received/sent LSB to MSB

4. These signals have “don't care” conditions for the AT17C/LV512/010(A)

5. The 512K and 1M parts require 3 EEPROM address bytes; all 3 bytes must be individually ACK'd by the EEPROM

6. WP pins on 512K and 1M devices are internally pulled to GND; by default disabling the write protect feature of the devices

EEPROM Address is Defined as:

Note: where Xn ... X0 is (PAGE_COUNT)\bwhere Xn ... X0 is (PAGE_COUNT)\b

T_BYTE

T_PAGE

SER_EN ≤ Low6

CE ≤ Low4

RESET/OE ≤ Low4

PAGE_COUNT ≤ 0

START1

Send Start ConditionBYTE_COUNT ≤ 0

Send Device Address2

(AE\h or A6\h)ACK?

Send MSB ofEEPROM Address5 ACK?

Send LSB ofEEPROM Address5

Send Data Byte3

BYTE_COUNT ≤BYTE_COUNT+1

BYTE_COUNT =T_BYTE?

Send Stop ConditionPAGE_COUNT ≤PAGE_COUNT+1

PAGE_COUNT =T_PAGE?

Yes

No

No

No

Yes

No

Send Start Condition

Send Device Address(AF\h or A7\h)

END

ACK?

Yes

No

ACK?

Yes

No

ACK?

Yes

No

Yes

SER_EN ≤ HighCE ≤ High

RESET/OE ≤ "X"Low-power (Standby)

Power-Cycle EEPROM(Latches 1st Byte for

FPGA DownloadOperations)

1st Data ByteValue Changed Due

to Write?No

Ver

ify F

inal

Writ

eC

ycle

Com

plet

ion

Yes

65 000x6 x5x4x3x2 x1x000 0000

128 00x7x6 x5x4x3x2 x1x000 0000

256 0x8x7x6 x5x4x3x2 x1x000 0000

512 0000 0000 x8x7x6x5 x4x3x2x1 x0000 0000

010 0000 000x9 x8x7x6x5 x4x3x2x1 x0000 0000

AT17C/LV65/128/256(A) 64

AT17C/LV512/010(A) 128

AT17C/LV65(A) 128

AT17C/LV128(A) 256

AT17C/LV256(A) 512

AT17C/LV512(A) 512

AT17C/LV010(A) 1024

DATA

CLK

DATA

CLK

DATA BIT

STOP CONDITION

DATA

CLK

ACK BIT

DATA

CLK

ACK

START CONDITION

Page 43: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming6

Programming Summary: Read from Whole DeviceNotes1. Pull-up resistor required on DATA line

2. Pull-up (AE\h) or pull-down (A6\h) required on A2 pin of EEPROM (CEO)

3. Data byte received/sent LSB to MSB

4. These signals have “don't care” conditions for the AT17C/LV512/010(A)

5. The 512K and 1M parts require 3 EEPROM address bytes; all 3 bytes must be individually ACK'd by the EEPROM

6. WP pins on 512K and 1M devices are internally pulled to GND; by default disabling the write protect feature of the devices

EEPROM Address is Defined as:

TT_BYTE

SER_EN ≤ Low 6

CE ≤ Low4

RESET/OE ≤ Low4

START 1

Send Start Condition

Send Device Address2

(AE\h or A6\h)ACK?

Send MSB ofEEPROM Address5 ACK?

Send LSB ofEEPROM Address 5

Send Start conditionBYTE_COUNT ≤ 0

Send Device Address(AF\h or A7\h)

Yes

No

No

Read Data Byte 3

BYTE_COUNT ≤ BYTE_COUNT+1

Send ACK

END

BYTE_COUNT=TT_BYTE?No

ACK?

Yes

No

Yes

Sent Stop Condition

SER_EN ≤ HighCE ≤ High

RESET/OE ≤ "X"Low-power (Standby)

Seq

uent

ial R

ead

from

Cur

rent

Add

ress

ACK? No

Yes

Yes

Ran

dom

Acc

ess

Set

up

65/128/256 00 00 \h

512/010 00 00 00 \h

AT17C/LV65(A) 8192 \d

AT17C/LV128(A) 16384 \d

AT17C/LV256(A) 32768 \d

AT17C/LV512(A) 65536 \d

AT17C/LV010(A) 131072 \d

DATA

CLK

DATA

CLK

SAMPLE DATA BIT

STOP CONDITION

START CONDITION

DATA

CLK

ACK BIT

DATA

CLK

ACK

Page 44: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming

7

Programming Summary: Write Reset PolarityNotes1. Pull-up resistor required on DATA line

2. Pull-up (AE\h) or pull-down (A6\h) required on A2 pin of EEPROM (CEO)

3. Data byte received/sent LSB to MSB

4. These signals have “don't care” conditions for the AT17C/LV512/010(A)

5. The 512K and 1M parts require 3 EEPROM address bytes; all 3 bytes must be individually ACK'd by the EEPROM

6. WP pins on 512K and 1M devices are internally pulled to GND; by default disabling the write protect feature of the devices

7. Drive RESET/OE high for active low reset, active high OE Drive RESET/OE ≤ low for active high reset, active low OE

8. The 512K and 1M parts require 4 data bytes of the same value to program the reset polarity; all 4 bytes must be individually ACK'd by the EEPROM

EEPROM Address is Defined as:

Data Byte is Defined as:

SER_EN ≤ Low6

CE ≤ High4

RESET/OE ≤ Low4,7

START1

Send Start Condition

Send Device Address2

(AE\h or A6\h)ACK?

Send MSB ofEEPROM Address 5 ACK?

Send LSB ofEEPROM Address5

Send Data Byte8

Send Stop Condition

Yes

No

No

Send Start Condition

Send Device Address(AF\h or A7\h)

END

ACK? No

ACK?

Yes

No

Yes

SER_EN ≤ HighCE ≤ high

RESET/OE ≤ "X"Low-power (Standby)

Ver

ify F

inal

Writ

eC

ycle

Com

plet

ion

Yes

ACK? No

Yes

Is Reset Polaritya New Value? No

Yes

Power Cycle EEPROM(Latches New Polarityfor FPGA Download

Operations)

AT17C/LV65/128/256(A) 3F FF \h

AT17C/LV512/010(A) 02 00 00 \h

65/128/256 FF \h

512/010 (active low RESET) FF \h

512/010 (active high RESET) 00 \h

DATA

CLK

DATA

CLK

DATA BIT

STOP CONDITION

START CONDITION

DATA

CLK

ACK BIT

DATA

CLK

ACK

Page 45: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming8

Data ByteThe organization of the Data Byte is shown below. Notethat in this case, the Data Byte is clocked into the deviceLSB first and MSB last.

WritingWriting to the normal address space takes place in pages.A page is 64 bytes long in 64K, 128K, and 256K parts, and128 bytes long in 512K, 1M, and 2M parts. The pageboundaries are, respectively, addresses where AE6 down to

AEOS are all zero, and AE6 down to AE0 are all zero. Writingcan start at any address within a page and the number ofbytes written must be 64 for the 64K, 128K and 256K parts,or 128 for the 512K, 1M, and 2M parts. The first byte is writ-ten at the transmitted address. The address is incrementedin the Configurator following the receipt of each Data Byte.Only the lower six or seven bits of the address (varies withpage length) are incremented. Thus, after writing to the lastbyte address within the given page, the address will rollover to the first byte address of the same page.

A Write Instruction consists of

a Start Condition

a Device Address Byte with R/W = 0

An Acknowledge Bit from the Configurator

MS Byte of the EEPROM Address (512K, 1M, and 2M parts only)

An Acknowledge Bit from the Configurator

(Next) Byte of the EEPROM Address

An Acknowledge Bit from the Configurator

LS Byte of EEPROM Address

An Acknowledge Bit from the Configurator

One or more Data Bytes (sent to the Configurator)

Each followed by an Acknowledge Bit from theConfigurator

a Stop Condition

WRITE POLLING: On receipt of the Stop Condition, theConfigurator enters an internally-timed write cycle. Whilethe Configurator is busy with this write cycle, it will notacknowledge any transfers. The programmer can start thenext page write by sending the Start Condition followed bythe Device Address, in effect polling the Configurator. If thisis not acknowledged, then the programmer should aban-don the transfer without asserting a Stop Condition. Theprogrammer can then repeatedly initiate a write instructionas above, until an acknowledge is received. When theAcknowledge Bit is received, the write instruction shouldcontinue by sending the first EEPROM Address Byte to theConfigurator.

An alternative to write polling would be to wait a period oftWR before sending the next page of data or exiting theprogramming mode. All signals must be maintained duringthe entire write cycle.

ReadingRead instructions are initiated similarly to write instructions.However with the R/W bit in the Device Address set to one.There are three variants of the read instruction: currentaddress read, random read and sequential read.

For all reads, it is important to understand that the internalData Byte address counter maintains the last addressaccessed during the previous read or write operation, incre-mented by one. This address remains valid betweenoperations as long as the chip power is maintained and thedevice remains in 2-wire access mode (i.e., SER_EN isdriven Low). If the last operation was a read at address n,then the current address would be n + 1. If the final opera-tion was a write at address n, then the current addresswould again be n + 1 with one exception. If address n wasthe last byte address in the page, the incremented addressn + 1 would “roll over” to the first byte address on the nextpage.

CURRENT ADDRESS READ: Once the Device Address(with the R/W select bit set to High) is clocked in andacknowledged by the Configurator, the Data Byte at thecurrent address is serially clocked out by the Configuratorin response to the clock from the programmer. The pro-grammer generates a Stop Condition to accept the singlebyte of data and terminate the read instruction.

A Current Address Read instruction consists of

a Start Condition

a Device Address with R/W = 1

An Acknowledge Bit from the Configurator

a Data Byte from the Configurator

a Stop Condition from the programmer.

Data Byte

LSB MSB

D0 D1 D2 D3 D4 D5 D6 D7

1st 2nd 3rd 4th 5th 6th 7th 8th

Page 46: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming

9

RANDOM READ: A Random Read is a Current AddressRead preceded by an aborted write instruction. The writeinstruction is only initiated for the purpose of loading theEEPROM Address Bytes. Once the Device Address Byteand the EEPROM Address Bytes are clocked in andacknowledged by the Configurator, the programmer imme-diately initiates a Current Address Read.

A Random Address Read instruction consists of

a Start Condition

a Device Address with R/W = 0

An Acknowledge Bit from the Configurator

MS Byte of the EEPROM Address (512K, 1M, and2M parts only)

An Acknowledge Bit from the Configurator

(Next) Byte of the EEPROM Address

An Acknowledge Bit from the Configurator

LS Byte of EEPROM Address

An Acknowledge bit from the Configurator

a Start Condition

a Device Address with R/W = 1

An Acknowledge Bit from the Configurator

a Data Byte from the Configurator

a Stop Condition from the programmer.

SEQUENTIAL READ: Sequential Reads follow either aCurrent Address Read or a Random Address Read. Afterthe programmer receives a Data Byte, it may respond withan Acknowledge Bit. As long as the Configurator receivesan Acknowledge Bit, it will continue to increment the DataByte address and serially clock out sequential Data Bytesuntil the memory address limit is reached. The SequentialRead instruction is terminated when the programmer doesnot respond with an Acknowledge Bit but instead generatesa Stop Condition following the receipt of a Data Byte.Note: On 2M-bit Configurators, the internal Data Byte address

counter cannot “roll over” from the lower memory to the upper memory.

Programmer FunctionsThe following programmer functions are supported whilethe Configurator is in programming mode (i.e., whenSER_EN is driven Low):

1. Read the Manufacturers Code and the Device Code (Optional for In-System Programming);

2. Program the device;

3. Verify the device;

4. Set the Reset Polarity option; and

5. Enable/disable the internal oscillator (AT17C/LV512A/010A/020A devices only).

In the order given above, they are performed in the follow-ing manner. (The same protocol and operations are usedfor both 5V and 3.3V devices, as well as for the Alterapinout variants except where stated.)

Reading Manufacturers and Device CodesThe 512/010/020 Configurators use a different algorithmthan the 65/128/256 Configurators for reading the Manu-facturers and Device Codes.

On 512/010/020 Configurators, the sequential reading ofthese bytes are accomplished by performing a RandomRead at EEPROM Address 040000H.

On 65/128/256 Configurators, the sequential read is doneat EEPROM Address 0 by performing a Current AddressRead with the following additional DC voltages set:

RESET/OE = 0V

CE = 11.5 ± 0.5V

The correct codes areManufacturers Code -Byte 0 1E

Device Code - Byte 1 FF AT17C/LV128(A)

7F AT17C/LV65(A)

77 AT17C/LV256(A)

37 AT17C/LV512(A)

F7 AT17C/LV010(A)

73 AT17C/LV020(A)

Note: The Manufacturer’s Code and Device Code are read using the byte ordering specified for Data Bytes; i.e., LSB first, MSB last. These procedures are not supported by the supplied ISP reference design schematics for 65/128/256 Configurators.

Programming the DeviceAll the bytes in a given page must be written. The pageaccess order is not important but it is suggested that theConfigurator be written sequentially from address 0. Writingis accomplished by using the DATA and CLOCK pins.

For the 65/128/256 Configurators only, two additional pro-gramming pins must be set as follows:

RESET/OE = 0V (Write protection disable)

CE = 0V

Important Note on AT17 and AT17A Series Configurators Programming

The first byte of data will not be cached for read back dur-ing FPGA Configuration (i.e., when SER_EN is drivenHigh) until the Configurator is power-cycled. This may becritical in cascaded ISP applications where the first byte ofthe second or subsequent EEPROM is likely to changebetween updated bitstreams.

Page 47: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming10

Write Protect OperationThe AT17 and AT17A Series Configurators have a “WriteProtect” feature which allows portions of the memory to beblocked during Write instructions. When the blocking is ineffect, data will not be written in the blocked portion and theexisting data in the blocked portion will be preserved.

For the 65/128/256 Configurators, the RESET/OE pinis used as a WRITE PROTECT pin while in programmingmode (i.e., SER_EN is Low with CE Low). When theRESET/OE pin is High under these conditions, memory isprotected as follows:

65: The lower 1/2 of memory is protected(address 0000 - 0FFF)

128: The lower 1/4 of memory is protected(address 0000 - 0FFF)

256: The lower 1/4 of memory is protected(address 0000 - 1FFF)

For the 512/010 Configurators, there are up to two dedi-cated Write Protect pins; WP1 (pin 5) and WP2 (pin 7).They are decoded to provide protection as describedbelow. (WP1/WP2 have weak internal pull-downs bydefault.)

The 020 Configurator does not support the Write Protectionfeature. The AT17A Series 512/010 parts do not supportWP2.

Verifying the DeviceAll bytes in the Configurator should be read and comparedto their intended values. Reading is done using the CLOCKand DATA pins.

For the 65/128/256 Configurators, two additional program-ming pins must be set as follows:

RESET/OE = 0V (Write protection disable)

CE = 0V

RESET Polarity OptionAll Configurators in the AT17 and AT17A Series have theability to change the polarity of the RESET/OE pin. This isrequired to allow the devices to properly configure variousFPGA families. The default condition is active Low OE andactive High RESET.

The 65/128/256 Configurators use a different algorithmfrom the 512/010/020 Configurators; both algorithms aredescribed below.

1. 65/128/256 Configurator RESET/OE Polarity Programming

A. Setting the polarity option ACTIVE HIGH OE (ACTIVE LOW RESET): Write Data Byte “FF” to address 3FFFH, with two additional program-ming pins set to the following:

RESET/OE = VCC +/- 0.25V

CE = VCC +/- 0.25V

B. Setting the polarity option ACTIVE LOW OE (ACTIVE HIGH RESET): Write a byte “FF” to address 3FFFH, with two additional program-ming pins set to the following:

RESET/OE = 0V

CE = VCC +/- 0.25V

C. Verifying the RESET Polarity: Power up the device with:

RESET/OE = 0V

CE = 0V

A2 (CEO) = Input to programmer (High Z)

SER_EN = VCC +/- 0.25V

CLOCK = 0V

DATA = Input to programmer

In this condition, if the DATA pin is tri-stated, then theRESET/OE fuse is programmed for active High OE(active Low RESET); if the DATA pin reads a “0” or a“1”, the RESET/OE fuse is active Low OE (active HighRESET).

2. 512/010/020 Configurator RESET/OE polarity programming

A. Setting the polarity option ACTIVE HIGH OE (ACTIVE LOW RESET): Write 4 bytes “FF FF FF FF” to addresses 20000H - 20003H.

B. Setting the polarity option ACTIVE LOW OE (ACTIVE HIGH RESET): Write 4 bytes “00 00 00 00” to addresses 20000H - 20003H.

C. Verifying the RESET/OE Polarity 512/010/020 Configurators: Perform a Random Read of 4 Data Bytes from addresses 20000H - 20003H. If the data is “00 00 00 00” then the fuse is pro-grammed for ACTIVE LOW OE (ACTIVE HIGH RESET); if the data is “FF FF FF FF” then the

AT17 Series Write Protection (512/010)

WP2 WP1 Protection

0 0 No protection

0 1 Addresses 00000 - 07FFF (1/4 of 010, 1/2 of 512)

1 0 Addresses 00000 - 0FFFF (1/2 of 010, All of 512)

1 1 Addresses 00000 - 17FFF (3/4 of 010, All of 512)

AT17A Series Write Protection(512A/010A)

WP1 Protection

0 No protection

1 Addresses 00000 - 07FFF (1/4 of 010A, 1/2 of 512A)

Page 48: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming

11

fuse is programmed for ACTIVE HIGH OE (ACTIVE LOW RESET).

Important Notes on AT17 and AT17A Series Configurators RESET Polarity Programming

1. The pin conditions above must be maintained dur-ing the entire write cycle; tWR or until the next Device Address is acknowledged (if using Write polling).

2. After the RESET polarity has been modified, the Configurator MUST be powered down and back-up again before attempting to verify functionality or use the newly programmed RESET function.

3. For 020, the reset polarity must be properly set for both 1M portions of the device. Please refer to the section “Programming the AT17C/LV020(A)”

DCLK Pin OptionThe 512A/010A/020A devices have the ability to disabletheir DCLK output. These devices can be used in mastermode where the clock pin is an output, or in slave modewhere the clock pin is an input.

The mode is normally determined by the state of the nCSpin on power-up and reset. However, there are instanceswhere it may be desirable to program the device into slavemode regardless of the power-up sequence.

The default status of the DCLK pin is with the internaloscillator enabled.

To disable the internal oscillator and program the deviceinto slave mode:

Write a byte “00” of data to Address 0011100xxxxxxxxx xxxxxxxx with nCS held to ground.

To enable the internal oscillator which allows the device toact as either master or slave depending on the state of nCSduring power-up and reset:

Write a byte “FF” of data to Address 0011100xxxxxxxxx xxxxxxxx with nCS held to ground.

Page 49: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming12

In-System Programming ApplicationsThe AT17 and AT17A Series Configurators are in-system(re)programmable (ISP). The examples shown in thefollowing pages support the following programmerfunctions:

1. Read the Manufacturers Code and the Device Code (512K, 1M and 2M parts only)

2. Program the device

3. Verify the device data

4. Set the Reset Polarity option

While Atmel’s FPGA Configurators can be programmedfrom various sources (e.g. on-board microcontrollers orPLDs), the applications shown here are designed to facili-tate users of our ATDH2200E Configurator ProgrammingKit. The typical system setup is shown in Figure 2.

Figure 2. Typical System Setup

In selecting a device and generating a circuit for anySRAM-based FPGAs, the key issues to address are:• Number of FPGA program bits versus Configurator

data space

• Pinout compatibility and package availability

• Configurator master or slave operation (512A/010A/020A only)

• Existence of weak internal pull-up or pull-down resistors on the inputs of the FPGA or Configurator

• Avoiding contention on the clock line during ISP

• Avoiding contention on the RESET/OE and CE (nCS) lines during ISP (65/128/256 only)

• Use of the A2 pin for addressing (up to 2 Configurators in cascade) or as a chip select (up to n Configurators in cascade) during ISP

• Use of the Ready pin, an external Reset signal, and/or an RC constant to delay configuration

• 3-wire (512/010/020 only) or 5-wire (65/128/256) ISP interface

Please note that the pages within the configurationEEPROM can be selectively rewritten. It follows that thereset polarity need only be written once. The reset polarityvalue is latched only during the power-on reset cycle.

The AT17 Series Configurators can interface with manySRAM-based FPGA families. This document is limited toexample implementations for the following applications:

1. Atmel AT6K and AT40K

2. Xilinx XC4000

3. Altera EPF6K, EPF8K, and EPF10K

4. Guidelines for cascading AT17C/LV020(A) Configurators

Atmel AT40K and AT6K ApplicationsAll AT6K FPGAs and many of the AT40K FPGAs can beconfigured with our low-density AT17 Series Configurators(64K, 128K, 256K bit storage). The high-density AT17Series Configurators (512K, 1M and 2M bit storage),however, introduce a simplified 3-wire interface that ishighly desirable for ISP applications.

ParallelPort

AT17CXXXConfigurator

10-pinRibbon CableDB-25M

PC

In-System ProgrammingConnector Header

Parallel Cable

DB-25F

ATDH2200

Target System

FPGA FPGA

Page 50: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming

13

Figures 3 and 4 employ the low-density AT17 Configuratorsfor a single AT6K and AT40K FPGA, respectively. Themultiplexer IC “74HC(T)157” connects the Configurator sig-nals to either the FPGA or the ISP header. The pull-downresistor on the A2 input pin of the Configurator provides therequired addressing for the incoming bitstream messagesduring programming. SER_EN serves as a control signalfor the multiplexer select input and determines the

operational mode of the EEPROM. For the low-densityAT17 Configurators, control of the CE and RESET/OE pinsis necessary for the programming of user data and settingof the reset polarity.

The pull-up resistor required on the line to CON is presenton the input (internally) to the AT6K FPGA family.

Figure 3. ISP of the AT17C65/128/256 in an AT60xx FPGA Application

Notes: 1. 4.7kΩ resistors used unless otherwise specified

2. Reset polarity must be set active High

REBOOT M2M1M0CS

D<0>

CCLKCON

V

CLKRESET/OECEDATASER_EN

CEO (A2)

2

4

6

8

10

DATA 1SCLK 3

5

7

9

74HC(T)157

1A 1B 2A 2B 3A 3B 4A 4B

1Y 2Y 3Y 4Y

E S

SER_ENRESET/OECE

AT60xx

AT17C65/128/256AT17LV65/128/256

15

2 3 5 6 11 10 14 13

1

4 7 9 12

CC VCC VCCVCC

Page 51: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming14

Figure 4. ISP of the AT17C65/128/256 in an AT40K FPGA Application

Notes: 1. 4.7kΩ resistors used unless otherwise specified

2. Reset polarity must be set active Low

RESET RESETM2M1M0

D<0>

CCLKINIT

CON

V

CLKRESET/OECEDATASER_EN

CEO (A2)

2

4

6

8

10

DATA 1SCLK 3

5

7

9

74HC(T)157

1A 1B 2A 2B 3A 3B 4A 4B

1Y 2Y 3Y 4Y

E S

SER_ENRESET/OECE

AT40K

AT17C65/128/256AT17LV65/128/256

15

2 3 5 6 11 10 14 13

1

4 7 9 12

CC VCC VCC

Page 52: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming

15

The complexity of the ISP circuit is significantly reducedwith the high-density AT17 Configurators as shown inFigure 5. The diode connection between the AT40K’sRESET pin and the SER_EN signal allows the externalprogrammer to force the FPGA into a reset state duringISP. This eliminates the potential for contention on theSCLK line. The READY pin (optional feature) of theConfigurator can also be connected to the AT40K’s RESETpin to force the FPGA to wait in a reset state as the Config-urator completes its power on reset cycle.

The pull-up resistors required on the lines to RESET, CONand INIT are present on the inputs (internally) to the AT40KFPGA family.

The dedicated WP1 and WP2 pins for the 512/010 parts, ifleft unconnected, have weak internal pull-down resistorsthat conveniently disable the Write Protection feature ofthese Configurators. Similarly, an external pull-down resis-tor is not required on the A2 input during ISP of 512/010Configurators, since there is a weak internal pull-downresistor present on those pins.

Figure 5. ISP of the AT17C512/010/020 in an AT40K FPGA Application

Notes: 1. 4.7kΩ resistors used unless otherwise specified

2. Use of the READY pin function is optional

3. Reset polarity must be set active Low

4. The pull-up resistor on the A2 input of the Configurator is optional for 512/010 devices.

RESET RESETM2M1M0

D<0>CCLKCONINIT

V

SER_ENDATACLKCERESET/OE

CEO (A2)READY

2

4

6

8

10

DATA 1SCLK 3

5

7

9

SER_EN

AT40K

AT17C512/010/020AT17LV512/010/020

CC VCC

VCC

VCC

Page 53: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming16

Xilinx ApplicationsXilinx FPGAs (e.g. XC4000, Spartan, Virtex) can be config-ured with AT17 Series Configurators. The high-densityAT17 Series Configurators (512K, 1M and 2M bit storage),however, introduce a simplified 3-wire interface that ishighly desirable for ISP applications. For high-density ordaisy-chained FPGAs, the AT17 Configurators can becascaded to provide the necessary memory.

Figure 6 employs the low-density AT17 Configurator for asingle XC4000 FPGA. The multiplexer IC “74HC(T)157”connects the Configurator signals to either the FPGA or theISP header. The pull-down resistor on the A2 input pin of

the Configurator provides the required addressing for theincoming bitstream messages during programming.SER_EN serves as a control signal for the multiplexerselect input and determines the operational mode of theEEPROM. For the low-density AT17 Configurators, controlof the CE and RESET/OE pins is necessary for theprogramming of user data and setting of the reset polarity.

The pull-up resistor required on the lines to PROGRAMand DONE are present on the inputs (internally) to theXC4000 FPGA family.

Figure 6. ISP of the AT17C65/128/256 in a XC4000 FPGA Application

Notes: 1. 4.7kΩ resistors used unless otherwise specified

2. An optional internal pull-up resistor is enabled here for DONE

3. Reset polarity must be set active Low

PROGRAM PROGRAM

M2M1M0

DIN

CCLKINIT

DONE

V

CLKRESET/OECEDATASER_EN

CEO (A2)

2

4

6

8

10

DATA 1SCLK 3

5

7

9

74HC(T)157

1A 1B 2A 2B 3A 3B 4A 4B

1Y 2Y 3Y 4Y

E S

SER_ENRESET/OECE

XC4000

AT17C65/128/256AT17LV65/128/256

15

2 3 5 6 11 10 14 13

1

4 7 9 12

CC VCC VCCCCV

Page 54: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming

17

The complexity of the ISP circuit is significantly reducedwith the high-density AT17 Configurators as shown inFigure 7. The diode connection between the XC4000’sPROGRAM pin and the SER_EN signal allows the externalprogrammer to force the FPGA into a reset state duringISP. This eliminates the potential for contention on theSCLK line. The READY pin (optional feature) of theConfigurator can also be connected to the XC4000’s

PROGRAM pin to force the FPGA to wait in a reset state asthe Configurator completes its power on reset cycle.

The pull-up resistors required on the lines to PROGRAMand DONE are present on the inputs (internally) to theXC4000 FPGA family. The internal pull-up resistor on theDONE input is available as an option to the user (via Xilinxbitstreaming tools).

Figure 7. ISP of the AT17C512/010/020 in a XC4000 FPGA Application

Notes: 1. 4.7kΩ resistors used unless otherwise specified

2. An optional internal pull-up resistor is enabled here for DONE

3. Use of the READY pin function is optional

4. Reset polarity must be set active Low

5. The pull-up resistor on the A2 input of the Configurator is optional for 512/010 devices.

PROGRAMM2M1M0

PROGRAM

V

2

4

6

8

10

DATA 1SCLK 3

5

7

9

SER_EN

CC VCC

VCC

CCLKDIN

DONEINIT

XC4000

CC

SER_ENCLKDATACERESET/OE

V

AT17C512/010/020AT17LV512/010/020 VCC

CEO (A2)READY

Page 55: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming18

The dedicated WP1 and WP2 pins for the 512/010 parts ifleft unconnected, have weak internal pull-down resistorsthat conveniently disable the Write Protection feature ofthese Configurators. Similarly, an external pull-down resis-to r i s no t requ i red on the A2 input fo r 512/010Configurators during ISP since there is a weak internal pull-down resistor present on those pins.

In simple cascaded Configurator applications involving twoEEPROMs (Figure 8), the A2 input can be used as anaddressing pin (set to logic level “0” for one EEPROM and

logic level “1” for the other EEPROM). The programmingutility can then modify the A2 bit sent in the bitstream mes-sages to target one of the two EEPROMs.

Applications involving more than two EEPROMs must usethe A2 input pin as a chip select. Pull-up resistors on eachA2 input are required, in addition to an external decodercircuit which must be able to selectively drive each A2 inputLow. For further details please refer to the “ProgrammingCascaded Configurators” application note.

Figure 8. ISP of 2 Cascaded AT17C512/010s in a XC4000 FPGA Application

Notes: 1. 4.7kΩ resistors used unless otherwise specified

2. An optional internal pull-up resistor is enabled here for DONE

3. Use of the READY pin function is optional

4. Reset polarity must be set active Low

5. This schematic cannot be used with an 020 Configurator

CEO (A2)

READY

PROGRAMM2M1M0

PROGRAM

V

CLKDATACERESET/OESER_EN

2

4

6

8

10

DATA 1SCLK 3

5

7

9

SER_EN

CC VCC

VCC

CCLKDIN

DONEINIT

XC4000

CC

CESER_ENCLKDATARESET/OE

CEO (A2)

READY

VCC

AT17C512/010AT17LV512/010

Device 1

V

AT17C512/010AT17LV512/010

Device 2

Page 56: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming

19

Altera ApplicationsAltera FLEX devices (e.g. EPF10K, EPF6K, EPF8K) canbe configured with AT17A Series Configurators. The high-density AT17A Series Configurators (512K, 1M and 2M bitstorage), however, introduce a simplified 3-wire interfacethat is highly desirable for ISP applications. For high-den-sity or daisy-chained FPGAs, the AT17A Configurators canbe cascaded to provide the necessary memory.

Figures 9 and 10 employ the low-density AT17(A) Configu-rator for a single EPF8K and EPF6K device, respectively.The multiplexer IC (74HC(T)157) connects the Configuratorsignals to either the FPGA or the ISP header. The pull-down resistor on the A2 input pin of the Configurator pro-

vides the required addressing for the incoming bitstreammessages during programming. SER_EN serves as a con-trol signal for the multiplexer select input and determinesthe operational mode of the EEPROM. For the low-densityAT17(A) Configurators, control of the nCS and OE pins isnecessary for the programming of user data and setting ofthe reset polarity.

While the nCONFIG input pin can be connected directly toVCC, we recommend the use of an RC delay or connectionto an active Low system reset signal for Altera EPF10K/6Kapplications; to ensure that the VCC has entered into normaloperating levels prior to initiating configuration.

Figure 9. ISP of the AT17C65(A)/128(A)/256(A) in an Altera EPF8K Application

Notes: 1. 1.0kΩ resistors used unless otherwise specified

2. Reset polarity must be set active Low

nCONFIG

nS/PMSEL0MSEL1

nSTATUSDATA0

DCLKCONF_DONE

V

DCLKOEnCSDATASER_EN

nCASC (A2)

2

4

6

8

10

DATA 1DCLK 3

5

7

9

74HC(T)157

1A 1B 2A 2B 3A 3B 4A 4B

1Y 2Y 3Y 4Y

E S

SER_ENOEnCS

EPF8K

AT17C65(A)/128(A)/256(A)AT17LV65(A)/128(A)/256(A)

15

2 3 5 6 11 10 14 13

1

4 7 9 12

CC VCC VCC

CC

VCC

VCCV

Page 57: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming20

Figure 10. ISP of the AT17C65(A)/128(A)/256(A) in an Altera EPF6K Application

Notes: 1. 1.0kΩ resistors used unless otherwise specified

2. Applicable to EPF10K

3. Reset polarity must be set active Low

4. RC filter recommended for input to nCONFIG to delay configuration until VCC is stable (nCONFIG can instead be connected to an active low system reset signal)

Since the low-density AT17(A) Series Configurators cannotprovide the necessary clock signal (i.e. act as system mas-

ter) during configuration, a clock must be suppliedexternally or from the FPGA.

CCV

nCONFIG

nCEMSEL

DCLKDATA0

nSTATUSCONF_DONE

V

DCLKOEnCSDATASER_EN

nCASC (A2)

2

4

6

8

10

DATA 1DCLK 3

5

7

9

74HC(T)157

1A 1B 2A 2B 3A 3B 4A 4B

1Y 2Y 3Y 4Y

E S

SER_ENOEnCS

EPF6K

AT17C65(A)/128(A)/256(A)AT17LV65(A)/128(A)/256(A)

15

2 3 5 6 11 10 14 13

1

4 7 9 12

CC VCC VCC

CCV

EXT_CLK

VCC

Page 58: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming

21

The complexity of the ISP circuit is significantly reducedwith the high-density AT17A Configurators as shown inFigures 11 and 12. The diode connection between theEPF8K’s nCONFIG pin and the SER_EN signal allows theexternal programmer to force the FPGA into a reset stateduring ISP. This eliminates the potential for contention onthe SCLK line. The READY pin (optional feature) ofthe Configurator can also be connected to the FPGA’s

nCONFIG pin to force the FPGA to remain in a reset stateas the Configurator completes its power on reset cycle.

For the Altera EPF8K application in Figure 11, the internaloscillator of the high-density AT17A Configurator must bedisabled. This need only be performed once before deviceinsertion, or during ISP by connecting nCS to the ISPheader (not shown).

Figure 11. ISP of the AT17C512A/010A/020A in an Altera EPF8K Application

Notes: 1. 1.0kΩ resistors used unless otherwise specified

2. The internal oscillator of the AT17A Configurator is disabled

3. Reset polarity must be set active Low

4. Use of the READY pin function is optional

5. The pull-up resistor on the A2 input pin of 512A/010A Configurators is optional

nCONFIGnS/PMSEL0MSEL1

V

2

4

6

8

10

DATA 1DCLK 3

5

7

9

SER_EN

CC VCC

VCC

nSTATUSDCLK

DATA0CONF_DONE

EPF8K

CCVCC

VCC VCCV

SER_ENDCLKDATAnCSOE

AT17C512A/010A/020AAT17LV512A/010A/020A

Device 1 VCC

CEO (A2)READY

Page 59: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming22

Figure 12. ISP of the AT17C512A/010A in an Altera EPF10K or EPF6K Application

Notes: 1. 4.7kΩ resistors used unless otherwise specified

2. Applicable to EPF6K

3. Reset polarity must be set active Low

4. Use of the READY pin function is optional

5. RC filter recommended for input to nCONFIG to delay configuration until VCC is stable (nCONFIG can instead be connected to an active low system reset signal)

6. The pull-up resistor on the A2 input pin of 512A/010A Configurators is optional

nCONFIG

nCEMSEL0MSEL1

V

2

4

6

8

10

DATA 1DCLK 3

5

7

9

SER_EN

CC VCC

VCC

DCLKDATA0

CONF_DONEnSTATUS

EPF10K

CCVCCVCC V

SER_ENDCLKDATAnCSOE

AT17C512A/010A/020AAT17LV512A/010A/020A

Device 1 VCC

CEO (A2)READY

Page 60: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming

23

The dedicated WP1 pin for the 512A/010A parts if leftunconnected, has a weak internal pull-down resistor thatconveniently disables the Write Protection feature of theseConfigurators. Similarly, an external pull-down resistor isnot required on the A2 input for 512A/010A Configuratorsduring ISP since there is a weak internal pull-down resistorpresent on that pin.

In simple cascaded Configurator applications involving twoEEPROMs (Figure 13), the A2 input can be used as anaddressing pin (set to logic level “0” for one EEPROM and

logic level “1” for the other EEPROM). The programmingutility can then modify the A2 bit sent in the bitstream mes-sages to target one of the two EEPROMs.

Applications involving more than two EEPROMs must usethe A2 input pin as a chip select. Pull-up resistors on eachA2 input is required, in addition to an external decodercircuit which must be able to selectively drive each A2 inputLow. For further details please refer to the “ProgrammingCascaded Configurators” application note.

Figure 13. ISP of 2 Cascaded AT17C512A/010As in an Altera FLEX10K Application

Notes: 1. 4.7kΩ resistors used unless otherwise specified

2. Use of the READY pin function is optional

3. Reset polarity must be set active Low

4. RC filter recommended for input to nCONFIG to delay configuration until VCC is stable (nCONFIG can instead be connected to an active low system reset signal)

5. This schematic cannot be used with 020 Configurators

nCONFIG

nCEMSEL0MSEL1

V

2

4

6

8

10

DATA 1DCLK 3

5

7

9

SER_EN

CC VCC

VCC

DCLKDATA0

CONF_DONEnSTATUS

EPF10K

CCVCCVCC V

nCASC (A2)

READY

DCLKDATAnCSOESER_EN

nCSSER_ENDCLKDATAOE

nCASC (A2)

READY

VCC

AT17C512A/010AAT17LV512A/010A

Device 1

AT17C512A/010AAT17LV512A/010A

Device 2

Page 61: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator Programming24

Notes: 1. This parameter is characterized and is not 100% tested2. Commercial temperature range 15°C - 70°C3. Industrial temperature range 15°C - 85°C4. Specific to programming mode (i.e., when SER_EN is driven Low)

Notes: 1. This parameter is characterized and is not 100% tested2. Commercial temperature range 15°C - 70°C3. Industrial temperature range 15°C - 85°C4. Specific to programming mode (i.e., when SER_EN is driven Low)

DC Characteristics(4)

VCC = 5.0V ± 5%, TA = 15°C - 85°C(1)(2)(3)

Symbol Parameter Test Condition Min Typ Max Units

VCC Supply Voltage 4.75 5.0 5.25 V

ICC Supply Current VCC = 5V 2.0 5.0 mA

ILL Input Leakage Current VIN = VCC or VSS 0.10 10 µA

ILO Output Leakage Current VOUT = VCC or VSS 0.05 10 µA

VIH High-Level Input Voltage VCC x 0.7 VCC + 0.5 V

VIL Low-Level Input Voltage -0.5 0.4 V

VOL Output Low Level Voltage IOL = 3 mA 0.4 V

AC Characteristics(4) VCC = 5.0V ± 5%, TA = 15°C - 85°C(1)(2)(3)

Symbol Parameter Min Max Units

fCLOCK Clock Frequency, Clock 400 KHz

tLOW Clock Pulse Width Low 1.2 µs

tHIGH Clock Pulse Width High 0.8 µs

tAA Clock Low to Data Out Valid 0.1 0.9 µs

tBUF Time the bus must be free before a new transmission can start 1.2 µs

tHD;STA Start Hold Time 0.6 µs

tSU;STA Start Set-Up Time 0.6 µs

tHD DAT Data In Hold Time 0 µs

tSU DAT Data In Set-up Time 0.1 µs

tR Inputs Rise Time 0.3 µs

tF Inputs Fall Time 0.3 µs

tSU STO Stop Set-up Time 0.6 µs

tDH Data Out Hold Time 0.05 µs

tWR Write Cycle Time 10 ms

Page 62: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator

25

Notes: 1. This parameter is characterized and is not 100% tested2. Commercial temperature range 15°C - 70°C3. Industrial temperature range 15°C - 85°C4. Specific to programming mode (i.e., when SER_EN is driven Low)

Notes: 1. This parameter is characterized and is not 100% tested2. Commercial temperature range 15°C - 70°C3. Industrial temperature range 15°C - 85°C4. Specific to programming mode (i.e., when SER_EN is driven Low)

DC Characteristics(4)

VCC = 3.3V ± 5%, TA = 15°C - 85°C(1)(2)(3)

Symbol Parameter Test Condition Min Typ Max Units

VCC Supply Voltage 3.0 3.3 3.6 V

ICC Supply Current VCC = 3.6 2.0 3.0 mA

ILL Input Leakage Current VIN = VCC or VSS 0.10 10 µA

ILO Output Leakage Current VOUT = VCC or VSS 0.05 10 µA

VIH High-Level Input Voltage VCC x 0.7 VCC + 0.5 V

VIL Low-Level Input Voltage -0.5 0.2 V

VOL Output Low Level Voltage IOL = 2.1 mA 0.4 V

AC Characteristics(4) VCC = 3.3V ± 5%, TA = 15°C - 85°C(1)(2)(3)

Symbol Parameter Min Max Units

fCLOCK Clock Frequency, Clock 100 KHz

tLOW Clock Pulse Width Low 4.0 µs

tHIGH Clock Pulse Width High 4.0 µs

tAA Clock Low to Data Out Valid 0.1 1.0 µs

tBUF Time the bus must be free before a new transmission can start 4.5 µs

tHD;STA Start Hold Time 2.0 µs

tSU;STA Start Set-Up Time 2.0 µs

tHD DAT Data In Hold Time 0 µs

tSU DAT Data In Set-up Time 0.2 µs

tR Inputs Rise Time 0.3 µs

tF Inputs Fall Time 0.3 µs

tSU STO Stop Set-up Time 2.0 µs

tDH Data Out Hold Time 0.1 µs

tWR Write Cycle Time 20 ms

Page 63: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator26

Figure 14. Serial Data Timing Diagram

tLOW tHIGH

tHD.STA

tSU.STA

tR tF

tSU.DAT

tHD.DAT

tDHtAA

tSU.STO

tBUF

CLOCK

DATA(IN)

DATA(OUT)

Pin Configurations

20-pin PLCCA Series Only(2)

20-pinPLCC/SOIC

Device

8-pinDIP

Device(2) Name I/O Description

2 2 1 DATA I/O Three-state DATA output for configuration. Open-collector bidirectional pin for programming.

4 4 2 CLK I/O CLOCK input/output. Used to increment the internal address and bit counter for reading and programming. Can be programmed as an output for the 512A/010A/020A only.

5(1) 5(1) N/A WP1 (512/010 Only)

I/O Write Protect (1). Used to inhibit Write instructions to blocks of memory (512/010 only). Can be combined with WP2, if available, to define portions of the memory that will not be over written.

8 6 3 RESET/OE I RESET/OE input (when SER_EN is High). A Low level on both the CE and RESET/OE inputs enables the data output driver. A High level on RESET/OE resets both the address and bit counters. The logic polarity of this input is programmable as either RESET/OE or RESET/OE. This document describes the pin as RESET/OE.

RESET Polarity Select(65/128/256 Only)

I RESET Polarity Select Input. During programming, when CE is High, this input is used to determine the polarity of the RESET pin (for operation when SER_EN is High).

WP (65/128/256 Only)

I Write Protect (WP) input (when CE is Low). When WP is Low or floating, the entire memory can be written. When WP is enabled (High), the lowest block of the memory cannot be written; i.e., 32K in 65 parts, 32K in 128 parts and 64K in 256 parts. Note that when WP is High, the chip will still acknowledge the receipt of data, but it will not write it into memory.

Page 64: PROYECTO DE INGENIERÍ A ELECTRÓNICA

Configurator

27

Notes: 1. This input pin contains a weak internal pull-down and when forced High will draw ~5 µA/pin current while SER_EN is Low. They will draw no current when SER_EN is High.

2. Refer to Altera conversion application note.

N/A 7(1) N/A WP2 (512/010 Only)

I Write Protect (2). Used to inhibit Write instructions to blocks of memory (512/010 only). Combined with WP1, this pin defines portions of the memory that will not be written.

9 8 4 CE I Chip Enable input. Used for device selection only when SER_EN is High. A Low level on both CE and OE enables the data output driver. A High level on CE disables both the address and bit counters and forces the device into a low-power mode. Note this pin will NOT enable/disable the device in the 2-wire Serial mode (i.e., when SER_EN is driven Low).During programming of 65/128/256 parts, when CE is Low, the main array is read and written. When CE is High, the main array is deselected and a Serial WRITE operation will change the polarity of the RESET pin.

10 10 5 GND Ground Pin.

12 14(1) 6 CEO O Chip Enable Output when SER_EN is High. This signal is asserted Low on the clock cycle following the last bit read from the memory. It will stay Low as long as CE and OE are both Low. It will then follow CE until OE goes High. Thereafter, CEO will stay High until the entire PROM is read again.

A2 I Device selection input, A2. Used to enable (select) the device during programming. When SER_EN is Low, this pin MUST be at either a logic level “1” or “0” (i.e., not tristate) and the A2 bit of the Device Address must match the condition of this pin for the Configurator to be selected.

15 15 N/A READY (512/010 Only)

O Ready output (512/010/020 only). This pin is an open-collector indicator of the device’s internal Power-up RESET condition. It is driven Low until the Power-up RESET is cleared, at which time it is released to a tri-state condition. This can be used with an external pull-up resistor for a Ready indication.

18 17 7 SER_EN I Serial enable is normally high during FPGA loading operations. Bringing SER_EN Low enables the programming mode.

20 20 8 VCC Power Supply Pin.

Pin Configurations (Continued)

20-pin PLCCA Series Only(2)

20-pinPLCC/SOIC

Device

8-pinDIP

Device(2) Name I/O Description

Page 65: PROYECTO DE INGENIERÍ A ELECTRÓNICA

© Atmel Corporation 1999.Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company’s standard war-ranty which is detailed in Atmel’s Terms and Conditions located on the Company’s web site. The Company assumes no responsibility forany errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time withoutnotice, and does not make any commitment to update the information contained herein. No licenses to patents or other intellectual prop-erty of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel’s products arenot authorized for use as critical components in life support devices or systems.

Atmel Headquarters Atmel Operations

Corporate Headquarters2325 Orchard ParkwaySan Jose, CA 95131TEL (408) 441-0311FAX (408) 487-2600

EuropeAtmel U.K., Ltd.Coliseum Business CentreRiverside WayCamberley, Surrey GU15 3YLEnglandTEL (44) 1276-686-677FAX (44) 1276-686-697

AsiaAtmel Asia, Ltd.Room 1219Chinachem Golden Plaza77 Mody Road TsimhatsuiEast KowloonHong KongTEL (852) 2721-9778FAX (852) 2722-1369

JapanAtmel Japan K.K.9F, Tonetsu Shinkawa Bldg.1-24-8 ShinkawaChuo-ku, Tokyo 104-0033JapanTEL (81) 3-3523-3551FAX (81) 3-3523-7581

Atmel Colorado Springs1150 E. Cheyenne Mtn. Blvd.Colorado Springs, CO 80906TEL (719) 576-3300FAX (719) 540-1759

Atmel RoussetZone Industrielle13106 Rousset CedexFranceTEL (33) 4-4253-6000FAX (33) 4-4253-6001

Application Support Hotline:1-(408) 436-4119

e-mail: [email protected]

FAQ: Accessible from Web Site

Fax-on-DemandNorth America:1-(800) 292-8635

International:1-(408) 441-0732

[email protected]

Web Sitehttp://www.atmel.com

BBS1-(408) 436-4309

Printed on recycled paper.

0437G–07/99/xM

Marks bearing ® and/or ™ are registered trademarks and trademarks of Atmel Corporation.

Terms and product names in this document may be trademarks of others.

Page 66: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EL PUERTO PARALELO DE LA PC

1

ANEXO 2

PROYECTO DE INGENIERÍ A ELECTRÓNICAEMULADOR DE ROM SERIAL PARA ARRANQUE DE FPGA

EL PUERTO PARALELO DE LA PC

Comúnmente denominado puerto de impresora original o puerto centronix esteconector permite entrar y salir de una PC, señales las cuales podemos emplear paramuchas cosas mas que simplemente imprimir sobre papel. Toda computadora compatiblecon PC dispone de al menos un puerto paralelo el cual es compatible con la normaoriginal estándar o SPP .

Como todo dispositivo, el puerto paralelo dispone de una dirección de memoriabase que puede ser 0x378h. Es por esta dirección por la que el usuario (a través de unprograma) se comunica y emplea el puerto paralelo.

Técnicamente el puerto paralelo dispone de 8 lí neas digitales de salida, las cualesllamaremos D0 a D7, cuyos niveles posibles son 0v (para bajo) y 5v (para alto),cumpliendo con el estándar de la familia lógica TTL. Estas lí neas están conectadas a lospines 2 al 9 para los bits 0 al 7 respectivamente. Estas ocho lí neas conforman elcomúnmente llamado bus de datos del puerto.

El bus de estado se empleaba originalmente para censar justamente el estado enel que se encontraba la impresora para saber, entre otras cosas, si esta encendida, siesta en lí nea, si dispone de espacio para recibir datos, si hay papel, etc. Pero puede serempleado para ingresar datos hacia la computadora desde periféricos que enví aninformación e iniciar así un protocolo de comunicación con el dispositivo externo enfunción a los datos que por aquí ingresen. Este puerto, a diferencia del de datos, disponede sólo 5 lí neas digitales de entrada partiendo desde el bit 3 y hasta el bit 7. Por logeneral a estas lí neas se las denomina S3 a S7 y la asignación de pines se la puede veren la tabla #1. La dirección de memoria asignada para comunicarse con este bus es iguala la dirección base (la del bus de datos) mas 1. Un dato a resaltar es que el bit 7 de estepuerto (conectado al terminal 11 del conector) presenta un estado lógico inverso. Estosignifica que, si en el pin 11 se colocan 5v (nivel lógico alto) el bit al ser leí do presentaráun cero. Y, por consiguiente, si el pin 11 es puesto a masa (nivel lógico bajo) al leer el bitse verá un uno.

En tanto, el bus de control, al igual que el de datos, dispone de lí neas de salidadesde la computadora hacia el exterior. Las lí neas también son digitales pero en estecaso son solo cuatro, los bits menos significativos que van del bit 0 al 3. Estas cuatrolí neas son generalmente llamadas como C0 a C4 y se pueden controlar por medio de ladirección de memoria base (la del bus de datos) mas 2 es decir, 0x37A.

En este bus hay tres bits cuyos niveles lógicos se encuentran invertidos (bit0, bit1y bit 3) y sólo uno que presenta un un estado lógico normal.

Page 67: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EL PUERTO PARALELO DE LA PC

2

Resumiendo podemos decir que un puerto paralelo estándar o SPP permite salirdesde la computadora hacia el exterior por medio de 12 lí neas o bits y posibilita entrar a lamisma por medio de 5 lí neas o bits.

tabla #1 Esquema general del puerto paralelo

DB25 Señal Registro Tipo Activo Sentido1 Control 0 C0- Salida Bajo Invertido

2 Dato 0 D0 Salida Alto directo

3 Dato 1 D1 Salida Alto directo

4 Dato 2 D2 Salida Alto directo

5 Dato 3 D3 Salida Alto directo

6 Dato 4 D4 Salida Alto directo

7 Dato 5 D5 Salida Alto directo

8 Dato 6 D6 Salida Alto directo

9 Dato 7 D7 Salida Alto directo

10 Estado 6 S6+ Entrada Alto directo

11 Estado 7 S7- Entrada Bajo Invertido

12 Estado 5 S5+ Entrada Alto directo

13 Estado 4 S4+ Entrada Alto directo

14 Control 1 C1- Salida Bajo Invertido

15 Estado 3 S3+ Entrada Alto directo

16 Control 2 C2+ Salida Alto directo

17 Control 3 C3- Salida Bajo Invertido

18-25 Tierra

Nota: Un dato en alto es un 1, un dato en bajo es un 0

En la figura #1 se muestran el esquema general del puerto paralelo y la figura #2muestra las conexiones fí sicas del puerto paralelo, tal como se verí an en la parte de atrásde la computadora.

Es importante hacer notar, que al puerto paralelo se le han hecho extensiones a sufuncionamiento como en el caso de los puertos extendidos (como el “ Enhanced ParallelPort” o EPP), en donde se maneja la bidireccionalidad del puerto, es decir; se permite queun mismo pin sea entrada y salida simultáneamente.

Para el diseño del programa para grabar la memoria AT17LV256 para interfase deun FPGA, se utilizó el modo EPP.

Page 68: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EL PUERTO PARALELO DE LA PC

3

Figura #1. Esquema del puerto paralelo del IBM PC

Page 69: PROYECTO DE INGENIERÍ A ELECTRÓNICA

EL PUERTO PARALELO DE LA PC

4

Figura #2. Conector DB25 Vista de los pines del puerto paralelo de la PC.

Page 70: PROYECTO DE INGENIERÍ A ELECTRÓNICA

5-1

FAST AND LS TTL DATA

OCTAL BUFFER/LINE DRIVERWITH 3-STATE OUTPUTS

The SN54/74LS240, 241 and 244 are Octal Buffers and Line Driversdesigned to be employed as memory address drivers, clock drivers andbus-oriented transmitters/receivers which provide improved PC boarddensity.

• Hysteresis at Inputs to Improve Noise Margins• 3-State Outputs Drive Bus Lines or Buffer Memory Address Registers• Input Clamp Diodes Limit High-Speed Termination Effects

LOGIC AND CONNECTION DIAGRAMS DIP (TOP VIEW)

18 17 16 15 14 13

1 2 3 4 5 6 7

20 19

8

VCC

1G

2G 1Y1 2A4 1Y2 1Y32A3 2A2

1A1 2Y4 1A2 2Y3 1A3 2Y2 1A49 10

2Y1 GND

12 11

1Y4 2A1

18 17 16 15 14 13

1 2 3 4 5 6 7

20 19

8

VCC

1G

2G 1Y1 2A4 1Y2 1Y32A3 2A2

1A1 2Y4 1A2 2Y3 1A3 2Y2 1A49 10

2Y1 GND

12 11

1Y4 2A1

18 17 16 15 14 13

1 2 3 4 5 6 7

20 19

8

VCC

1G

2G 1Y1 2A4 1Y2 1Y32A3 2A2

1A1 2Y4 1A2 2Y3 1A3 2Y2 1A49 10

2Y1 GND

12 11

1Y4 2A1

SN54/74LS240

SN54/74LS241

SN54/74LS244

SN54/74LS240SN54/74LS241SN54/74LS244

OCTAL BUFFER/LINE DRIVERWITH 3-STATE OUTPUTS

LOW POWER SCHOTTKY

ORDERING INFORMATION

SN54LSXXXJ CeramicSN74LSXXXN PlasticSN74LSXXXDW SOIC

20

1

J SUFFIXCERAMIC

CASE 732-03

20

1

N SUFFIXPLASTIC

CASE 738-03

20

1

DW SUFFIXSOIC

CASE 751D-03

Page 71: PROYECTO DE INGENIERÍ A ELECTRÓNICA

5-2

FAST AND LS TTL DATA

SN54/74LS240 • SN54/74LS241 • SN54/74LS244

TRUTH TABLES

SN54/74LS240

INPUTSOUTPUT

1G, 2G DOUTPUT

LLH

LHX

HL

(Z)

SN54/74LS244

INPUTSOUTPUT

1G, 2G DOUTPUT

LLH

LHX

LH(Z)

SN54/74LS241

INPUTSOUTPUT

INPUTSOUTPUT

1G DOUTPUT

2G DOUTPUT

LLH

LHX

LH(Z)

HHL

LHX

LH(Z)

H = HIGH Voltage LevelL = LOW Voltage LevelX = ImmaterialZ = HIGH Impedance

GUARANTEED OPERATING RANGES

Symbol Parameter Min Typ Max Unit

VCC Supply Voltage 5474

4.54.75

5.05.0

5.55.25

V

TA Operating Ambient Temperature Range 5474

–550

2525

12570

°C

IOH Output Current — High 54, 74 –3.0 mA

5474

–12–15

mA

IOL Output Current — Low 5474

1224

mA

Page 72: PROYECTO DE INGENIERÍ A ELECTRÓNICA

5-3

FAST AND LS TTL DATA

SN54/74LS240 • SN54/74LS241 • SN54/74LS244

DC CHARACTERISTICS OVER OPERATING TEMPERATURE RANGE (unless otherwise specified)

S b l P

Limits

U i T C di iSymbol Parameter Min Typ Max Unit Test Conditions

VIH Input HIGH Voltage 2.0 VGuaranteed Input HIGH Voltage forAll Inputs

VIL Input LOW Voltage54 0.7

VGuaranteed Input LOW Voltage for

VIL Input LOW Voltage74 0.8

Vp g

All Inputs

VT+–VT– Hysteresis 0.2 0.4 V VCC = MIN

VIK Input Clamp Diode Voltage –0.65 –1.5 V VCC = MIN, IIN = –18 mA

VOH Output HIGH Voltage54, 74 2.4 3.4 V VCC = MIN, IOH = –3.0 mA

VOH Output HIGH Voltage54, 74 2.0 V VCC = MIN, IOH = MAX

VOL Output LOW Voltage54, 74 0.25 0.4 V IOL = 12 mA VCC = VCC MIN,

VIN = VIL or VIHVOL Output LOW Voltage74 0.35 0.5 V IOL = 24 mA

VIN = VIL or VIHper Truth Table

IOZH Output Off Current HIGH 20 µA VCC = MAX, VOUT = 2.7 V

IOZL Output Off Current LOW –20 µA VCC = MAX, VOUT = 0.4 V

IIH Input HIGH Current20 µA VCC = MAX, VIN = 2.7 V

IIH Input HIGH Current0.1 mA VCC = MAX, VIN = 7.0 V

IIL Input LOW Current –0.2 mA VCC = MAX, VIN = 0.4 V

IOS Output Short Circuit Current (Note 1) –40 –225 mA VCC = MAX

I

Power Supply CurrentTotal, Output HIGH 27

A V MAXITotal, Output LOW LS240 44

mA V MAXICC LS241/244 46mA VCC = MAX

Total at HIGH Z LS240 50

LS241/244 54

Note 1: Not more than one output should be shorted at a time, nor for more than 1 second.

AC CHARACTERISTICS (TA = 25°C, VCC = 5.0 V)

S b l P

Limits

U i T C di iSymbol Parameter Min Typ Max Unit Test Conditions

tPLHtPHL

Propagation Delay, Data to OutputLS240

9.012

1418 ns

C 45 FtPLHtPHL

Propagation Delay, Data to OutputLS241/244

1212

1818 ns CL = 45 pF,

RL = 667 Ω

tPZH Output Enable Time to HIGH Level 15 23 ns

L

tPZL Output Enable Time to LOW Level 20 30 ns

tPLZ Output Disable Time from LOW Level 15 25 ns CL = 5.0 pF,

tPHZ Output Disable Time from HIGH Level 10 18 nsL p ,

RL = 667 Ω

Page 73: PROYECTO DE INGENIERÍ A ELECTRÓNICA

AC WAVEFORMS

1.3 V

1.3 V 1.3 V

1.3 V

1.3 V 1.3 V

1.3 V

VIN

VOUT

tPLH tPHL

1.3 V

1.3 V

VIN

VOUT SW2CL*

5 kΩ

SW1

VCC

RL

TO OUTPUTUNDER TEST

1.3 V

tPHL tPLH

VE

VE

VOUT

VE

VE

VOUT

tPHZ

1.3 V 1.3 V

tPZL tPLZ

VOL1.3 V

≥VOH

0.5 V

tPZH

1.3 V

Figure 1

Figure 2

Figure 3

Figure 4

Figure 5

≈ 1.3 V

0.5 V

≈ 1.3 V

SWITCH POSITIONS

5-4

FAST AND LS TTL DATA

SN54/74LS240 • SN54/74LS241 • SN54/74LS244

SYMBOL SW1 SW2

tPZH Open Closed

tPZL Closed Open

tPLZ Closed Closed

tPHZ Closed Closed