implementaciÓn en fpga de mÓdulos de software para...

247
Instituto Politécnico Nacional Escuela Superior de Ingeniería Mecánica y Eléctrica Unidad Zacatenco IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE Alumnos Nombre: Gómez Régules José Luis Rangel Reyes Emmanuel Asesor Metodológico M. en C: Gregorio García Pérez Asesor(es) Técnico(s) M. en C: Gabriela Sánchez Meléndez M. en C : David Vázquez Álvarez

Upload: others

Post on 16-Apr-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

Instituto Politécnico Nacional

Escuela Superior de Ingeniería Mecánica y Eléctrica Unidad Zacatenco

IMPLEMENTACIÓN EN FPGA

DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

Alumnos

Nombre:

Gómez Régules José Luis

Rangel Reyes Emmanuel

Asesor Metodológico

M. en C: Gregorio García Pérez

Asesor(es) Técnico(s)

M. en C: Gabriela Sánchez Meléndez

M. en C : David Vázquez Álvarez

Page 2: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

ÍNDICE Número Tema Página

Objetivo general. I

Objetivos Específicos. I

Justificación. II

1 CAPÍTULO I: Introducción y evolución de los sistemas de comunicación móviles

1.1 Introducción. 1

1.2 Primera generación. 3

1.3 Segunda generación. 5

1.4 Generación 2.5. 7

1.5 Tercera generación. 8

1.6 Cuarta generación. 10

2 CAPÍTULO II: Radio definido por software

2.1 Introducción. 12

2.2 Radio definido por software. 12

2.2.1 Arquitectura de Transmisiones de Radio Tradicional. 13

2.2.2 Arquitectura Ideal de Transmisores de Radio Basados en Software. 14

2.2.3 Principio de Funcionamiento de un Receptor RDS. 16

2.2.4 Conversión de Frecuencia. 17

2.3 Modulación. 17

2.3.1 Tipos de Modulación Analógica y Digital. 18

2.3.2 Demodulación. 20

2.4 Transmisión por Desplazamiento de Fase Binaria (BPSK). 20

2.4.1 Transmisor BPSK. 20

2.4.2 Receptor BPSK. 22

2.5 Codificación. 23

2.5.1 Códigos de Paridad. 23

2.5.2 Códigos m entre n. 23

2.6 Códigos de Bloque Lineales Sistemáticos. 24

2.7 Código de Hamming. 27

2.8 Decodificación Hamming. 29

2.9 Códigos Convolucionales. 30

3 CAPÍTULO III: Dispositivos de lógica programable

3.1 Introducción. 31

3.2 PLDs (Programmable Logic Devices). 32

3.3 ASPLDs (Application Specific Programmable Logic Devices). 33

3.4 PAL (Programmable Array Logic). 33

3.5 FPGA (Field Programmable Gate Array). 34

Page 3: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

Número Tema Página

3.5.1 Estructura General de la FPGA. 35

3.5.2 Lenguajes para programar en fpgas. 37

4 CAPÍTULO IV: Simulación e implementación en fpga

4.1 Introducción. 41

4.2 Modulador BPSK. 41

4.3 Demodulador BPSK. 44

4.4 Codificador Hamming 7,4. 45

4.5 Decodificador Hamming 7,4. 47

4.6 Generar Proyecto ISE para grabar la tarjeta FPGA. 54

4.7 Grabación de la tarjeta FPGA. 56

Conclusiones 64

Recomendaciones para trabajos futuros 64

Glosario 65

Apéndice A 67

Apéndice B 68

Referencias 239

Page 4: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

Número Tema Página

ÍNDICE DE TABLAS

CAPÍTULO I

1.1 Rangos de frecuencias a las que se trabajaban para eliminar interferencias que llegaran a surgir. 2

1.2 Características de la primera generación. 5

1.3 Características de la segunda generación. 7

1.4 Los principales estándares de comunicación móvil y su evolución de cada uno. 10

CAPÍTULO IV

4.1 Tabla para determinar las salidas trt dependiendo el número de error 50

ÍNDICE DE FIGURAS

CAPÍTULO I

1.1

Figura 1.1 Áreas en formas hexagonales, con su estación móvil y los usuarios que se encuentra adentro de cada una de ellas. 3

CAPÍTULO II

2.1 Arquitectura Tradicional de Transmisores de Radio. 13

2.2 Arquitectura ideal de Transmisores de Radio Basados en Software. 15

2.3 Combinación de dos señales (fa y fo) mediante un mezclador. 17

2.4 Ejemplo de Modulación. 18

2.5 Gráficas de la modulación en amplitud y en frecuencia. 19

2.6 Demodulación. 20

2.7 Diagrama de un Transmisor BPSK. 21

2.8 Diagrama Fasorial y de Constelación del Modulador BPSK. 21

2.9 Fase de salida contra la relación de tiempo para una forma de onda BPSK. 22

2.10 Diagrama de un Receptor BPSK. 23

CAPÍTULO III

3.1 Estructura interna de un PLD. 32

3.2 Estructura interna de un PAL. 34

3.3 Estructura interna de una FPGA. 36

3.4 Estructura del LUT de un bloque lógico. 37

3.5 Programación de una tarjeta FPGA a pasos. 38

3.6 Tarjeta FPGA Xilinx Spartan-3 200000-puerta. 39

CAPÍTULO IV

4.1 Fase de salida contra la relación de tiempo para una forma de onda BPSK. 41

4.2 Diagrama del modulador BPSK. 42

4.3 Subsistema generador de bits. 42

4.4 Resultados obtenidos del modulador BPSK. 43

Page 5: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

Número Tema Página

4.5 Diagrama del demodulador BPSK. 44

4.6 Resultados obtenidos del demodulador BPSK. 44

4.7 Diagrama del codificador implementado con compuertas AND y XOR. 46

4.8 Bloque de entrada y salida del codificador. 46

4.9 Subsistema generador de bits. 47

4.10 Resultado obtenido de la simulación del codificador. 47

4.11 Esquema del decodificador hamming. 48

4.12 Subsistema Hamming Decoder. 48

4.13 Diagrama del subsistema syndrome implementado con compuertas AND y XOR. 49

4.14 Entradas y salidas del subsistema syndrome para obtener el número de errores. 50

4.15 Diagrama del subsistema Err loc implementado con compuertas AND y NOT. 51

4.16 Entradas y salidas del subsistema Err loc. 52

4.17 Diagrama de la decodificación, el mensaje original sale por Out2 y los bits de paridad que se le quitan al mensaje por Out1. 52

4.18 Mensaje codificado. 53

4.19 Resultado obtenido de la simulación del decodificador el mensaje original se muestra por el display2. 53

4.20 Ventana del bloque System Generator para crear proyecto ISE. 54

4.21 Ventana del bloque System Generator generando proyecto ISE. 55

4.22 Archivos generados por System Genrator. 55

4.23 Tarjeta FPGA Spartan 3 Starter Kit. 56

4.24 Conexión del cable JTAG. 56

4.25 Entorno Xilinx ISE. 57

4.26 Ventana del código VHD generado por system generator. 58

4.27 Ventana Xilinx PACE. 59

4.28 Ventana Process Properties – Startup Options. 60

4.29 Ventana iMPACT. 60

4.30 Abriendo el archivo .bit que se va a grabar en el FPGA. 61

4.31 Después de cargar el archivo .bit se abre otra ventana para seleccionar otro archivo. 62

4.32 Ventana Device Programming Properties. 62

4.33 Programando el FPGA. 63

Page 6: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

Objetivo General:

Simular en un sistema FPGA para su implementación en hardware los

elementos de software necesarios de un Radio Definido por Software, en operaciones de banda base mediante herramientas actuales de tipo visual.

Objetivos Específicos:

Conocer que es un Radio Definido por Software, cual es su funcionamiento o su uso, como esta compuesto y en base a esto tener un diagrama a bloques de las partes que lo componen.

Hacer más eficiente la metodología y diseño de sistemas complejos a través

del modelado y la simulación con implementación en hardware. Conocer y manejar Simulink de Matlab, en el cual vamos a realizar la

simulación del Radio Definido por Software, teniendo su diagrama a bloques empezamos por realizar simulaciones por separado de la modulación,

demodulación, codificación y decodificación, una vez funcionando estos 4 elementos, se va a realizar una simulación conjuntada modulación –

codificación – decodificación – demodulación. Conocer y manejar Xilinx System Generator, software con el cual utilizaremos

las simulaciones de Simulink y de este software se hará la grabación del FPGA. Se utilizará System Generator para programar el FPGA debido a que nos

reduce muchas líneas de código. Conocer el funcionamiento de un FPGA y su programación. En la tarjeta FPGA

se grabará la modulación, la codificación, decodificación y demodulación y se probará su funcionamiento interactuando con el Simulink o el System

Generator. Establecer la Interfaz rápidamente y de manera rentable con hardware de

medidas y control, analizar datos, compartir resultados y distribuir sistemas.

I

Page 7: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

Justificación

En varias partes del mundo existen muchos proyectos que proponen la

integración de los estándares de comunicación móvil con funcionalidades

mejores que los sistemas de tercera generación.

El escenario genérico de comunicaciones móviles de 4G consiste en distintos

tipos de redes terrestres de comunicaciones móviles e inalámbricas integradas,

usando el protocolo de encaminamiento IP como elemento integrador.

Desde la creación y evolución constante de estándares de comunicación móvil

tales como 2G, 2.5G, 3G y 4G, existen diferencias entre los estándares de

sistemas de comunicación móvil utilizadas por diferentes países para ser

integrados. Desde un punto de vista comercial y global, este problema inhibe

el uso de servicios de roaming y otras facilidades, ya que los estándares varían

los protocolos en su desempeño cuando es aplicado a enlaces, lo cual afecta

directamente a los enlaces inalámbricos.

Para estos problemas se puede aplicar el RDS (Radio Definido por Software),

ya que una de sus aplicaciones es el describir control de software para una

aplicación de radio, además de que se caracteriza por ser flexible, se puede

modificar o ampliar su funcionamiento únicamente cambiando su software, el

cual provee técnicas de operaciones de banda base, funciones de seguridad en

comunicaciones, requerimientos de forma de onda, tipo de modulación y

codificación, etc.

II

Page 8: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

1

CAPÍTULO I: Introducción y evolución de los sistemas

de comunicación móviles. Este capítulo contiene una reseña histórica de cómo se inicio la

comunicación inalámbrica, cómo se da la evolución de los sistemas de

comunicación móviles y sus estándares creados a través de las llamadas generaciones de comunicación móvil.

1.1 INTRODUCCIÓN

Para comenzar este capítulo tenemos que saber el concepto de ¿qué es un sistema de comunicación móvil? Un sistema de comunicación móvil

surge cuando existe el desplazamiento o movimiento de un dispositivo de comunicación (transmisor o receptor) en una determinada área

geográfica.

La historia en los sistemas de comunicación móvil nos remonta a 1897 donde el ingeniero de origen Italiano Guillermo Marconi en el Reino

Unido, demostró que puede existir la comunicación entre dos puntos en el agua por medio de la telegrafía inalámbrica, esto beneficiaria a los

submarinos y eliminaría los cables, de esta forma se presenta el primer sistema de comunicación móvil que existió, después implantó en su

compañía de investigación un transmisor y un receptor, en el cual comunicaría a Reino Unido con Canadá atravesando el océano Atlántico.

Gracias a estas demostraciones el Ing. Guillermo Marconi en 1909 ganó

el premio Nobel de Física, por lo cual se le conoce como el padre de la radio y las comunicaciones inalámbricas. [1]

Después el inventor estadounidense Lee de Forest consiguió un tubo de

vacío de tres electrodos y logró la primera emisión de radio la cual tuvo lugar en 1906 en los Estados Unidos. En 1910, De Forest transmitió por

primera vez una ópera desde el (Metropolitan Opera House) de Nueva York.[2]

Como es costumbre esto fue utilizado para actividades bélicas, como la

segunda guerra mundial, el que tiempo después fue en los Estados Unidos en Detroit el departamento de Policía empezó a utilizar el

sistema móvil de radio telefonía y once años después en New York, así se fue incrementando la demanda de uso de radio frecuencia, la cual

variaba de 2 MHz hasta 450 Mhz incluyendo la segunda guerra mundial,

la organización que regulaba las señales era la FCC (Comisión Federal de Comunicaciones).

Page 9: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

2

Luego a mediados de la década de los sesentas la empresa Bell

Telephone (AT&T) desarrolló la operación full-duplex, que se utilizó para

la búsqueda de canales y la marcación desde una estación móvil. A finales de esta década los sistemas móviles trabajaban a 460 Mhz, ya

después en la siguiente década este sistema de comunicación móvil se utilizaba para servicio público como el policíaco, la industria, el

transporte terrestre y marítimo.

Pero en el transcurso del tiempo fue creciendo la demanda de frecuencias y crecieron las interferencias, para esto la FFC propuso una

tabla en la cual indica cómo se deben utilizar las frecuencias, pero esto no es suficiente, y abre un canal UHF que maneja frecuencias de

806MHz a 881MHz.

Tabla 1.1 Rangos de frecuencias a las que se trabajaban para eliminar

interferencias que llegaran a surgir.

Ya para la década de los setentas, Bell Laboratories empieza a manejar

la división en áreas geográficas en células hexagonales en las que se coloca la estación base para la comunicación de un usuario móvil que se

encuentre dentro de esta célula, y el usuario móvil pueda comunicarse con otro usuario que se encuentre dentro de esa célula o en otras, esta

estructura de comunicación móvil sigue llevando en la actualidad así como se muestra en la figura 1.1. [1]

Page 10: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

3

Figura 1.1. Áreas en formas hexagonales, con su estación móvil y los usuarios

que se encuentra adentro de cada una de ellas.

1.2 PRIMERA GENERACIÓN 1G

Para principios de los ochentas salen los primeros sistemas de comunicación comerciales mejor conocidos como sistemas 1G, estos

son implementados en la Unión Americana, Inglaterra y Japón. Este sistema de comunicación móvil es analógica y utiliza la técnica FDMA

(Frequency Division Multiple Access) / FDD (Frecuency Division Duplex), aplica la división de áreas geográficas en células.

Para la primera generación fue utilizado el AMPS (Advanced Mobile Phone System) es un sistema con una costoso y complejo cuya

arquitectura en la cual toda la inteligencia fue situada en una central de conmutación de sistemas en 1981. El punto de partida fue que el

roaming debería estar disponible entre redes, aunque esto no estuvo disponible a gran escala hasta los años 90.

Para los noventas fue desarrollada NAMPS (Narrowbadamps), es una

variante de la AMPS, esté reduce el espacio de canal, mejora la frecuencia y en forma comercial aumenta su precio de las terminales.

Para 1996 ya se había utilizado este servicio para un millón de subscritores.

En Europa se utilizó NMT (Nordic Mobile Telephony) un estándar abierto,

que fue presentado a mediados de los setentas en la Conferencia

Page 11: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

4

Nórdica de Telecomunicaciones, éste habla de interfaces de radio y de

otros interfaces incluyendo el enlace entre la estación base y un switch.

Ya después, fue insuficiente la comunicación con el estándar NMT y

surgió el estándar NMT-450; el estándar fue utilizado en España y Francia así como en otros países del este de Europa; el estándar tiene

sistemas celulares que utilizan una estructura de red jerárquica y las estaciones base son relativamente inteligentes, comparándolo con AMPS

éste tiene todas las funcionalidades que estaban situadas en la central de conmutación.

Años después a mediados de los ochentas surgió el NMT-900, pero este

no era el único estándar que estaba en Europa, en el Reino Unido se desarrollaba un estándar basándose en el AMPS llamado TACS (Total

Access Communication System) utilizando otra banda de frecuencia que los británicos tenían asignado, ya después los demás países europeos

empezaron a utilizar el estándar TACS.

Pero en Europa no eran los únicos estándares, también surgieron tres

más a principios de los ochentas como el C-450 que fue establecido en Alemania, el RC-2000 desarrollado en Francia, pero estos estándares no

fueron exitosos.

En Asia la primera generación apareció con Japón siendo un país en el cual se invierte mucho en tecnología, empezó a desarrollar sus propios

estándares como el NTT (Nippon Telegraph and Telephone) a fines de la década de los setentas, e instaló su primer sistema celular que era el

MSCL1, a mediados de los ochentas surgió el MSCL2, que maneja capacidad de celdas con una eficiencia del espectro mucho mayor, pero

que seguía trabajando en la misma banda de frecuencia.

También en Japón había proveedores que utilizaban el TACS para dar el servicio y posteriormente salió el J-TACS pero sería implementado para

la segunda generación. En la tabla 1.2 se observan los estándares y sus

características a las que trabajaban.

La siguiente tabla fue elaborada por Siemens Telecom Report of Communications mobile special.

Page 12: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

5

Tabla 1.2. Características de la primera generación.

Para la primera generación lo que se debe tomar en cuenta es como los

sistemas utilizan la técnica de acceso al medio en este caso la llamada FDMA cuyo espectro radioeléctrico se divide en una serie de secciones o

ranuras dependiendo del número de usuarios que tengamos en ese

momento.

La configuración es rígida e invariante pues cada estación debe transmitir siempre con la misma frecuencia central o portadora y es

válida cuando se puede garantizar que durante la mayor parte del tiempo, cada una de ellas ocupará activo ese ancho de banda que se le

asignó. Por esa razón se llama acceso múltiple con división de frecuencia con asignación fija. Cuando el número de subportadoras aumenta, el

ancho de banda asignado a cada una de ellas debe disminuir lo que conlleva a una reducción de la capacidad de las mismas.

1.3 SEGUNDA GENERACIÓN 2G

Cuando se tenía el sistema de comunicación de primera generación, el pronóstico era que para principios de los noventa ya sería mucha la

demanda del servicio y habría una sobresaturación. Para solucionar el problema se deberían dividir las células existentes en otras más

pequeñas, ampliar nuevas frecuencias de banda y poner dispositivos para aprovechar el ancho de banda, para la segunda generación la señal

se digitalizaba en los sistemas de comunicación móvil, y cada continente generaba sus propios sistemas de tecnologías híbridas.

Page 13: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

6

En Europa las redes de comunicación empezaban a llegar a su máxima

capacidad ya que era mucha la demanda, por lo cual surgió la necesidad de hacer los sistemas de comunicación en términos de usuarios en MHz,

también se necesitó hacer la compatibilidad de los diversos sistemas de

comunicación existentes de otros países, para esto se desarrolló el estándar GSM (Global System for Mobile Communications) que fue

creado en la década de los ochentas implementado en los noventas, ya con esto se le daba apertura a la segunda generación de telefonía móvil.

Para definir como trabajaría el estándar GSM en los sistemas de

comunicación móvil se creó el Grupo Especial Móvil que tenía los objetivos de generalizar un sistema en toda Europa, crear una

estructura celular digital con el sistema de acceso múltiple TDMA (Time division multiple access) de banda estrecha, Algoritmo de codificación de

fuente de velocidad binaria y permitir terminales de mayor seguridad.

En la evolución americana no había problemas como en Europa que se tenían que compatibilizar los diversos sistemas de comunicación

existentes, ya que éste contaba con uno sólo el AMPS, pero llegó a

cambiar los canales de comunicación por unos nuevos. Luego también aparecen las operaciones de modo dual en 1991, que permitieron dar

servicio a los sistemas antiguos análogos, utilizaba una técnica de TDMA y era conocida como NADC o IS−54 o DAMPS, ya que tomaban

como infraestructura el AMPS.

A mediados de los noventas también fue instaurado D-AMPS y D-AMPS-1900 que llegaban a utilizar frecuencias superiores al AMPS, ya después

surgió el estándar CDMA (Code division multiple access) que llegaba a sustituir el estándar TDMA, ya que este trabajaba un acceso múltiple

por división de código. Este estándar también ofreció una capacidad mayor, simplificaba el plano de frecuencias y tenía mayor flexibilidad, al

tener canales más anchos era menos susceptibles a la propagación multicamino, ya después el estándar fue nombrado por la TIA como

IS−95.

En Asia surgió el PDS (Pacific Digital cellular), el cual fue hecho por

empresas como Ericsson, NEC, etc. Junto con la NTT, después otras empresas asiáticas quisieron crear estándares implementarlos en otros

países asiáticos, pero no se tuvo éxito.

Después surgieron otros sistemas como el PHS (Personal Handyphon System) el cual era un sistema un poco limitado en su alcance ya que

daba una cobertura no mayor de 200 mts. se aplicaba en áreas muy

Page 14: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

7

pobladas y no era de uso especial para celulares, fue implementado a

mediados de la década de los noventas.

A continuación tenemos la tabla 1.3 en ella se muestra cómo

trabajaban algunos estándares de la segunda generación.

Tabla 1.3. Características de la segunda generación.

La segunda generación aprovecha las ventajas de los sistemas anteriores de la primera generación, pero al introducir la comunicación

digital, tanto para las comunicaciones vocales y de datos como para la señalización, permite la prestación de un gran número de servicios

adicionales. Asimismo, mejora la eficiencia de los sistemas analógicos permitiendo, en consecuencia un incremento en la capacidad de manejo

de tráfico.

1.4 GENERACIÓN 2.5

Con el transcurso de los años también evolucionarán otros medios de comunicación, una de las herramientas que en la actualidad utiliza el

hombre para comunicarse es el internet, el cual llegó a tomar fuerza dentro de las comunicaciones móviles por lo cual se llega a la necesidad,

de crear GPRS (Global Packet Radio Service).

La tecnología GPRS tiene bases sobre GSM que utiliza las mismas frecuencias, utilizando la transmisión de datos por medio de paquetes,

pero esta tecnología tiene dos características importantes, la primera es

Page 15: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

8

que los usuarios comparten los canales y la segunda es que se obtiene

una mejor eficiencia y velocidad en la red.

El servicio de soporte de nodos GPRS (SGSN: Serving GPRS Support

Node) es el encargado de elegir los paquetes de datos desde y hacia las estaciones móviles sin su servicio de área. Su táctica incluye

transferencia y ruteado de paquetes, gestión de la movilidad, gestión lógica del enlace y autenticación. El registro de información del SGSN

almacena información de localización y perfiles de usuario de todos los usuarios registrados a la SGSN. Un nodo de soporte GPRS (GGSN:

Gateway GPRS Support Node) actúa como una interfaz entre la red tronca GPRS y las redes de paquetes de datos externas. Convierte los

paquetes GPRS entrantes de la SGSN en los correspondientes formatos para los paquetes de datos de control (PDP), y los envía fuera a la

correspondiente red de paquetes de datos.

Para la tecnología GPRS se incluyeron una nueva serie de nodos llamados nodos de soporte GPRS (GSM), que son responsables de

deliberar y direccionar los paquetes de datos entre estaciones móviles y

redes de paquetes de datos externas (PDN).

Para esta generación también llegaron a existir otros dos tipos más de estándares que son la EDGE (Enhanced data rates for Global Evolution)

permite conseguir transmisiones de datos a velocidades de 384kbps cuando todas las ranuras de datos son usadas, y la HSCSD (High Speed

Circuit Switched Data) proporciona a un usuario el poder acceder a varios canales a la vez.

1.5 TERCERA GENERACIÓN 3G

El crecimiento de usuarios de telefonía celular junto a la demanda del

uso de internet, uso del correo electrónico desde terminales móviles, y la capacidad de transmitir datos e imágenes desde teléfonos celulares,

nos lleva a la transformación de los estándares de servicio existentes en

la segunda generación ya que estos no fueron creados para la transmisión de datos.

En los últimos años de la década de los noventas, la evolución en los

sistemas móviles creció rápidamente, hasta llegar a la llamada 3G, en la cual cada área geográfica toma los estándares, mejora sus velocidades

y aplicaciones. Es importante que al mencionar la 3G se basa en los estándares de la segunda generación como (GSM, D-AMPS, etc).

Page 16: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

9

En América para la 3G salieron los estándares CDMA2000 Y WCDMA,

que son sistemas de banda ancha que permiten al usuario, mayores velocidades de transmisión de datos y un uso más eficaz del espectro de

radio.

WCDMA se destina en manera esencial a aquellos operadores de

espectro de 2GHz, sobre todo en los mercados en los que GSM ha sido la primera tecnología celular digital en implementarse.

CDMA2000 se designa principalmente a los operadores de IS-95, ya

existentes en bandas de 800 y 1900 MHz y trabaja en dos tipos de modulación, la MC (Modulación Multiportadora) y la DS (Esparcimiento

Directo).[3]

Para Europa se adopta el sistema UMTS, éste se considera una evolución de GSM, en la configuración de los canales de acuerdo a las necesidades

del servicio, cosa que no ofrecía.

También cuenta con una arquitectura bien planeada y se puede definir

en tres partes, en el equipo del usuario, la red UTRAN (Terrestrial Radio Access Network) y la red central, la cual puede garantizar el

funcionamiento global en los sistemas, al ser un proceso gradual con continuas evoluciones y revisiones, 3GPP se propuso para dar cada

cierto tiempo un conjunto de especificaciones que constituyen el estándar.[4]

Para Asia específicamente en China y Corea, se están trabajando entre

los estándares de CDMA2000, WCDMA/UMTS y algunos otros.

En la figura 1.4 vemos la aparición de algunos estándares de Europa y de la Unión Americana de acuerdo a su generación.

Page 17: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

10

Tabla 1.4. Los principales estándares de comunicación móvil y su evolución.

1.6 CUARTA GENERACIÓN 4G

Esta cuarta generación se prevé que saldrá al servicio para el 2012 en

Asia, las innovaciones serán: mensajería de multimedia, TV de alta definición, DVB, video chat, video y televisión; todo esto manejado bajo

protocolo de internet TCP/IP basado en la tecnología de comunicación WiMax.

Ahora se están implementando estándares para esta generación como la

USRAM (UMTS Satellite Radio Acces), ésta se considera como una red satelital que estará conectada a UMTS. Después seguimos con la OFDMA

(Orthogonal Frequency Division Multiple Access). Ésta se define por funciones de sistema en donde las subportadoras se agrupan en

unidades más grandes, conocidos como subcanales, que estos son

agrupados en ráfagas que pueden ser asignados a los usuarios inalámbricos.

Otro estándar es el LTE (Long Term Evolution) que empresas como

Ericsson, Motorola, Nortel, Alcatel-Lucent y Qualcomm son sólo algunas que ya están trabajando con esta tecnología en Europa, cada uno con su

propia visión pero, al parecer, esta vez con estándares abiertos lo que

Page 18: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

11

redundará no sólo en que las operadoras que adquieran esta

infraestructura, sino también en los consumidores porque se podrá llegar a economías de escala.

Una de las tecnologías en la cual se trabaja la 4G se llama RDS (Radio definido por software) el cual es definido en software y cuyo

comportamiento en capa física puede ser significativamente alterado a través de cambios a este nivel. El RDS se inicia a trabajar con el desde

2.5G, 3G y 4G su trabajo es integrar las diversas arquitecturas de comunicación, en la cual podremos ver en le siguiente caíitulo su

definición y funcionalidad.[5]

Page 19: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

12

CAPÍTULO II: Radio definido por software.

En este capítulo veremos lo que es un Radio Definido por Software

(RDS), su arquitectura, su funcionamiento, el proceso de conversión de frecuencia de las señales para trabajar con ellas, así como su

modulación y codificación para transmitir la información.

2.1 INTRODUCCIÓN

En el siglo XX se da un auge de aplicaciones de radio basadas en Hardware con el propósito de lograr comunicación a grandes distancias.

La mayoría de las transmisiones de radio se basaban en Hardware y muy poco o nada de Software de control, por lo cual tenían un periodo

de vida corto y estaban diseñadas para ser descartadas y reemplazadas.

A principios del año 2000 se ha estado investigando y desarrollando un nuevo concepto de equipos de radiocomunicaciones, equipos de radio

que son desarrollados por programas llamados “radios software” o Radio

Definidos por Software, en donde la parte del Hardware es mínima y la mayor parte de su funcionamiento esta definido por un programa en una

PC.

El Radio Definido por Software usa dispositivos digitales programables que ayudan para mejorar el procesamiento de señales necesarias para

transmitir y recibir información en banda base a radiofrecuencia. Los dispositivos más usados son los DSP´s (Procesadores Digitales de

Señales), y los FPGA’s (Arreglos de Compuertas de Campo Programables) ya que ofrecen más flexibilidad y un periodo de vida más

largo.

El propósito del RDS es igualar a los dispositivos basados en Hardware mientras proporcionan mayor flexibilidad e inteligencia que el software

puede ofrecer, además de que el usuario no necesitara saber lo

fundamental de la tecnología en transmisiones de radio [6].

2.2 RADIO DEFINIDO POR SOFTWARE

El Radio Definido por Software es un equipo con la característica de ser flexible, lo cual significa que podemos diversificar su funcionalidad

únicamente modificando su programa o software, por ejemplo, un equipo de radio se puede configurar para que pueda operar en

cualquiera de los modos actualmente en uso: banda lateral única, amplitud modulada, frecuencia modulada, e incluso incorporar nuevas

modalidades como (PSK, SSTV, etc.) con solo modificar el software [7].

Page 20: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

13

El RDS tiene como propósito realizar gran parte de las funciones de un equipo de radio mediante el software. La mayoría de equipos de radio

modernos dotados de interfaces informáticas, son equipos que pueden

ser controlados desde una PC donde se pueden visualizar funciones y parámetros que se encuentran en la parte frontal del equipo como: la

frecuencia, selección de modo de operación (AM, FM, CW…), Control Automático de Ganancia (CAG).

El RDS tiene casi todos sus componentes definidos y funcionando en

programas (software) a excepción de algunos componentes físicos necesarios para el RDS que no pueden ser definidos en software, el

software es el que define el esquema de modulación a emplear, la codificación, el tipo de silenciador (squelch) y como actúa el CAG.

Como ya se ha mencionado el RDS es muy flexible, ya que modificando

el software se pueden modificar su funcionalidad lo cual permite acomodar el RDS de acuerdo a las necesidades del usuario [8].

2.2.1 ARQUITECTURA DE TRANSMISIONES DE RADIO TRADICIONAL

La figura 2.1, muestra un transceiver superheterodino con conversión dual. Es un diseño del año 1930, y es casi seguro que una gran mayoría

de hogares poseen un receptor superheterodino de alguna clase (difusión de radio, televisión, etc.).

Figura 2.1. Arquitectura Tradicional de Transmisores de Radio.

Page 21: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

14

Desde el punto de vista del receptor la radiofrecuencia de la antena es

convertida en una frecuencia intermedia debido a un proceso de mezcla o multiplexado de la señal entrante con el primer oscilador local LO1. La

frecuencia intermedia es filtrada y luego mezclada a banda base por el

segundo oscilador LO2, y el mezclador. La señal modulada en banda base es demodulada para producir la información analógica del receptor,

y la función recíproca es realizada por el transmisor. El número de etapas de conversión depende de la frecuencia de operación,

teóricamente es posible agregar etapas y empujar la frecuencia de operación más alta.

El transceiver superheterodino ha experimentado un maravilloso éxito a

lo largo de la historia; fue utilizado en teléfonos móviles terminales de 1G y es seguro que soportará los receptores de radio de bajo costo de

muchos años por venir. Esta arquitectura fue muy útil para los sistemas de teléfonos móviles 1G, como los sistemas de telefonía móvil avanzada

(AMPS), la cual usa frecuencia modulada (FM) multiplexación por división de frecuencia (FD) para permitir el acceso a múltiples usuarios a

porciones fijas del espectro. Los sistemas AMPS asignan una porción del

espectro dedicado de 30KHz para cada usuario sin tener en cuenta la cantidad de información a ser intercambiada.

2.2.2 ARQUITECTURA IDEAL DE TRANSMISORES DE RADIO BASADOS

EN SOFTWARE

La arquitectura de transmisores basados en software ideal se muestra en la figura 2.2, consiste en un subsistema digital y un simple

subsistema analógico. Las funciones analógicas son restringidas a aquellas que no pueden ser mejoradas digitalmente, que son: antena,

filtrado RF, Combinación RF, Preamplificación en recepción, transmisión de potencia de amplificación y generación de frecuencia de referencia.

Page 22: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

15

Figura 2.2. Arquitectura ideal de Transmisores de Radio Basados en Software.

La arquitectura empuja la etapa de conversión analógica hacia la

derecha lo más cerca posible de la antena, en este caso se prioriza al amplificador de potencia (PA) en el transmisor y después al amplificador

de bajo ruido (LNA) en el receptor. La separación de portadoras y la conversión de frecuencias altas y bajas a banda base es mejorada por

los medios de procesamiento digital. De igual manera la codificación del canal y las funciones de modulación son mejoradas digitalmente en

banda base por los mismos medios de procesamiento. El software para una arquitectura ideal es en capas entonces el hardware es

completamente abstracto de la aplicación de software. Una capa intermedia logra esa funcionalidad cubriendo los elementos del

hardware como objetos y proveyendo servicios que permiten a los objetos comunicarse unos con otros mediante interfases estándar, por

ejemplo Common Object Request Broker Architecture (CORBA). La capa intermedia incluye: sistema operativo, controladores del hardware,

recursos de administración y otras aplicaciones no específicas de

software. La combinación del hardware y la capa intermedia frecuentemente se llama framework.

Diseños futuros de RDS y frameworks usarán una API abierta en capa

intermedia que desarrollara aplicaciones más portábles, rápidas y más baratas. Los desarrollos de aplicaciones serán liberados para diseñar

para diseñar programas en hardware de bajo nivel y permitirán

Page 23: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

16

concentrar en bloques, más complicadas y de complejas aplicaciones

[6].

2.2.3 PRINCIPIO DE FUNCIONAMIENTO DE UN RECEPTOR RDS

Consta de una etapa frontal de radiofrecuencia (RF) cuya función es

convertir la señal de radio recibida, trasladándola a frecuencias muy inferiores, en la banda de audio. Aquí es colocado un detector un tanto

especial de conversión directa a la cual se le ha añadido unos filtros de banda seleccionables en el paso de antena. En esta etapa la señal de

radiofrecuencia es bajada al rango de las frecuencias de audio, pero sigue siendo una señal sin demodular. La etapa de conversión directa

hace trasladar las señales de RF a otras frecuencias muy inferiores, dicha señal ya desplazada a la banda de audio, ocupa un margen de

frecuencias que puede ser de 20 a 40 KHz.

Se utilizan convertidores analógico-digitales (A/D) que digitalizan la señal generando un flujo continuo de bits que representan digitalmente

las señales analógicas de entrada, se puede decir que el convertidor A/D

está conectado casi directamente a la antena.

En la digitalización las señales de entrada, se transforman de señales analógicas de entrada, continuas en el tiempo en una secuencia de

señales discretas, esto es, que se presentan a intervalos determinados y que se denominan muestras. Una vez digitalizadas estas muestras de la

señal analógica, las señales eléctricas que las componen (bits) tendrán un número de valores posibles de amplitud fijo y determinado, dos en el

caso de las señales digitales binarias denominadas “0” y “1” lógicos. Una vez que la señal ha sido muestreada y digitalizada podemos procesarla

como queramos.

Todos estos procesos se realizan mediante cálculos matemáticos adecuados por software, pues al fin y al cabo las señales digitales son

señales discretas que representan valores numéricos y por tanto se

pueden tratar matemáticamente con el software. Los resultados numéricos de estos tratamientos matemáticos son también

representados por señales digitales, las cuales son procesadas para mostrar la información en la pantalla de la PC, o a través de dispositivos

de lógica programable.

Page 24: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

17

2.2.4 CONVERSIÓN DE FRECUENCIA

Para trabajar una señal en software no se puede trabajar con señales de

frecuencias altas, por lo tanto es necesario convertir las señales de RF a

señales de frecuencias bajas que estén en el rango de frecuencias que se pueden aceptar 20 KHz a 40 KHz.

Para convertir una señal de un tipo de banda de frecuencia a otra se

utiliza un “mezclador” el cual combina 2 señales, la que recibe la antena y una generada por un oscilador local, la cual es una señal sin modular,

como se ve en la figura 2.3. Lo que se obtiene a la salida del mezclador son las señales cuya frecuencia es la suma y resta de las frecuencias

aplicadas en ambas entradas del mezclador, fa es la señal de la antena y fo es la señal generada por el oscilador local y también algo de las 2

señales.

Figura 2.3. Combinación de dos señales (fa y fo) mediante un mezclador.

Un receptor que trabaja por conversión de frecuencias debe utilizar un

filtro a la salida del mezclador esto con el fin de dejar pasar únicamente

la señal que nos interesa y eliminar las demás [8].

2.3 MODULACIÓN

Modular una señal llamada portadora consiste en modificar algunas de

sus características de acuerdo a características de otra señal llamada moduladora [9].

La modulación es un proceso en el cual se coloca información que está

contenida en una señal de baja frecuencia (moduladora) en una de alta frecuencia (portadora), dicha señal es modificada en algunos de sus

parámetros, la modificación es proporcional a la amplitud de la señal moduladora [10].

El propósito de la modulación es tener control de algunos elementos de la señal, los cuales son modificados de acuerdo a la forma de onda de la

señal a transmitir, como se muestra en la figura 2.4 [9].

Page 25: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

18

Figura 2.4. Ejemplo de Modulación.

Existen varios motivos por los que se modula una señal: Para facilitar la propagación de la señal de información ya sea por

medios alámbricos o inalámbricos.

Ordena el radioespectro, distribuyendo canales a cada tipo de

información.

Disminuye dimensiones de antenas.

Optimiza el ancho de banda de cada canal.

Evita interferencias entre canales.

Protege la información contra degradaciones por ruido.

Define la calidad de la información transmitida [11].

2.3.1 TIPOS DE MODULACIÓN ANALÓGICA Y DIGITAL

Existen 2 tipos de modulación básicas; la analógica que se realiza a partir de señales de información como: la voz, audio y video en su

forma eléctrica y la modulación digital que se realiza a partir de señales generadas por fuentes digitales como una PC.

Tipos de modulación analógica: Modulación en Amplitud (AM),

Modulación en Frecuencia (FM), Modulación en Fase (PM), Modulación por Amplitud de Pulsos (PAM), Modulación por Anchura de Pulsos

(PWM), Modulación por Posición de Pulso (PPM).

Page 26: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

19

Tipos de modulación digital: Modulación en Amplitud, Apagado Encendido (ASK), Modulación por Desviación de Frecuencia (FSK),

Modulación por Desviación de Fase (PSK), Modulación de Amplitud en

Cuadratura (QAM) [11].

En la figura 2.5 se observa las gráficas de la modulación en amplitud y en frecuencia.

Figura 2.5. Gráficas de la modulación en amplitud y en frecuencia

Page 27: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

20

2.4 DEMODULACIÓN

Es el proceso por el cual se puede recuperar una señal de datos o señal

moduladora de una señal modulada, es decir obtener la fuente de

información original, como se muestra en la figura 2.6.

Figura 2.6. Demodulación

El proceso de modulación – demodulación para el RDS es básicamente

el esquema BPSK, se explica a continuación.

2.4 TRANSMISIÓN POR DESPLAZAMIENTO DE FASE BINARIA

(BPSK)

Este es un tipo de modulación digital, donde la señal de entrada es una señal digital binaria y son posibles 2 fases de salida para una sola

frecuencia de portadora, una fase representa un “1” lógico y la otra un “0” lógico. Conforme va cambiando de estado la señal de entrada, la

fase de la señal portadora de salida se desplaza entre dos ángulos que se encuentran desfasados 180º.

2.4.1 TRANSMISOR BPSK

En la figura 2.7 se muestra un diagrama de un modulador BPSK. El

modulador balanceado actúa como conmutador para invertir la fase,

dependiendo del estado de la señal digital de entrada “1” o “0”, la portadora es transferida a la salida ya sea en fase o 180º desfasada con

el oscilador de la portadora de referencia.

Page 28: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

21

Figura 2.7. Diagrama de un Transmisor BPSK.

En la figura 2.8 se muestra el diagrama fasorial y el diagrama de

constelación o diagrama de espacio de estado de señal del modulador BPSK.

Figura 2.8. Diagrama Fasorial y de Constelación del Modulador BPSK.

La figura 2.9 muestra la fase de salida contra la relación de tiempo para una forma de onda BPSK. El espectro de salida de un modulador de

BPSK es, sólo una señal de doble banda lateral con portadora suprimida, donde las frecuencias laterales superiores e inferiores están separadas

Page 29: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

22

de la frecuencia de la portadora por un valor igual a la mitad de la razón

de bit.

Figura 2.9. Fase de salida contra la relación de tiempo para una forma de onda BPSK.

2.4.2 RECEPTOR BPSK

La figura 2.10 muestra el diagrama a bloques del receptor BPSK. La señal de entrada puede ser ±sen w ct. El circuito de recuperación de

portadora coherente detecta y regenera una señal de portadora que es

coherente, tanto en frecuencia como en fase, con la portadora del transmisor original. El modulador balanceado es un detector de

producto; la salida es el producto de las dos entradas (la señal de BPSK y la portadora recuperada). El filtro pasa-bajas (LPF) separa los datos

binarios recuperados de la señal demodulada compleja [13].

Page 30: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

23

Figura 2.10. Diagrama de un Receptor BPSK.

2.5 CODIFICACIÓN

La codificación de un canal consiste en mapear la secuencia de datos entrantes en una secuencia de entrada al canal y realizar el mapeo

inverso a la salida en una secuencia de datos donde el ruido sea mínimo, esto con el fin de mejorar la fiabilidad de la transmisión [12].

La codificación de canal es representar la información de manera que se minimice la probabilidad de error.

Existen diversos tipos de código a continuación se expondrán algunos de ellos:

2.5.1 CÓDIGOS DE PARIDAD

Los códigos de paridad añaden un bit a la secuencia que se va a enviar,

de tal forma que el número de unos (1s) sea par o impar, dependiendo el tipo de paridad:

Si la paridad es par, el número final de unos debe ser par.

Si la paridad es impar, el número final de unos debe ser impar.

2.5.2 CÓDIGOS M ENTRE N

Este tipo de código tiene la característica de que todas las palabras de

código tienen la misma longitud de “m” bits, de los cuales, “n” bits son

1s, ejemplo:

5 bits entre 3: 01101, 10011, 11100.

Page 31: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

24

2.6 CÓDIGOS DE BLOQUE LINEALES SISTEMÁTICOS

Este tipo de códigos es capaz de detectar x-1 bits erróneos, donde x

esta dado por la distancia haming mínima entre 2 palabras de código y

también es capaz de corregir (x-1)/2 bits erróneos. Estos códigos cumplen la siguiente propiedad:

La suma módulo-2 de 2 palabras del código, da lugar a otra palabra de

código.

Para la especificación de estos códigos se usa la notación (n,k) donde “n” es el tamaño de la palabra codificada, “k” es el tamaño del mensaje

original, estos “k” bits se envían sin alterar, los n-k bits restantes son los bits de paridad, está es la redundancia mediante la cual se detectan

y corrigen los errores.

La forma de una palabra de código de un código de bloque lineal sistemático es la siguiente:

m0m1 . . . mk-1b0b1 b2 . . . bn-k-1

Donde m0.....mk-1 son los bits del mensaje original y b0....bn-k-1 son los bits de paridad que se añaden como redundancia.

De esta forma, podemos expresar una palabra de código como:

c0c1. . . cn-k-1cn-k. . . cn-1

El cálculo de los bits de paridad se realiza de la siguiente forma:

bi = P0i m0 + P1i m1 + . . . + Pk-1i mk-1

Donde los Pij deben ser tales que la matriz generadora del código tenga

filas independientes y las ecuaciones de paridad sean iguales.

Para realizar la codificación se utiliza una notación matricial.

Consideraremos la palabra original, la palabra formada por los bits de paridad y la palabra de código como vectores: m = (m0m1. . . mk-1), b =

(b0b1. . . bn-k-1), c = (c0c1. . . cn-1)

Page 32: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

25

También se utiliza la matriz de coeficientes:

Para realizar la codificación se utiliza la matriz generadora:

G = [Ik,k | P ]

Siendo Ik,k la matriz identidad de tamaño k X k.

De esta forma podemos obtener cada palabra de código a partir de cada palabra de mensaje original realizando la siguiente multiplicación:

c = m • G

Para realizar la decodificación, en destino se recibe un vector “c” de tamaño “n” y lo que se puede hacer es repetir la operación realizada en

la codificación: se toman los primeros “k” bits y se calcula la redundancia usando la matriz generadora y se comprueba si la

redundancia obtenida es igual a la redundancia recibida.

Otra opción más eficiente es la basada en el concepto de síndrome. En el proceso de decodificación basado en el síndrome se utiliza la matriz

de chequeo de paridad, que se define de la siguiente forma:

H = [I | Pt]

“H” tiene la propiedad de que sólo las palabras de código verifican que al multiplicarlas por Ht el resultado es el vector nulo. Esta propiedad será

utilizada para la detección y corrección de errores.

A cada palabra que el receptor recibe a través del canal la

denominaremos palabra recibida y la denominaremos “r”. Una palabra recibida la podemos expresar como:

r = c + e

Page 33: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

26

Donde “c” es la palabra de código enviada por el emisor y e es una

palabra de error. Cada componente ei de la palabra de error podrá valer “1” si hay un error en esa posición y “0” si no lo hay.

El receptor para realizar la codificación utiliza la matriz “H” para calcular el vector de síndrome de error a partir de la palabra recibida. El vector

de síndrome de error se obtiene de la siguiente forma:

s = r • Ht

El vector de síndrome tiene tantos elementos como bits de paridad se estén usando el vector de síndrome sólo depende de la secuencia de

error y no de la palabra de código transmitida.

Si en la transmisión no se ha producido un error, el síndrome es el vector nulo:

s = r • Ht = 0

Si se ha producido un error la multiplicación de la palabra recibida por Ht nos da un vector que es igual a una de las filas de Ht. La posición que

ocupa esa fila es la posición donde hay un error.

Todas estas operaciones se hacen en módulo-2 (sin acarreo).

Para la detección y corrección de errores simples la matriz “H” debe cumplir con las siguientes condiciones:

Todas las columnas de la matriz “H” deben ser diferentes. Esta

condición hace que se pueda localizar la posición del error.

Ninguna de las columnas de “H” pueden ser todas ceros. Esta

condición se debe a que el síndrome es el vector nulo cuando no

hay error.

Cuando se quiere corregir más de un error, por ejemplo dos errores, la matriz “H” debe verificar lo siguiente:

Todas las columnas de la matriz “H” deben ser diferentes.

Ninguna de las columnas de “H” pueden ser todas ceros.

La suma de las columnas dos a dos debe ser diferente (Si la

matriz “H” tiene 5 columnas hay 10 sumas diferentes que se

pueden hacer. Lo que dice esta propiedad es que todas ellas

deben dar resultados diferentes).

Page 34: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

27

Esta última condición complica el cálculo de códigos correctores de dos bits y en la práctica no se suelen utilizar. Cuando hay más de un error

se pedirá una repetición de la secuencia al emisor (vuelta atrás).

2.7 CÓDIGO DE HAMMING

El código de Hamming es un código de bloque lineal el cual se puede

denotar mediante un par (n,k), sin embargo estos valores “n” y “k” deberán cumplir algunas condiciones:

“n” es la longitud de la palabra de código.

“k” es el número de bits de datos de la palabra original sin codificar.

El número de bits de paridad será m=n-k, pero deberá cumplirse la

siguiente relación entre la longitud de la palabra de código y el número

de bits de paridad: n=2m-1 con m>=3.

Según esto también se cumplirá la siguiente relación entre el número de

bits de datos y el número de bits de paridad: k=2m-m-1.

A cada palabra original le serán añadidos unos bits de paridad para

obtener la palabra de código, de forma que estos bits de paridad sirvan

después para detectar y corregir errores que se hayan producido durante la transmisión.

Cada bit de paridad que se haya añadido a la palabra original va a

afectar a ciertas posiciones de la palabra de código nueva tomando un valor adecuado para que cumpla el criterio de paridad (par o impar).

Después se determina que posiciones de bits de la palabra código afecta

cada bit de paridad, para eso se construyen todas las combinaciones posibles con “m” bits de paridad y se interpreta cada uno en binario

natural.

bm ..................... b3 b2 b1 Posición 0....................... 0 0 0............ 0

0....................... 0 0 1............ 1 0....................... 0 1 0............ 2

0....................... 0 1 1............ 3

Cada bit de paridad va a afectar a aquellas posiciones en las que ese bit

vale 1.

Page 35: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

28

Bit de paridad Posiciones

b1................. 1, 3, 5, 7,.......... b2................. 2, 3, 6, 7,..........

..................................................

bm ................. 2m, 2m+1,2m+2,…

Por último sólo nos queda determinar que posiciones de cada palabra de código ocupará cada bit de paridad. Los bits de paridad han de colocarse

en aquellas posiciones en las que no se vean afectados por otros bits de paridad. Estas posiciones serán:

Bit de paridad Posición

b1................... 20

b2................... 21

b3................... 22

De esta forma queda completado el proceso de construcción de un código de Hamming [12].

Por ejemplo, si se quiere transmitir el dato: 1101101101 (paridad

impar) [14].

Page 36: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

29

2.8 DECODIFICACIÓN HAMMING

En este proceso, el receptor recibe una palabra con codificación Hamming y debe comprobar si es correcta o no, en caso de no ser

correcta debe comprobar en que bit se produjo el error y corregirlo. Para comprobar que la palabra recibida es correcta, el receptor debe

utilizar los bits de paridad de la palabra y hacer con ellos un control de

paridad, para esto se crea una palabra que tendrá un bit por cada uno de los bits de paridad usados. Cada uno de los bits de esta palabra

tomará el valor 0 o 1 dependiendo de que el número de 1s de las posiciones de la palabra de código afectadas por su bit de paridad

correspondiente cumple con el criterio de paridad. Interpretando la combinación resultante en binario natural se tendrán dos posibilidades:

Que sea un 0, lo que significa que no hubo errores durante la

transmisión.

Que sea un número distinto de 0, lo cual quiere decir que hubo error

durante la transmisión y que el bit situado en la posición indicada por

ese número cambio.

Ya obtenida la palabra de código correcta, se quitan los bits de paridad para obtener la palabra original enviada por el emisor [12].

Si recibimos el dato: 111000101101101

Page 37: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

30

El resultado de calcular nuevamente el código Hamming nos da la

posición del bit erróneo 0101. No habrá bit erróneo si la posición resultante es 0. O bien se ha producido un error indetectable. La ventaja

de estos códigos es la detección y conexión de errores [14].

2.9 CÓDIGOS CONVOLUCIONALES

Son códigos diferentes a los códigos de bloque en su forma estructural y

su forma para la detección de errores. Los códigos de bloque tienen una capacidad limitada para corregir errores, únicamente 1 o 2 símbolos

erróneos por palabra de código. Estos códigos son buenos para usarse en canales con una probabilidad de error muy baja, los códigos

Convolucionales son adecuados para usarse en canales con una probabilidad de error alta.

Los códigos Convolucionales son códigos lineales, en donde la suma de

2 palabras de código cualesquiera también es una palabra de código. El sistema tiene memoria, la codificación actual depende de los datos que

se envían ahora y que se enviaron en el pasado.

Los códigos Convolucionales son especificados por 3 parámetros

(n,k,m), donde “n” es el número de bits de la palabra codificada, “k” es el número de bits de la palabra de datos y “m” es la memoria del código

o longitud restringida [12].

Los procesos mencionados tales como la modulación – demodulación y la codificación, se pueden programar a través de dispositivos de lógica

programable tales como los FPGA’s, a través de lenguajes de programación los cuales estudiamos en el siguiente capitulo.

Page 38: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

31

CAPÍTULO III: Dispositivos de lógica programable.

3.1 INTRODUCCIÓN.

Los dispositivos de lógica programable PLD ( Programmable Logic

Device) en las últimas décadas se han colocado en los circuitos electrónicos de control, para trabajar con funciones muy complejas que

exigirían un número elevado de circuitos integrados (CI) de función específica, éstos son los llamados CI específicos a una aplicación o ASIC

(Application Specific Integrated Circuit). Por regla general, los ASICs son producidos por fabricantes de CI con las especificaciones proporcionadas

por el usuario.

Los ASICs en gran cantidad resultan ser más baratos que los equipos CI de función fija, ocupan menos espacio, consumen menos energía y son

mas fiables. Existen diferentes tipos de ASICs y son los siguientes:

- Circuitos Integrados a Medida (Full Custom)

Se diseñan de acuerdo a las especificaciones que requiere el cliente para

que resuelva una determinada aplicación, para hacer este tipo de CI a medida su empleo se justifica para volúmenes de producción muy altos

y es mayor el costo de desarrollo. El tiempo necesario para construir una CI a medida puede llevar desde unos meses hasta un año.

- Las Matrices de Puertas (Gate Arrays)

Se elaboran con matrices que trabajan con pequeños trozos de silicio,

con un proceso de metalización que define las conexiones entre un importante número de puertas o transistores, y crean una serie de

células básicas utilizadas por los macros y realizan funciones como:

sumadores; puertas NOT, AND, NAND, NOR XOR, etc.; latches y

flip−flops S−R, J−K, D; buffer; osciladores; registros, decodificadores,

multiplexores, etc.

- Células Normalizadas (Standard Cell)

Las tarjetas Standard Cell son similares a las Gate Arrays, pero trabajan mejor con circuitos depurados como: puertas lógicas, circuitos Msi, Ram

estáticas, ficheros de registro, etc. Para las matrices de puertas sólo hay que realizar la máscara final que define las conexiones entre las puertas

y las células normalizadas, hay que realizar máscaras para todos los procesos de producción de los CI.

Page 39: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

32

- FPIC (Field Programmable Integrated Circuits)

Son chips que se programan por el usuario mediante programadores

comerciales, el término FPIC también incluye a los CI no destinados a las aplicaciones lógicas, tienen aplicaciones de bajo costo y se clasifican

en PLD (Programmable Logic Device), las FPGA (Field Programmable Gate Array) y los ASPLD (Aplication Specific Programmable Logic

Devices).

3.2 PLD

Los PLDs (Programmable Logic Devices) son pequeñas ASICs configurables por el usuario capaces de realizar una determinada

función lógica. La mayoría de los PLD consisten en una matriz de puertas AND seguida de otra matriz de puertas OR como se muestra en

la figura 3.1. Mediante esta estructura, puede realizarse cualquier función como suma de términos productos.

Figura 3.1. Estructura interna de un PLD.

Aunque las memorias PROM, EPROM y EEPROM son PLDs, muchas veces se las excluye de esta denominación debido a que su contenido se

Page 40: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

33

define utilizando elementos de desarrollo propios de microprocesadores,

tales como; ensambladores, emuladores y lenguajes de programación de alto nivel. Otras veces, cuando estas memorias se usan para realizar

una función lógica y no para guardar un programa de un

microprocesador, se las incluye dentro del término PLD.

3.3 ASPLD

Los ASPLDs (Application Specific Programmable Logic Devices) son PLDs diseñados para realizar funciones específicas como, decodificadores de

alta velocidad, secuenciadores, interfaces para buses particulares, periféricos programables para microprocesadores, etc.

Partes del ASPLD son programables permitiendo la adaptación del

circuito a una aplicación determinada, pero manteniendo su función básica; así, por ejemplo, un decodificador lo personaliza el usuario, pero

sigue siendo un decodificador. Estos circuitos están muy optimizados para la función a la que han sido diseñados. Los decodificadores sólo

tienen un término producto, carecen de puertas OR y resultan por

consiguiente muy rápidos; por otro lado, los circuitos de interface para buses normalmente tienen un Fan−Out (número de entradas elevado).

3.4 PAL

La PAL (Programmable Array Logic) también conocidas como PLA que

permitieron un mayor número de entradas y la inclusión de registros, esos dispositivos han continuado creciendo en tamaño y potencia, son

como PLDs que tiene una OR de efectos fijos y AND en serie de matriz programable como se uestra en la figura 3.2.

Page 41: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

34

Figura 3.2. Estructura interna de una PAL.

3.5 FPGA

La FPGA (Field Programmable Gate Array) es un dispositivo que surgió a mediados de los ochentas, fue una de las nuevas arquitecturas de los

circuitos integrados, ha sido consideraba como un circuito de lógica programable.

Este dispositivo ayuda a los diseñadores de sistemas, a revolucionar la

implementación de sistemas digitales configurables ya que permite

manejar y modificar miles de compuertas lógicas que la componen de esta forma ayuda a evolucionar y mejorar el funcionamiento de otros

sistemas electrónicos de control y de comunicaciones. En este capítulo hablaremos sobre estas tarjetas.

La tarjeta FPGA salió gracias al conjunto de dos tecnologías distintas

que son dispositivos lógicos programables PLDs [Programmable Logic Devices] y los ASIC (Application Specific Iintegrated Circuit).

Page 42: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

35

Después como evolución de las ASIC surgió la FPGA creada por Xilinx, es un dispositivo que no sólo tendría puertas programables, sino que

también tienen interconexiones programables entre puertas.

Tiempo después surgió la idea de crear un chip de computadora que se

utilizara la nueva tecnología de matrices de puertas programables y pudo ser completamente personalizado utilizando un software.

En el proyecto se dispuso dos objetivos: determinar la manera de

interconectar los planos de conjuntos, y para crear un compilador que se pueden programar funciones en estos nuevos chips. Después para 1986

sale a al mercado la tarjeta FPGA y llegan a tomar diferentes aplicaciones como para sistemas de seguridad, equipos de

comunicación, control, etc.[16]

Existen dispositivos FPGA de baja tecnología antifusibles, ésta fue creada en el año de 1991 por las empresas Plus Logic y Texas

Instruments, esta tarjeta tenia una arquitectura parecida a la LCA (logic

cell array) donde su similitud de ésta, es que tiende a la utilización de los recursos dispuestos en la pastilla mediante una extensión de bloques

de entradas y salidas repartidos alrededor de la pastilla y posibilidades de interconexión entre diferentes bloques lógicos colocados en la matriz

en el centro con sus líneas de interconexión.

Ya en la actualidad la mayoría de los dispositivos de la FPGA se basan en la tecnología SRAM por lo que permite tener una configuración

volátil, que permite la flexibilidad para modificar el comportamiento del dispositivo.[17]

3.5.1 ESTRUCTURA GENERAL DE LA FPGA

Los dispositivos lógicos programables como las PAL, PLD y ASIC, tenían

una estructura con compuertas fijas (AND/OR) que podrían ser

programadas, pero para las FPGA tiene en su lugar bloques lógicos ya que se pueden implementar mas funciones de transferencia. En la figura

3.3 se muestra la estructura general de una FPGA.

Page 43: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

36

Figura 3.3. Estructura interna de una FPGA general

En la figura 3.3 se muestran los elementos básicos que contiene una FPGA que son los siguientes:

- Las células de entrada y salida.

- Recursos de interconexión, cuya estructura y contenido se denomina arquitectura de rutado.

- Los bloques lógicos, los componentes que disponen cada uno

pueden variar de acuerdo al fabricante.

El bloque más utilizado por los fabricantes es el LUT (Lookup table) como se muestra en la figura 3.4, este contiene celdas de

almacenamiento, las que se ocupan para implementar simples funciones lógicas. Cada celda es capaz de mantener un simple valor lógico, ya sea

un 0 o un 1. Este valor almacenado (0 o 1) es obtenido luego a la salida de la celda de almacenamiento.

Page 44: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

37

Figura 3.4. Estructura del LUT de un bloque lógico

Para la asignación de las entradas y salidas, asi como la programación

de las LUT existen varios métodos, los mas utilizados son los de tecnología antifusible (antifuse) y la tecnología SRAM.

Para la tecnología SRAM este problema no es válido, pero la precisión

de los programas de simulación disponibles se impone para optimizar el uso de simuladores ya que no son reprogramables las tecnologías ya

mencionadas, pero va creciendo la complejidad y se hace difícil la depuración de los mismos ya que no cuenta con los accesos directos a

los distintos puntos de interés.

La forma de configurar la FPGA varia dependiendo de la tecnología adoptada, en caso de las FPGA basadas en tecnología antifusible las

mismas son programadas una sola vez y haciendo uso de un programador dedicado.

La tecnología SRAM en las FPGA, leen su configuración interna de una memoria no volátil que es la que mantiene el programa. Una vez

finalizada la transferencia la FPGA se configura y comienza a funcionar. Esta carga se realiza en los POWER-UP o por un reset del dispositivo

[18,19].

3.5.2 LENGUAJES PARA PROGRAMAR EN FPGAs

Se pueden ocupar diferentes tipos de lenguajes para programar la FPGAs de acuerdo a su utilidad y algunos ejemplos son los siguientes:

• Lenguajes de Descripción de hardware

– VHDL, Verilog. • Lenguajes de Alto Nivel

– HandelC, System C, Forge.

Page 45: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

38

• Simuladores: – Active HDL, ModelSim, Cadence, LAbView, Simulink (Matlab),

System Generator.

• Síntesis: – FPGA Compiler, Synplicity, Leonardo.

• Ambientes integrados – Xilinx ISE, Max Plus, Libero.

En la figura 3.5 se muestra los pasos de programación de una FPGA ya

que en este caso la escritura de este tipode programación, es igual al código de un programa de un ordenador, todo depende de la máquina

que se este trabajando, para la configuración de la FPGA que se inicia en un alto nivel.

En la etapa se introduce el lenguaje de descripción del hardware (HDL),

un programa llamado flowcharting, para describir el diseño que tendrá el chip.

Ya que existen muchos programas (HDL), cada una contiene sus propias funciones simplificando el diseño para hacer más eficientes, proponiendo

sus ventajas para el funcionamiento de las mismas. Pero los primeros pasos son similares a los de un compilador de lenguaje de

programación.

Figura 3.5. Programación de una tarjeta FPGA a pasos.

Page 46: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

39

Utilizamos las FPGA ya que es una clase especial de chip para implementar en hardware un código de aplicación, es como tener una

placa para implementar circuitería personalizada por medio de

hardware.

Para este proyecto estamos trabajando con la tarjeta Xilinx Spartan-3 200000-puerta Plataforma FPGA - XC3S200 como se muestra en la

figura 3.6.

Figura 3.6. Tarjeta FPGA Xilinx Spartan-3 200000-puerta.

Page 47: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

40

Los beneficios de la FPGA son el rendimiento, la fiabilidad y la

flexibilidad. Se tiene flexibilidad que puede definir por software el comportamiento del chip, ya proporciona el rendimiento de la circuitería

personalizada para su ejecución de aplicación de medida y control, y

también tiene una fiabilidad máxima ya que su aplicación se basa en hardware.

Con esto tenemos la flexibilidad de un hardware personalizado, y

permitir la flexibilidad para trabajar en un sistema definido por software, con esto se podrá ayudar a diseñadores de sistemas a revolucionar la

implementación de sistemas digitales configurables.

Los otros dispositivos como PLD y ASPLD son de función específica, y de poca capacidad de programación para ejecución de funciones más

complejas, en sistemas digitales.

Page 48: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

41

CAPÍTULO IV: Simulación e implementación en FPGA,

pruebas y resultados.

4.1 INTRODUCCIÓN

En este capítulo se presenta el proceso de diseño, simulación e

implementación del Modulador, Demodulador BPSK, Codificador y Decodificador Hamming 7,4. El entorno de desarrollo utilizado para

realizar la simulación es Simulink de Mathworks, además de herramientas de Xilinx como System Generator para realizar los

diagramas a bloques, y Xilinx ISE para grabar la tarjeta FPGA Spartan-3 Starter Kit Board.

4.2 MODULADOR BPSK.

Como ya se ha mencionado en el capítulo 2, la modulación BPSK es una

modulación digital, por lo tanto trabaja con una señal de entrada digital

binaria y tiene 2 fases de salida dependiendo el estado de la señal de entrada, cuando se tiene un estado alto “1” la portadora se transfiere a

la salida en fase y si es un estado bajo “0” se transfiere desfasada 180º. En la figura 4.1 se muestra como se realiza la modulación.

Figura 4.1. Fase de salida contra la relación de tiempo para una forma de onda BPSK.

Page 49: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

42

Para la simulación y posterior implementación, el esquema general para

la modulación es como se muestra en la figura 4.2.

Figura 4.2. Diagrama del Modulador BPSK.

Los bloques utilizados para realizar el modulador BPSK son: sine wave, gain, scope, random number, constant y relational operator (de

simulink) y gateway in, gateway out, mux de system generator.

Para crear el generador de bits (binary data source) se crea un subsistema utilizando los bloques random number, que generará

números 0 ó 1 en forma aleatoria, el bloque constant, para asignar valores constantes y el bloque relational operator, con el cual

podemos hacer comparaciones entre dos valores. Nuestro subsistema quedaría como se muestra en la figura 4.3

Figura 4.3. Subsistema generador de bits (binary data source).

Para crear el bloque de subsistema se selecciona el diagrama con el

mouse, después hacemos clic derecho sobre el diagrama y seleccionamos la opción crear subsistema quedándonos un bloque

llamado subsystem (binary data source) como se ve en la figura 4.2. La función de este subsistema es que compara el número generado por el

bloque random number y el valor constante “0” mediante el bloque relational operator, si ese número es mayor a cero la salida será un

“1”, lo cual significa que la salida será únicamente un “1” o un “0”.

Page 50: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

43

Con el bloque sine wave vamos a generar la señal sen wct y para

generar la señal - sen wct se pasa por el bloque gain el cual multiplica la salida del sine wave por -1.

Utilizamos el bloque mux de las herramientas de Xilinx para seleccionar la señal que pasará por este bloque dependiendo el estado de la salida

del generador de bits. El generador de bits se conecta a la entrada sel del bloque mux, a la entrada d0 se conecta la salida del bloque gain y

a la entrada d1 se conecta la salida del bloque sine wave, cabe mencionar que para conectar el generador de bits y las 2 señales al

bloque mux se hace utilizando el bloque gateway in el cual convierte los datos de los bloques de Simulink para poder usarlos con los bloques

de Xilinx, de igual forma se utiliza el bloque gateway out para convertir los datos de los bloques de Xilinx para usarlos con los de Simulink.

Conectamos las salidas de los bloques mux, sine wave, gain y del

generador de bits al scope para observar las señales obtenidas de la modulación y que se muestran en la figura 4.4.

Figura 4.4. Resultados obtenidos de la simulación del modulador BPSK.

Generador de Bits

Salida del Modulador

Señal –sen wct

Señal sen wct

Page 51: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

44

4.3 DEMODULADOR BPSK.

En la figura 4.5 se muestra el diagrama del demodulador BPSK:

Figura 4.5. Diagrama del demodulador BPSK.

Para la señal de entrada del demodulador, se creó un subsistema

llamado BPSK el cual contiene el esquema del modulador. Para recuperar el mensaje original multiplicamos la señal modulada por la

portadora sen wct utilizando el bloque mult, después se pasa por un filtro pasa bajas en este caso es el bloque Transfer Fcn para separar

los datos binarios recuperados de la señal demodulada y finalmente

pasarla por un comparador el cual es el bloque relational operator para detectar los niveles de voltaje unos y ceros.

Los resultados obtenidos de la simulación se muestran en la figura 4.6.

Figura 4.6. Resultados obtenidos de la simulación para la demodulación BPSK.

Señal modulada

Señal demodulada

Page 52: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

45

4.4 CODIFICADOR HAMMING 7,4

Para implementar la codificación hamming 7,4 realizamos un análisis del

código de la función de matlab encoder para determinar la matriz

generadora “g” utilizada en esta codificación, la cual debe ser una matriz de tamaño 4x7. Para esto, primero se obtiene la matriz de verificación

de paridad con la función h=hammgen(m), donde “m” es el número de bits de paridad que se van a agregar y la matriz generadora se

obtiene con la función g=gen2par(h) donde “h” es la matriz de verificación de paridad. Después de realizar varias pruebas la matriz

generadora es la siguiente:

La codificación hamming es un código de bloque lineal denotado por (n, k) donde “n” es el tamaño de la palabra codificada y “k” es el tamaño

del mensaje, esto quiere decir que el mensaje será de 4 bits y codificado será de 7 bits. El mensaje será de la forma a = [a3 a2 a1 a0] y el

mensaje codificado será b = [b6 b5 b4 b3 b2 b1 b0]. Para obtener cada uno de los elementos de “b” se realiza de la siguiente forma:

Operaciones para obtener el mensaje codificado y con lo cual se puede

generar el diagrama de la figura 4.7 son:

Page 53: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

46

Figura 4.7. Diagrama del codificador implementado con compuertas AND y

XOR.

En la figura 4.8 se muestran los bloques de entrada y salida del codificador, así como los valores constantes 1 y 0 que son utilizados

para los valores de la matriz generadora.

Figura 4.8. Bloques de entrada y salida del codificador.

Para comprobar el funcionamiento del codificador hamming creamos un subsistema que servirá como generador de bits con el que

introduciremos el mensaje a codificar el cual será para ejemplificar [1 0 0 1], como se observa en la figura 4.9.

Page 54: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

47

Figura 4.9. Subsistema generador de bits.

Para crear nuestro bloque o subsistema Hamming Encoder, seleccionamos el diagrama mostrado en la figura 4.7, damos clic

derecho sobre el y seleccionamos la opción crear subsistema. En la figura 4.10 se muestra el diagrama del codificador, así como los

resultados obtenidos de la simulación.

Figura 4.10. Resultado obtenido de la simulación de la codificación.

4.5 DECODIFICADOR HAMMING 7,4

De la misma forma que en la codificación se revisó el código de la

función decoder de matlab para determinar la matriz de verificación de paridad obtenida con la función [h,gen] = hammgen(m), “h” será la

matriz de verificación de paridad y “gen” la matriz generadora, el parámetro “m” resulta de la operación para determinar el número de

bits de paridad, en este caso m = n – k, 7 – 4 = 3.

Page 55: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

48

Se puede ver que la función trt = syndtable(h), contiene la matriz de

verificación de paridad y da como resultado “trt” una matriz de verificación de errores para la decodificación de palabras codificadas, en

este caso de longitud 7 y longitud de mensaje original 4. Las matrices

obtenidas son las siguientes:

En la figura 4.11, se muestra el diagrama del decodificador el cual esta

conformado por 2 subsistemas, el generador de bits y el Hamming decoder.

Figura 4.11. Esquema del decodificador hamming.

Figura 4.12. Subsistema Hamming Decoder.

Page 56: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

49

El decodificador Hamming esta formado por dos subsistemas: syndrome

y decodificación como se aprecia en la figura 4.12, empezaremos por explicar el subsistema syndrome. Con el subsistema syndrome

obtenemos el número de errores de la palabra codificada, para esto

aplicamos la matriz transpuesta a la matriz “h” para multiplicarla por el mensaje codificado “b” y obtendremos el número de errores e = [e2 e1

e0] como se vio en el capítulo 2.

Las operaciones para obtener el número de errores en el mensaje codificado y con lo cual se puede generar el diagrama del subsistema

syndrome figura 4.13 son las siguientes:

Figura 4.13. Diagrama del subsistema syndrome implementado con

compuertas AND y XOR.

Page 57: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

50

Figura 4.14. Entradas y salidas del subsistema syndrome para obtener el

número de errores.

En la figura 4.14 se observan las salidas del bloque syndrome, en la cual las salidas de la 1 a la 7 sale el mensaje codificado que se utilizará en el

siguiente bloque que es la decodificación y de las salidas 8 a la 10 sale el número de errores en bits.

Dentro del subsistema decodificación se encuentra el subsistema Err_loc

con el cual vamos a obtener la posición del error en el mensaje codificado. Para determinar la posición del error utilizaremos la matriz

“trt” y dependiendo del número de errores obtenidos del bloque síndrome, se va a seleccionar el renglón de dicha matriz, ejemplo:

supongamos que el error es [1 1 0] que en número decimal es igual a 6, esto es, se selecciona el renglón 6 de la matriz “trt” [0 0 0 1 0 0 0],

para poder implementar esta parte realizamos la tabla de verdad para cada uno de los valores de número de error y obtendremos la salida del

bloque Err_loc:

Número de error Salida del bloque Err_loc

s2 s1 s0 trt6 trt5 trt4 trt3 trt2 trt1 trt0

0 0 0 0 0 0 0 0 0 0

0 0 1 0 0 1 0 0 0 0

0 1 0 0 1 0 0 0 0 0

0 1 1 0 0 0 0 1 0 0

1 0 0 1 0 0 0 0 0 0

1 0 1 0 0 0 0 0 0 1

1 1 0 0 0 0 1 0 0 0

1 1 1 0 0 0 0 0 1 0

Tabla 4.1 Tabla para determinar las salidas trt dependiendo el número de error

Page 58: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

51

Las operaciones obtenidas de la tabla para seleccionar el renglón de la

matriz “trt” y con las cuales vamos a implementar el diagrama del subsistema Err_loc es mostrado en la figura 4.15:

Figura 4.15. Diagrama del subsistema Err_loc implementado con compuertas

AND y NOT.

Page 59: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

52

Figura 4.16. Entradas y salidas del subsistema Err_loc.

Por último se realiza una operación XOR entre el mensaje codificado “b”

y la salida del subsistema Err_loc o posición del error “trt” para obtener el mensaje original “dec”:

En la figura 4.17 se muestra el diagrama del subsistema decodificador.

Figura 4.17. Diagrama de la decodificación, el mensaje original sale por Out2 y

los bits de paridad que se le quitan al mensaje por Out1.

Page 60: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

53

Para realizar la simulación asignamos el mensaje codificado [0 1 1 1 0 0

1] obtenido de la codificación como se muestra en la figura 4.18.

Figura 4.18. Mensaje codificado.

Los resultados obtenidos de la simulación son mostrados en la figura

4.19.

Figura 4.19. Resultado obtenido de la simulación del decodificador el mensaje original se muestra por el display2.

Page 61: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

54

4.6 GENERACIÓN DE PROYECTO ISE PARA GRABAR LA TARJETA

FPGA.

El proyecto ISE es una serie de archivos utilizados por la herramienta

Xilinx ISE 10.1 para grabar la tarjeta FPGA que se genera por medio del bloque system generator. Para generar este proyecto hacemos doble

clic en el bloque system generator y nos aparece una ventana como la que se muestra en la figura 4.20.

Figura 4.20. Ventana del bloque System Generator para crear proyecto ISE.

Antes de generar el proyecto primero hay que configurar el modelo de la

tarjeta con la que se está trabajando, en compilations options en la

opción que dice Part seleccionamos Spartan3 xc3s200-4ft256 y en donde dice Target Directory seleccionamos la ubicación de la carpeta

donde vamos a generar el proyecto ISE.

Una vez que configuramos el modelo de la tarjeta y la ubicación de nuestra carpeta damos clic en el botón Generate para generar el

proyecto el cual va a contener el código fuente del esquema realizado así como el archivo que se va a grabar en la tarjeta.

Page 62: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

55

Figura 4.21. Ventana del bloque System Generator generando proyecto ISE.

Los archivos generados por system generator se muestran en la figura 4.22, el proyecto ISE es el archivo codificadorhamming_cw.ise

Figura 4.22. Archivos generados por System Generator para el codificador Hamming.

Page 63: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

56

4.7 GRABACIÓN DE LA TARJETA FPGA.

Antes que nada debemos conectar nuestra tarjeta FPGA (figura 4.23), a

la computadora por medio del cable JTAG y a la alimentación (figura

4.24).

Figura 4.23. Tarjeta FPGA Spartan 3 Starter Kit.

Figura 4.24. Conexión del cable JTAG.

Page 64: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

57

Para grabar la tarjeta ejecutamos el archivo (en este caso)

codificadorhamming_cw.ise para abrir el proyecto (figura 4.25).

Figura 4.25. Entorno Xilinx ISE.

En la figura 4.26 observamos una parte del código fuente generado por System Generator y que podemos accesar a él dando doble clic en los

iconos VHD que aparecen en la ventana sources.

Page 65: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

58

Figura 4.26. Ventana del código VHD generado por System Generator.

En nuestro proyecto se pueden programar las entradas y salidas

generadas por system generator, para asignarles cualquier pin de entrada y salida de la tarjeta, leds, switches, push buttons o los displays

de 7 segmentos, para esto seleccionamos el primer icono VHD que aparece en la ventana sources, en este caso seleccionamos

codificadorhamming_cw – structural (codificadorhamming_cw.vhd) después en la ventana processes

damos clic en el triángulo que está a la izquierda de la opción user constraints para ver las demás opciones, luego damos doble clic en

Floorplan Area / IO / Logic – Post – Synthesis para ver la ventana Xilinx PACE, la cual nos muestra las entradas (gateway_in) y salidas

(gateway_out) de nuestro proyecto. En la sub ventana Design Object

List – I/O asignamos a cada entrada o salida el nombre o valor correspondiente a un led, switch, push button, display o pin de la tarjeta

según el manual de usuario de la FPGA, por ejemplo se desea utilizar el Led6 el cual tiene como valor o nomenclatura P12 y se desea asignarlo a

un gateway_out, entonces en la columna Loc se escribe este valor, en la figura 4.27 se observa la ventana Xilinx PACE.

Page 66: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

59

Figura 4.27. Ventana Xilinx PACE.

Para empezar a grabar el FPGA seleccionamos nuevamente el primer

icono VHD de la ventana sources y luego en la ventana processes damos clic derecho sobre la opción Generate Programming File y

seleccionamos la opción properties, después en startup options en FPGA Startup Clock seleccionamos JTAG Clock, damos clic en el

botón Apply y luego en el botón OK (figura 4.28).

Page 67: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

60

Figura 4.28. Ventana Process Properties – Startup Options.

En la ventana Processes en la opción Configure Target Device

damos clic en el triángulo del lado izquierdo para ver las demás opciones, damos doble clic en Manage Configuration Project

(iMPACT), aparece la ventana iMPACT y seleccionamos la primera

opción Configure Devices using Boundary-Scan (JTAG) y damos clic en el botón Finalizar (figura 4.29).

Figura 4.29. Ventana iMPACT.

Page 68: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

61

Una vez que dimos clic en el botón finalizar de la ventana iMPACT se

abrirá una ventana donde seleccionaremos el archivo .bit que se grabará en la tarjeta y que en este caso es el archivo

codificadorhamming_cw.bit, lo seleccionamos y damos clic en el

botón Abrir (figura 4.30), después se vuelve a abrir una ventana para abrir otro archivo, damos clic en el botón que dice Bypass (figura 4.31).

Figura 4.30. Abriendo el archivo .bit que se va a grabar en el FPGA.

Page 69: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

62

Figura 4.31. Después de cargar el archivo .bit se abre otra ventana para seleccionar otro archivo.

A continuación se abre una ventana donde seleccionaremos la opción Device1 (FPGA, xc3s200) y del lado derecho en Property Name

debemos asegurarnos que no esté activada ninguna casilla, damos clic en el botón Apply y luego en el botón OK (figura 4.32).

Figura 4.32. Ventana Device Programming Properties.

Por último en la ventana Processes, seleccionamos la opción que dice Program para empezar a grabar el FPGA (figura 4.33).

Page 70: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

63

Figura 4.33. Programando el FPGA.

La grabación de la modulación y demodulación BPSK, así como la

codificación y decodificación hamming 7,4, se realizaron por separado ya que no se implemento todo el sistema de RDS, únicamente se realizó

la simulación e implementación de estos módulos de software que se pueden programar para el RDS y con esto ejemplificar como se puede

diversificar la funcionalidad del RDS solamente cambiando su software y

así como se implementaron estos módulos se puedan implementar otros tipos de modulación o de codificación.

Page 71: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

64

CONCLUSIONES El RDS es un sistema cuyo principal objetivo es resolver la

incompatibilidad de estándares, que como se describió al inicio del

trabajo, han crecido y en cada continente son diferentes, lo que hace que no se pueda tener un roaming mundial.

Sin embargo la posibilidad de integrar módulos programables en

software permite la creación de bases de datos que contengan estos programas para que el sistema pueda elegir entre estos y utilizar el

adecuado para el estándar requerido.

Cada módulo representará una de las funciones que forman parte de la comunicación digital, en este trabajo se logró la implementación de 4

módulos, la modulación y la codificación para el caso del emisor y la demodulación y la decodificación en el caso del receptor.

Con herramientas de tipo visual como Simulink de matlab y System

Generator de Xilinx creamos los programas del modulador y

demodulador BPSK así como el codificador y decodificador hamming 7,4 para después implementarlos en la FPGA, logrando con esto mostrar que

es posible cambiar la programación de un hardware una vez teniendo el programa de la función que va a realizar, lo cual sería el objetivo

primordial de la 4G.

RECOMENDACIONES PARA TRABAJOS FUTUROS

En el desarrollo del proyecto se comenzó a trabajar en Simulink de Matlab y con System Generator de Xilinx debido a la excelente

compatibilidad para generar el código de los módulos, sin embargo después de contar con esta implementación se pretendió realizarla a

través de otro software para la programación de tarjetas FPGAs como Labview, que esta teniendo mucho auge en la industria sin embargo,

encontramos que a pesar de ser un software visual como simulink, este

no cuenta con la misma compatibilidad de trabajo con Simulink como System Generator, pues desde este se puede generar el código para

llevarlo a las tarjetas, por lo que es recomendable trabajar con tarjetas del mismo fabricante en este caso National Instruments cuenta con sus

propias tarjetas las cuales puede programar y/o controlar con Labview.

Page 72: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

65

GLOSARIO:

Banda base.- Se denomina banda base al conjunto de señales que no sufren ningún proceso de modulación a la salida de la fuente que las origina, es decir son señales que son transmitidas en su frecuencia original. Dichas señales se

pueden codificar y ello da lugar a los códigos de banda base.

Digitalización.- Es el proceso mediante el cual un mensaje se convierte en una sucesión de impulsos eléctricos, equivalente a dígitos combinados (código binario), el 0 ó el 1 (en realidad es una serie de apagado y prendido de

impulso combinados). Estos dígitos son los llamados bits. De esta forma, todo mensaje que es susceptible de transformarse en señal eléctrica y ser codificado

digitalmente puede almacenarse en soporte informático o transmitirse como tren de impulsos por una red adecuada (hilo telefónico, microondas, fibra óptica, cable coaxial, etc.).

Framework.- En el desarrollo de software, es una estructura de soporte

definido, mediante la cual otro proyecto de software puede ser organizado y desarrollado. Típicamente, puede incluir soporte de programas, bibliotecas y un lenguaje interpretado entre otros software para ayudar a desarrollar y unir

los diferentes componentes de un proyecto.

Frecuencia intermedia.- Se denomina Frecuencia intermedia (FI) a la Frecuencia que en los aparatos de radio que emplean el principio superheterodino se obtiene de la mezcla de la señal sintonizada en antena con

una frecuencia variable generada localmente en el propio aparato mediante un oscilador local (OL) y que guarda con ella una diferencia constante. Esta

diferencia entre las dos frecuencias es precisamente la frecuencia intermedia. Filtro pasa-bajas.- Es un circuito formado por una resistencia y un

condensador, que permite el paso de las frecuencias por debajo de la frecuencia de corte y elimina las que sean superiores a ésta.

Muestreo.- Es uno de los procesos involucrados en la digitalización de las

señales analógicas. Consiste en tomar muestras periódicas de la amplitud de la señal analógica. El intervalo entre muestras debe ser constante. El ritmo de este muestreo, llamado frecuencia o tasa de muestreo, determina el número

de muestras que se toma en un intervalo de tiempo.

Multiplexación por división de frecuencias.- La multiplexación por división en frecuencia es una técnica que consiste en dividir mediante

filtros el espectro de frecuencias del canal de transmisión y desplazar la señal a transmitir dentro del margen del espectro correspondiente

mediante modulaciones, de tal forma que cada usuario tiene posesión exclusiva de su banda de frecuencias (llamadas subcanales).

Page 73: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

66

Radiofrecuencia.- También denominado espectro de radiofrecuencia o RF, se aplica a la porción menos energética del espectro electromagnético, situada

entre unos 3 Hz y unos 300 GHz. Señal moduladora.- Señal que contiene la información a transmitir.

Señal portadora.- Es una forma de onda, generalmente senoidal, que es

modulada por una señal que se quiere transmitir. Esta onda portadora es de una frecuencia mucho más alta que la de la señal moduladora (la señal que contiene la información a transmitir).

Page 74: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

67

APÉNDICE A

ESPECIFICACIONES FÍSICAS Y TÉCNICAS DE LA TARJETA:

Para este proyecto estamos trabajando con la tarjeta Xilinx Spartan-3 200000-puerta Plataforma FPGA - XC3S200 contiene los siguientes

componentes y recursos:

• Completamente equipado de placa de circuito impreso que contenga: - Xilinx Spartan-3 200000-puerta Plataforma FPGA - XC3S200

- XCF02S - Xilinx Plataforma Flash de 2 Mbit configuración PROM - XCF02S

- 1 MB de Fast asíncrona de la memoria SRAM proveedor ISSI - Plena capacidad de depuración

- Puertos de la extensión de la tarjeta hija • Evaluación y Fundación ISE WebPACK

- Terminar con el más rápido de la industria de más avanzado

software de diseño.

• Spartan-3 CD de Recursos - Una recopilación de documentación útil sobre el Spartan-3 familia, incluyendo notas de aplicación, hojas de

datos, diseños de referencia y los esquemas.

• JTAG Cable - Fácil de descargar un diseño a la FPGA desde el PC puerto paralelo.

• Power Supply - fuente de alimentación universal (110-220 V, 50/60

Hz) proporciona una salida de +5 V a bordo de regulación de voltaje a 3,3 V, 2,5 V y 1,2 V.

• Guía - Detalles de Xilinx FPGA y los dispositivos de lógica programable

CPLD.

Page 75: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

68

APÉNDICE B

PROGRAMAS GENERADOS EN VHDL

MODULADOR BPSK:

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

package conv_pkg is

constant simulating : boolean := false

-- synopsys translate_off

or true

-- synopsys translate_on

;

constant xlUnsigned : integer := 1;

constant xlSigned : integer := 2;

constant xlWrap : integer := 1;

constant xlSaturate : integer := 2;

constant xlTruncate : integer := 1;

constant xlRound : integer := 2;

constant xlRoundBanker : integer := 3;

constant xlAddMode : integer := 1;

constant xlSubMode : integer := 2;

attribute black_box : boolean;

attribute syn_black_box : boolean;

attribute fpga_dont_touch: string;

attribute box_type : string;

attribute keep : string;

attribute syn_keep : boolean;

function std_logic_vector_to_unsigned(inp : std_logic_vector) return unsigned;

function unsigned_to_std_logic_vector(inp : unsigned) return std_logic_vector;

function std_logic_vector_to_signed(inp : std_logic_vector) return signed;

function signed_to_std_logic_vector(inp : signed) return std_logic_vector;

function unsigned_to_signed(inp : unsigned) return signed;

function signed_to_unsigned(inp : signed) return unsigned;

function pos(inp : std_logic_vector; arith : INTEGER) return boolean;

function all_same(inp: std_logic_vector) return boolean;

function all_zeros(inp: std_logic_vector) return boolean;

function is_point_five(inp: std_logic_vector) return boolean;

function all_ones(inp: std_logic_vector) return boolean;

function convert_type (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith,

quantization, overflow : INTEGER)

return std_logic_vector;

function cast (inp : std_logic_vector; old_bin_pt,

new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector;

function vec_slice (inp : std_logic_vector; upper, lower : INTEGER)

return std_logic_vector;

function s2u_slice (inp : signed; upper, lower : INTEGER)

Page 76: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

69

return unsigned;

function u2u_slice (inp : unsigned; upper, lower : INTEGER)

return unsigned;

function s2s_cast (inp : signed; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return signed;

function u2s_cast (inp : unsigned; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return signed;

function s2u_cast (inp : signed; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return unsigned;

function u2u_cast (inp : unsigned; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return unsigned;

function u2v_cast (inp : unsigned; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return std_logic_vector;

function s2v_cast (inp : signed; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return std_logic_vector;

function trunc (inp : std_logic_vector; old_width, old_bin_pt, old_arith,

new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector;

function round_towards_inf (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt,

new_arith : INTEGER) return std_logic_vector;

function round_towards_even (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt,

new_arith : INTEGER) return std_logic_vector;

function max_signed(width : INTEGER) return std_logic_vector;

function min_signed(width : INTEGER) return std_logic_vector;

function saturation_arith(inp: std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

: INTEGER) return std_logic_vector;

function wrap_arith(inp: std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector;

function fractional_bits(a_bin_pt, b_bin_pt: INTEGER) return INTEGER;

function integer_bits(a_width, a_bin_pt, b_width, b_bin_pt: INTEGER)

return INTEGER;

function sign_ext(inp : std_logic_vector; new_width : INTEGER)

return std_logic_vector;

function zero_ext(inp : std_logic_vector; new_width : INTEGER)

return std_logic_vector;

function zero_ext(inp : std_logic; new_width : INTEGER)

return std_logic_vector;

function extend_MSB(inp : std_logic_vector; new_width, arith : INTEGER)

return std_logic_vector;

function align_input(inp : std_logic_vector; old_width, delta, new_arith,

new_width: INTEGER)

return std_logic_vector;

function pad_LSB(inp : std_logic_vector; new_width: integer)

Page 77: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

70

return std_logic_vector;

function pad_LSB(inp : std_logic_vector; new_width, arith : integer)

return std_logic_vector;

function max(L, R: INTEGER) return INTEGER;

function min(L, R: INTEGER) return INTEGER;

function "="(left,right: STRING) return boolean;

function boolean_to_signed (inp : boolean; width: integer)

return signed;

function boolean_to_unsigned (inp : boolean; width: integer)

return unsigned;

function boolean_to_vector (inp : boolean)

return std_logic_vector;

function std_logic_to_vector (inp : std_logic)

return std_logic_vector;

function integer_to_std_logic_vector (inp : integer; width, arith : integer)

return std_logic_vector;

function std_logic_vector_to_integer (inp : std_logic_vector; arith : integer)

return integer;

function std_logic_to_integer(constant inp : std_logic := '0')

return integer;

function bin_string_element_to_std_logic_vector (inp : string; width, index :

integer)

return std_logic_vector;

function bin_string_to_std_logic_vector (inp : string)

return std_logic_vector;

function hex_string_to_std_logic_vector (inp : string; width : integer)

return std_logic_vector;

function makeZeroBinStr (width : integer) return STRING;

function and_reduce(inp: std_logic_vector) return std_logic;

-- synopsys translate_off

function is_binary_string_invalid (inp : string)

return boolean;

function is_binary_string_undefined (inp : string)

return boolean;

function is_XorU(inp : std_logic_vector)

return boolean;

function to_real(inp : std_logic_vector; bin_pt : integer; arith : integer)

return real;

function std_logic_to_real(inp : std_logic; bin_pt : integer; arith : integer)

return real;

function real_to_std_logic_vector (inp : real; width, bin_pt, arith : integer)

return std_logic_vector;

function real_string_to_std_logic_vector (inp : string; width, bin_pt, arith : integer)

return std_logic_vector;

constant display_precision : integer := 20;

function real_to_string (inp : real) return string;

function valid_bin_string(inp : string) return boolean;

function std_logic_vector_to_bin_string(inp : std_logic_vector) return string;

function std_logic_to_bin_string(inp : std_logic) return string;

function std_logic_vector_to_bin_string_w_point(inp : std_logic_vector; bin_pt :

integer)

return string;

function real_to_bin_string(inp : real; width, bin_pt, arith : integer)

Page 78: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

71

return string;

type stdlogic_to_char_t is array(std_logic) of character;

constant to_char : stdlogic_to_char_t := (

'U' => 'U',

'X' => 'X',

'0' => '0',

'1' => '1',

'Z' => 'Z',

'W' => 'W',

'L' => 'L',

'H' => 'H',

'-' => '-');

-- synopsys translate_on

end conv_pkg;

package body conv_pkg is

function std_logic_vector_to_unsigned(inp : std_logic_vector)

return unsigned

is

begin

return unsigned (inp);

end;

function unsigned_to_std_logic_vector(inp : unsigned)

return std_logic_vector

is

begin

return std_logic_vector(inp);

end;

function std_logic_vector_to_signed(inp : std_logic_vector)

return signed

is

begin

return signed (inp);

end;

function signed_to_std_logic_vector(inp : signed)

return std_logic_vector

is

begin

return std_logic_vector(inp);

end;

function unsigned_to_signed (inp : unsigned)

return signed

is

begin

return signed(std_logic_vector(inp));

end;

function signed_to_unsigned (inp : signed)

return unsigned

is

begin

return unsigned(std_logic_vector(inp));

end;

function pos(inp : std_logic_vector; arith : INTEGER)

return boolean

Page 79: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

72

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

begin

vec := inp;

if arith = xlUnsigned then

return true;

else

if vec(width-1) = '0' then

return true;

else

return false;

end if;

end if;

return true;

end;

function max_signed(width : INTEGER)

return std_logic_vector

is

variable ones : std_logic_vector(width-2 downto 0);

variable result : std_logic_vector(width-1 downto 0);

begin

ones := (others => '1');

result(width-1) := '0';

result(width-2 downto 0) := ones;

return result;

end;

function min_signed(width : INTEGER)

return std_logic_vector

is

variable zeros : std_logic_vector(width-2 downto 0);

variable result : std_logic_vector(width-1 downto 0);

begin

zeros := (others => '0');

result(width-1) := '1';

result(width-2 downto 0) := zeros;

return result;

end;

function and_reduce(inp: std_logic_vector) return std_logic

is

variable result: std_logic;

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

begin

vec := inp;

result := vec(0);

if width > 1 then

for i in 1 to width-1 loop

result := result and vec(i);

end loop;

end if;

return result;

end;

Page 80: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

73

function all_same(inp: std_logic_vector) return boolean

is

variable result: boolean;

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

begin

vec := inp;

result := true;

if width > 0 then

for i in 1 to width-1 loop

if vec(i) /= vec(0) then

result := false;

end if;

end loop;

end if;

return result;

end;

function all_zeros(inp: std_logic_vector)

return boolean

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable zero : std_logic_vector(width-1 downto 0);

variable result : boolean;

begin

zero := (others => '0');

vec := inp;

-- synopsys translate_off

if (is_XorU(vec)) then

return false;

end if;

-- synopsys translate_on

if (std_logic_vector_to_unsigned(vec) = std_logic_vector_to_unsigned(zero))

then

result := true;

else

result := false;

end if;

return result;

end;

function is_point_five(inp: std_logic_vector)

return boolean

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable result : boolean;

begin

vec := inp;

-- synopsys translate_off

if (is_XorU(vec)) then

return false;

end if;

-- synopsys translate_on

Page 81: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

74

if (width > 1) then

if ((vec(width-1) = '1') and (all_zeros(vec(width-2 downto 0)) = true)) then

result := true;

else

result := false;

end if;

else

if (vec(width-1) = '1') then

result := true;

else

result := false;

end if;

end if;

return result;

end;

function all_ones(inp: std_logic_vector)

return boolean

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable one : std_logic_vector(width-1 downto 0);

variable result : boolean;

begin

one := (others => '1');

vec := inp;

-- synopsys translate_off

if (is_XorU(vec)) then

return false;

end if;

-- synopsys translate_on

if (std_logic_vector_to_unsigned(vec) = std_logic_vector_to_unsigned(one))

then

result := true;

else

result := false;

end if;

return result;

end;

function full_precision_num_width(quantization, overflow, old_width,

old_bin_pt, old_arith,

new_width, new_bin_pt, new_arith : INTEGER)

return integer

is

variable result : integer;

begin

result := old_width + 2;

return result;

end;

function quantized_num_width(quantization, overflow, old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

: INTEGER)

return integer

is

Page 82: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

75

variable right_of_dp, left_of_dp, result : integer;

begin

right_of_dp := max(new_bin_pt, old_bin_pt);

left_of_dp := max((new_width - new_bin_pt), (old_width - old_bin_pt));

result := (old_width + 2) + (new_bin_pt - old_bin_pt);

return result;

end;

function convert_type (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith,

quantization, overflow : INTEGER)

return std_logic_vector

is

constant fp_width : integer :=

full_precision_num_width(quantization, overflow, old_width,

old_bin_pt, old_arith, new_width,

new_bin_pt, new_arith);

constant fp_bin_pt : integer := old_bin_pt;

constant fp_arith : integer := old_arith;

variable full_precision_result : std_logic_vector(fp_width-1 downto 0);

constant q_width : integer :=

quantized_num_width(quantization, overflow, old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith);

constant q_bin_pt : integer := new_bin_pt;

constant q_arith : integer := old_arith;

variable quantized_result : std_logic_vector(q_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

result := (others => '0');

full_precision_result := cast(inp, old_bin_pt, fp_width, fp_bin_pt,

fp_arith);

if (quantization = xlRound) then

quantized_result := round_towards_inf(full_precision_result,

fp_width, fp_bin_pt,

fp_arith, q_width, q_bin_pt,

q_arith);

elsif (quantization = xlRoundBanker) then

quantized_result := round_towards_even(full_precision_result,

fp_width, fp_bin_pt,

fp_arith, q_width, q_bin_pt,

q_arith);

else

quantized_result := trunc(full_precision_result, fp_width, fp_bin_pt,

fp_arith, q_width, q_bin_pt, q_arith);

end if;

if (overflow = xlSaturate) then

result := saturation_arith(quantized_result, q_width, q_bin_pt,

q_arith, new_width, new_bin_pt, new_arith);

else

result := wrap_arith(quantized_result, q_width, q_bin_pt, q_arith,

new_width, new_bin_pt, new_arith);

end if;

return result;

end;

Page 83: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

76

function cast (inp : std_logic_vector; old_bin_pt, new_width,

new_bin_pt, new_arith : INTEGER)

return std_logic_vector

is

constant old_width : integer := inp'length;

constant left_of_dp : integer := (new_width - new_bin_pt)

- (old_width - old_bin_pt);

constant right_of_dp : integer := (new_bin_pt - old_bin_pt);

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

variable j : integer;

begin

vec := inp;

for i in new_width-1 downto 0 loop

j := i - right_of_dp;

if ( j > old_width-1) then

if (new_arith = xlUnsigned) then

result(i) := '0';

else

result(i) := vec(old_width-1);

end if;

elsif ( j >= 0) then

result(i) := vec(j);

else

result(i) := '0';

end if;

end loop;

return result;

end;

function vec_slice (inp : std_logic_vector; upper, lower : INTEGER)

return std_logic_vector

is

begin

return inp(upper downto lower);

end;

function s2u_slice (inp : signed; upper, lower : INTEGER)

return unsigned

is

begin

return unsigned(vec_slice(std_logic_vector(inp), upper, lower));

end;

function u2u_slice (inp : unsigned; upper, lower : INTEGER)

return unsigned

is

begin

return unsigned(vec_slice(std_logic_vector(inp), upper, lower));

end;

function s2s_cast (inp : signed; old_bin_pt, new_width, new_bin_pt : INTEGER)

return signed

is

begin

return signed(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlSigned));

Page 84: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

77

end;

function s2u_cast (inp : signed; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return unsigned

is

begin

return unsigned(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlSigned));

end;

function u2s_cast (inp : unsigned; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return signed

is

begin

return signed(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlUnsigned));

end;

function u2u_cast (inp : unsigned; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return unsigned

is

begin

return unsigned(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlUnsigned));

end;

function u2v_cast (inp : unsigned; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return std_logic_vector

is

begin

return cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlUnsigned);

end;

function s2v_cast (inp : signed; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return std_logic_vector

is

begin

return cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt, xlSigned);

end;

function boolean_to_signed (inp : boolean; width : integer)

return signed

is

variable result : signed(width - 1 downto 0);

begin

result := (others => '0');

if inp then

result(0) := '1';

else

result(0) := '0';

end if;

return result;

end;

Page 85: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

78

function boolean_to_unsigned (inp : boolean; width : integer)

return unsigned

is

variable result : unsigned(width - 1 downto 0);

begin

result := (others => '0');

if inp then

result(0) := '1';

else

result(0) := '0';

end if;

return result;

end;

function boolean_to_vector (inp : boolean)

return std_logic_vector

is

variable result : std_logic_vector(1 - 1 downto 0);

begin

result := (others => '0');

if inp then

result(0) := '1';

else

result(0) := '0';

end if;

return result;

end;

function std_logic_to_vector (inp : std_logic)

return std_logic_vector

is

variable result : std_logic_vector(1 - 1 downto 0);

begin

result(0) := inp;

return result;

end;

function trunc (inp : std_logic_vector; old_width, old_bin_pt, old_arith,

new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector

is

constant right_of_dp : integer := (old_bin_pt - new_bin_pt);

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if right_of_dp >= 0 then

if new_arith = xlUnsigned then

result := zero_ext(vec(old_width-1 downto right_of_dp), new_width);

else

result := sign_ext(vec(old_width-1 downto right_of_dp), new_width);

end if;

else

if new_arith = xlUnsigned then

result := zero_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

Page 86: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

79

else

result := sign_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

end if;

end if;

return result;

end;

function round_towards_inf (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

: INTEGER)

return std_logic_vector

is

constant right_of_dp : integer := (old_bin_pt - new_bin_pt);

constant expected_new_width : integer := old_width - right_of_dp + 1;

variable vec : std_logic_vector(old_width-1 downto 0);

variable one_or_zero : std_logic_vector(new_width-1 downto 0);

variable truncated_val : std_logic_vector(new_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if right_of_dp >= 0 then

if new_arith = xlUnsigned then

truncated_val := zero_ext(vec(old_width-1 downto right_of_dp),

new_width);

else

truncated_val := sign_ext(vec(old_width-1 downto right_of_dp),

new_width);

end if;

else

if new_arith = xlUnsigned then

truncated_val := zero_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

else

truncated_val := sign_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

end if;

end if;

one_or_zero := (others => '0');

if (new_arith = xlSigned) then

if (vec(old_width-1) = '0') then

one_or_zero(0) := '1';

end if;

if (right_of_dp >= 2) and (right_of_dp <= old_width) then

if (all_zeros(vec(right_of_dp-2 downto 0)) = false) then

one_or_zero(0) := '1';

end if;

end if;

if (right_of_dp >= 1) and (right_of_dp <= old_width) then

if vec(right_of_dp-1) = '0' then

one_or_zero(0) := '0';

end if;

else

one_or_zero(0) := '0';

Page 87: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

80

end if;

else

if (right_of_dp >= 1) and (right_of_dp <= old_width) then

one_or_zero(0) := vec(right_of_dp-1);

end if;

end if;

if new_arith = xlSigned then

result :=

signed_to_std_logic_vector(std_logic_vector_to_signed(truncated_val) +

std_logic_vector_to_signed(one_or_zero));

else

result :=

unsigned_to_std_logic_vector(std_logic_vector_to_unsigned(truncated_val) +

std_logic_vector_to_unsigned(one_or_zero));

end if;

return result;

end;

function round_towards_even (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

: INTEGER)

return std_logic_vector

is

constant right_of_dp : integer := (old_bin_pt - new_bin_pt);

constant expected_new_width : integer := old_width - right_of_dp + 1;

variable vec : std_logic_vector(old_width-1 downto 0);

variable one_or_zero : std_logic_vector(new_width-1 downto 0);

variable truncated_val : std_logic_vector(new_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if right_of_dp >= 0 then

if new_arith = xlUnsigned then

truncated_val := zero_ext(vec(old_width-1 downto right_of_dp),

new_width);

else

truncated_val := sign_ext(vec(old_width-1 downto right_of_dp),

new_width);

end if;

else

if new_arith = xlUnsigned then

truncated_val := zero_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

else

truncated_val := sign_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

end if;

end if;

one_or_zero := (others => '0');

if (right_of_dp >= 1) and (right_of_dp <= old_width) then

if (is_point_five(vec(right_of_dp-1 downto 0)) = false) then

one_or_zero(0) := vec(right_of_dp-1);

else

one_or_zero(0) := vec(right_of_dp);

Page 88: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

81

end if;

end if;

if new_arith = xlSigned then

result :=

signed_to_std_logic_vector(std_logic_vector_to_signed(truncated_val) +

std_logic_vector_to_signed(one_or_zero));

else

result :=

unsigned_to_std_logic_vector(std_logic_vector_to_unsigned(truncated_val) +

std_logic_vector_to_unsigned(one_or_zero));

end if;

return result;

end;

function saturation_arith(inp: std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

: INTEGER)

return std_logic_vector

is

constant left_of_dp : integer := (old_width - old_bin_pt) -

(new_width - new_bin_pt);

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

variable overflow : boolean;

begin

vec := inp;

overflow := true;

result := (others => '0');

if (new_width >= old_width) then

overflow := false;

end if;

if ((old_arith = xlSigned and new_arith = xlSigned) and (old_width >

new_width)) then

if all_same(vec(old_width-1 downto new_width-1)) then

overflow := false;

end if;

end if;

if (old_arith = xlSigned and new_arith = xlUnsigned) then

if (old_width > new_width) then

if all_zeros(vec(old_width-1 downto new_width)) then

overflow := false;

end if;

else

if (old_width = new_width) then

if (vec(new_width-1) = '0') then

overflow := false;

end if;

end if;

end if;

end if;

if (old_arith = xlUnsigned and new_arith = xlUnsigned) then

if (old_width > new_width) then

if all_zeros(vec(old_width-1 downto new_width)) then

overflow := false;

Page 89: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

82

end if;

else

if (old_width = new_width) then

overflow := false;

end if;

end if;

end if;

if ((old_arith = xlUnsigned and new_arith = xlSigned) and (old_width >

new_width)) then

if all_same(vec(old_width-1 downto new_width-1)) then

overflow := false;

end if;

end if;

if overflow then

if new_arith = xlSigned then

if vec(old_width-1) = '0' then

result := max_signed(new_width);

else

result := min_signed(new_width);

end if;

else

if ((old_arith = xlSigned) and vec(old_width-1) = '1') then

result := (others => '0');

else

result := (others => '1');

end if;

end if;

else

if (old_arith = xlSigned) and (new_arith = xlUnsigned) then

if (vec(old_width-1) = '1') then

vec := (others => '0');

end if;

end if;

if new_width <= old_width then

result := vec(new_width-1 downto 0);

else

if new_arith = xlUnsigned then

result := zero_ext(vec, new_width);

else

result := sign_ext(vec, new_width);

end if;

end if;

end if;

return result;

end;

function wrap_arith(inp: std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector

is

variable result : std_logic_vector(new_width-1 downto 0);

variable result_arith : integer;

begin

if (old_arith = xlSigned) and (new_arith = xlUnsigned) then

Page 90: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

83

result_arith := xlSigned;

end if;

result := cast(inp, old_bin_pt, new_width, new_bin_pt, result_arith);

return result;

end;

function fractional_bits(a_bin_pt, b_bin_pt: INTEGER) return INTEGER is

begin

return max(a_bin_pt, b_bin_pt);

end;

function integer_bits(a_width, a_bin_pt, b_width, b_bin_pt: INTEGER)

return INTEGER is

begin

return max(a_width - a_bin_pt, b_width - b_bin_pt);

end;

function pad_LSB(inp : std_logic_vector; new_width: integer)

return STD_LOGIC_VECTOR

is

constant orig_width : integer := inp'length;

variable vec : std_logic_vector(orig_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

variable pos : integer;

constant pad_pos : integer := new_width - orig_width - 1;

begin

vec := inp;

pos := new_width-1;

if (new_width >= orig_width) then

for i in orig_width-1 downto 0 loop

result(pos) := vec(i);

pos := pos - 1;

end loop;

if pad_pos >= 0 then

for i in pad_pos downto 0 loop

result(i) := '0';

end loop;

end if;

end if;

return result;

end;

function sign_ext(inp : std_logic_vector; new_width : INTEGER)

return std_logic_vector

is

constant old_width : integer := inp'length;

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if new_width >= old_width then

result(old_width-1 downto 0) := vec;

if new_width-1 >= old_width then

for i in new_width-1 downto old_width loop

result(i) := vec(old_width-1);

end loop;

end if;

Page 91: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

84

else

result(new_width-1 downto 0) := vec(new_width-1 downto 0);

end if;

return result;

end;

function zero_ext(inp : std_logic_vector; new_width : INTEGER)

return std_logic_vector

is

constant old_width : integer := inp'length;

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if new_width >= old_width then

result(old_width-1 downto 0) := vec;

if new_width-1 >= old_width then

for i in new_width-1 downto old_width loop

result(i) := '0';

end loop;

end if;

else

result(new_width-1 downto 0) := vec(new_width-1 downto 0);

end if;

return result;

end;

function zero_ext(inp : std_logic; new_width : INTEGER)

return std_logic_vector

is

variable result : std_logic_vector(new_width-1 downto 0);

begin

result(0) := inp;

for i in new_width-1 downto 1 loop

result(i) := '0';

end loop;

return result;

end;

function extend_MSB(inp : std_logic_vector; new_width, arith : INTEGER)

return std_logic_vector

is

constant orig_width : integer := inp'length;

variable vec : std_logic_vector(orig_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if arith = xlUnsigned then

result := zero_ext(vec, new_width);

else

result := sign_ext(vec, new_width);

end if;

return result;

end;

function pad_LSB(inp : std_logic_vector; new_width, arith: integer)

return STD_LOGIC_VECTOR

Page 92: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

85

is

constant orig_width : integer := inp'length;

variable vec : std_logic_vector(orig_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

variable pos : integer;

begin

vec := inp;

pos := new_width-1;

if (arith = xlUnsigned) then

result(pos) := '0';

pos := pos - 1;

else

result(pos) := vec(orig_width-1);

pos := pos - 1;

end if;

if (new_width >= orig_width) then

for i in orig_width-1 downto 0 loop

result(pos) := vec(i);

pos := pos - 1;

end loop;

if pos >= 0 then

for i in pos downto 0 loop

result(i) := '0';

end loop;

end if;

end if;

return result;

end;

function align_input(inp : std_logic_vector; old_width, delta, new_arith,

new_width: INTEGER)

return std_logic_vector

is

variable vec : std_logic_vector(old_width-1 downto 0);

variable padded_inp : std_logic_vector((old_width + delta)-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if delta > 0 then

padded_inp := pad_LSB(vec, old_width+delta);

result := extend_MSB(padded_inp, new_width, new_arith);

else

result := extend_MSB(vec, new_width, new_arith);

end if;

return result;

end;

function max(L, R: INTEGER) return INTEGER is

begin

if L > R then

return L;

else

return R;

end if;

end;

Page 93: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

86

function min(L, R: INTEGER) return INTEGER is

begin

if L < R then

return L;

else

return R;

end if;

end;

function "="(left,right: STRING) return boolean is

begin

if (left'length /= right'length) then

return false;

else

test : for i in 1 to left'length loop

if left(i) /= right(i) then

return false;

end if;

end loop test;

return true;

end if;

end;

-- synopsys translate_off

function is_binary_string_invalid (inp : string)

return boolean

is

variable vec : string(1 to inp'length);

variable result : boolean;

begin

vec := inp;

result := false;

for i in 1 to vec'length loop

if ( vec(i) = 'X' ) then

result := true;

end if;

end loop;

return result;

end;

function is_binary_string_undefined (inp : string)

return boolean

is

variable vec : string(1 to inp'length);

variable result : boolean;

begin

vec := inp;

result := false;

for i in 1 to vec'length loop

if ( vec(i) = 'U' ) then

result := true;

end if;

end loop;

return result;

end;

function is_XorU(inp : std_logic_vector)

Page 94: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

87

return boolean

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable result : boolean;

begin

vec := inp;

result := false;

for i in 0 to width-1 loop

if (vec(i) = 'U') or (vec(i) = 'X') then

result := true;

end if;

end loop;

return result;

end;

function to_real(inp : std_logic_vector; bin_pt : integer; arith : integer)

return real

is

variable vec : std_logic_vector(inp'length-1 downto 0);

variable result, shift_val, undefined_real : real;

variable neg_num : boolean;

begin

vec := inp;

result := 0.0;

neg_num := false;

if vec(inp'length-1) = '1' then

neg_num := true;

end if;

for i in 0 to inp'length-1 loop

if vec(i) = 'U' or vec(i) = 'X' then

return undefined_real;

end if;

if arith = xlSigned then

if neg_num then

if vec(i) = '0' then

result := result + 2.0**i;

end if;

else

if vec(i) = '1' then

result := result + 2.0**i;

end if;

end if;

else

if vec(i) = '1' then

result := result + 2.0**i;

end if;

end if;

end loop;

if arith = xlSigned then

if neg_num then

result := result + 1.0;

result := result * (-1.0);

end if;

Page 95: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

88

end if;

shift_val := 2.0**(-1*bin_pt);

result := result * shift_val;

return result;

end;

function std_logic_to_real(inp : std_logic; bin_pt : integer; arith : integer)

return real

is

variable result : real := 0.0;

begin

if inp = '1' then

result := 1.0;

end if;

if arith = xlSigned then

assert false

report "It doesn't make sense to convert a 1 bit number to a signed real.";

end if;

return result;

end;

-- synopsys translate_on

function integer_to_std_logic_vector (inp : integer; width, arith : integer)

return std_logic_vector

is

variable result : std_logic_vector(width-1 downto 0);

variable unsigned_val : unsigned(width-1 downto 0);

variable signed_val : signed(width-1 downto 0);

begin

if (arith = xlSigned) then

signed_val := to_signed(inp, width);

result := signed_to_std_logic_vector(signed_val);

else

unsigned_val := to_unsigned(inp, width);

result := unsigned_to_std_logic_vector(unsigned_val);

end if;

return result;

end;

function std_logic_vector_to_integer (inp : std_logic_vector; arith : integer)

return integer

is

constant width : integer := inp'length;

variable unsigned_val : unsigned(width-1 downto 0);

variable signed_val : signed(width-1 downto 0);

variable result : integer;

begin

if (arith = xlSigned) then

signed_val := std_logic_vector_to_signed(inp);

result := to_integer(signed_val);

else

unsigned_val := std_logic_vector_to_unsigned(inp);

result := to_integer(unsigned_val);

end if;

return result;

end;

Page 96: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

89

function std_logic_to_integer(constant inp : std_logic := '0')

return integer

is

begin

if inp = '1' then

return 1;

else

return 0;

end if;

end;

function makeZeroBinStr (width : integer) return STRING is

variable result : string(1 to width+3);

begin

result(1) := '0';

result(2) := 'b';

for i in 3 to width+2 loop

result(i) := '0';

end loop;

result(width+3) := '.';

return result;

end;

-- synopsys translate_off

function real_string_to_std_logic_vector (inp : string; width, bin_pt, arith : integer)

return std_logic_vector

is

variable result : std_logic_vector(width-1 downto 0);

begin

result := (others => '0');

return result;

end;

function real_to_std_logic_vector (inp : real; width, bin_pt, arith : integer)

return std_logic_vector

is

variable real_val : real;

variable int_val : integer;

variable result : std_logic_vector(width-1 downto 0) := (others => '0');

variable unsigned_val : unsigned(width-1 downto 0) := (others => '0');

variable signed_val : signed(width-1 downto 0) := (others => '0');

begin

real_val := inp;

int_val := integer(real_val * 2.0**(bin_pt));

if (arith = xlSigned) then

signed_val := to_signed(int_val, width);

result := signed_to_std_logic_vector(signed_val);

else

unsigned_val := to_unsigned(int_val, width);

result := unsigned_to_std_logic_vector(unsigned_val);

end if;

return result;

end;

-- synopsys translate_on

function valid_bin_string (inp : string)

return boolean

Page 97: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

90

is

variable vec : string(1 to inp'length);

begin

vec := inp;

if (vec(1) = '0' and vec(2) = 'b') then

return true;

else

return false;

end if;

end;

function hex_string_to_std_logic_vector(inp: string; width : integer)

return std_logic_vector is

constant strlen : integer := inp'LENGTH;

variable result : std_logic_vector(width-1 downto 0);

variable bitval : std_logic_vector((strlen*4)-1 downto 0);

variable posn : integer;

variable ch : character;

variable vec : string(1 to strlen);

begin

vec := inp;

result := (others => '0');

posn := (strlen*4)-1;

for i in 1 to strlen loop

ch := vec(i);

case ch is

when '0' => bitval(posn downto posn-3) := "0000";

when '1' => bitval(posn downto posn-3) := "0001";

when '2' => bitval(posn downto posn-3) := "0010";

when '3' => bitval(posn downto posn-3) := "0011";

when '4' => bitval(posn downto posn-3) := "0100";

when '5' => bitval(posn downto posn-3) := "0101";

when '6' => bitval(posn downto posn-3) := "0110";

when '7' => bitval(posn downto posn-3) := "0111";

when '8' => bitval(posn downto posn-3) := "1000";

when '9' => bitval(posn downto posn-3) := "1001";

when 'A' | 'a' => bitval(posn downto posn-3) := "1010";

when 'B' | 'b' => bitval(posn downto posn-3) := "1011";

when 'C' | 'c' => bitval(posn downto posn-3) := "1100";

when 'D' | 'd' => bitval(posn downto posn-3) := "1101";

when 'E' | 'e' => bitval(posn downto posn-3) := "1110";

when 'F' | 'f' => bitval(posn downto posn-3) := "1111";

when others => bitval(posn downto posn-3) := "XXXX";

-- synopsys translate_off

ASSERT false

REPORT "Invalid hex value" SEVERITY ERROR;

-- synopsys translate_on

end case;

posn := posn - 4;

end loop;

if (width <= strlen*4) then

result := bitval(width-1 downto 0);

else

result((strlen*4)-1 downto 0) := bitval;

Page 98: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

91

end if;

return result;

end;

function bin_string_to_std_logic_vector (inp : string)

return std_logic_vector

is

variable pos : integer;

variable vec : string(1 to inp'length);

variable result : std_logic_vector(inp'length-1 downto 0);

begin

vec := inp;

pos := inp'length-1;

result := (others => '0');

for i in 1 to vec'length loop

-- synopsys translate_off

if (pos < 0) and (vec(i) = '0' or vec(i) = '1' or vec(i) = 'X' or vec(i) = 'U') then

assert false

report "Input string is larger than output std_logic_vector. Truncating

output.";

return result;

end if;

-- synopsys translate_on

if vec(i) = '0' then

result(pos) := '0';

pos := pos - 1;

end if;

if vec(i) = '1' then

result(pos) := '1';

pos := pos - 1;

end if;

-- synopsys translate_off

if (vec(i) = 'X' or vec(i) = 'U') then

result(pos) := 'U';

pos := pos - 1;

end if;

-- synopsys translate_on

end loop;

return result;

end;

function bin_string_element_to_std_logic_vector (inp : string; width, index :

integer)

return std_logic_vector

is

constant str_width : integer := width + 4;

constant inp_len : integer := inp'length;

constant num_elements : integer := (inp_len + 1)/str_width;

constant reverse_index : integer := (num_elements-1) - index;

variable left_pos : integer;

variable right_pos : integer;

variable vec : string(1 to inp'length);

variable result : std_logic_vector(width-1 downto 0);

begin

vec := inp;

Page 99: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

92

result := (others => '0');

if (reverse_index = 0) and (reverse_index < num_elements) and (inp_len-3 >=

width) then

left_pos := 1;

right_pos := width + 3;

result := bin_string_to_std_logic_vector(vec(left_pos to right_pos));

end if;

if (reverse_index > 0) and (reverse_index < num_elements) and (inp_len-3 >=

width) then

left_pos := (reverse_index * str_width) + 1;

right_pos := left_pos + width + 2;

result := bin_string_to_std_logic_vector(vec(left_pos to right_pos));

end if;

return result;

end;

-- synopsys translate_off

function std_logic_vector_to_bin_string(inp : std_logic_vector)

return string

is

variable vec : std_logic_vector(1 to inp'length);

variable result : string(vec'range);

begin

vec := inp;

for i in vec'range loop

result(i) := to_char(vec(i));

end loop;

return result;

end;

function std_logic_to_bin_string(inp : std_logic)

return string

is

variable result : string(1 to 3);

begin

result(1) := '0';

result(2) := 'b';

result(3) := to_char(inp);

return result;

end;

function std_logic_vector_to_bin_string_w_point(inp : std_logic_vector; bin_pt :

integer)

return string

is

variable width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable str_pos : integer;

variable result : string(1 to width+3);

begin

vec := inp;

str_pos := 1;

result(str_pos) := '0';

str_pos := 2;

result(str_pos) := 'b';

str_pos := 3;

Page 100: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

93

for i in width-1 downto 0 loop

if (((width+3) - bin_pt) = str_pos) then

result(str_pos) := '.';

str_pos := str_pos + 1;

end if;

result(str_pos) := to_char(vec(i));

str_pos := str_pos + 1;

end loop;

if (bin_pt = 0) then

result(str_pos) := '.';

end if;

return result;

end;

function real_to_bin_string(inp : real; width, bin_pt, arith : integer)

return string

is

variable result : string(1 to width);

variable vec : std_logic_vector(width-1 downto 0);

begin

vec := real_to_std_logic_vector(inp, width, bin_pt, arith);

result := std_logic_vector_to_bin_string(vec);

return result;

end;

function real_to_string (inp : real) return string

is

variable result : string(1 to display_precision) := (others => ' ');

begin

result(real'image(inp)'range) := real'image(inp);

return result;

end;

-- synopsys translate_on

end conv_pkg;

library IEEE;

use IEEE.std_logic_1164.all;

package clock_pkg is

-- synopsys translate_off

signal int_clk : std_logic;

-- synopsys translate_on

end clock_pkg;

library unisim;

use unisim.vcomponents.all;

-- synopsys translate_on

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity srl17e is

generic (width : integer:=16;

latency : integer :=8);

port (clk : in std_logic;

ce : in std_logic;

d : in std_logic_vector(width-1 downto 0);

q : out std_logic_vector(width-1 downto 0));

Page 101: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

94

end srl17e;

architecture structural of srl17e is

component SRL16E

port (D : in STD_ULOGIC;

CE : in STD_ULOGIC;

CLK : in STD_ULOGIC;

A0 : in STD_ULOGIC;

A1 : in STD_ULOGIC;

A2 : in STD_ULOGIC;

A3 : in STD_ULOGIC;

Q : out STD_ULOGIC);

end component;

attribute syn_black_box of SRL16E : component is true;

attribute fpga_dont_touch of SRL16E : component is "true";

component FDE

port(

Q : out STD_ULOGIC;

D : in STD_ULOGIC;

C : in STD_ULOGIC;

CE : in STD_ULOGIC);

end component;

attribute syn_black_box of FDE : component is true;

attribute fpga_dont_touch of FDE : component is "true";

constant a : std_logic_vector(4 downto 0) :=

integer_to_std_logic_vector(latency-2,5,xlSigned);

signal d_delayed : std_logic_vector(width-1 downto 0);

signal srl16_out : std_logic_vector(width-1 downto 0);

begin

d_delayed <= d after 200 ps;

reg_array : for i in 0 to width-1 generate

srl16_used: if latency > 1 generate

u1 : srl16e port map(clk => clk,

d => d_delayed(i),

q => srl16_out(i),

ce => ce,

a0 => a(0),

a1 => a(1),

a2 => a(2),

a3 => a(3));

end generate;

srl16_not_used: if latency <= 1 generate

srl16_out(i) <= d_delayed(i);

end generate;

fde_used: if latency /= 0 generate

u2 : fde port map(c => clk,

d => srl16_out(i),

q => q(i),

ce => ce);

end generate;

fde_not_used: if latency = 0 generate

q(i) <= srl16_out(i);

end generate;

end generate;

Page 102: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

95

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity synth_reg is

generic (width : integer := 8;

latency : integer := 1);

port (i : in std_logic_vector(width-1 downto 0);

ce : in std_logic;

clr : in std_logic;

clk : in std_logic;

o : out std_logic_vector(width-1 downto 0));

end synth_reg;

architecture structural of synth_reg is

component srl17e

generic (width : integer:=16;

latency : integer :=8);

port (clk : in std_logic;

ce : in std_logic;

d : in std_logic_vector(width-1 downto 0);

q : out std_logic_vector(width-1 downto 0));

end component;

function calc_num_srl17es (latency : integer)

return integer

is

variable remaining_latency : integer;

variable result : integer;

begin

result := latency / 17;

remaining_latency := latency - (result * 17);

if (remaining_latency /= 0) then

result := result + 1;

end if;

return result;

end;

constant complete_num_srl17es : integer := latency / 17;

constant num_srl17es : integer := calc_num_srl17es(latency);

constant remaining_latency : integer := latency - (complete_num_srl17es * 17);

type register_array is array (num_srl17es downto 0) of

std_logic_vector(width-1 downto 0);

signal z : register_array;

begin

z(0) <= i;

complete_ones : if complete_num_srl17es > 0 generate

srl17e_array: for i in 0 to complete_num_srl17es-1 generate

delay_comp : srl17e

generic map (width => width,

latency => 17)

port map (clk => clk,

ce => ce,

d => z(i),

q => z(i+1));

end generate;

Page 103: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

96

end generate;

partial_one : if remaining_latency > 0 generate

last_srl17e : srl17e

generic map (width => width,

latency => remaining_latency)

port map (clk => clk,

ce => ce,

d => z(num_srl17es-1),

q => z(num_srl17es));

end generate;

o <= z(num_srl17es);

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity synth_reg_reg is

generic (width : integer := 8;

latency : integer := 1);

port (i : in std_logic_vector(width-1 downto 0);

ce : in std_logic;

clr : in std_logic;

clk : in std_logic;

o : out std_logic_vector(width-1 downto 0));

end synth_reg_reg;

architecture behav of synth_reg_reg is

type reg_array_type is array (latency-1 downto 0) of std_logic_vector(width -1

downto 0);

signal reg_bank : reg_array_type := (others => (others => '0'));

signal reg_bank_in : reg_array_type := (others => (others => '0'));

attribute syn_allow_retiming : boolean;

attribute syn_srlstyle : string;

attribute syn_allow_retiming of reg_bank : signal is true;

attribute syn_allow_retiming of reg_bank_in : signal is true;

attribute syn_srlstyle of reg_bank : signal is "registers";

attribute syn_srlstyle of reg_bank_in : signal is "registers";

begin

latency_eq_0: if latency = 0 generate

o <= i;

end generate latency_eq_0;

latency_gt_0: if latency >= 1 generate

o <= reg_bank(latency-1);

reg_bank_in(0) <= i;

loop_gen: for idx in latency-2 downto 0 generate

reg_bank_in(idx+1) <= reg_bank(idx);

end generate loop_gen;

sync_loop: for sync_idx in latency-1 downto 0 generate

sync_proc: process (clk)

begin

if clk'event and clk = '1' then

if ce = '1' then

reg_bank(sync_idx) <= reg_bank_in(sync_idx);

end if;

end if;

Page 104: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

97

end process sync_proc;

end generate sync_loop;

end generate latency_gt_0;

end behav;

library unisim;

use unisim.vcomponents.all;

-- synopsys translate_on

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity single_reg_w_init is

generic (

width: integer := 8;

init_index: integer := 0;

init_value: bit_vector := b"0000"

);

port (

i: in std_logic_vector(width - 1 downto 0);

ce: in std_logic;

clr: in std_logic;

clk: in std_logic;

o: out std_logic_vector(width - 1 downto 0)

);

end single_reg_w_init;

architecture structural of single_reg_w_init is

function build_init_const(width: integer;

init_index: integer;

init_value: bit_vector)

return std_logic_vector

is

variable result: std_logic_vector(width - 1 downto 0);

begin

if init_index = 0 then

result := (others => '0');

elsif init_index = 1 then

result := (others => '0');

result(0) := '1';

else

result := to_stdlogicvector(init_value);

end if;

return result;

end;

component fdre

port (

q: out std_ulogic;

d: in std_ulogic;

c: in std_ulogic;

ce: in std_ulogic;

r: in std_ulogic

);

end component;

attribute syn_black_box of fdre: component is true;

Page 105: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

98

attribute fpga_dont_touch of fdre: component is "true";

component fdse

port (

q: out std_ulogic;

d: in std_ulogic;

c: in std_ulogic;

ce: in std_ulogic;

s: in std_ulogic

);

end component;

attribute syn_black_box of fdse: component is true;

attribute fpga_dont_touch of fdse: component is "true";

constant init_const: std_logic_vector(width - 1 downto 0)

:= build_init_const(width, init_index, init_value);

begin

fd_prim_array: for index in 0 to width - 1 generate

bit_is_0: if (init_const(index) = '0') generate

fdre_comp: fdre

port map (

c => clk,

d => i(index),

q => o(index),

ce => ce,

r => clr

);

end generate;

bit_is_1: if (init_const(index) = '1') generate

fdse_comp: fdse

port map (

c => clk,

d => i(index),

q => o(index),

ce => ce,

s => clr

);

end generate;

end generate;

end architecture structural;

-- synopsys translate_off

library unisim;

use unisim.vcomponents.all;

-- synopsys translate_on

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity synth_reg_w_init is

generic (

width: integer := 8;

init_index: integer := 0;

init_value: bit_vector := b"0000";

latency: integer := 1

);

port (

Page 106: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

99

i: in std_logic_vector(width - 1 downto 0);

ce: in std_logic;

clr: in std_logic;

clk: in std_logic;

o: out std_logic_vector(width - 1 downto 0)

);

end synth_reg_w_init;

architecture structural of synth_reg_w_init is

component single_reg_w_init

generic (

width: integer := 8;

init_index: integer := 0;

init_value: bit_vector := b"0000"

);

port (

i: in std_logic_vector(width - 1 downto 0);

ce: in std_logic;

clr: in std_logic;

clk: in std_logic;

o: out std_logic_vector(width - 1 downto 0)

);

end component;

signal dly_i: std_logic_vector((latency + 1) * width - 1 downto 0);

signal dly_clr: std_logic;

begin

latency_eq_0: if (latency = 0) generate

o <= i;

end generate;

latency_gt_0: if (latency >= 1) generate

dly_i((latency + 1) * width - 1 downto latency * width) <= i

after 200 ps;

dly_clr <= clr after 200 ps;

fd_array: for index in latency downto 1 generate

reg_comp: single_reg_w_init

generic map (

width => width,

init_index => init_index,

init_value => init_value

)

port map (

clk => clk,

i => dly_i((index + 1) * width - 1 downto index * width),

o => dly_i(index * width - 1 downto (index - 1) * width),

ce => ce,

clr => dly_clr

);

end generate;

o <= dly_i(width - 1 downto 0);

end generate;

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

Page 107: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

100

use work.conv_pkg.all;

entity mux_ac2c510b5b is

port (

sel : in std_logic_vector((1 - 1) downto 0);

d0 : in std_logic_vector((6 - 1) downto 0);

d1 : in std_logic_vector((6 - 1) downto 0);

y : out std_logic_vector((6 - 1) downto 0);

clk : in std_logic;

ce : in std_logic;

clr : in std_logic);

end mux_ac2c510b5b;

architecture behavior of mux_ac2c510b5b is

signal sel_1_20: std_logic;

signal d0_1_24: std_logic_vector((6 - 1) downto 0);

signal d1_1_27: std_logic_vector((6 - 1) downto 0);

signal sel_internal_2_1_convert: std_logic_vector((1 - 1) downto 0);

signal unregy_join_6_1: std_logic_vector((6 - 1) downto 0);

begin

sel_1_20 <= sel(0);

d0_1_24 <= d0;

d1_1_27 <= d1;

sel_internal_2_1_convert <= cast(std_logic_to_vector(sel_1_20), 0, 1, 0,

xlUnsigned);

proc_switch_6_1: process (d0_1_24, d1_1_27, sel_internal_2_1_convert)

is

begin

case sel_internal_2_1_convert is

when "0" =>

unregy_join_6_1 <= d0_1_24;

when others =>

unregy_join_6_1 <= d1_1_27;

end case;

end process proc_switch_6_1;

y <= unregy_join_6_1;

end behavior;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

-- Generated from Simulink block "modulacionBPSK"

entity modulacionbpsk is

port (

gateway_in: in std_logic_vector(5 downto 0);

gateway_in1: in std_logic_vector(5 downto 0);

gateway_in2: in std_logic;

gateway_out: out std_logic_vector(5 downto 0)

);

end modulacionbpsk;

Page 108: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

101

architecture structural of modulacionbpsk is

signal gateway_in1_net: std_logic_vector(5 downto 0);

signal gateway_in2_net: std_logic;

signal gateway_in_net: std_logic_vector(5 downto 0);

signal gateway_out_net: std_logic_vector(5 downto 0);

begin

gateway_in_net <= gateway_in;

gateway_in1_net <= gateway_in1;

gateway_in2_net <= gateway_in2;

gateway_out <= gateway_out_net;

mux: entity work.mux_ac2c510b5b

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => gateway_in_net,

d1 => gateway_in1_net,

sel(0) => gateway_in2_net,

y => gateway_out_net

);

end structural;

DEMODULADOR BPSK:

LIBRARY ieee;

USE ieee.std_logic_1164.ALL;

-- synthesis translate_off

Library XilinxCoreLib;

-- synthesis translate_on

ENTITY multiplier_spartan3_10_0_be7d54a806175751 IS

port (

clk: IN std_logic;

a: IN std_logic_VECTOR(5 downto 0);

b: IN std_logic_VECTOR(5 downto 0);

ce: IN std_logic;

sclr: IN std_logic;

p: OUT std_logic_VECTOR(11 downto 0));

END multiplier_spartan3_10_0_be7d54a806175751;

ARCHITECTURE multiplier_spartan3_10_0_be7d54a806175751_a OF

multiplier_spartan3_10_0_be7d54a806175751 IS

-- synthesis translate_off

component wrapped_multiplier_spartan3_10_0_be7d54a806175751

port (

clk: IN std_logic;

a: IN std_logic_VECTOR(5 downto 0);

b: IN std_logic_VECTOR(5 downto 0);

ce: IN std_logic;

sclr: IN std_logic;

Page 109: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

102

p: OUT std_logic_VECTOR(11 downto 0));

end component;

-- Configuration specification

for all : wrapped_multiplier_spartan3_10_0_be7d54a806175751 use entity

XilinxCoreLib.mult_gen_v10_0(behavioral)

generic map(

c_a_width => 6,

c_b_type => 0,

c_ce_overrides_sclr => 1,

c_opt_goal => 1,

c_has_sclr => 1,

c_round_pt => 0,

c_out_high => 11,

c_mult_type => 1,

c_ccm_imp => 0,

c_has_load_done => 0,

c_pipe_stages => 3,

c_has_ce => 1,

c_has_zero_detect => 0,

c_round_output => 0,

c_use_p_cascade_out => 0,

c_mem_init_prefix => "mgv10",

c_xdevicefamily => "spartan3",

c_a_type => 0,

c_out_low => 0,

c_b_width => 6,

c_b_value => "10000001");

-- synthesis translate_on

BEGIN

-- synthesis translate_off

U0 : wrapped_multiplier_spartan3_10_0_be7d54a806175751

port map (

clk => clk,

a => a,

b => b,

ce => ce,

sclr => sclr,

p => p);

-- synthesis translate_on

END multiplier_spartan3_10_0_be7d54a806175751_a;

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

package conv_pkg is

constant simulating : boolean := false

-- synopsys translate_off

or true

-- synopsys translate_on

;

constant xlUnsigned : integer := 1;

Page 110: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

103

constant xlSigned : integer := 2;

constant xlWrap : integer := 1;

constant xlSaturate : integer := 2;

constant xlTruncate : integer := 1;

constant xlRound : integer := 2;

constant xlRoundBanker : integer := 3;

constant xlAddMode : integer := 1;

constant xlSubMode : integer := 2;

attribute black_box : boolean;

attribute syn_black_box : boolean;

attribute fpga_dont_touch: string;

attribute box_type : string;

attribute keep : string;

attribute syn_keep : boolean;

function std_logic_vector_to_unsigned(inp : std_logic_vector) return unsigned;

function unsigned_to_std_logic_vector(inp : unsigned) return std_logic_vector;

function std_logic_vector_to_signed(inp : std_logic_vector) return signed;

function signed_to_std_logic_vector(inp : signed) return std_logic_vector;

function unsigned_to_signed(inp : unsigned) return signed;

function signed_to_unsigned(inp : signed) return unsigned;

function pos(inp : std_logic_vector; arith : INTEGER) return boolean;

function all_same(inp: std_logic_vector) return boolean;

function all_zeros(inp: std_logic_vector) return boolean;

function is_point_five(inp: std_logic_vector) return boolean;

function all_ones(inp: std_logic_vector) return boolean;

function convert_type (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith,

quantization, overflow : INTEGER)

return std_logic_vector;

function cast (inp : std_logic_vector; old_bin_pt,

new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector;

function vec_slice (inp : std_logic_vector; upper, lower : INTEGER)

return std_logic_vector;

function s2u_slice (inp : signed; upper, lower : INTEGER)

return unsigned;

function u2u_slice (inp : unsigned; upper, lower : INTEGER)

return unsigned;

function s2s_cast (inp : signed; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return signed;

function u2s_cast (inp : unsigned; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return signed;

function s2u_cast (inp : signed; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return unsigned;

function u2u_cast (inp : unsigned; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return unsigned;

function u2v_cast (inp : unsigned; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return std_logic_vector;

Page 111: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

104

function s2v_cast (inp : signed; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return std_logic_vector;

function trunc (inp : std_logic_vector; old_width, old_bin_pt, old_arith,

new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector;

function round_towards_inf (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt,

new_arith : INTEGER) return std_logic_vector;

function round_towards_even (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt,

new_arith : INTEGER) return std_logic_vector;

function max_signed(width : INTEGER) return std_logic_vector;

function min_signed(width : INTEGER) return std_logic_vector;

function saturation_arith(inp: std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

: INTEGER) return std_logic_vector;

function wrap_arith(inp: std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector;

function fractional_bits(a_bin_pt, b_bin_pt: INTEGER) return INTEGER;

function integer_bits(a_width, a_bin_pt, b_width, b_bin_pt: INTEGER)

return INTEGER;

function sign_ext(inp : std_logic_vector; new_width : INTEGER)

return std_logic_vector;

function zero_ext(inp : std_logic_vector; new_width : INTEGER)

return std_logic_vector;

function zero_ext(inp : std_logic; new_width : INTEGER)

return std_logic_vector;

function extend_MSB(inp : std_logic_vector; new_width, arith : INTEGER)

return std_logic_vector;

function align_input(inp : std_logic_vector; old_width, delta, new_arith,

new_width: INTEGER)

return std_logic_vector;

function pad_LSB(inp : std_logic_vector; new_width: integer)

return std_logic_vector;

function pad_LSB(inp : std_logic_vector; new_width, arith : integer)

return std_logic_vector;

function max(L, R: INTEGER) return INTEGER;

function min(L, R: INTEGER) return INTEGER;

function "="(left,right: STRING) return boolean;

function boolean_to_signed (inp : boolean; width: integer)

return signed;

function boolean_to_unsigned (inp : boolean; width: integer)

return unsigned;

function boolean_to_vector (inp : boolean)

return std_logic_vector;

function std_logic_to_vector (inp : std_logic)

return std_logic_vector;

function integer_to_std_logic_vector (inp : integer; width, arith : integer)

return std_logic_vector;

function std_logic_vector_to_integer (inp : std_logic_vector; arith : integer)

return integer;

Page 112: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

105

function std_logic_to_integer(constant inp : std_logic := '0')

return integer;

function bin_string_element_to_std_logic_vector (inp : string; width, index :

integer)

return std_logic_vector;

function bin_string_to_std_logic_vector (inp : string)

return std_logic_vector;

function hex_string_to_std_logic_vector (inp : string; width : integer)

return std_logic_vector;

function makeZeroBinStr (width : integer) return STRING;

function and_reduce(inp: std_logic_vector) return std_logic;

-- synopsys translate_off

function is_binary_string_invalid (inp : string)

return boolean;

function is_binary_string_undefined (inp : string)

return boolean;

function is_XorU(inp : std_logic_vector)

return boolean;

function to_real(inp : std_logic_vector; bin_pt : integer; arith : integer)

return real;

function std_logic_to_real(inp : std_logic; bin_pt : integer; arith : integer)

return real;

function real_to_std_logic_vector (inp : real; width, bin_pt, arith : integer)

return std_logic_vector;

function real_string_to_std_logic_vector (inp : string; width, bin_pt, arith : integer)

return std_logic_vector;

constant display_precision : integer := 20;

function real_to_string (inp : real) return string;

function valid_bin_string(inp : string) return boolean;

function std_logic_vector_to_bin_string(inp : std_logic_vector) return string;

function std_logic_to_bin_string(inp : std_logic) return string;

function std_logic_vector_to_bin_string_w_point(inp : std_logic_vector; bin_pt :

integer)

return string;

function real_to_bin_string(inp : real; width, bin_pt, arith : integer)

return string;

type stdlogic_to_char_t is array(std_logic) of character;

constant to_char : stdlogic_to_char_t := (

'U' => 'U',

'X' => 'X',

'0' => '0',

'1' => '1',

'Z' => 'Z',

'W' => 'W',

'L' => 'L',

'H' => 'H',

'-' => '-');

-- synopsys translate_on

end conv_pkg;

package body conv_pkg is

function std_logic_vector_to_unsigned(inp : std_logic_vector)

return unsigned

is

Page 113: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

106

begin

return unsigned (inp);

end;

function unsigned_to_std_logic_vector(inp : unsigned)

return std_logic_vector

is

begin

return std_logic_vector(inp);

end;

function std_logic_vector_to_signed(inp : std_logic_vector)

return signed

is

begin

return signed (inp);

end;

function signed_to_std_logic_vector(inp : signed)

return std_logic_vector

is

begin

return std_logic_vector(inp);

end;

function unsigned_to_signed (inp : unsigned)

return signed

is

begin

return signed(std_logic_vector(inp));

end;

function signed_to_unsigned (inp : signed)

return unsigned

is

begin

return unsigned(std_logic_vector(inp));

end;

function pos(inp : std_logic_vector; arith : INTEGER)

return boolean

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

begin

vec := inp;

if arith = xlUnsigned then

return true;

else

if vec(width-1) = '0' then

return true;

else

return false;

end if;

end if;

return true;

end;

function max_signed(width : INTEGER)

return std_logic_vector

Page 114: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

107

is

variable ones : std_logic_vector(width-2 downto 0);

variable result : std_logic_vector(width-1 downto 0);

begin

ones := (others => '1');

result(width-1) := '0';

result(width-2 downto 0) := ones;

return result;

end;

function min_signed(width : INTEGER)

return std_logic_vector

is

variable zeros : std_logic_vector(width-2 downto 0);

variable result : std_logic_vector(width-1 downto 0);

begin

zeros := (others => '0');

result(width-1) := '1';

result(width-2 downto 0) := zeros;

return result;

end;

function and_reduce(inp: std_logic_vector) return std_logic

is

variable result: std_logic;

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

begin

vec := inp;

result := vec(0);

if width > 1 then

for i in 1 to width-1 loop

result := result and vec(i);

end loop;

end if;

return result;

end;

function all_same(inp: std_logic_vector) return boolean

is

variable result: boolean;

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

begin

vec := inp;

result := true;

if width > 0 then

for i in 1 to width-1 loop

if vec(i) /= vec(0) then

result := false;

end if;

end loop;

end if;

return result;

end;

function all_zeros(inp: std_logic_vector)

Page 115: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

108

return boolean

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable zero : std_logic_vector(width-1 downto 0);

variable result : boolean;

begin

zero := (others => '0');

vec := inp;

-- synopsys translate_off

if (is_XorU(vec)) then

return false;

end if;

-- synopsys translate_on

if (std_logic_vector_to_unsigned(vec) = std_logic_vector_to_unsigned(zero))

then

result := true;

else

result := false;

end if;

return result;

end;

function is_point_five(inp: std_logic_vector)

return boolean

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable result : boolean;

begin

vec := inp;

-- synopsys translate_off

if (is_XorU(vec)) then

return false;

end if;

-- synopsys translate_on

if (width > 1) then

if ((vec(width-1) = '1') and (all_zeros(vec(width-2 downto 0)) = true)) then

result := true;

else

result := false;

end if;

else

if (vec(width-1) = '1') then

result := true;

else

result := false;

end if;

end if;

return result;

end;

function all_ones(inp: std_logic_vector)

return boolean

is

Page 116: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

109

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable one : std_logic_vector(width-1 downto 0);

variable result : boolean;

begin

one := (others => '1');

vec := inp;

-- synopsys translate_off

if (is_XorU(vec)) then

return false;

end if;

-- synopsys translate_on

if (std_logic_vector_to_unsigned(vec) = std_logic_vector_to_unsigned(one))

then

result := true;

else

result := false;

end if;

return result;

end;

function full_precision_num_width(quantization, overflow, old_width,

old_bin_pt, old_arith,

new_width, new_bin_pt, new_arith : INTEGER)

return integer

is

variable result : integer;

begin

result := old_width + 2;

return result;

end;

function quantized_num_width(quantization, overflow, old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

: INTEGER)

return integer

is

variable right_of_dp, left_of_dp, result : integer;

begin

right_of_dp := max(new_bin_pt, old_bin_pt);

left_of_dp := max((new_width - new_bin_pt), (old_width - old_bin_pt));

result := (old_width + 2) + (new_bin_pt - old_bin_pt);

return result;

end;

function convert_type (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith,

quantization, overflow : INTEGER)

return std_logic_vector

is

constant fp_width : integer :=

full_precision_num_width(quantization, overflow, old_width,

old_bin_pt, old_arith, new_width,

new_bin_pt, new_arith);

constant fp_bin_pt : integer := old_bin_pt;

constant fp_arith : integer := old_arith;

Page 117: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

110

variable full_precision_result : std_logic_vector(fp_width-1 downto 0);

constant q_width : integer :=

quantized_num_width(quantization, overflow, old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith);

constant q_bin_pt : integer := new_bin_pt;

constant q_arith : integer := old_arith;

variable quantized_result : std_logic_vector(q_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

result := (others => '0');

full_precision_result := cast(inp, old_bin_pt, fp_width, fp_bin_pt,

fp_arith);

if (quantization = xlRound) then

quantized_result := round_towards_inf(full_precision_result,

fp_width, fp_bin_pt,

fp_arith, q_width, q_bin_pt,

q_arith);

elsif (quantization = xlRoundBanker) then

quantized_result := round_towards_even(full_precision_result,

fp_width, fp_bin_pt,

fp_arith, q_width, q_bin_pt,

q_arith);

else

quantized_result := trunc(full_precision_result, fp_width, fp_bin_pt,

fp_arith, q_width, q_bin_pt, q_arith);

end if;

if (overflow = xlSaturate) then

result := saturation_arith(quantized_result, q_width, q_bin_pt,

q_arith, new_width, new_bin_pt, new_arith);

else

result := wrap_arith(quantized_result, q_width, q_bin_pt, q_arith,

new_width, new_bin_pt, new_arith);

end if;

return result;

end;

function cast (inp : std_logic_vector; old_bin_pt, new_width,

new_bin_pt, new_arith : INTEGER)

return std_logic_vector

is

constant old_width : integer := inp'length;

constant left_of_dp : integer := (new_width - new_bin_pt)

- (old_width - old_bin_pt);

constant right_of_dp : integer := (new_bin_pt - old_bin_pt);

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

variable j : integer;

begin

vec := inp;

for i in new_width-1 downto 0 loop

j := i - right_of_dp;

if ( j > old_width-1) then

if (new_arith = xlUnsigned) then

result(i) := '0';

Page 118: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

111

else

result(i) := vec(old_width-1);

end if;

elsif ( j >= 0) then

result(i) := vec(j);

else

result(i) := '0';

end if;

end loop;

return result;

end;

function vec_slice (inp : std_logic_vector; upper, lower : INTEGER)

return std_logic_vector

is

begin

return inp(upper downto lower);

end;

function s2u_slice (inp : signed; upper, lower : INTEGER)

return unsigned

is

begin

return unsigned(vec_slice(std_logic_vector(inp), upper, lower));

end;

function u2u_slice (inp : unsigned; upper, lower : INTEGER)

return unsigned

is

begin

return unsigned(vec_slice(std_logic_vector(inp), upper, lower));

end;

function s2s_cast (inp : signed; old_bin_pt, new_width, new_bin_pt : INTEGER)

return signed

is

begin

return signed(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlSigned));

end;

function s2u_cast (inp : signed; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return unsigned

is

begin

return unsigned(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlSigned));

end;

function u2s_cast (inp : unsigned; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return signed

is

begin

return signed(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlUnsigned));

end;

function u2u_cast (inp : unsigned; old_bin_pt, new_width,

Page 119: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

112

new_bin_pt : INTEGER)

return unsigned

is

begin

return unsigned(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlUnsigned));

end;

function u2v_cast (inp : unsigned; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return std_logic_vector

is

begin

return cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlUnsigned);

end;

function s2v_cast (inp : signed; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return std_logic_vector

is

begin

return cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt, xlSigned);

end;

function boolean_to_signed (inp : boolean; width : integer)

return signed

is

variable result : signed(width - 1 downto 0);

begin

result := (others => '0');

if inp then

result(0) := '1';

else

result(0) := '0';

end if;

return result;

end;

function boolean_to_unsigned (inp : boolean; width : integer)

return unsigned

is

variable result : unsigned(width - 1 downto 0);

begin

result := (others => '0');

if inp then

result(0) := '1';

else

result(0) := '0';

end if;

return result;

end;

function boolean_to_vector (inp : boolean)

return std_logic_vector

is

variable result : std_logic_vector(1 - 1 downto 0);

begin

Page 120: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

113

result := (others => '0');

if inp then

result(0) := '1';

else

result(0) := '0';

end if;

return result;

end;

function std_logic_to_vector (inp : std_logic)

return std_logic_vector

is

variable result : std_logic_vector(1 - 1 downto 0);

begin

result(0) := inp;

return result;

end;

function trunc (inp : std_logic_vector; old_width, old_bin_pt, old_arith,

new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector

is

constant right_of_dp : integer := (old_bin_pt - new_bin_pt);

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if right_of_dp >= 0 then

if new_arith = xlUnsigned then

result := zero_ext(vec(old_width-1 downto right_of_dp), new_width);

else

result := sign_ext(vec(old_width-1 downto right_of_dp), new_width);

end if;

else

if new_arith = xlUnsigned then

result := zero_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

else

result := sign_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

end if;

end if;

return result;

end;

function round_towards_inf (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

: INTEGER)

return std_logic_vector

is

constant right_of_dp : integer := (old_bin_pt - new_bin_pt);

constant expected_new_width : integer := old_width - right_of_dp + 1;

variable vec : std_logic_vector(old_width-1 downto 0);

variable one_or_zero : std_logic_vector(new_width-1 downto 0);

variable truncated_val : std_logic_vector(new_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

Page 121: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

114

begin

vec := inp;

if right_of_dp >= 0 then

if new_arith = xlUnsigned then

truncated_val := zero_ext(vec(old_width-1 downto right_of_dp),

new_width);

else

truncated_val := sign_ext(vec(old_width-1 downto right_of_dp),

new_width);

end if;

else

if new_arith = xlUnsigned then

truncated_val := zero_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

else

truncated_val := sign_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

end if;

end if;

one_or_zero := (others => '0');

if (new_arith = xlSigned) then

if (vec(old_width-1) = '0') then

one_or_zero(0) := '1';

end if;

if (right_of_dp >= 2) and (right_of_dp <= old_width) then

if (all_zeros(vec(right_of_dp-2 downto 0)) = false) then

one_or_zero(0) := '1';

end if;

end if;

if (right_of_dp >= 1) and (right_of_dp <= old_width) then

if vec(right_of_dp-1) = '0' then

one_or_zero(0) := '0';

end if;

else

one_or_zero(0) := '0';

end if;

else

if (right_of_dp >= 1) and (right_of_dp <= old_width) then

one_or_zero(0) := vec(right_of_dp-1);

end if;

end if;

if new_arith = xlSigned then

result :=

signed_to_std_logic_vector(std_logic_vector_to_signed(truncated_val) +

std_logic_vector_to_signed(one_or_zero));

else

result :=

unsigned_to_std_logic_vector(std_logic_vector_to_unsigned(truncated_val) +

std_logic_vector_to_unsigned(one_or_zero));

end if;

return result;

end;

function round_towards_even (inp : std_logic_vector; old_width, old_bin_pt,

Page 122: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

115

old_arith, new_width, new_bin_pt, new_arith

: INTEGER)

return std_logic_vector

is

constant right_of_dp : integer := (old_bin_pt - new_bin_pt);

constant expected_new_width : integer := old_width - right_of_dp + 1;

variable vec : std_logic_vector(old_width-1 downto 0);

variable one_or_zero : std_logic_vector(new_width-1 downto 0);

variable truncated_val : std_logic_vector(new_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if right_of_dp >= 0 then

if new_arith = xlUnsigned then

truncated_val := zero_ext(vec(old_width-1 downto right_of_dp),

new_width);

else

truncated_val := sign_ext(vec(old_width-1 downto right_of_dp),

new_width);

end if;

else

if new_arith = xlUnsigned then

truncated_val := zero_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

else

truncated_val := sign_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

end if;

end if;

one_or_zero := (others => '0');

if (right_of_dp >= 1) and (right_of_dp <= old_width) then

if (is_point_five(vec(right_of_dp-1 downto 0)) = false) then

one_or_zero(0) := vec(right_of_dp-1);

else

one_or_zero(0) := vec(right_of_dp);

end if;

end if;

if new_arith = xlSigned then

result :=

signed_to_std_logic_vector(std_logic_vector_to_signed(truncated_val) +

std_logic_vector_to_signed(one_or_zero));

else

result :=

unsigned_to_std_logic_vector(std_logic_vector_to_unsigned(truncated_val) +

std_logic_vector_to_unsigned(one_or_zero));

end if;

return result;

end;

function saturation_arith(inp: std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

: INTEGER)

return std_logic_vector

is

Page 123: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

116

constant left_of_dp : integer := (old_width - old_bin_pt) -

(new_width - new_bin_pt);

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

variable overflow : boolean;

begin

vec := inp;

overflow := true;

result := (others => '0');

if (new_width >= old_width) then

overflow := false;

end if;

if ((old_arith = xlSigned and new_arith = xlSigned) and (old_width >

new_width)) then

if all_same(vec(old_width-1 downto new_width-1)) then

overflow := false;

end if;

end if;

if (old_arith = xlSigned and new_arith = xlUnsigned) then

if (old_width > new_width) then

if all_zeros(vec(old_width-1 downto new_width)) then

overflow := false;

end if;

else

if (old_width = new_width) then

if (vec(new_width-1) = '0') then

overflow := false;

end if;

end if;

end if;

end if;

if (old_arith = xlUnsigned and new_arith = xlUnsigned) then

if (old_width > new_width) then

if all_zeros(vec(old_width-1 downto new_width)) then

overflow := false;

end if;

else

if (old_width = new_width) then

overflow := false;

end if;

end if;

end if;

if ((old_arith = xlUnsigned and new_arith = xlSigned) and (old_width >

new_width)) then

if all_same(vec(old_width-1 downto new_width-1)) then

overflow := false;

end if;

end if;

if overflow then

if new_arith = xlSigned then

if vec(old_width-1) = '0' then

result := max_signed(new_width);

else

Page 124: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

117

result := min_signed(new_width);

end if;

else

if ((old_arith = xlSigned) and vec(old_width-1) = '1') then

result := (others => '0');

else

result := (others => '1');

end if;

end if;

else

if (old_arith = xlSigned) and (new_arith = xlUnsigned) then

if (vec(old_width-1) = '1') then

vec := (others => '0');

end if;

end if;

if new_width <= old_width then

result := vec(new_width-1 downto 0);

else

if new_arith = xlUnsigned then

result := zero_ext(vec, new_width);

else

result := sign_ext(vec, new_width);

end if;

end if;

end if;

return result;

end;

function wrap_arith(inp: std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector

is

variable result : std_logic_vector(new_width-1 downto 0);

variable result_arith : integer;

begin

if (old_arith = xlSigned) and (new_arith = xlUnsigned) then

result_arith := xlSigned;

end if;

result := cast(inp, old_bin_pt, new_width, new_bin_pt, result_arith);

return result;

end;

function fractional_bits(a_bin_pt, b_bin_pt: INTEGER) return INTEGER is

begin

return max(a_bin_pt, b_bin_pt);

end;

function integer_bits(a_width, a_bin_pt, b_width, b_bin_pt: INTEGER)

return INTEGER is

begin

return max(a_width - a_bin_pt, b_width - b_bin_pt);

end;

function pad_LSB(inp : std_logic_vector; new_width: integer)

return STD_LOGIC_VECTOR

is

constant orig_width : integer := inp'length;

Page 125: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

118

variable vec : std_logic_vector(orig_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

variable pos : integer;

constant pad_pos : integer := new_width - orig_width - 1;

begin

vec := inp;

pos := new_width-1;

if (new_width >= orig_width) then

for i in orig_width-1 downto 0 loop

result(pos) := vec(i);

pos := pos - 1;

end loop;

if pad_pos >= 0 then

for i in pad_pos downto 0 loop

result(i) := '0';

end loop;

end if;

end if;

return result;

end;

function sign_ext(inp : std_logic_vector; new_width : INTEGER)

return std_logic_vector

is

constant old_width : integer := inp'length;

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if new_width >= old_width then

result(old_width-1 downto 0) := vec;

if new_width-1 >= old_width then

for i in new_width-1 downto old_width loop

result(i) := vec(old_width-1);

end loop;

end if;

else

result(new_width-1 downto 0) := vec(new_width-1 downto 0);

end if;

return result;

end;

function zero_ext(inp : std_logic_vector; new_width : INTEGER)

return std_logic_vector

is

constant old_width : integer := inp'length;

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if new_width >= old_width then

result(old_width-1 downto 0) := vec;

if new_width-1 >= old_width then

for i in new_width-1 downto old_width loop

result(i) := '0';

Page 126: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

119

end loop;

end if;

else

result(new_width-1 downto 0) := vec(new_width-1 downto 0);

end if;

return result;

end;

function zero_ext(inp : std_logic; new_width : INTEGER)

return std_logic_vector

is

variable result : std_logic_vector(new_width-1 downto 0);

begin

result(0) := inp;

for i in new_width-1 downto 1 loop

result(i) := '0';

end loop;

return result;

end;

function extend_MSB(inp : std_logic_vector; new_width, arith : INTEGER)

return std_logic_vector

is

constant orig_width : integer := inp'length;

variable vec : std_logic_vector(orig_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if arith = xlUnsigned then

result := zero_ext(vec, new_width);

else

result := sign_ext(vec, new_width);

end if;

return result;

end;

function pad_LSB(inp : std_logic_vector; new_width, arith: integer)

return STD_LOGIC_VECTOR

is

constant orig_width : integer := inp'length;

variable vec : std_logic_vector(orig_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

variable pos : integer;

begin

vec := inp;

pos := new_width-1;

if (arith = xlUnsigned) then

result(pos) := '0';

pos := pos - 1;

else

result(pos) := vec(orig_width-1);

pos := pos - 1;

end if;

if (new_width >= orig_width) then

for i in orig_width-1 downto 0 loop

result(pos) := vec(i);

Page 127: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

120

pos := pos - 1;

end loop;

if pos >= 0 then

for i in pos downto 0 loop

result(i) := '0';

end loop;

end if;

end if;

return result;

end;

function align_input(inp : std_logic_vector; old_width, delta, new_arith,

new_width: INTEGER)

return std_logic_vector

is

variable vec : std_logic_vector(old_width-1 downto 0);

variable padded_inp : std_logic_vector((old_width + delta)-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if delta > 0 then

padded_inp := pad_LSB(vec, old_width+delta);

result := extend_MSB(padded_inp, new_width, new_arith);

else

result := extend_MSB(vec, new_width, new_arith);

end if;

return result;

end;

function max(L, R: INTEGER) return INTEGER is

begin

if L > R then

return L;

else

return R;

end if;

end;

function min(L, R: INTEGER) return INTEGER is

begin

if L < R then

return L;

else

return R;

end if;

end;

function "="(left,right: STRING) return boolean is

begin

if (left'length /= right'length) then

return false;

else

test : for i in 1 to left'length loop

if left(i) /= right(i) then

return false;

end if;

end loop test;

Page 128: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

121

return true;

end if;

end;

-- synopsys translate_off

function is_binary_string_invalid (inp : string)

return boolean

is

variable vec : string(1 to inp'length);

variable result : boolean;

begin

vec := inp;

result := false;

for i in 1 to vec'length loop

if ( vec(i) = 'X' ) then

result := true;

end if;

end loop;

return result;

end;

function is_binary_string_undefined (inp : string)

return boolean

is

variable vec : string(1 to inp'length);

variable result : boolean;

begin

vec := inp;

result := false;

for i in 1 to vec'length loop

if ( vec(i) = 'U' ) then

result := true;

end if;

end loop;

return result;

end;

function is_XorU(inp : std_logic_vector)

return boolean

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable result : boolean;

begin

vec := inp;

result := false;

for i in 0 to width-1 loop

if (vec(i) = 'U') or (vec(i) = 'X') then

result := true;

end if;

end loop;

return result;

end;

function to_real(inp : std_logic_vector; bin_pt : integer; arith : integer)

return real

is

Page 129: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

122

variable vec : std_logic_vector(inp'length-1 downto 0);

variable result, shift_val, undefined_real : real;

variable neg_num : boolean;

begin

vec := inp;

result := 0.0;

neg_num := false;

if vec(inp'length-1) = '1' then

neg_num := true;

end if;

for i in 0 to inp'length-1 loop

if vec(i) = 'U' or vec(i) = 'X' then

return undefined_real;

end if;

if arith = xlSigned then

if neg_num then

if vec(i) = '0' then

result := result + 2.0**i;

end if;

else

if vec(i) = '1' then

result := result + 2.0**i;

end if;

end if;

else

if vec(i) = '1' then

result := result + 2.0**i;

end if;

end if;

end loop;

if arith = xlSigned then

if neg_num then

result := result + 1.0;

result := result * (-1.0);

end if;

end if;

shift_val := 2.0**(-1*bin_pt);

result := result * shift_val;

return result;

end;

function std_logic_to_real(inp : std_logic; bin_pt : integer; arith : integer)

return real

is

variable result : real := 0.0;

begin

if inp = '1' then

result := 1.0;

end if;

if arith = xlSigned then

assert false

report "It doesn't make sense to convert a 1 bit number to a signed real.";

end if;

return result;

Page 130: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

123

end;

-- synopsys translate_on

function integer_to_std_logic_vector (inp : integer; width, arith : integer)

return std_logic_vector

is

variable result : std_logic_vector(width-1 downto 0);

variable unsigned_val : unsigned(width-1 downto 0);

variable signed_val : signed(width-1 downto 0);

begin

if (arith = xlSigned) then

signed_val := to_signed(inp, width);

result := signed_to_std_logic_vector(signed_val);

else

unsigned_val := to_unsigned(inp, width);

result := unsigned_to_std_logic_vector(unsigned_val);

end if;

return result;

end;

function std_logic_vector_to_integer (inp : std_logic_vector; arith : integer)

return integer

is

constant width : integer := inp'length;

variable unsigned_val : unsigned(width-1 downto 0);

variable signed_val : signed(width-1 downto 0);

variable result : integer;

begin

if (arith = xlSigned) then

signed_val := std_logic_vector_to_signed(inp);

result := to_integer(signed_val);

else

unsigned_val := std_logic_vector_to_unsigned(inp);

result := to_integer(unsigned_val);

end if;

return result;

end;

function std_logic_to_integer(constant inp : std_logic := '0')

return integer

is

begin

if inp = '1' then

return 1;

else

return 0;

end if;

end;

function makeZeroBinStr (width : integer) return STRING is

variable result : string(1 to width+3);

begin

result(1) := '0';

result(2) := 'b';

for i in 3 to width+2 loop

result(i) := '0';

end loop;

Page 131: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

124

result(width+3) := '.';

return result;

end;

-- synopsys translate_off

function real_string_to_std_logic_vector (inp : string; width, bin_pt, arith : integer)

return std_logic_vector

is

variable result : std_logic_vector(width-1 downto 0);

begin

result := (others => '0');

return result;

end;

function real_to_std_logic_vector (inp : real; width, bin_pt, arith : integer)

return std_logic_vector

is

variable real_val : real;

variable int_val : integer;

variable result : std_logic_vector(width-1 downto 0) := (others => '0');

variable unsigned_val : unsigned(width-1 downto 0) := (others => '0');

variable signed_val : signed(width-1 downto 0) := (others => '0');

begin

real_val := inp;

int_val := integer(real_val * 2.0**(bin_pt));

if (arith = xlSigned) then

signed_val := to_signed(int_val, width);

result := signed_to_std_logic_vector(signed_val);

else

unsigned_val := to_unsigned(int_val, width);

result := unsigned_to_std_logic_vector(unsigned_val);

end if;

return result;

end;

-- synopsys translate_on

function valid_bin_string (inp : string)

return boolean

is

variable vec : string(1 to inp'length);

begin

vec := inp;

if (vec(1) = '0' and vec(2) = 'b') then

return true;

else

return false;

end if;

end;

function hex_string_to_std_logic_vector(inp: string; width : integer)

return std_logic_vector is

constant strlen : integer := inp'LENGTH;

variable result : std_logic_vector(width-1 downto 0);

variable bitval : std_logic_vector((strlen*4)-1 downto 0);

variable posn : integer;

variable ch : character;

variable vec : string(1 to strlen);

Page 132: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

125

begin

vec := inp;

result := (others => '0');

posn := (strlen*4)-1;

for i in 1 to strlen loop

ch := vec(i);

case ch is

when '0' => bitval(posn downto posn-3) := "0000";

when '1' => bitval(posn downto posn-3) := "0001";

when '2' => bitval(posn downto posn-3) := "0010";

when '3' => bitval(posn downto posn-3) := "0011";

when '4' => bitval(posn downto posn-3) := "0100";

when '5' => bitval(posn downto posn-3) := "0101";

when '6' => bitval(posn downto posn-3) := "0110";

when '7' => bitval(posn downto posn-3) := "0111";

when '8' => bitval(posn downto posn-3) := "1000";

when '9' => bitval(posn downto posn-3) := "1001";

when 'A' | 'a' => bitval(posn downto posn-3) := "1010";

when 'B' | 'b' => bitval(posn downto posn-3) := "1011";

when 'C' | 'c' => bitval(posn downto posn-3) := "1100";

when 'D' | 'd' => bitval(posn downto posn-3) := "1101";

when 'E' | 'e' => bitval(posn downto posn-3) := "1110";

when 'F' | 'f' => bitval(posn downto posn-3) := "1111";

when others => bitval(posn downto posn-3) := "XXXX";

-- synopsys translate_off

ASSERT false

REPORT "Invalid hex value" SEVERITY ERROR;

-- synopsys translate_on

end case;

posn := posn - 4;

end loop;

if (width <= strlen*4) then

result := bitval(width-1 downto 0);

else

result((strlen*4)-1 downto 0) := bitval;

end if;

return result;

end;

function bin_string_to_std_logic_vector (inp : string)

return std_logic_vector

is

variable pos : integer;

variable vec : string(1 to inp'length);

variable result : std_logic_vector(inp'length-1 downto 0);

begin

vec := inp;

pos := inp'length-1;

result := (others => '0');

for i in 1 to vec'length loop

-- synopsys translate_off

if (pos < 0) and (vec(i) = '0' or vec(i) = '1' or vec(i) = 'X' or vec(i) = 'U') then

assert false

Page 133: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

126

report "Input string is larger than output std_logic_vector. Truncating

output.";

return result;

end if;

-- synopsys translate_on

if vec(i) = '0' then

result(pos) := '0';

pos := pos - 1;

end if;

if vec(i) = '1' then

result(pos) := '1';

pos := pos - 1;

end if;

-- synopsys translate_off

if (vec(i) = 'X' or vec(i) = 'U') then

result(pos) := 'U';

pos := pos - 1;

end if;

-- synopsys translate_on

end loop;

return result;

end;

function bin_string_element_to_std_logic_vector (inp : string; width, index :

integer)

return std_logic_vector

is

constant str_width : integer := width + 4;

constant inp_len : integer := inp'length;

constant num_elements : integer := (inp_len + 1)/str_width;

constant reverse_index : integer := (num_elements-1) - index;

variable left_pos : integer;

variable right_pos : integer;

variable vec : string(1 to inp'length);

variable result : std_logic_vector(width-1 downto 0);

begin

vec := inp;

result := (others => '0');

if (reverse_index = 0) and (reverse_index < num_elements) and (inp_len-3 >=

width) then

left_pos := 1;

right_pos := width + 3;

result := bin_string_to_std_logic_vector(vec(left_pos to right_pos));

end if;

if (reverse_index > 0) and (reverse_index < num_elements) and (inp_len-3 >=

width) then

left_pos := (reverse_index * str_width) + 1;

right_pos := left_pos + width + 2;

result := bin_string_to_std_logic_vector(vec(left_pos to right_pos));

end if;

return result;

end;

-- synopsys translate_off

function std_logic_vector_to_bin_string(inp : std_logic_vector)

Page 134: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

127

return string

is

variable vec : std_logic_vector(1 to inp'length);

variable result : string(vec'range);

begin

vec := inp;

for i in vec'range loop

result(i) := to_char(vec(i));

end loop;

return result;

end;

function std_logic_to_bin_string(inp : std_logic)

return string

is

variable result : string(1 to 3);

begin

result(1) := '0';

result(2) := 'b';

result(3) := to_char(inp);

return result;

end;

function std_logic_vector_to_bin_string_w_point(inp : std_logic_vector; bin_pt :

integer)

return string

is

variable width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable str_pos : integer;

variable result : string(1 to width+3);

begin

vec := inp;

str_pos := 1;

result(str_pos) := '0';

str_pos := 2;

result(str_pos) := 'b';

str_pos := 3;

for i in width-1 downto 0 loop

if (((width+3) - bin_pt) = str_pos) then

result(str_pos) := '.';

str_pos := str_pos + 1;

end if;

result(str_pos) := to_char(vec(i));

str_pos := str_pos + 1;

end loop;

if (bin_pt = 0) then

result(str_pos) := '.';

end if;

return result;

end;

function real_to_bin_string(inp : real; width, bin_pt, arith : integer)

return string

is

variable result : string(1 to width);

Page 135: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

128

variable vec : std_logic_vector(width-1 downto 0);

begin

vec := real_to_std_logic_vector(inp, width, bin_pt, arith);

result := std_logic_vector_to_bin_string(vec);

return result;

end;

function real_to_string (inp : real) return string

is

variable result : string(1 to display_precision) := (others => ' ');

begin

result(real'image(inp)'range) := real'image(inp);

return result;

end;

-- synopsys translate_on

end conv_pkg;

library IEEE;

use IEEE.std_logic_1164.all;

package clock_pkg is

-- synopsys translate_off

signal int_clk : std_logic;

-- synopsys translate_on

end clock_pkg;

library unisim;

use unisim.vcomponents.all;

-- synopsys translate_on

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity srl17e is

generic (width : integer:=16;

latency : integer :=8);

port (clk : in std_logic;

ce : in std_logic;

d : in std_logic_vector(width-1 downto 0);

q : out std_logic_vector(width-1 downto 0));

end srl17e;

architecture structural of srl17e is

component SRL16E

port (D : in STD_ULOGIC;

CE : in STD_ULOGIC;

CLK : in STD_ULOGIC;

A0 : in STD_ULOGIC;

A1 : in STD_ULOGIC;

A2 : in STD_ULOGIC;

A3 : in STD_ULOGIC;

Q : out STD_ULOGIC);

end component;

attribute syn_black_box of SRL16E : component is true;

attribute fpga_dont_touch of SRL16E : component is "true";

component FDE

port(

Q : out STD_ULOGIC;

Page 136: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

129

D : in STD_ULOGIC;

C : in STD_ULOGIC;

CE : in STD_ULOGIC);

end component;

attribute syn_black_box of FDE : component is true;

attribute fpga_dont_touch of FDE : component is "true";

constant a : std_logic_vector(4 downto 0) :=

integer_to_std_logic_vector(latency-2,5,xlSigned);

signal d_delayed : std_logic_vector(width-1 downto 0);

signal srl16_out : std_logic_vector(width-1 downto 0);

begin

d_delayed <= d after 200 ps;

reg_array : for i in 0 to width-1 generate

srl16_used: if latency > 1 generate

u1 : srl16e port map(clk => clk,

d => d_delayed(i),

q => srl16_out(i),

ce => ce,

a0 => a(0),

a1 => a(1),

a2 => a(2),

a3 => a(3));

end generate;

srl16_not_used: if latency <= 1 generate

srl16_out(i) <= d_delayed(i);

end generate;

fde_used: if latency /= 0 generate

u2 : fde port map(c => clk,

d => srl16_out(i),

q => q(i),

ce => ce);

end generate;

fde_not_used: if latency = 0 generate

q(i) <= srl16_out(i);

end generate;

end generate;

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity synth_reg is

generic (width : integer := 8;

latency : integer := 1);

port (i : in std_logic_vector(width-1 downto 0);

ce : in std_logic;

clr : in std_logic;

clk : in std_logic;

o : out std_logic_vector(width-1 downto 0));

end synth_reg;

architecture structural of synth_reg is

component srl17e

generic (width : integer:=16;

latency : integer :=8);

Page 137: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

130

port (clk : in std_logic;

ce : in std_logic;

d : in std_logic_vector(width-1 downto 0);

q : out std_logic_vector(width-1 downto 0));

end component;

function calc_num_srl17es (latency : integer)

return integer

is

variable remaining_latency : integer;

variable result : integer;

begin

result := latency / 17;

remaining_latency := latency - (result * 17);

if (remaining_latency /= 0) then

result := result + 1;

end if;

return result;

end;

constant complete_num_srl17es : integer := latency / 17;

constant num_srl17es : integer := calc_num_srl17es(latency);

constant remaining_latency : integer := latency - (complete_num_srl17es * 17);

type register_array is array (num_srl17es downto 0) of

std_logic_vector(width-1 downto 0);

signal z : register_array;

begin

z(0) <= i;

complete_ones : if complete_num_srl17es > 0 generate

srl17e_array: for i in 0 to complete_num_srl17es-1 generate

delay_comp : srl17e

generic map (width => width,

latency => 17)

port map (clk => clk,

ce => ce,

d => z(i),

q => z(i+1));

end generate;

end generate;

partial_one : if remaining_latency > 0 generate

last_srl17e : srl17e

generic map (width => width,

latency => remaining_latency)

port map (clk => clk,

ce => ce,

d => z(num_srl17es-1),

q => z(num_srl17es));

end generate;

o <= z(num_srl17es);

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity synth_reg_reg is

generic (width : integer := 8;

Page 138: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

131

latency : integer := 1);

port (i : in std_logic_vector(width-1 downto 0);

ce : in std_logic;

clr : in std_logic;

clk : in std_logic;

o : out std_logic_vector(width-1 downto 0));

end synth_reg_reg;

architecture behav of synth_reg_reg is

type reg_array_type is array (latency-1 downto 0) of std_logic_vector(width -1

downto 0);

signal reg_bank : reg_array_type := (others => (others => '0'));

signal reg_bank_in : reg_array_type := (others => (others => '0'));

attribute syn_allow_retiming : boolean;

attribute syn_srlstyle : string;

attribute syn_allow_retiming of reg_bank : signal is true;

attribute syn_allow_retiming of reg_bank_in : signal is true;

attribute syn_srlstyle of reg_bank : signal is "registers";

attribute syn_srlstyle of reg_bank_in : signal is "registers";

begin

latency_eq_0: if latency = 0 generate

o <= i;

end generate latency_eq_0;

latency_gt_0: if latency >= 1 generate

o <= reg_bank(latency-1);

reg_bank_in(0) <= i;

loop_gen: for idx in latency-2 downto 0 generate

reg_bank_in(idx+1) <= reg_bank(idx);

end generate loop_gen;

sync_loop: for sync_idx in latency-1 downto 0 generate

sync_proc: process (clk)

begin

if clk'event and clk = '1' then

if ce = '1' then

reg_bank(sync_idx) <= reg_bank_in(sync_idx);

end if;

end if;

end process sync_proc;

end generate sync_loop;

end generate latency_gt_0;

end behav;

library unisim;

use unisim.vcomponents.all;

-- synopsys translate_on

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity single_reg_w_init is

generic (

width: integer := 8;

init_index: integer := 0;

init_value: bit_vector := b"0000"

);

Page 139: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

132

port (

i: in std_logic_vector(width - 1 downto 0);

ce: in std_logic;

clr: in std_logic;

clk: in std_logic;

o: out std_logic_vector(width - 1 downto 0)

);

end single_reg_w_init;

architecture structural of single_reg_w_init is

function build_init_const(width: integer;

init_index: integer;

init_value: bit_vector)

return std_logic_vector

is

variable result: std_logic_vector(width - 1 downto 0);

begin

if init_index = 0 then

result := (others => '0');

elsif init_index = 1 then

result := (others => '0');

result(0) := '1';

else

result := to_stdlogicvector(init_value);

end if;

return result;

end;

component fdre

port (

q: out std_ulogic;

d: in std_ulogic;

c: in std_ulogic;

ce: in std_ulogic;

r: in std_ulogic

);

end component;

attribute syn_black_box of fdre: component is true;

attribute fpga_dont_touch of fdre: component is "true";

component fdse

port (

q: out std_ulogic;

d: in std_ulogic;

c: in std_ulogic;

ce: in std_ulogic;

s: in std_ulogic

);

end component;

attribute syn_black_box of fdse: component is true;

attribute fpga_dont_touch of fdse: component is "true";

constant init_const: std_logic_vector(width - 1 downto 0)

:= build_init_const(width, init_index, init_value);

begin

fd_prim_array: for index in 0 to width - 1 generate

bit_is_0: if (init_const(index) = '0') generate

Page 140: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

133

fdre_comp: fdre

port map (

c => clk,

d => i(index),

q => o(index),

ce => ce,

r => clr

);

end generate;

bit_is_1: if (init_const(index) = '1') generate

fdse_comp: fdse

port map (

c => clk,

d => i(index),

q => o(index),

ce => ce,

s => clr

);

end generate;

end generate;

end architecture structural;

-- synopsys translate_off

library unisim;

use unisim.vcomponents.all;

-- synopsys translate_on

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity synth_reg_w_init is

generic (

width: integer := 8;

init_index: integer := 0;

init_value: bit_vector := b"0000";

latency: integer := 1

);

port (

i: in std_logic_vector(width - 1 downto 0);

ce: in std_logic;

clr: in std_logic;

clk: in std_logic;

o: out std_logic_vector(width - 1 downto 0)

);

end synth_reg_w_init;

architecture structural of synth_reg_w_init is

component single_reg_w_init

generic (

width: integer := 8;

init_index: integer := 0;

init_value: bit_vector := b"0000"

);

port (

i: in std_logic_vector(width - 1 downto 0);

ce: in std_logic;

Page 141: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

134

clr: in std_logic;

clk: in std_logic;

o: out std_logic_vector(width - 1 downto 0)

);

end component;

signal dly_i: std_logic_vector((latency + 1) * width - 1 downto 0);

signal dly_clr: std_logic;

begin

latency_eq_0: if (latency = 0) generate

o <= i;

end generate;

latency_gt_0: if (latency >= 1) generate

dly_i((latency + 1) * width - 1 downto latency * width) <= i

after 200 ps;

dly_clr <= clr after 200 ps;

fd_array: for index in latency downto 1 generate

reg_comp: single_reg_w_init

generic map (

width => width,

init_index => init_index,

init_value => init_value

)

port map (

clk => clk,

i => dly_i((index + 1) * width - 1 downto index * width),

o => dly_i(index * width - 1 downto (index - 1) * width),

ce => ce,

clr => dly_clr

);

end generate;

o <= dly_i(width - 1 downto 0);

end generate;

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

use work.conv_pkg.all;

entity mux_ac2c510b5b is

port (

sel : in std_logic_vector((1 - 1) downto 0);

d0 : in std_logic_vector((6 - 1) downto 0);

d1 : in std_logic_vector((6 - 1) downto 0);

y : out std_logic_vector((6 - 1) downto 0);

clk : in std_logic;

ce : in std_logic;

clr : in std_logic);

end mux_ac2c510b5b;

architecture behavior of mux_ac2c510b5b is

signal sel_1_20: std_logic;

signal d0_1_24: std_logic_vector((6 - 1) downto 0);

Page 142: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

135

signal d1_1_27: std_logic_vector((6 - 1) downto 0);

signal sel_internal_2_1_convert: std_logic_vector((1 - 1) downto 0);

signal unregy_join_6_1: std_logic_vector((6 - 1) downto 0);

begin

sel_1_20 <= sel(0);

d0_1_24 <= d0;

d1_1_27 <= d1;

sel_internal_2_1_convert <= cast(std_logic_to_vector(sel_1_20), 0, 1, 0,

xlUnsigned);

proc_switch_6_1: process (d0_1_24, d1_1_27, sel_internal_2_1_convert)

is

begin

case sel_internal_2_1_convert is

when "0" =>

unregy_join_6_1 <= d0_1_24;

when others =>

unregy_join_6_1 <= d1_1_27;

end case;

end process proc_switch_6_1;

y <= unregy_join_6_1;

end behavior;

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

use work.conv_pkg.all;

entity constant_9f5572ba51 is

port (

op : out std_logic_vector((16 - 1) downto 0);

clk : in std_logic;

ce : in std_logic;

clr : in std_logic);

end constant_9f5572ba51;

architecture behavior of constant_9f5572ba51 is

begin

op <= "0000000000000000";

end behavior;

library XilinxCoreLib;

-- synopsys translate_on

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.std_logic_arith.all;

use work.conv_pkg.all;

entity xlmult_v9_0 is

generic (

core_name0: string := "";

a_width: integer := 4;

a_bin_pt: integer := 2;

a_arith: integer := xlSigned;

Page 143: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

136

b_width: integer := 4;

b_bin_pt: integer := 1;

b_arith: integer := xlSigned;

p_width: integer := 8;

p_bin_pt: integer := 2;

p_arith: integer := xlSigned;

rst_width: integer := 1;

rst_bin_pt: integer := 0;

rst_arith: integer := xlUnsigned;

en_width: integer := 1;

en_bin_pt: integer := 0;

en_arith: integer := xlUnsigned;

quantization: integer := xlTruncate;

overflow: integer := xlWrap;

extra_registers: integer := 0;

c_a_width: integer := 7;

c_b_width: integer := 7;

c_type: integer := 0;

c_a_type: integer := 0;

c_b_type: integer := 0;

c_pipelined: integer := 1;

c_baat: integer := 4;

multsign: integer := xlSigned;

c_output_width: integer := 16

);

port (

a: in std_logic_vector(a_width - 1 downto 0);

b: in std_logic_vector(b_width - 1 downto 0);

ce: in std_logic;

clr: in std_logic;

clk: in std_logic;

core_ce: in std_logic := '0';

core_clr: in std_logic := '0';

core_clk: in std_logic := '0';

rst: in std_logic_vector(rst_width - 1 downto 0);

en: in std_logic_vector(en_width - 1 downto 0);

p: out std_logic_vector(p_width - 1 downto 0)

);

end xlmult_v9_0 ;

architecture behavior of xlmult_v9_0 is

component synth_reg

generic (

width: integer := 16;

latency: integer := 5

);

port (

i: in std_logic_vector(width - 1 downto 0);

ce: in std_logic;

clr: in std_logic;

clk: in std_logic;

o: out std_logic_vector(width - 1 downto 0)

);

end component;

Page 144: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

137

component multiplier_spartan3_10_0_be7d54a806175751

port (

b: in std_logic_vector(c_b_width - 1 downto 0);

p: out std_logic_vector(c_output_width - 1 downto 0);

clk: in std_logic;

ce: in std_logic;

sclr: in std_logic;

a: in std_logic_vector(c_a_width - 1 downto 0)

);

end component;

attribute syn_black_box of multiplier_spartan3_10_0_be7d54a806175751:

component is true;

attribute fpga_dont_touch of multiplier_spartan3_10_0_be7d54a806175751:

component is "true";

attribute box_type of multiplier_spartan3_10_0_be7d54a806175751:

component is "black_box";

signal tmp_a: std_logic_vector(c_a_width - 1 downto 0);

signal conv_a: std_logic_vector(c_a_width - 1 downto 0);

signal tmp_b: std_logic_vector(c_b_width - 1 downto 0);

signal conv_b: std_logic_vector(c_b_width - 1 downto 0);

signal tmp_p: std_logic_vector(c_output_width - 1 downto 0);

signal conv_p: std_logic_vector(p_width - 1 downto 0);

-- synopsys translate_off

signal real_a, real_b, real_p: real;

-- synopsys translate_on

signal rfd: std_logic;

signal rdy: std_logic;

signal nd: std_logic;

signal internal_ce: std_logic;

signal internal_clr: std_logic;

signal internal_core_ce: std_logic;

begin

-- synopsys translate_off

-- synopsys translate_on

internal_ce <= ce and en(0);

internal_core_ce <= core_ce and en(0);

internal_clr <= (clr or rst(0)) and ce;

nd <= internal_ce;

input_process: process (a,b)

begin

tmp_a <= zero_ext(a, c_a_width);

tmp_b <= zero_ext(b, c_b_width);

end process;

output_process: process (tmp_p)

begin

conv_p <= convert_type(tmp_p, c_output_width, a_bin_pt+b_bin_pt, multsign,

p_width, p_bin_pt, p_arith, quantization, overflow);

end process;

comp0: if ((core_name0 = "multiplier_spartan3_10_0_be7d54a806175751"))

generate

core_instance0: multiplier_spartan3_10_0_be7d54a806175751

port map (

a => tmp_a,

Page 145: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

138

clk => clk,

ce => internal_ce,

sclr => internal_clr,

p => tmp_p,

b => tmp_b

);

end generate;

latency_gt_0: if (extra_registers > 0) generate

reg: synth_reg

generic map (

width => p_width,

latency => extra_registers

)

port map (

i => conv_p,

ce => internal_ce,

clr => internal_clr,

clk => clk,

o => p

);

end generate;

latency_eq_0: if (extra_registers = 0) generate

p <= conv_p;

end generate;

end architecture behavior;

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

use work.conv_pkg.all;

entity relational_17f4965351 is

port (

a : in std_logic_vector((6 - 1) downto 0);

b : in std_logic_vector((16 - 1) downto 0);

op : out std_logic_vector((1 - 1) downto 0);

clk : in std_logic;

ce : in std_logic;

clr : in std_logic);

end relational_17f4965351;

architecture behavior of relational_17f4965351 is

signal a_1_31: signed((6 - 1) downto 0);

signal b_1_34: signed((16 - 1) downto 0);

type array_type_op_mem_32_22 is array (0 to (1 - 1)) of boolean;

signal op_mem_32_22: array_type_op_mem_32_22 := (

0 => false);

signal op_mem_32_22_front_din: boolean;

signal op_mem_32_22_back: boolean;

signal op_mem_32_22_push_front_pop_back_en: std_logic;

signal cast_18_12: signed((16 - 1) downto 0);

signal result_18_3_rel: boolean;

begin

Page 146: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

139

a_1_31 <= std_logic_vector_to_signed(a);

b_1_34 <= std_logic_vector_to_signed(b);

op_mem_32_22_back <= op_mem_32_22(0);

proc_op_mem_32_22: process (clk)

is

variable i: integer;

begin

if (clk'event and (clk = '1')) then

if ((ce = '1') and (op_mem_32_22_push_front_pop_back_en = '1')) then

op_mem_32_22(0) <= op_mem_32_22_front_din;

end if;

end if;

end process proc_op_mem_32_22;

cast_18_12 <= s2s_cast(a_1_31, 4, 16, 14);

result_18_3_rel <= cast_18_12 > b_1_34;

op_mem_32_22_front_din <= result_18_3_rel;

op_mem_32_22_push_front_pop_back_en <= '1';

op <= boolean_to_vector(op_mem_32_22_back);

end behavior;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

-- Generated from Simulink block "moddembpsk/BPSK"

entity bpsk_entity_e7592e6a9e is

port (

gateway_in: in std_logic_vector(5 downto 0);

gateway_in1: in std_logic_vector(5 downto 0);

gateway_in2: in std_logic;

out1: out std_logic_vector(5 downto 0)

);

end bpsk_entity_e7592e6a9e;

architecture structural of bpsk_entity_e7592e6a9e is

signal gateway_in1_net_x0: std_logic_vector(5 downto 0);

signal gateway_in2_net_x0: std_logic;

signal gateway_in_net_x0: std_logic_vector(5 downto 0);

signal mux_y_net_x0: std_logic_vector(5 downto 0);

begin

gateway_in_net_x0 <= gateway_in;

gateway_in1_net_x0 <= gateway_in1;

gateway_in2_net_x0 <= gateway_in2;

out1 <= mux_y_net_x0;

mux: entity work.mux_ac2c510b5b

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => gateway_in_net_x0,

Page 147: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

140

d1 => gateway_in1_net_x0,

sel(0) => gateway_in2_net_x0,

y => mux_y_net_x0

);

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

-- Generated from Simulink block "moddembpsk"

entity moddembpsk is

port (

ce_1: in std_logic;

clk_1: in std_logic;

gateway_in: in std_logic_vector(5 downto 0);

gateway_in1: in std_logic_vector(5 downto 0);

gateway_in1_x0: in std_logic_vector(5 downto 0);

gateway_in2: in std_logic;

gateway_in3: in std_logic_vector(5 downto 0);

gateway_out1: out std_logic;

gateway_out2: out std_logic_vector(11 downto 0)

);

end moddembpsk;

architecture structural of moddembpsk is

signal ce_1_sg_x0: std_logic;

signal clk_1_sg_x0: std_logic;

signal constant_op_net: std_logic_vector(15 downto 0);

signal gateway_in1_net: std_logic_vector(5 downto 0);

signal gateway_in1_x0_net: std_logic_vector(5 downto 0);

signal gateway_in2_net: std_logic;

signal gateway_in3_net: std_logic_vector(5 downto 0);

signal gateway_in_net: std_logic_vector(5 downto 0);

signal gateway_out1_net: std_logic;

signal gateway_out2_net: std_logic_vector(11 downto 0);

signal mux_y_net_x0: std_logic_vector(5 downto 0);

begin

ce_1_sg_x0 <= ce_1;

clk_1_sg_x0 <= clk_1;

gateway_in_net <= gateway_in;

gateway_in1_net <= gateway_in1;

gateway_in1_x0_net <= gateway_in1_x0;

gateway_in2_net <= gateway_in2;

gateway_in3_net <= gateway_in3;

gateway_out1 <= gateway_out1_net;

gateway_out2 <= gateway_out2_net;

bpsk_e7592e6a9e: entity work.bpsk_entity_e7592e6a9e

port map (

gateway_in => gateway_in_net,

Page 148: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

141

gateway_in1 => gateway_in1_x0_net,

gateway_in2 => gateway_in2_net,

out1 => mux_y_net_x0

);

constant_x0: entity work.constant_9f5572ba51

port map (

ce => '0',

clk => '0',

clr => '0',

op => constant_op_net

);

mult: entity work.xlmult_v9_0

generic map (

a_arith => xlSigned,

a_bin_pt => 4,

a_width => 6,

b_arith => xlSigned,

b_bin_pt => 4,

b_width => 6,

c_a_type => 0,

c_a_width => 6,

c_b_type => 0,

c_b_width => 6,

c_baat => 6,

c_output_width => 12,

c_type => 0,

core_name0 => "multiplier_spartan3_10_0_be7d54a806175751",

extra_registers => 0,

multsign => 2,

overflow => 1,

p_arith => xlSigned,

p_bin_pt => 8,

p_width => 12,

quantization => 1

)

port map (

a => mux_y_net_x0,

b => gateway_in3_net,

ce => ce_1_sg_x0,

clk => clk_1_sg_x0,

clr => '0',

core_ce => ce_1_sg_x0,

core_clk => clk_1_sg_x0,

core_clr => '1',

en => "1",

rst => "0",

p => gateway_out2_net

);

relational: entity work.relational_17f4965351

port map (

Page 149: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

142

a => gateway_in1_net,

b => constant_op_net,

ce => ce_1_sg_x0,

clk => clk_1_sg_x0,

clr => '0',

op(0) => gateway_out1_net

);

end structural;

CODIFICADOR HAMMING 7,4:

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

package conv_pkg is

constant simulating : boolean := false

-- synopsys translate_off

or true

-- synopsys translate_on

;

constant xlUnsigned : integer := 1;

constant xlSigned : integer := 2;

constant xlWrap : integer := 1;

constant xlSaturate : integer := 2;

constant xlTruncate : integer := 1;

constant xlRound : integer := 2;

constant xlRoundBanker : integer := 3;

constant xlAddMode : integer := 1;

constant xlSubMode : integer := 2;

attribute black_box : boolean;

attribute syn_black_box : boolean;

attribute fpga_dont_touch: string;

attribute box_type : string;

attribute keep : string;

attribute syn_keep : boolean;

function std_logic_vector_to_unsigned(inp : std_logic_vector) return unsigned;

function unsigned_to_std_logic_vector(inp : unsigned) return std_logic_vector;

function std_logic_vector_to_signed(inp : std_logic_vector) return signed;

function signed_to_std_logic_vector(inp : signed) return std_logic_vector;

function unsigned_to_signed(inp : unsigned) return signed;

function signed_to_unsigned(inp : signed) return unsigned;

function pos(inp : std_logic_vector; arith : INTEGER) return boolean;

function all_same(inp: std_logic_vector) return boolean;

function all_zeros(inp: std_logic_vector) return boolean;

function is_point_five(inp: std_logic_vector) return boolean;

function all_ones(inp: std_logic_vector) return boolean;

function convert_type (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith,

quantization, overflow : INTEGER)

return std_logic_vector;

function cast (inp : std_logic_vector; old_bin_pt,

new_width, new_bin_pt, new_arith : INTEGER)

Page 150: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

143

return std_logic_vector;

function vec_slice (inp : std_logic_vector; upper, lower : INTEGER)

return std_logic_vector;

function s2u_slice (inp : signed; upper, lower : INTEGER)

return unsigned;

function u2u_slice (inp : unsigned; upper, lower : INTEGER)

return unsigned;

function s2s_cast (inp : signed; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return signed;

function u2s_cast (inp : unsigned; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return signed;

function s2u_cast (inp : signed; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return unsigned;

function u2u_cast (inp : unsigned; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return unsigned;

function u2v_cast (inp : unsigned; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return std_logic_vector;

function s2v_cast (inp : signed; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return std_logic_vector;

function trunc (inp : std_logic_vector; old_width, old_bin_pt, old_arith,

new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector;

function round_towards_inf (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt,

new_arith : INTEGER) return std_logic_vector;

function round_towards_even (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt,

new_arith : INTEGER) return std_logic_vector;

function max_signed(width : INTEGER) return std_logic_vector;

function min_signed(width : INTEGER) return std_logic_vector;

function saturation_arith(inp: std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

: INTEGER) return std_logic_vector;

function wrap_arith(inp: std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector;

function fractional_bits(a_bin_pt, b_bin_pt: INTEGER) return INTEGER;

function integer_bits(a_width, a_bin_pt, b_width, b_bin_pt: INTEGER)

return INTEGER;

function sign_ext(inp : std_logic_vector; new_width : INTEGER)

return std_logic_vector;

function zero_ext(inp : std_logic_vector; new_width : INTEGER)

return std_logic_vector;

function zero_ext(inp : std_logic; new_width : INTEGER)

return std_logic_vector;

function extend_MSB(inp : std_logic_vector; new_width, arith : INTEGER)

return std_logic_vector;

Page 151: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

144

function align_input(inp : std_logic_vector; old_width, delta, new_arith,

new_width: INTEGER)

return std_logic_vector;

function pad_LSB(inp : std_logic_vector; new_width: integer)

return std_logic_vector;

function pad_LSB(inp : std_logic_vector; new_width, arith : integer)

return std_logic_vector;

function max(L, R: INTEGER) return INTEGER;

function min(L, R: INTEGER) return INTEGER;

function "="(left,right: STRING) return boolean;

function boolean_to_signed (inp : boolean; width: integer)

return signed;

function boolean_to_unsigned (inp : boolean; width: integer)

return unsigned;

function boolean_to_vector (inp : boolean)

return std_logic_vector;

function std_logic_to_vector (inp : std_logic)

return std_logic_vector;

function integer_to_std_logic_vector (inp : integer; width, arith : integer)

return std_logic_vector;

function std_logic_vector_to_integer (inp : std_logic_vector; arith : integer)

return integer;

function std_logic_to_integer(constant inp : std_logic := '0')

return integer;

function bin_string_element_to_std_logic_vector (inp : string; width, index :

integer)

return std_logic_vector;

function bin_string_to_std_logic_vector (inp : string)

return std_logic_vector;

function hex_string_to_std_logic_vector (inp : string; width : integer)

return std_logic_vector;

function makeZeroBinStr (width : integer) return STRING;

function and_reduce(inp: std_logic_vector) return std_logic;

-- synopsys translate_off

function is_binary_string_invalid (inp : string)

return boolean;

function is_binary_string_undefined (inp : string)

return boolean;

function is_XorU(inp : std_logic_vector)

return boolean;

function to_real(inp : std_logic_vector; bin_pt : integer; arith : integer)

return real;

function std_logic_to_real(inp : std_logic; bin_pt : integer; arith : integer)

return real;

function real_to_std_logic_vector (inp : real; width, bin_pt, arith : integer)

return std_logic_vector;

function real_string_to_std_logic_vector (inp : string; width, bin_pt, arith : integer)

return std_logic_vector;

constant display_precision : integer := 20;

function real_to_string (inp : real) return string;

function valid_bin_string(inp : string) return boolean;

function std_logic_vector_to_bin_string(inp : std_logic_vector) return string;

function std_logic_to_bin_string(inp : std_logic) return string;

Page 152: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

145

function std_logic_vector_to_bin_string_w_point(inp : std_logic_vector; bin_pt :

integer)

return string;

function real_to_bin_string(inp : real; width, bin_pt, arith : integer)

return string;

type stdlogic_to_char_t is array(std_logic) of character;

constant to_char : stdlogic_to_char_t := (

'U' => 'U',

'X' => 'X',

'0' => '0',

'1' => '1',

'Z' => 'Z',

'W' => 'W',

'L' => 'L',

'H' => 'H',

'-' => '-');

-- synopsys translate_on

end conv_pkg;

package body conv_pkg is

function std_logic_vector_to_unsigned(inp : std_logic_vector)

return unsigned

is

begin

return unsigned (inp);

end;

function unsigned_to_std_logic_vector(inp : unsigned)

return std_logic_vector

is

begin

return std_logic_vector(inp);

end;

function std_logic_vector_to_signed(inp : std_logic_vector)

return signed

is

begin

return signed (inp);

end;

function signed_to_std_logic_vector(inp : signed)

return std_logic_vector

is

begin

return std_logic_vector(inp);

end;

function unsigned_to_signed (inp : unsigned)

return signed

is

begin

return signed(std_logic_vector(inp));

end;

function signed_to_unsigned (inp : signed)

return unsigned

is

begin

Page 153: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

146

return unsigned(std_logic_vector(inp));

end;

function pos(inp : std_logic_vector; arith : INTEGER)

return boolean

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

begin

vec := inp;

if arith = xlUnsigned then

return true;

else

if vec(width-1) = '0' then

return true;

else

return false;

end if;

end if;

return true;

end;

function max_signed(width : INTEGER)

return std_logic_vector

is

variable ones : std_logic_vector(width-2 downto 0);

variable result : std_logic_vector(width-1 downto 0);

begin

ones := (others => '1');

result(width-1) := '0';

result(width-2 downto 0) := ones;

return result;

end;

function min_signed(width : INTEGER)

return std_logic_vector

is

variable zeros : std_logic_vector(width-2 downto 0);

variable result : std_logic_vector(width-1 downto 0);

begin

zeros := (others => '0');

result(width-1) := '1';

result(width-2 downto 0) := zeros;

return result;

end;

function and_reduce(inp: std_logic_vector) return std_logic

is

variable result: std_logic;

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

begin

vec := inp;

result := vec(0);

if width > 1 then

for i in 1 to width-1 loop

result := result and vec(i);

Page 154: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

147

end loop;

end if;

return result;

end;

function all_same(inp: std_logic_vector) return boolean

is

variable result: boolean;

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

begin

vec := inp;

result := true;

if width > 0 then

for i in 1 to width-1 loop

if vec(i) /= vec(0) then

result := false;

end if;

end loop;

end if;

return result;

end;

function all_zeros(inp: std_logic_vector)

return boolean

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable zero : std_logic_vector(width-1 downto 0);

variable result : boolean;

begin

zero := (others => '0');

vec := inp;

-- synopsys translate_off

if (is_XorU(vec)) then

return false;

end if;

-- synopsys translate_on

if (std_logic_vector_to_unsigned(vec) = std_logic_vector_to_unsigned(zero))

then

result := true;

else

result := false;

end if;

return result;

end;

function is_point_five(inp: std_logic_vector)

return boolean

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable result : boolean;

begin

vec := inp;

-- synopsys translate_off

Page 155: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

148

if (is_XorU(vec)) then

return false;

end if;

-- synopsys translate_on

if (width > 1) then

if ((vec(width-1) = '1') and (all_zeros(vec(width-2 downto 0)) = true)) then

result := true;

else

result := false;

end if;

else

if (vec(width-1) = '1') then

result := true;

else

result := false;

end if;

end if;

return result;

end;

function all_ones(inp: std_logic_vector)

return boolean

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable one : std_logic_vector(width-1 downto 0);

variable result : boolean;

begin

one := (others => '1');

vec := inp;

-- synopsys translate_off

if (is_XorU(vec)) then

return false;

end if;

-- synopsys translate_on

if (std_logic_vector_to_unsigned(vec) = std_logic_vector_to_unsigned(one))

then

result := true;

else

result := false;

end if;

return result;

end;

function full_precision_num_width(quantization, overflow, old_width,

old_bin_pt, old_arith,

new_width, new_bin_pt, new_arith : INTEGER)

return integer

is

variable result : integer;

begin

result := old_width + 2;

return result;

end;

function quantized_num_width(quantization, overflow, old_width, old_bin_pt,

Page 156: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

149

old_arith, new_width, new_bin_pt, new_arith

: INTEGER)

return integer

is

variable right_of_dp, left_of_dp, result : integer;

begin

right_of_dp := max(new_bin_pt, old_bin_pt);

left_of_dp := max((new_width - new_bin_pt), (old_width - old_bin_pt));

result := (old_width + 2) + (new_bin_pt - old_bin_pt);

return result;

end;

function convert_type (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith,

quantization, overflow : INTEGER)

return std_logic_vector

is

constant fp_width : integer :=

full_precision_num_width(quantization, overflow, old_width,

old_bin_pt, old_arith, new_width,

new_bin_pt, new_arith);

constant fp_bin_pt : integer := old_bin_pt;

constant fp_arith : integer := old_arith;

variable full_precision_result : std_logic_vector(fp_width-1 downto 0);

constant q_width : integer :=

quantized_num_width(quantization, overflow, old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith);

constant q_bin_pt : integer := new_bin_pt;

constant q_arith : integer := old_arith;

variable quantized_result : std_logic_vector(q_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

result := (others => '0');

full_precision_result := cast(inp, old_bin_pt, fp_width, fp_bin_pt,

fp_arith);

if (quantization = xlRound) then

quantized_result := round_towards_inf(full_precision_result,

fp_width, fp_bin_pt,

fp_arith, q_width, q_bin_pt,

q_arith);

elsif (quantization = xlRoundBanker) then

quantized_result := round_towards_even(full_precision_result,

fp_width, fp_bin_pt,

fp_arith, q_width, q_bin_pt,

q_arith);

else

quantized_result := trunc(full_precision_result, fp_width, fp_bin_pt,

fp_arith, q_width, q_bin_pt, q_arith);

end if;

if (overflow = xlSaturate) then

result := saturation_arith(quantized_result, q_width, q_bin_pt,

q_arith, new_width, new_bin_pt, new_arith);

else

result := wrap_arith(quantized_result, q_width, q_bin_pt, q_arith,

Page 157: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

150

new_width, new_bin_pt, new_arith);

end if;

return result;

end;

function cast (inp : std_logic_vector; old_bin_pt, new_width,

new_bin_pt, new_arith : INTEGER)

return std_logic_vector

is

constant old_width : integer := inp'length;

constant left_of_dp : integer := (new_width - new_bin_pt)

- (old_width - old_bin_pt);

constant right_of_dp : integer := (new_bin_pt - old_bin_pt);

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

variable j : integer;

begin

vec := inp;

for i in new_width-1 downto 0 loop

j := i - right_of_dp;

if ( j > old_width-1) then

if (new_arith = xlUnsigned) then

result(i) := '0';

else

result(i) := vec(old_width-1);

end if;

elsif ( j >= 0) then

result(i) := vec(j);

else

result(i) := '0';

end if;

end loop;

return result;

end;

function vec_slice (inp : std_logic_vector; upper, lower : INTEGER)

return std_logic_vector

is

begin

return inp(upper downto lower);

end;

function s2u_slice (inp : signed; upper, lower : INTEGER)

return unsigned

is

begin

return unsigned(vec_slice(std_logic_vector(inp), upper, lower));

end;

function u2u_slice (inp : unsigned; upper, lower : INTEGER)

return unsigned

is

begin

return unsigned(vec_slice(std_logic_vector(inp), upper, lower));

end;

function s2s_cast (inp : signed; old_bin_pt, new_width, new_bin_pt : INTEGER)

return signed

Page 158: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

151

is

begin

return signed(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlSigned));

end;

function s2u_cast (inp : signed; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return unsigned

is

begin

return unsigned(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlSigned));

end;

function u2s_cast (inp : unsigned; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return signed

is

begin

return signed(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlUnsigned));

end;

function u2u_cast (inp : unsigned; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return unsigned

is

begin

return unsigned(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlUnsigned));

end;

function u2v_cast (inp : unsigned; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return std_logic_vector

is

begin

return cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlUnsigned);

end;

function s2v_cast (inp : signed; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return std_logic_vector

is

begin

return cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt, xlSigned);

end;

function boolean_to_signed (inp : boolean; width : integer)

return signed

is

variable result : signed(width - 1 downto 0);

begin

result := (others => '0');

if inp then

result(0) := '1';

else

Page 159: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

152

result(0) := '0';

end if;

return result;

end;

function boolean_to_unsigned (inp : boolean; width : integer)

return unsigned

is

variable result : unsigned(width - 1 downto 0);

begin

result := (others => '0');

if inp then

result(0) := '1';

else

result(0) := '0';

end if;

return result;

end;

function boolean_to_vector (inp : boolean)

return std_logic_vector

is

variable result : std_logic_vector(1 - 1 downto 0);

begin

result := (others => '0');

if inp then

result(0) := '1';

else

result(0) := '0';

end if;

return result;

end;

function std_logic_to_vector (inp : std_logic)

return std_logic_vector

is

variable result : std_logic_vector(1 - 1 downto 0);

begin

result(0) := inp;

return result;

end;

function trunc (inp : std_logic_vector; old_width, old_bin_pt, old_arith,

new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector

is

constant right_of_dp : integer := (old_bin_pt - new_bin_pt);

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if right_of_dp >= 0 then

if new_arith = xlUnsigned then

result := zero_ext(vec(old_width-1 downto right_of_dp), new_width);

else

result := sign_ext(vec(old_width-1 downto right_of_dp), new_width);

end if;

Page 160: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

153

else

if new_arith = xlUnsigned then

result := zero_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

else

result := sign_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

end if;

end if;

return result;

end;

function round_towards_inf (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

: INTEGER)

return std_logic_vector

is

constant right_of_dp : integer := (old_bin_pt - new_bin_pt);

constant expected_new_width : integer := old_width - right_of_dp + 1;

variable vec : std_logic_vector(old_width-1 downto 0);

variable one_or_zero : std_logic_vector(new_width-1 downto 0);

variable truncated_val : std_logic_vector(new_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if right_of_dp >= 0 then

if new_arith = xlUnsigned then

truncated_val := zero_ext(vec(old_width-1 downto right_of_dp),

new_width);

else

truncated_val := sign_ext(vec(old_width-1 downto right_of_dp),

new_width);

end if;

else

if new_arith = xlUnsigned then

truncated_val := zero_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

else

truncated_val := sign_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

end if;

end if;

one_or_zero := (others => '0');

if (new_arith = xlSigned) then

if (vec(old_width-1) = '0') then

one_or_zero(0) := '1';

end if;

if (right_of_dp >= 2) and (right_of_dp <= old_width) then

if (all_zeros(vec(right_of_dp-2 downto 0)) = false) then

one_or_zero(0) := '1';

end if;

end if;

if (right_of_dp >= 1) and (right_of_dp <= old_width) then

if vec(right_of_dp-1) = '0' then

Page 161: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

154

one_or_zero(0) := '0';

end if;

else

one_or_zero(0) := '0';

end if;

else

if (right_of_dp >= 1) and (right_of_dp <= old_width) then

one_or_zero(0) := vec(right_of_dp-1);

end if;

end if;

if new_arith = xlSigned then

result :=

signed_to_std_logic_vector(std_logic_vector_to_signed(truncated_val) +

std_logic_vector_to_signed(one_or_zero));

else

result :=

unsigned_to_std_logic_vector(std_logic_vector_to_unsigned(truncated_val) +

std_logic_vector_to_unsigned(one_or_zero));

end if;

return result;

end;

function round_towards_even (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

: INTEGER)

return std_logic_vector

is

constant right_of_dp : integer := (old_bin_pt - new_bin_pt);

constant expected_new_width : integer := old_width - right_of_dp + 1;

variable vec : std_logic_vector(old_width-1 downto 0);

variable one_or_zero : std_logic_vector(new_width-1 downto 0);

variable truncated_val : std_logic_vector(new_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if right_of_dp >= 0 then

if new_arith = xlUnsigned then

truncated_val := zero_ext(vec(old_width-1 downto right_of_dp),

new_width);

else

truncated_val := sign_ext(vec(old_width-1 downto right_of_dp),

new_width);

end if;

else

if new_arith = xlUnsigned then

truncated_val := zero_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

else

truncated_val := sign_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

end if;

end if;

one_or_zero := (others => '0');

if (right_of_dp >= 1) and (right_of_dp <= old_width) then

Page 162: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

155

if (is_point_five(vec(right_of_dp-1 downto 0)) = false) then

one_or_zero(0) := vec(right_of_dp-1);

else

one_or_zero(0) := vec(right_of_dp);

end if;

end if;

if new_arith = xlSigned then

result :=

signed_to_std_logic_vector(std_logic_vector_to_signed(truncated_val) +

std_logic_vector_to_signed(one_or_zero));

else

result :=

unsigned_to_std_logic_vector(std_logic_vector_to_unsigned(truncated_val) +

std_logic_vector_to_unsigned(one_or_zero));

end if;

return result;

end;

function saturation_arith(inp: std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

: INTEGER)

return std_logic_vector

is

constant left_of_dp : integer := (old_width - old_bin_pt) -

(new_width - new_bin_pt);

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

variable overflow : boolean;

begin

vec := inp;

overflow := true;

result := (others => '0');

if (new_width >= old_width) then

overflow := false;

end if;

if ((old_arith = xlSigned and new_arith = xlSigned) and (old_width >

new_width)) then

if all_same(vec(old_width-1 downto new_width-1)) then

overflow := false;

end if;

end if;

if (old_arith = xlSigned and new_arith = xlUnsigned) then

if (old_width > new_width) then

if all_zeros(vec(old_width-1 downto new_width)) then

overflow := false;

end if;

else

if (old_width = new_width) then

if (vec(new_width-1) = '0') then

overflow := false;

end if;

end if;

end if;

end if;

Page 163: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

156

if (old_arith = xlUnsigned and new_arith = xlUnsigned) then

if (old_width > new_width) then

if all_zeros(vec(old_width-1 downto new_width)) then

overflow := false;

end if;

else

if (old_width = new_width) then

overflow := false;

end if;

end if;

end if;

if ((old_arith = xlUnsigned and new_arith = xlSigned) and (old_width >

new_width)) then

if all_same(vec(old_width-1 downto new_width-1)) then

overflow := false;

end if;

end if;

if overflow then

if new_arith = xlSigned then

if vec(old_width-1) = '0' then

result := max_signed(new_width);

else

result := min_signed(new_width);

end if;

else

if ((old_arith = xlSigned) and vec(old_width-1) = '1') then

result := (others => '0');

else

result := (others => '1');

end if;

end if;

else

if (old_arith = xlSigned) and (new_arith = xlUnsigned) then

if (vec(old_width-1) = '1') then

vec := (others => '0');

end if;

end if;

if new_width <= old_width then

result := vec(new_width-1 downto 0);

else

if new_arith = xlUnsigned then

result := zero_ext(vec, new_width);

else

result := sign_ext(vec, new_width);

end if;

end if;

end if;

return result;

end;

function wrap_arith(inp: std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector

is

Page 164: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

157

variable result : std_logic_vector(new_width-1 downto 0);

variable result_arith : integer;

begin

if (old_arith = xlSigned) and (new_arith = xlUnsigned) then

result_arith := xlSigned;

end if;

result := cast(inp, old_bin_pt, new_width, new_bin_pt, result_arith);

return result;

end;

function fractional_bits(a_bin_pt, b_bin_pt: INTEGER) return INTEGER is

begin

return max(a_bin_pt, b_bin_pt);

end;

function integer_bits(a_width, a_bin_pt, b_width, b_bin_pt: INTEGER)

return INTEGER is

begin

return max(a_width - a_bin_pt, b_width - b_bin_pt);

end;

function pad_LSB(inp : std_logic_vector; new_width: integer)

return STD_LOGIC_VECTOR

is

constant orig_width : integer := inp'length;

variable vec : std_logic_vector(orig_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

variable pos : integer;

constant pad_pos : integer := new_width - orig_width - 1;

begin

vec := inp;

pos := new_width-1;

if (new_width >= orig_width) then

for i in orig_width-1 downto 0 loop

result(pos) := vec(i);

pos := pos - 1;

end loop;

if pad_pos >= 0 then

for i in pad_pos downto 0 loop

result(i) := '0';

end loop;

end if;

end if;

return result;

end;

function sign_ext(inp : std_logic_vector; new_width : INTEGER)

return std_logic_vector

is

constant old_width : integer := inp'length;

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if new_width >= old_width then

result(old_width-1 downto 0) := vec;

if new_width-1 >= old_width then

Page 165: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

158

for i in new_width-1 downto old_width loop

result(i) := vec(old_width-1);

end loop;

end if;

else

result(new_width-1 downto 0) := vec(new_width-1 downto 0);

end if;

return result;

end;

function zero_ext(inp : std_logic_vector; new_width : INTEGER)

return std_logic_vector

is

constant old_width : integer := inp'length;

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if new_width >= old_width then

result(old_width-1 downto 0) := vec;

if new_width-1 >= old_width then

for i in new_width-1 downto old_width loop

result(i) := '0';

end loop;

end if;

else

result(new_width-1 downto 0) := vec(new_width-1 downto 0);

end if;

return result;

end;

function zero_ext(inp : std_logic; new_width : INTEGER)

return std_logic_vector

is

variable result : std_logic_vector(new_width-1 downto 0);

begin

result(0) := inp;

for i in new_width-1 downto 1 loop

result(i) := '0';

end loop;

return result;

end;

function extend_MSB(inp : std_logic_vector; new_width, arith : INTEGER)

return std_logic_vector

is

constant orig_width : integer := inp'length;

variable vec : std_logic_vector(orig_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if arith = xlUnsigned then

result := zero_ext(vec, new_width);

else

result := sign_ext(vec, new_width);

end if;

Page 166: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

159

return result;

end;

function pad_LSB(inp : std_logic_vector; new_width, arith: integer)

return STD_LOGIC_VECTOR

is

constant orig_width : integer := inp'length;

variable vec : std_logic_vector(orig_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

variable pos : integer;

begin

vec := inp;

pos := new_width-1;

if (arith = xlUnsigned) then

result(pos) := '0';

pos := pos - 1;

else

result(pos) := vec(orig_width-1);

pos := pos - 1;

end if;

if (new_width >= orig_width) then

for i in orig_width-1 downto 0 loop

result(pos) := vec(i);

pos := pos - 1;

end loop;

if pos >= 0 then

for i in pos downto 0 loop

result(i) := '0';

end loop;

end if;

end if;

return result;

end;

function align_input(inp : std_logic_vector; old_width, delta, new_arith,

new_width: INTEGER)

return std_logic_vector

is

variable vec : std_logic_vector(old_width-1 downto 0);

variable padded_inp : std_logic_vector((old_width + delta)-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if delta > 0 then

padded_inp := pad_LSB(vec, old_width+delta);

result := extend_MSB(padded_inp, new_width, new_arith);

else

result := extend_MSB(vec, new_width, new_arith);

end if;

return result;

end;

function max(L, R: INTEGER) return INTEGER is

begin

if L > R then

return L;

Page 167: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

160

else

return R;

end if;

end;

function min(L, R: INTEGER) return INTEGER is

begin

if L < R then

return L;

else

return R;

end if;

end;

function "="(left,right: STRING) return boolean is

begin

if (left'length /= right'length) then

return false;

else

test : for i in 1 to left'length loop

if left(i) /= right(i) then

return false;

end if;

end loop test;

return true;

end if;

end;

-- synopsys translate_off

function is_binary_string_invalid (inp : string)

return boolean

is

variable vec : string(1 to inp'length);

variable result : boolean;

begin

vec := inp;

result := false;

for i in 1 to vec'length loop

if ( vec(i) = 'X' ) then

result := true;

end if;

end loop;

return result;

end;

function is_binary_string_undefined (inp : string)

return boolean

is

variable vec : string(1 to inp'length);

variable result : boolean;

begin

vec := inp;

result := false;

for i in 1 to vec'length loop

if ( vec(i) = 'U' ) then

result := true;

end if;

Page 168: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

161

end loop;

return result;

end;

function is_XorU(inp : std_logic_vector)

return boolean

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable result : boolean;

begin

vec := inp;

result := false;

for i in 0 to width-1 loop

if (vec(i) = 'U') or (vec(i) = 'X') then

result := true;

end if;

end loop;

return result;

end;

function to_real(inp : std_logic_vector; bin_pt : integer; arith : integer)

return real

is

variable vec : std_logic_vector(inp'length-1 downto 0);

variable result, shift_val, undefined_real : real;

variable neg_num : boolean;

begin

vec := inp;

result := 0.0;

neg_num := false;

if vec(inp'length-1) = '1' then

neg_num := true;

end if;

for i in 0 to inp'length-1 loop

if vec(i) = 'U' or vec(i) = 'X' then

return undefined_real;

end if;

if arith = xlSigned then

if neg_num then

if vec(i) = '0' then

result := result + 2.0**i;

end if;

else

if vec(i) = '1' then

result := result + 2.0**i;

end if;

end if;

else

if vec(i) = '1' then

result := result + 2.0**i;

end if;

end if;

end loop;

if arith = xlSigned then

Page 169: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

162

if neg_num then

result := result + 1.0;

result := result * (-1.0);

end if;

end if;

shift_val := 2.0**(-1*bin_pt);

result := result * shift_val;

return result;

end;

function std_logic_to_real(inp : std_logic; bin_pt : integer; arith : integer)

return real

is

variable result : real := 0.0;

begin

if inp = '1' then

result := 1.0;

end if;

if arith = xlSigned then

assert false

report "It doesn't make sense to convert a 1 bit number to a signed real.";

end if;

return result;

end;

-- synopsys translate_on

function integer_to_std_logic_vector (inp : integer; width, arith : integer)

return std_logic_vector

is

variable result : std_logic_vector(width-1 downto 0);

variable unsigned_val : unsigned(width-1 downto 0);

variable signed_val : signed(width-1 downto 0);

begin

if (arith = xlSigned) then

signed_val := to_signed(inp, width);

result := signed_to_std_logic_vector(signed_val);

else

unsigned_val := to_unsigned(inp, width);

result := unsigned_to_std_logic_vector(unsigned_val);

end if;

return result;

end;

function std_logic_vector_to_integer (inp : std_logic_vector; arith : integer)

return integer

is

constant width : integer := inp'length;

variable unsigned_val : unsigned(width-1 downto 0);

variable signed_val : signed(width-1 downto 0);

variable result : integer;

begin

if (arith = xlSigned) then

signed_val := std_logic_vector_to_signed(inp);

result := to_integer(signed_val);

else

unsigned_val := std_logic_vector_to_unsigned(inp);

Page 170: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

163

result := to_integer(unsigned_val);

end if;

return result;

end;

function std_logic_to_integer(constant inp : std_logic := '0')

return integer

is

begin

if inp = '1' then

return 1;

else

return 0;

end if;

end;

function makeZeroBinStr (width : integer) return STRING is

variable result : string(1 to width+3);

begin

result(1) := '0';

result(2) := 'b';

for i in 3 to width+2 loop

result(i) := '0';

end loop;

result(width+3) := '.';

return result;

end;

-- synopsys translate_off

function real_string_to_std_logic_vector (inp : string; width, bin_pt, arith : integer)

return std_logic_vector

is

variable result : std_logic_vector(width-1 downto 0);

begin

result := (others => '0');

return result;

end;

function real_to_std_logic_vector (inp : real; width, bin_pt, arith : integer)

return std_logic_vector

is

variable real_val : real;

variable int_val : integer;

variable result : std_logic_vector(width-1 downto 0) := (others => '0');

variable unsigned_val : unsigned(width-1 downto 0) := (others => '0');

variable signed_val : signed(width-1 downto 0) := (others => '0');

begin

real_val := inp;

int_val := integer(real_val * 2.0**(bin_pt));

if (arith = xlSigned) then

signed_val := to_signed(int_val, width);

result := signed_to_std_logic_vector(signed_val);

else

unsigned_val := to_unsigned(int_val, width);

result := unsigned_to_std_logic_vector(unsigned_val);

end if;

return result;

Page 171: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

164

end;

-- synopsys translate_on

function valid_bin_string (inp : string)

return boolean

is

variable vec : string(1 to inp'length);

begin

vec := inp;

if (vec(1) = '0' and vec(2) = 'b') then

return true;

else

return false;

end if;

end;

function hex_string_to_std_logic_vector(inp: string; width : integer)

return std_logic_vector is

constant strlen : integer := inp'LENGTH;

variable result : std_logic_vector(width-1 downto 0);

variable bitval : std_logic_vector((strlen*4)-1 downto 0);

variable posn : integer;

variable ch : character;

variable vec : string(1 to strlen);

begin

vec := inp;

result := (others => '0');

posn := (strlen*4)-1;

for i in 1 to strlen loop

ch := vec(i);

case ch is

when '0' => bitval(posn downto posn-3) := "0000";

when '1' => bitval(posn downto posn-3) := "0001";

when '2' => bitval(posn downto posn-3) := "0010";

when '3' => bitval(posn downto posn-3) := "0011";

when '4' => bitval(posn downto posn-3) := "0100";

when '5' => bitval(posn downto posn-3) := "0101";

when '6' => bitval(posn downto posn-3) := "0110";

when '7' => bitval(posn downto posn-3) := "0111";

when '8' => bitval(posn downto posn-3) := "1000";

when '9' => bitval(posn downto posn-3) := "1001";

when 'A' | 'a' => bitval(posn downto posn-3) := "1010";

when 'B' | 'b' => bitval(posn downto posn-3) := "1011";

when 'C' | 'c' => bitval(posn downto posn-3) := "1100";

when 'D' | 'd' => bitval(posn downto posn-3) := "1101";

when 'E' | 'e' => bitval(posn downto posn-3) := "1110";

when 'F' | 'f' => bitval(posn downto posn-3) := "1111";

when others => bitval(posn downto posn-3) := "XXXX";

-- synopsys translate_off

ASSERT false

REPORT "Invalid hex value" SEVERITY ERROR;

-- synopsys translate_on

end case;

posn := posn - 4;

end loop;

Page 172: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

165

if (width <= strlen*4) then

result := bitval(width-1 downto 0);

else

result((strlen*4)-1 downto 0) := bitval;

end if;

return result;

end;

function bin_string_to_std_logic_vector (inp : string)

return std_logic_vector

is

variable pos : integer;

variable vec : string(1 to inp'length);

variable result : std_logic_vector(inp'length-1 downto 0);

begin

vec := inp;

pos := inp'length-1;

result := (others => '0');

for i in 1 to vec'length loop

-- synopsys translate_off

if (pos < 0) and (vec(i) = '0' or vec(i) = '1' or vec(i) = 'X' or vec(i) = 'U') then

assert false

report "Input string is larger than output std_logic_vector. Truncating

output.";

return result;

end if;

-- synopsys translate_on

if vec(i) = '0' then

result(pos) := '0';

pos := pos - 1;

end if;

if vec(i) = '1' then

result(pos) := '1';

pos := pos - 1;

end if;

-- synopsys translate_off

if (vec(i) = 'X' or vec(i) = 'U') then

result(pos) := 'U';

pos := pos - 1;

end if;

-- synopsys translate_on

end loop;

return result;

end;

function bin_string_element_to_std_logic_vector (inp : string; width, index :

integer)

return std_logic_vector

is

constant str_width : integer := width + 4;

constant inp_len : integer := inp'length;

constant num_elements : integer := (inp_len + 1)/str_width;

constant reverse_index : integer := (num_elements-1) - index;

variable left_pos : integer;

variable right_pos : integer;

Page 173: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

166

variable vec : string(1 to inp'length);

variable result : std_logic_vector(width-1 downto 0);

begin

vec := inp;

result := (others => '0');

if (reverse_index = 0) and (reverse_index < num_elements) and (inp_len-3 >=

width) then

left_pos := 1;

right_pos := width + 3;

result := bin_string_to_std_logic_vector(vec(left_pos to right_pos));

end if;

if (reverse_index > 0) and (reverse_index < num_elements) and (inp_len-3 >=

width) then

left_pos := (reverse_index * str_width) + 1;

right_pos := left_pos + width + 2;

result := bin_string_to_std_logic_vector(vec(left_pos to right_pos));

end if;

return result;

end;

-- synopsys translate_off

function std_logic_vector_to_bin_string(inp : std_logic_vector)

return string

is

variable vec : std_logic_vector(1 to inp'length);

variable result : string(vec'range);

begin

vec := inp;

for i in vec'range loop

result(i) := to_char(vec(i));

end loop;

return result;

end;

function std_logic_to_bin_string(inp : std_logic)

return string

is

variable result : string(1 to 3);

begin

result(1) := '0';

result(2) := 'b';

result(3) := to_char(inp);

return result;

end;

function std_logic_vector_to_bin_string_w_point(inp : std_logic_vector; bin_pt :

integer)

return string

is

variable width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable str_pos : integer;

variable result : string(1 to width+3);

begin

vec := inp;

str_pos := 1;

Page 174: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

167

result(str_pos) := '0';

str_pos := 2;

result(str_pos) := 'b';

str_pos := 3;

for i in width-1 downto 0 loop

if (((width+3) - bin_pt) = str_pos) then

result(str_pos) := '.';

str_pos := str_pos + 1;

end if;

result(str_pos) := to_char(vec(i));

str_pos := str_pos + 1;

end loop;

if (bin_pt = 0) then

result(str_pos) := '.';

end if;

return result;

end;

function real_to_bin_string(inp : real; width, bin_pt, arith : integer)

return string

is

variable result : string(1 to width);

variable vec : std_logic_vector(width-1 downto 0);

begin

vec := real_to_std_logic_vector(inp, width, bin_pt, arith);

result := std_logic_vector_to_bin_string(vec);

return result;

end;

function real_to_string (inp : real) return string

is

variable result : string(1 to display_precision) := (others => ' ');

begin

result(real'image(inp)'range) := real'image(inp);

return result;

end;

-- synopsys translate_on

end conv_pkg;

library IEEE;

use IEEE.std_logic_1164.all;

package clock_pkg is

-- synopsys translate_off

signal int_clk : std_logic;

-- synopsys translate_on

end clock_pkg;

library unisim;

use unisim.vcomponents.all;

-- synopsys translate_on

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity srl17e is

generic (width : integer:=16;

latency : integer :=8);

Page 175: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

168

port (clk : in std_logic;

ce : in std_logic;

d : in std_logic_vector(width-1 downto 0);

q : out std_logic_vector(width-1 downto 0));

end srl17e;

architecture structural of srl17e is

component SRL16E

port (D : in STD_ULOGIC;

CE : in STD_ULOGIC;

CLK : in STD_ULOGIC;

A0 : in STD_ULOGIC;

A1 : in STD_ULOGIC;

A2 : in STD_ULOGIC;

A3 : in STD_ULOGIC;

Q : out STD_ULOGIC);

end component;

attribute syn_black_box of SRL16E : component is true;

attribute fpga_dont_touch of SRL16E : component is "true";

component FDE

port(

Q : out STD_ULOGIC;

D : in STD_ULOGIC;

C : in STD_ULOGIC;

CE : in STD_ULOGIC);

end component;

attribute syn_black_box of FDE : component is true;

attribute fpga_dont_touch of FDE : component is "true";

constant a : std_logic_vector(4 downto 0) :=

integer_to_std_logic_vector(latency-2,5,xlSigned);

signal d_delayed : std_logic_vector(width-1 downto 0);

signal srl16_out : std_logic_vector(width-1 downto 0);

begin

d_delayed <= d after 200 ps;

reg_array : for i in 0 to width-1 generate

srl16_used: if latency > 1 generate

u1 : srl16e port map(clk => clk,

d => d_delayed(i),

q => srl16_out(i),

ce => ce,

a0 => a(0),

a1 => a(1),

a2 => a(2),

a3 => a(3));

end generate;

srl16_not_used: if latency <= 1 generate

srl16_out(i) <= d_delayed(i);

end generate;

fde_used: if latency /= 0 generate

u2 : fde port map(c => clk,

d => srl16_out(i),

q => q(i),

ce => ce);

end generate;

Page 176: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

169

fde_not_used: if latency = 0 generate

q(i) <= srl16_out(i);

end generate;

end generate;

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity synth_reg is

generic (width : integer := 8;

latency : integer := 1);

port (i : in std_logic_vector(width-1 downto 0);

ce : in std_logic;

clr : in std_logic;

clk : in std_logic;

o : out std_logic_vector(width-1 downto 0));

end synth_reg;

architecture structural of synth_reg is

component srl17e

generic (width : integer:=16;

latency : integer :=8);

port (clk : in std_logic;

ce : in std_logic;

d : in std_logic_vector(width-1 downto 0);

q : out std_logic_vector(width-1 downto 0));

end component;

function calc_num_srl17es (latency : integer)

return integer

is

variable remaining_latency : integer;

variable result : integer;

begin

result := latency / 17;

remaining_latency := latency - (result * 17);

if (remaining_latency /= 0) then

result := result + 1;

end if;

return result;

end;

constant complete_num_srl17es : integer := latency / 17;

constant num_srl17es : integer := calc_num_srl17es(latency);

constant remaining_latency : integer := latency - (complete_num_srl17es * 17);

type register_array is array (num_srl17es downto 0) of

std_logic_vector(width-1 downto 0);

signal z : register_array;

begin

z(0) <= i;

complete_ones : if complete_num_srl17es > 0 generate

srl17e_array: for i in 0 to complete_num_srl17es-1 generate

delay_comp : srl17e

generic map (width => width,

latency => 17)

port map (clk => clk,

Page 177: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

170

ce => ce,

d => z(i),

q => z(i+1));

end generate;

end generate;

partial_one : if remaining_latency > 0 generate

last_srl17e : srl17e

generic map (width => width,

latency => remaining_latency)

port map (clk => clk,

ce => ce,

d => z(num_srl17es-1),

q => z(num_srl17es));

end generate;

o <= z(num_srl17es);

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity synth_reg_reg is

generic (width : integer := 8;

latency : integer := 1);

port (i : in std_logic_vector(width-1 downto 0);

ce : in std_logic;

clr : in std_logic;

clk : in std_logic;

o : out std_logic_vector(width-1 downto 0));

end synth_reg_reg;

architecture behav of synth_reg_reg is

type reg_array_type is array (latency-1 downto 0) of std_logic_vector(width -1

downto 0);

signal reg_bank : reg_array_type := (others => (others => '0'));

signal reg_bank_in : reg_array_type := (others => (others => '0'));

attribute syn_allow_retiming : boolean;

attribute syn_srlstyle : string;

attribute syn_allow_retiming of reg_bank : signal is true;

attribute syn_allow_retiming of reg_bank_in : signal is true;

attribute syn_srlstyle of reg_bank : signal is "registers";

attribute syn_srlstyle of reg_bank_in : signal is "registers";

begin

latency_eq_0: if latency = 0 generate

o <= i;

end generate latency_eq_0;

latency_gt_0: if latency >= 1 generate

o <= reg_bank(latency-1);

reg_bank_in(0) <= i;

loop_gen: for idx in latency-2 downto 0 generate

reg_bank_in(idx+1) <= reg_bank(idx);

end generate loop_gen;

sync_loop: for sync_idx in latency-1 downto 0 generate

sync_proc: process (clk)

begin

if clk'event and clk = '1' then

Page 178: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

171

if ce = '1' then

reg_bank(sync_idx) <= reg_bank_in(sync_idx);

end if;

end if;

end process sync_proc;

end generate sync_loop;

end generate latency_gt_0;

end behav;

library unisim;

use unisim.vcomponents.all;

-- synopsys translate_on

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity single_reg_w_init is

generic (

width: integer := 8;

init_index: integer := 0;

init_value: bit_vector := b"0000"

);

port (

i: in std_logic_vector(width - 1 downto 0);

ce: in std_logic;

clr: in std_logic;

clk: in std_logic;

o: out std_logic_vector(width - 1 downto 0)

);

end single_reg_w_init;

architecture structural of single_reg_w_init is

function build_init_const(width: integer;

init_index: integer;

init_value: bit_vector)

return std_logic_vector

is

variable result: std_logic_vector(width - 1 downto 0);

begin

if init_index = 0 then

result := (others => '0');

elsif init_index = 1 then

result := (others => '0');

result(0) := '1';

else

result := to_stdlogicvector(init_value);

end if;

return result;

end;

component fdre

port (

q: out std_ulogic;

d: in std_ulogic;

c: in std_ulogic;

ce: in std_ulogic;

Page 179: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

172

r: in std_ulogic

);

end component;

attribute syn_black_box of fdre: component is true;

attribute fpga_dont_touch of fdre: component is "true";

component fdse

port (

q: out std_ulogic;

d: in std_ulogic;

c: in std_ulogic;

ce: in std_ulogic;

s: in std_ulogic

);

end component;

attribute syn_black_box of fdse: component is true;

attribute fpga_dont_touch of fdse: component is "true";

constant init_const: std_logic_vector(width - 1 downto 0)

:= build_init_const(width, init_index, init_value);

begin

fd_prim_array: for index in 0 to width - 1 generate

bit_is_0: if (init_const(index) = '0') generate

fdre_comp: fdre

port map (

c => clk,

d => i(index),

q => o(index),

ce => ce,

r => clr

);

end generate;

bit_is_1: if (init_const(index) = '1') generate

fdse_comp: fdse

port map (

c => clk,

d => i(index),

q => o(index),

ce => ce,

s => clr

);

end generate;

end generate;

end architecture structural;

-- synopsys translate_off

library unisim;

use unisim.vcomponents.all;

-- synopsys translate_on

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity synth_reg_w_init is

generic (

width: integer := 8;

init_index: integer := 0;

Page 180: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

173

init_value: bit_vector := b"0000";

latency: integer := 1

);

port (

i: in std_logic_vector(width - 1 downto 0);

ce: in std_logic;

clr: in std_logic;

clk: in std_logic;

o: out std_logic_vector(width - 1 downto 0)

);

end synth_reg_w_init;

architecture structural of synth_reg_w_init is

component single_reg_w_init

generic (

width: integer := 8;

init_index: integer := 0;

init_value: bit_vector := b"0000"

);

port (

i: in std_logic_vector(width - 1 downto 0);

ce: in std_logic;

clr: in std_logic;

clk: in std_logic;

o: out std_logic_vector(width - 1 downto 0)

);

end component;

signal dly_i: std_logic_vector((latency + 1) * width - 1 downto 0);

signal dly_clr: std_logic;

begin

latency_eq_0: if (latency = 0) generate

o <= i;

end generate;

latency_gt_0: if (latency >= 1) generate

dly_i((latency + 1) * width - 1 downto latency * width) <= i

after 200 ps;

dly_clr <= clr after 200 ps;

fd_array: for index in latency downto 1 generate

reg_comp: single_reg_w_init

generic map (

width => width,

init_index => init_index,

init_value => init_value

)

port map (

clk => clk,

i => dly_i((index + 1) * width - 1 downto index * width),

o => dly_i(index * width - 1 downto (index - 1) * width),

ce => ce,

clr => dly_clr

);

end generate;

o <= dly_i(width - 1 downto 0);

end generate;

Page 181: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

174

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

use work.conv_pkg.all;

entity constant_515f6b5526 is

port (

op : out std_logic_vector((16 - 1) downto 0);

clk : in std_logic;

ce : in std_logic;

clr : in std_logic);

end constant_515f6b5526;

architecture behavior of constant_515f6b5526 is

begin

op <= "0100000000000000";

end behavior;

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

use work.conv_pkg.all;

entity constant_9f5572ba51 is

port (

op : out std_logic_vector((16 - 1) downto 0);

clk : in std_logic;

ce : in std_logic;

clr : in std_logic);

end constant_9f5572ba51;

architecture behavior of constant_9f5572ba51 is

begin

op <= "0000000000000000";

end behavior;

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

use work.conv_pkg.all;

entity logical_2a516dc919 is

port (

d0 : in std_logic_vector((16 - 1) downto 0);

d1 : in std_logic_vector((16 - 1) downto 0);

y : out std_logic_vector((16 - 1) downto 0);

clk : in std_logic;

ce : in std_logic;

clr : in std_logic);

end logical_2a516dc919;

Page 182: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

175

architecture behavior of logical_2a516dc919 is

signal d0_1_24: std_logic_vector((16 - 1) downto 0);

signal d1_1_27: std_logic_vector((16 - 1) downto 0);

signal fully_2_1_bit: std_logic_vector((16 - 1) downto 0);

begin

d0_1_24 <= d0;

d1_1_27 <= d1;

fully_2_1_bit <= d0_1_24 and d1_1_27;

y <= fully_2_1_bit;

end behavior;

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

use work.conv_pkg.all;

entity logical_d5863431f8 is

port (

d0 : in std_logic_vector((16 - 1) downto 0);

d1 : in std_logic_vector((16 - 1) downto 0);

d2 : in std_logic_vector((16 - 1) downto 0);

d3 : in std_logic_vector((16 - 1) downto 0);

y : out std_logic_vector((16 - 1) downto 0);

clk : in std_logic;

ce : in std_logic;

clr : in std_logic);

end logical_d5863431f8;

architecture behavior of logical_d5863431f8 is

signal d0_1_24: std_logic_vector((16 - 1) downto 0);

signal d1_1_27: std_logic_vector((16 - 1) downto 0);

signal d2_1_30: std_logic_vector((16 - 1) downto 0);

signal d3_1_33: std_logic_vector((16 - 1) downto 0);

signal fully_2_1_bit: std_logic_vector((16 - 1) downto 0);

begin

d0_1_24 <= d0;

d1_1_27 <= d1;

d2_1_30 <= d2;

d3_1_33 <= d3;

fully_2_1_bit <= d0_1_24 xor d1_1_27 xor d2_1_30 xor d3_1_33;

y <= fully_2_1_bit;

end behavior;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

-- Generated from Simulink block "codificadorhamming/Hamming Encoder"

entity hamming_encoder_entity_e8bb25a7c2 is

Page 183: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

176

port (

gateway_in: in std_logic_vector(15 downto 0);

gateway_in1: in std_logic_vector(15 downto 0);

gateway_in2: in std_logic_vector(15 downto 0);

gateway_in3: in std_logic_vector(15 downto 0);

logical14_x0: out std_logic_vector(15 downto 0);

logical19_x0: out std_logic_vector(15 downto 0);

logical24_x0: out std_logic_vector(15 downto 0);

logical29_x0: out std_logic_vector(15 downto 0);

logical34_x0: out std_logic_vector(15 downto 0);

logical4_x0: out std_logic_vector(15 downto 0);

logical9_x0: out std_logic_vector(15 downto 0)

);

end hamming_encoder_entity_e8bb25a7c2;

architecture structural of hamming_encoder_entity_e8bb25a7c2 is

signal constant1_op_net: std_logic_vector(15 downto 0);

signal constant_op_net: std_logic_vector(15 downto 0);

signal gateway_in1_net_x0: std_logic_vector(15 downto 0);

signal gateway_in2_net_x0: std_logic_vector(15 downto 0);

signal gateway_in3_net_x0: std_logic_vector(15 downto 0);

signal gateway_in_net_x0: std_logic_vector(15 downto 0);

signal logical10_y_net: std_logic_vector(15 downto 0);

signal logical11_y_net: std_logic_vector(15 downto 0);

signal logical12_y_net: std_logic_vector(15 downto 0);

signal logical13_y_net: std_logic_vector(15 downto 0);

signal logical14_y_net_x0: std_logic_vector(15 downto 0);

signal logical15_y_net: std_logic_vector(15 downto 0);

signal logical16_y_net: std_logic_vector(15 downto 0);

signal logical17_y_net: std_logic_vector(15 downto 0);

signal logical18_y_net: std_logic_vector(15 downto 0);

signal logical19_y_net_x0: std_logic_vector(15 downto 0);

signal logical1_y_net: std_logic_vector(15 downto 0);

signal logical20_y_net: std_logic_vector(15 downto 0);

signal logical21_y_net: std_logic_vector(15 downto 0);

signal logical22_y_net: std_logic_vector(15 downto 0);

signal logical23_y_net: std_logic_vector(15 downto 0);

signal logical24_y_net_x0: std_logic_vector(15 downto 0);

signal logical25_y_net: std_logic_vector(15 downto 0);

signal logical26_y_net: std_logic_vector(15 downto 0);

signal logical27_y_net: std_logic_vector(15 downto 0);

signal logical28_y_net: std_logic_vector(15 downto 0);

signal logical29_y_net_x0: std_logic_vector(15 downto 0);

signal logical2_y_net: std_logic_vector(15 downto 0);

signal logical30_y_net: std_logic_vector(15 downto 0);

signal logical31_y_net: std_logic_vector(15 downto 0);

signal logical32_y_net: std_logic_vector(15 downto 0);

signal logical33_y_net: std_logic_vector(15 downto 0);

signal logical34_y_net_x0: std_logic_vector(15 downto 0);

signal logical3_y_net: std_logic_vector(15 downto 0);

signal logical4_y_net_x0: std_logic_vector(15 downto 0);

signal logical5_y_net: std_logic_vector(15 downto 0);

signal logical6_y_net: std_logic_vector(15 downto 0);

Page 184: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

177

signal logical7_y_net: std_logic_vector(15 downto 0);

signal logical8_y_net: std_logic_vector(15 downto 0);

signal logical9_y_net_x0: std_logic_vector(15 downto 0);

signal logical_y_net: std_logic_vector(15 downto 0);

begin

gateway_in_net_x0 <= gateway_in;

gateway_in1_net_x0 <= gateway_in1;

gateway_in2_net_x0 <= gateway_in2;

gateway_in3_net_x0 <= gateway_in3;

logical14_x0 <= logical14_y_net_x0;

logical19_x0 <= logical19_y_net_x0;

logical24_x0 <= logical24_y_net_x0;

logical29_x0 <= logical29_y_net_x0;

logical34_x0 <= logical34_y_net_x0;

logical4_x0 <= logical4_y_net_x0;

logical9_x0 <= logical9_y_net_x0;

constant1: entity work.constant_9f5572ba51

port map (

ce => '0',

clk => '0',

clr => '0',

op => constant1_op_net

);

constant_x0: entity work.constant_515f6b5526

port map (

ce => '0',

clk => '0',

clr => '0',

op => constant_op_net

);

logical: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in_net_x0,

y => logical_y_net

);

logical1: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in1_net_x0,

y => logical1_y_net

);

Page 185: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

178

logical10: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in_net_x0,

y => logical10_y_net

);

logical11: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in1_net_x0,

y => logical11_y_net

);

logical12: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in2_net_x0,

y => logical12_y_net

);

logical13: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in3_net_x0,

y => logical13_y_net

);

logical14: entity work.logical_d5863431f8

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => logical13_y_net,

d1 => logical12_y_net,

d2 => logical11_y_net,

d3 => logical10_y_net,

y => logical14_y_net_x0

);

Page 186: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

179

logical15: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in_net_x0,

y => logical15_y_net

);

logical16: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in1_net_x0,

y => logical16_y_net

);

logical17: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in2_net_x0,

y => logical17_y_net

);

logical18: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in3_net_x0,

y => logical18_y_net

);

logical19: entity work.logical_d5863431f8

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => logical18_y_net,

d1 => logical17_y_net,

d2 => logical16_y_net,

d3 => logical15_y_net,

y => logical19_y_net_x0

);

logical2: entity work.logical_2a516dc919

Page 187: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

180

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in2_net_x0,

y => logical2_y_net

);

logical20: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in_net_x0,

y => logical20_y_net

);

logical21: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in1_net_x0,

y => logical21_y_net

);

logical22: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in2_net_x0,

y => logical22_y_net

);

logical23: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in3_net_x0,

y => logical23_y_net

);

logical24: entity work.logical_d5863431f8

port map (

ce => '0',

clk => '0',

Page 188: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

181

clr => '0',

d0 => logical23_y_net,

d1 => logical22_y_net,

d2 => logical21_y_net,

d3 => logical20_y_net,

y => logical24_y_net_x0

);

logical25: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in_net_x0,

y => logical25_y_net

);

logical26: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in1_net_x0,

y => logical26_y_net

);

logical27: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in2_net_x0,

y => logical27_y_net

);

logical28: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in3_net_x0,

y => logical28_y_net

);

logical29: entity work.logical_d5863431f8

port map (

ce => '0',

clk => '0',

clr => '0',

Page 189: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

182

d0 => logical28_y_net,

d1 => logical27_y_net,

d2 => logical26_y_net,

d3 => logical25_y_net,

y => logical29_y_net_x0

);

logical3: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in3_net_x0,

y => logical3_y_net

);

logical30: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in_net_x0,

y => logical30_y_net

);

logical31: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in1_net_x0,

y => logical31_y_net

);

logical32: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in2_net_x0,

y => logical32_y_net

);

logical33: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

Page 190: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

183

d1 => gateway_in3_net_x0,

y => logical33_y_net

);

logical34: entity work.logical_d5863431f8

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => logical33_y_net,

d1 => logical32_y_net,

d2 => logical31_y_net,

d3 => logical30_y_net,

y => logical34_y_net_x0

);

logical4: entity work.logical_d5863431f8

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => logical3_y_net,

d1 => logical2_y_net,

d2 => logical1_y_net,

d3 => logical_y_net,

y => logical4_y_net_x0

);

logical5: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in_net_x0,

y => logical5_y_net

);

logical6: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in1_net_x0,

y => logical6_y_net

);

logical7: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

Page 191: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

184

d0 => constant_op_net,

d1 => gateway_in2_net_x0,

y => logical7_y_net

);

logical8: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in3_net_x0,

y => logical8_y_net

);

logical9: entity work.logical_d5863431f8

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => logical8_y_net,

d1 => logical7_y_net,

d2 => logical6_y_net,

d3 => logical5_y_net,

y => logical9_y_net_x0

);

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

-- Generated from Simulink block "codificadorhamming"

entity codificadorhamming is

port (

gateway_in: in std_logic_vector(15 downto 0);

gateway_in1: in std_logic_vector(15 downto 0);

gateway_in2: in std_logic_vector(15 downto 0);

gateway_in3: in std_logic_vector(15 downto 0);

gateway_out: out std_logic_vector(15 downto 0);

gateway_out1: out std_logic_vector(15 downto 0);

gateway_out2: out std_logic_vector(15 downto 0);

gateway_out3: out std_logic_vector(15 downto 0);

gateway_out4: out std_logic_vector(15 downto 0);

gateway_out5: out std_logic_vector(15 downto 0);

gateway_out6: out std_logic_vector(15 downto 0)

);

end codificadorhamming;

architecture structural of codificadorhamming is

signal gateway_in1_net: std_logic_vector(15 downto 0);

signal gateway_in2_net: std_logic_vector(15 downto 0);

Page 192: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

185

signal gateway_in3_net: std_logic_vector(15 downto 0);

signal gateway_in_net: std_logic_vector(15 downto 0);

signal gateway_out1_net: std_logic_vector(15 downto 0);

signal gateway_out2_net: std_logic_vector(15 downto 0);

signal gateway_out3_net: std_logic_vector(15 downto 0);

signal gateway_out4_net: std_logic_vector(15 downto 0);

signal gateway_out5_net: std_logic_vector(15 downto 0);

signal gateway_out6_net: std_logic_vector(15 downto 0);

signal gateway_out_net: std_logic_vector(15 downto 0);

begin

gateway_in_net <= gateway_in;

gateway_in1_net <= gateway_in1;

gateway_in2_net <= gateway_in2;

gateway_in3_net <= gateway_in3;

gateway_out <= gateway_out_net;

gateway_out1 <= gateway_out1_net;

gateway_out2 <= gateway_out2_net;

gateway_out3 <= gateway_out3_net;

gateway_out4 <= gateway_out4_net;

gateway_out5 <= gateway_out5_net;

gateway_out6 <= gateway_out6_net;

hamming_encoder_e8bb25a7c2: entity work.hamming_encoder_entity_e8bb25a7c2

port map (

gateway_in => gateway_in_net,

gateway_in1 => gateway_in1_net,

gateway_in2 => gateway_in2_net,

gateway_in3 => gateway_in3_net,

logical14_x0 => gateway_out4_net,

logical19_x0 => gateway_out3_net,

logical24_x0 => gateway_out2_net,

logical29_x0 => gateway_out1_net,

logical34_x0 => gateway_out_net,

logical4_x0 => gateway_out6_net,

logical9_x0 => gateway_out5_net

);

end structural;

DECODIFICADOR HAMMING 7,4:

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

package conv_pkg is

constant simulating : boolean := false

-- synopsys translate_off

or true

-- synopsys translate_on

;

constant xlUnsigned : integer := 1;

constant xlSigned : integer := 2;

Page 193: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

186

constant xlWrap : integer := 1;

constant xlSaturate : integer := 2;

constant xlTruncate : integer := 1;

constant xlRound : integer := 2;

constant xlRoundBanker : integer := 3;

constant xlAddMode : integer := 1;

constant xlSubMode : integer := 2;

attribute black_box : boolean;

attribute syn_black_box : boolean;

attribute fpga_dont_touch: string;

attribute box_type : string;

attribute keep : string;

attribute syn_keep : boolean;

function std_logic_vector_to_unsigned(inp : std_logic_vector) return unsigned;

function unsigned_to_std_logic_vector(inp : unsigned) return std_logic_vector;

function std_logic_vector_to_signed(inp : std_logic_vector) return signed;

function signed_to_std_logic_vector(inp : signed) return std_logic_vector;

function unsigned_to_signed(inp : unsigned) return signed;

function signed_to_unsigned(inp : signed) return unsigned;

function pos(inp : std_logic_vector; arith : INTEGER) return boolean;

function all_same(inp: std_logic_vector) return boolean;

function all_zeros(inp: std_logic_vector) return boolean;

function is_point_five(inp: std_logic_vector) return boolean;

function all_ones(inp: std_logic_vector) return boolean;

function convert_type (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith,

quantization, overflow : INTEGER)

return std_logic_vector;

function cast (inp : std_logic_vector; old_bin_pt,

new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector;

function vec_slice (inp : std_logic_vector; upper, lower : INTEGER)

return std_logic_vector;

function s2u_slice (inp : signed; upper, lower : INTEGER)

return unsigned;

function u2u_slice (inp : unsigned; upper, lower : INTEGER)

return unsigned;

function s2s_cast (inp : signed; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return signed;

function u2s_cast (inp : unsigned; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return signed;

function s2u_cast (inp : signed; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return unsigned;

function u2u_cast (inp : unsigned; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return unsigned;

function u2v_cast (inp : unsigned; old_bin_pt,

new_width, new_bin_pt : INTEGER)

return std_logic_vector;

function s2v_cast (inp : signed; old_bin_pt,

Page 194: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

187

new_width, new_bin_pt : INTEGER)

return std_logic_vector;

function trunc (inp : std_logic_vector; old_width, old_bin_pt, old_arith,

new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector;

function round_towards_inf (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt,

new_arith : INTEGER) return std_logic_vector;

function round_towards_even (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt,

new_arith : INTEGER) return std_logic_vector;

function max_signed(width : INTEGER) return std_logic_vector;

function min_signed(width : INTEGER) return std_logic_vector;

function saturation_arith(inp: std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

: INTEGER) return std_logic_vector;

function wrap_arith(inp: std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector;

function fractional_bits(a_bin_pt, b_bin_pt: INTEGER) return INTEGER;

function integer_bits(a_width, a_bin_pt, b_width, b_bin_pt: INTEGER)

return INTEGER;

function sign_ext(inp : std_logic_vector; new_width : INTEGER)

return std_logic_vector;

function zero_ext(inp : std_logic_vector; new_width : INTEGER)

return std_logic_vector;

function zero_ext(inp : std_logic; new_width : INTEGER)

return std_logic_vector;

function extend_MSB(inp : std_logic_vector; new_width, arith : INTEGER)

return std_logic_vector;

function align_input(inp : std_logic_vector; old_width, delta, new_arith,

new_width: INTEGER)

return std_logic_vector;

function pad_LSB(inp : std_logic_vector; new_width: integer)

return std_logic_vector;

function pad_LSB(inp : std_logic_vector; new_width, arith : integer)

return std_logic_vector;

function max(L, R: INTEGER) return INTEGER;

function min(L, R: INTEGER) return INTEGER;

function "="(left,right: STRING) return boolean;

function boolean_to_signed (inp : boolean; width: integer)

return signed;

function boolean_to_unsigned (inp : boolean; width: integer)

return unsigned;

function boolean_to_vector (inp : boolean)

return std_logic_vector;

function std_logic_to_vector (inp : std_logic)

return std_logic_vector;

function integer_to_std_logic_vector (inp : integer; width, arith : integer)

return std_logic_vector;

function std_logic_vector_to_integer (inp : std_logic_vector; arith : integer)

return integer;

function std_logic_to_integer(constant inp : std_logic := '0')

Page 195: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

188

return integer;

function bin_string_element_to_std_logic_vector (inp : string; width, index :

integer)

return std_logic_vector;

function bin_string_to_std_logic_vector (inp : string)

return std_logic_vector;

function hex_string_to_std_logic_vector (inp : string; width : integer)

return std_logic_vector;

function makeZeroBinStr (width : integer) return STRING;

function and_reduce(inp: std_logic_vector) return std_logic;

-- synopsys translate_off

function is_binary_string_invalid (inp : string)

return boolean;

function is_binary_string_undefined (inp : string)

return boolean;

function is_XorU(inp : std_logic_vector)

return boolean;

function to_real(inp : std_logic_vector; bin_pt : integer; arith : integer)

return real;

function std_logic_to_real(inp : std_logic; bin_pt : integer; arith : integer)

return real;

function real_to_std_logic_vector (inp : real; width, bin_pt, arith : integer)

return std_logic_vector;

function real_string_to_std_logic_vector (inp : string; width, bin_pt, arith : integer)

return std_logic_vector;

constant display_precision : integer := 20;

function real_to_string (inp : real) return string;

function valid_bin_string(inp : string) return boolean;

function std_logic_vector_to_bin_string(inp : std_logic_vector) return string;

function std_logic_to_bin_string(inp : std_logic) return string;

function std_logic_vector_to_bin_string_w_point(inp : std_logic_vector; bin_pt :

integer)

return string;

function real_to_bin_string(inp : real; width, bin_pt, arith : integer)

return string;

type stdlogic_to_char_t is array(std_logic) of character;

constant to_char : stdlogic_to_char_t := (

'U' => 'U',

'X' => 'X',

'0' => '0',

'1' => '1',

'Z' => 'Z',

'W' => 'W',

'L' => 'L',

'H' => 'H',

'-' => '-');

-- synopsys translate_on

end conv_pkg;

package body conv_pkg is

function std_logic_vector_to_unsigned(inp : std_logic_vector)

return unsigned

is

begin

Page 196: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

189

return unsigned (inp);

end;

function unsigned_to_std_logic_vector(inp : unsigned)

return std_logic_vector

is

begin

return std_logic_vector(inp);

end;

function std_logic_vector_to_signed(inp : std_logic_vector)

return signed

is

begin

return signed (inp);

end;

function signed_to_std_logic_vector(inp : signed)

return std_logic_vector

is

begin

return std_logic_vector(inp);

end;

function unsigned_to_signed (inp : unsigned)

return signed

is

begin

return signed(std_logic_vector(inp));

end;

function signed_to_unsigned (inp : signed)

return unsigned

is

begin

return unsigned(std_logic_vector(inp));

end;

function pos(inp : std_logic_vector; arith : INTEGER)

return boolean

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

begin

vec := inp;

if arith = xlUnsigned then

return true;

else

if vec(width-1) = '0' then

return true;

else

return false;

end if;

end if;

return true;

end;

function max_signed(width : INTEGER)

return std_logic_vector

is

Page 197: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

190

variable ones : std_logic_vector(width-2 downto 0);

variable result : std_logic_vector(width-1 downto 0);

begin

ones := (others => '1');

result(width-1) := '0';

result(width-2 downto 0) := ones;

return result;

end;

function min_signed(width : INTEGER)

return std_logic_vector

is

variable zeros : std_logic_vector(width-2 downto 0);

variable result : std_logic_vector(width-1 downto 0);

begin

zeros := (others => '0');

result(width-1) := '1';

result(width-2 downto 0) := zeros;

return result;

end;

function and_reduce(inp: std_logic_vector) return std_logic

is

variable result: std_logic;

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

begin

vec := inp;

result := vec(0);

if width > 1 then

for i in 1 to width-1 loop

result := result and vec(i);

end loop;

end if;

return result;

end;

function all_same(inp: std_logic_vector) return boolean

is

variable result: boolean;

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

begin

vec := inp;

result := true;

if width > 0 then

for i in 1 to width-1 loop

if vec(i) /= vec(0) then

result := false;

end if;

end loop;

end if;

return result;

end;

function all_zeros(inp: std_logic_vector)

return boolean

Page 198: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

191

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable zero : std_logic_vector(width-1 downto 0);

variable result : boolean;

begin

zero := (others => '0');

vec := inp;

-- synopsys translate_off

if (is_XorU(vec)) then

return false;

end if;

-- synopsys translate_on

if (std_logic_vector_to_unsigned(vec) = std_logic_vector_to_unsigned(zero))

then

result := true;

else

result := false;

end if;

return result;

end;

function is_point_five(inp: std_logic_vector)

return boolean

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable result : boolean;

begin

vec := inp;

-- synopsys translate_off

if (is_XorU(vec)) then

return false;

end if;

-- synopsys translate_on

if (width > 1) then

if ((vec(width-1) = '1') and (all_zeros(vec(width-2 downto 0)) = true)) then

result := true;

else

result := false;

end if;

else

if (vec(width-1) = '1') then

result := true;

else

result := false;

end if;

end if;

return result;

end;

function all_ones(inp: std_logic_vector)

return boolean

is

constant width : integer := inp'length;

Page 199: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

192

variable vec : std_logic_vector(width-1 downto 0);

variable one : std_logic_vector(width-1 downto 0);

variable result : boolean;

begin

one := (others => '1');

vec := inp;

-- synopsys translate_off

if (is_XorU(vec)) then

return false;

end if;

-- synopsys translate_on

if (std_logic_vector_to_unsigned(vec) = std_logic_vector_to_unsigned(one))

then

result := true;

else

result := false;

end if;

return result;

end;

function full_precision_num_width(quantization, overflow, old_width,

old_bin_pt, old_arith,

new_width, new_bin_pt, new_arith : INTEGER)

return integer

is

variable result : integer;

begin

result := old_width + 2;

return result;

end;

function quantized_num_width(quantization, overflow, old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

: INTEGER)

return integer

is

variable right_of_dp, left_of_dp, result : integer;

begin

right_of_dp := max(new_bin_pt, old_bin_pt);

left_of_dp := max((new_width - new_bin_pt), (old_width - old_bin_pt));

result := (old_width + 2) + (new_bin_pt - old_bin_pt);

return result;

end;

function convert_type (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith,

quantization, overflow : INTEGER)

return std_logic_vector

is

constant fp_width : integer :=

full_precision_num_width(quantization, overflow, old_width,

old_bin_pt, old_arith, new_width,

new_bin_pt, new_arith);

constant fp_bin_pt : integer := old_bin_pt;

constant fp_arith : integer := old_arith;

variable full_precision_result : std_logic_vector(fp_width-1 downto 0);

Page 200: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

193

constant q_width : integer :=

quantized_num_width(quantization, overflow, old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith);

constant q_bin_pt : integer := new_bin_pt;

constant q_arith : integer := old_arith;

variable quantized_result : std_logic_vector(q_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

result := (others => '0');

full_precision_result := cast(inp, old_bin_pt, fp_width, fp_bin_pt,

fp_arith);

if (quantization = xlRound) then

quantized_result := round_towards_inf(full_precision_result,

fp_width, fp_bin_pt,

fp_arith, q_width, q_bin_pt,

q_arith);

elsif (quantization = xlRoundBanker) then

quantized_result := round_towards_even(full_precision_result,

fp_width, fp_bin_pt,

fp_arith, q_width, q_bin_pt,

q_arith);

else

quantized_result := trunc(full_precision_result, fp_width, fp_bin_pt,

fp_arith, q_width, q_bin_pt, q_arith);

end if;

if (overflow = xlSaturate) then

result := saturation_arith(quantized_result, q_width, q_bin_pt,

q_arith, new_width, new_bin_pt, new_arith);

else

result := wrap_arith(quantized_result, q_width, q_bin_pt, q_arith,

new_width, new_bin_pt, new_arith);

end if;

return result;

end;

function cast (inp : std_logic_vector; old_bin_pt, new_width,

new_bin_pt, new_arith : INTEGER)

return std_logic_vector

is

constant old_width : integer := inp'length;

constant left_of_dp : integer := (new_width - new_bin_pt)

- (old_width - old_bin_pt);

constant right_of_dp : integer := (new_bin_pt - old_bin_pt);

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

variable j : integer;

begin

vec := inp;

for i in new_width-1 downto 0 loop

j := i - right_of_dp;

if ( j > old_width-1) then

if (new_arith = xlUnsigned) then

result(i) := '0';

else

Page 201: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

194

result(i) := vec(old_width-1);

end if;

elsif ( j >= 0) then

result(i) := vec(j);

else

result(i) := '0';

end if;

end loop;

return result;

end;

function vec_slice (inp : std_logic_vector; upper, lower : INTEGER)

return std_logic_vector

is

begin

return inp(upper downto lower);

end;

function s2u_slice (inp : signed; upper, lower : INTEGER)

return unsigned

is

begin

return unsigned(vec_slice(std_logic_vector(inp), upper, lower));

end;

function u2u_slice (inp : unsigned; upper, lower : INTEGER)

return unsigned

is

begin

return unsigned(vec_slice(std_logic_vector(inp), upper, lower));

end;

function s2s_cast (inp : signed; old_bin_pt, new_width, new_bin_pt : INTEGER)

return signed

is

begin

return signed(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlSigned));

end;

function s2u_cast (inp : signed; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return unsigned

is

begin

return unsigned(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlSigned));

end;

function u2s_cast (inp : unsigned; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return signed

is

begin

return signed(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlUnsigned));

end;

function u2u_cast (inp : unsigned; old_bin_pt, new_width,

new_bin_pt : INTEGER)

Page 202: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

195

return unsigned

is

begin

return unsigned(cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlUnsigned));

end;

function u2v_cast (inp : unsigned; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return std_logic_vector

is

begin

return cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt,

xlUnsigned);

end;

function s2v_cast (inp : signed; old_bin_pt, new_width,

new_bin_pt : INTEGER)

return std_logic_vector

is

begin

return cast(std_logic_vector(inp), old_bin_pt, new_width, new_bin_pt, xlSigned);

end;

function boolean_to_signed (inp : boolean; width : integer)

return signed

is

variable result : signed(width - 1 downto 0);

begin

result := (others => '0');

if inp then

result(0) := '1';

else

result(0) := '0';

end if;

return result;

end;

function boolean_to_unsigned (inp : boolean; width : integer)

return unsigned

is

variable result : unsigned(width - 1 downto 0);

begin

result := (others => '0');

if inp then

result(0) := '1';

else

result(0) := '0';

end if;

return result;

end;

function boolean_to_vector (inp : boolean)

return std_logic_vector

is

variable result : std_logic_vector(1 - 1 downto 0);

begin

result := (others => '0');

Page 203: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

196

if inp then

result(0) := '1';

else

result(0) := '0';

end if;

return result;

end;

function std_logic_to_vector (inp : std_logic)

return std_logic_vector

is

variable result : std_logic_vector(1 - 1 downto 0);

begin

result(0) := inp;

return result;

end;

function trunc (inp : std_logic_vector; old_width, old_bin_pt, old_arith,

new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector

is

constant right_of_dp : integer := (old_bin_pt - new_bin_pt);

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if right_of_dp >= 0 then

if new_arith = xlUnsigned then

result := zero_ext(vec(old_width-1 downto right_of_dp), new_width);

else

result := sign_ext(vec(old_width-1 downto right_of_dp), new_width);

end if;

else

if new_arith = xlUnsigned then

result := zero_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

else

result := sign_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

end if;

end if;

return result;

end;

function round_towards_inf (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

: INTEGER)

return std_logic_vector

is

constant right_of_dp : integer := (old_bin_pt - new_bin_pt);

constant expected_new_width : integer := old_width - right_of_dp + 1;

variable vec : std_logic_vector(old_width-1 downto 0);

variable one_or_zero : std_logic_vector(new_width-1 downto 0);

variable truncated_val : std_logic_vector(new_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

Page 204: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

197

vec := inp;

if right_of_dp >= 0 then

if new_arith = xlUnsigned then

truncated_val := zero_ext(vec(old_width-1 downto right_of_dp),

new_width);

else

truncated_val := sign_ext(vec(old_width-1 downto right_of_dp),

new_width);

end if;

else

if new_arith = xlUnsigned then

truncated_val := zero_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

else

truncated_val := sign_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

end if;

end if;

one_or_zero := (others => '0');

if (new_arith = xlSigned) then

if (vec(old_width-1) = '0') then

one_or_zero(0) := '1';

end if;

if (right_of_dp >= 2) and (right_of_dp <= old_width) then

if (all_zeros(vec(right_of_dp-2 downto 0)) = false) then

one_or_zero(0) := '1';

end if;

end if;

if (right_of_dp >= 1) and (right_of_dp <= old_width) then

if vec(right_of_dp-1) = '0' then

one_or_zero(0) := '0';

end if;

else

one_or_zero(0) := '0';

end if;

else

if (right_of_dp >= 1) and (right_of_dp <= old_width) then

one_or_zero(0) := vec(right_of_dp-1);

end if;

end if;

if new_arith = xlSigned then

result :=

signed_to_std_logic_vector(std_logic_vector_to_signed(truncated_val) +

std_logic_vector_to_signed(one_or_zero));

else

result :=

unsigned_to_std_logic_vector(std_logic_vector_to_unsigned(truncated_val) +

std_logic_vector_to_unsigned(one_or_zero));

end if;

return result;

end;

function round_towards_even (inp : std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

Page 205: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

198

: INTEGER)

return std_logic_vector

is

constant right_of_dp : integer := (old_bin_pt - new_bin_pt);

constant expected_new_width : integer := old_width - right_of_dp + 1;

variable vec : std_logic_vector(old_width-1 downto 0);

variable one_or_zero : std_logic_vector(new_width-1 downto 0);

variable truncated_val : std_logic_vector(new_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if right_of_dp >= 0 then

if new_arith = xlUnsigned then

truncated_val := zero_ext(vec(old_width-1 downto right_of_dp),

new_width);

else

truncated_val := sign_ext(vec(old_width-1 downto right_of_dp),

new_width);

end if;

else

if new_arith = xlUnsigned then

truncated_val := zero_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

else

truncated_val := sign_ext(pad_LSB(vec, old_width +

abs(right_of_dp)), new_width);

end if;

end if;

one_or_zero := (others => '0');

if (right_of_dp >= 1) and (right_of_dp <= old_width) then

if (is_point_five(vec(right_of_dp-1 downto 0)) = false) then

one_or_zero(0) := vec(right_of_dp-1);

else

one_or_zero(0) := vec(right_of_dp);

end if;

end if;

if new_arith = xlSigned then

result :=

signed_to_std_logic_vector(std_logic_vector_to_signed(truncated_val) +

std_logic_vector_to_signed(one_or_zero));

else

result :=

unsigned_to_std_logic_vector(std_logic_vector_to_unsigned(truncated_val) +

std_logic_vector_to_unsigned(one_or_zero));

end if;

return result;

end;

function saturation_arith(inp: std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith

: INTEGER)

return std_logic_vector

is

constant left_of_dp : integer := (old_width - old_bin_pt) -

Page 206: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

199

(new_width - new_bin_pt);

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

variable overflow : boolean;

begin

vec := inp;

overflow := true;

result := (others => '0');

if (new_width >= old_width) then

overflow := false;

end if;

if ((old_arith = xlSigned and new_arith = xlSigned) and (old_width >

new_width)) then

if all_same(vec(old_width-1 downto new_width-1)) then

overflow := false;

end if;

end if;

if (old_arith = xlSigned and new_arith = xlUnsigned) then

if (old_width > new_width) then

if all_zeros(vec(old_width-1 downto new_width)) then

overflow := false;

end if;

else

if (old_width = new_width) then

if (vec(new_width-1) = '0') then

overflow := false;

end if;

end if;

end if;

end if;

if (old_arith = xlUnsigned and new_arith = xlUnsigned) then

if (old_width > new_width) then

if all_zeros(vec(old_width-1 downto new_width)) then

overflow := false;

end if;

else

if (old_width = new_width) then

overflow := false;

end if;

end if;

end if;

if ((old_arith = xlUnsigned and new_arith = xlSigned) and (old_width >

new_width)) then

if all_same(vec(old_width-1 downto new_width-1)) then

overflow := false;

end if;

end if;

if overflow then

if new_arith = xlSigned then

if vec(old_width-1) = '0' then

result := max_signed(new_width);

else

result := min_signed(new_width);

Page 207: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

200

end if;

else

if ((old_arith = xlSigned) and vec(old_width-1) = '1') then

result := (others => '0');

else

result := (others => '1');

end if;

end if;

else

if (old_arith = xlSigned) and (new_arith = xlUnsigned) then

if (vec(old_width-1) = '1') then

vec := (others => '0');

end if;

end if;

if new_width <= old_width then

result := vec(new_width-1 downto 0);

else

if new_arith = xlUnsigned then

result := zero_ext(vec, new_width);

else

result := sign_ext(vec, new_width);

end if;

end if;

end if;

return result;

end;

function wrap_arith(inp: std_logic_vector; old_width, old_bin_pt,

old_arith, new_width, new_bin_pt, new_arith : INTEGER)

return std_logic_vector

is

variable result : std_logic_vector(new_width-1 downto 0);

variable result_arith : integer;

begin

if (old_arith = xlSigned) and (new_arith = xlUnsigned) then

result_arith := xlSigned;

end if;

result := cast(inp, old_bin_pt, new_width, new_bin_pt, result_arith);

return result;

end;

function fractional_bits(a_bin_pt, b_bin_pt: INTEGER) return INTEGER is

begin

return max(a_bin_pt, b_bin_pt);

end;

function integer_bits(a_width, a_bin_pt, b_width, b_bin_pt: INTEGER)

return INTEGER is

begin

return max(a_width - a_bin_pt, b_width - b_bin_pt);

end;

function pad_LSB(inp : std_logic_vector; new_width: integer)

return STD_LOGIC_VECTOR

is

constant orig_width : integer := inp'length;

variable vec : std_logic_vector(orig_width-1 downto 0);

Page 208: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

201

variable result : std_logic_vector(new_width-1 downto 0);

variable pos : integer;

constant pad_pos : integer := new_width - orig_width - 1;

begin

vec := inp;

pos := new_width-1;

if (new_width >= orig_width) then

for i in orig_width-1 downto 0 loop

result(pos) := vec(i);

pos := pos - 1;

end loop;

if pad_pos >= 0 then

for i in pad_pos downto 0 loop

result(i) := '0';

end loop;

end if;

end if;

return result;

end;

function sign_ext(inp : std_logic_vector; new_width : INTEGER)

return std_logic_vector

is

constant old_width : integer := inp'length;

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if new_width >= old_width then

result(old_width-1 downto 0) := vec;

if new_width-1 >= old_width then

for i in new_width-1 downto old_width loop

result(i) := vec(old_width-1);

end loop;

end if;

else

result(new_width-1 downto 0) := vec(new_width-1 downto 0);

end if;

return result;

end;

function zero_ext(inp : std_logic_vector; new_width : INTEGER)

return std_logic_vector

is

constant old_width : integer := inp'length;

variable vec : std_logic_vector(old_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if new_width >= old_width then

result(old_width-1 downto 0) := vec;

if new_width-1 >= old_width then

for i in new_width-1 downto old_width loop

result(i) := '0';

end loop;

Page 209: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

202

end if;

else

result(new_width-1 downto 0) := vec(new_width-1 downto 0);

end if;

return result;

end;

function zero_ext(inp : std_logic; new_width : INTEGER)

return std_logic_vector

is

variable result : std_logic_vector(new_width-1 downto 0);

begin

result(0) := inp;

for i in new_width-1 downto 1 loop

result(i) := '0';

end loop;

return result;

end;

function extend_MSB(inp : std_logic_vector; new_width, arith : INTEGER)

return std_logic_vector

is

constant orig_width : integer := inp'length;

variable vec : std_logic_vector(orig_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if arith = xlUnsigned then

result := zero_ext(vec, new_width);

else

result := sign_ext(vec, new_width);

end if;

return result;

end;

function pad_LSB(inp : std_logic_vector; new_width, arith: integer)

return STD_LOGIC_VECTOR

is

constant orig_width : integer := inp'length;

variable vec : std_logic_vector(orig_width-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

variable pos : integer;

begin

vec := inp;

pos := new_width-1;

if (arith = xlUnsigned) then

result(pos) := '0';

pos := pos - 1;

else

result(pos) := vec(orig_width-1);

pos := pos - 1;

end if;

if (new_width >= orig_width) then

for i in orig_width-1 downto 0 loop

result(pos) := vec(i);

pos := pos - 1;

Page 210: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

203

end loop;

if pos >= 0 then

for i in pos downto 0 loop

result(i) := '0';

end loop;

end if;

end if;

return result;

end;

function align_input(inp : std_logic_vector; old_width, delta, new_arith,

new_width: INTEGER)

return std_logic_vector

is

variable vec : std_logic_vector(old_width-1 downto 0);

variable padded_inp : std_logic_vector((old_width + delta)-1 downto 0);

variable result : std_logic_vector(new_width-1 downto 0);

begin

vec := inp;

if delta > 0 then

padded_inp := pad_LSB(vec, old_width+delta);

result := extend_MSB(padded_inp, new_width, new_arith);

else

result := extend_MSB(vec, new_width, new_arith);

end if;

return result;

end;

function max(L, R: INTEGER) return INTEGER is

begin

if L > R then

return L;

else

return R;

end if;

end;

function min(L, R: INTEGER) return INTEGER is

begin

if L < R then

return L;

else

return R;

end if;

end;

function "="(left,right: STRING) return boolean is

begin

if (left'length /= right'length) then

return false;

else

test : for i in 1 to left'length loop

if left(i) /= right(i) then

return false;

end if;

end loop test;

return true;

Page 211: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

204

end if;

end;

-- synopsys translate_off

function is_binary_string_invalid (inp : string)

return boolean

is

variable vec : string(1 to inp'length);

variable result : boolean;

begin

vec := inp;

result := false;

for i in 1 to vec'length loop

if ( vec(i) = 'X' ) then

result := true;

end if;

end loop;

return result;

end;

function is_binary_string_undefined (inp : string)

return boolean

is

variable vec : string(1 to inp'length);

variable result : boolean;

begin

vec := inp;

result := false;

for i in 1 to vec'length loop

if ( vec(i) = 'U' ) then

result := true;

end if;

end loop;

return result;

end;

function is_XorU(inp : std_logic_vector)

return boolean

is

constant width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable result : boolean;

begin

vec := inp;

result := false;

for i in 0 to width-1 loop

if (vec(i) = 'U') or (vec(i) = 'X') then

result := true;

end if;

end loop;

return result;

end;

function to_real(inp : std_logic_vector; bin_pt : integer; arith : integer)

return real

is

variable vec : std_logic_vector(inp'length-1 downto 0);

Page 212: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

205

variable result, shift_val, undefined_real : real;

variable neg_num : boolean;

begin

vec := inp;

result := 0.0;

neg_num := false;

if vec(inp'length-1) = '1' then

neg_num := true;

end if;

for i in 0 to inp'length-1 loop

if vec(i) = 'U' or vec(i) = 'X' then

return undefined_real;

end if;

if arith = xlSigned then

if neg_num then

if vec(i) = '0' then

result := result + 2.0**i;

end if;

else

if vec(i) = '1' then

result := result + 2.0**i;

end if;

end if;

else

if vec(i) = '1' then

result := result + 2.0**i;

end if;

end if;

end loop;

if arith = xlSigned then

if neg_num then

result := result + 1.0;

result := result * (-1.0);

end if;

end if;

shift_val := 2.0**(-1*bin_pt);

result := result * shift_val;

return result;

end;

function std_logic_to_real(inp : std_logic; bin_pt : integer; arith : integer)

return real

is

variable result : real := 0.0;

begin

if inp = '1' then

result := 1.0;

end if;

if arith = xlSigned then

assert false

report "It doesn't make sense to convert a 1 bit number to a signed real.";

end if;

return result;

end;

Page 213: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

206

-- synopsys translate_on

function integer_to_std_logic_vector (inp : integer; width, arith : integer)

return std_logic_vector

is

variable result : std_logic_vector(width-1 downto 0);

variable unsigned_val : unsigned(width-1 downto 0);

variable signed_val : signed(width-1 downto 0);

begin

if (arith = xlSigned) then

signed_val := to_signed(inp, width);

result := signed_to_std_logic_vector(signed_val);

else

unsigned_val := to_unsigned(inp, width);

result := unsigned_to_std_logic_vector(unsigned_val);

end if;

return result;

end;

function std_logic_vector_to_integer (inp : std_logic_vector; arith : integer)

return integer

is

constant width : integer := inp'length;

variable unsigned_val : unsigned(width-1 downto 0);

variable signed_val : signed(width-1 downto 0);

variable result : integer;

begin

if (arith = xlSigned) then

signed_val := std_logic_vector_to_signed(inp);

result := to_integer(signed_val);

else

unsigned_val := std_logic_vector_to_unsigned(inp);

result := to_integer(unsigned_val);

end if;

return result;

end;

function std_logic_to_integer(constant inp : std_logic := '0')

return integer

is

begin

if inp = '1' then

return 1;

else

return 0;

end if;

end;

function makeZeroBinStr (width : integer) return STRING is

variable result : string(1 to width+3);

begin

result(1) := '0';

result(2) := 'b';

for i in 3 to width+2 loop

result(i) := '0';

end loop;

result(width+3) := '.';

Page 214: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

207

return result;

end;

-- synopsys translate_off

function real_string_to_std_logic_vector (inp : string; width, bin_pt, arith : integer)

return std_logic_vector

is

variable result : std_logic_vector(width-1 downto 0);

begin

result := (others => '0');

return result;

end;

function real_to_std_logic_vector (inp : real; width, bin_pt, arith : integer)

return std_logic_vector

is

variable real_val : real;

variable int_val : integer;

variable result : std_logic_vector(width-1 downto 0) := (others => '0');

variable unsigned_val : unsigned(width-1 downto 0) := (others => '0');

variable signed_val : signed(width-1 downto 0) := (others => '0');

begin

real_val := inp;

int_val := integer(real_val * 2.0**(bin_pt));

if (arith = xlSigned) then

signed_val := to_signed(int_val, width);

result := signed_to_std_logic_vector(signed_val);

else

unsigned_val := to_unsigned(int_val, width);

result := unsigned_to_std_logic_vector(unsigned_val);

end if;

return result;

end;

-- synopsys translate_on

function valid_bin_string (inp : string)

return boolean

is

variable vec : string(1 to inp'length);

begin

vec := inp;

if (vec(1) = '0' and vec(2) = 'b') then

return true;

else

return false;

end if;

end;

function hex_string_to_std_logic_vector(inp: string; width : integer)

return std_logic_vector is

constant strlen : integer := inp'LENGTH;

variable result : std_logic_vector(width-1 downto 0);

variable bitval : std_logic_vector((strlen*4)-1 downto 0);

variable posn : integer;

variable ch : character;

variable vec : string(1 to strlen);

begin

Page 215: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

208

vec := inp;

result := (others => '0');

posn := (strlen*4)-1;

for i in 1 to strlen loop

ch := vec(i);

case ch is

when '0' => bitval(posn downto posn-3) := "0000";

when '1' => bitval(posn downto posn-3) := "0001";

when '2' => bitval(posn downto posn-3) := "0010";

when '3' => bitval(posn downto posn-3) := "0011";

when '4' => bitval(posn downto posn-3) := "0100";

when '5' => bitval(posn downto posn-3) := "0101";

when '6' => bitval(posn downto posn-3) := "0110";

when '7' => bitval(posn downto posn-3) := "0111";

when '8' => bitval(posn downto posn-3) := "1000";

when '9' => bitval(posn downto posn-3) := "1001";

when 'A' | 'a' => bitval(posn downto posn-3) := "1010";

when 'B' | 'b' => bitval(posn downto posn-3) := "1011";

when 'C' | 'c' => bitval(posn downto posn-3) := "1100";

when 'D' | 'd' => bitval(posn downto posn-3) := "1101";

when 'E' | 'e' => bitval(posn downto posn-3) := "1110";

when 'F' | 'f' => bitval(posn downto posn-3) := "1111";

when others => bitval(posn downto posn-3) := "XXXX";

-- synopsys translate_off

ASSERT false

REPORT "Invalid hex value" SEVERITY ERROR;

-- synopsys translate_on

end case;

posn := posn - 4;

end loop;

if (width <= strlen*4) then

result := bitval(width-1 downto 0);

else

result((strlen*4)-1 downto 0) := bitval;

end if;

return result;

end;

function bin_string_to_std_logic_vector (inp : string)

return std_logic_vector

is

variable pos : integer;

variable vec : string(1 to inp'length);

variable result : std_logic_vector(inp'length-1 downto 0);

begin

vec := inp;

pos := inp'length-1;

result := (others => '0');

for i in 1 to vec'length loop

-- synopsys translate_off

if (pos < 0) and (vec(i) = '0' or vec(i) = '1' or vec(i) = 'X' or vec(i) = 'U') then

assert false

report "Input string is larger than output std_logic_vector. Truncating

output.";

Page 216: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

209

return result;

end if;

-- synopsys translate_on

if vec(i) = '0' then

result(pos) := '0';

pos := pos - 1;

end if;

if vec(i) = '1' then

result(pos) := '1';

pos := pos - 1;

end if;

-- synopsys translate_off

if (vec(i) = 'X' or vec(i) = 'U') then

result(pos) := 'U';

pos := pos - 1;

end if;

-- synopsys translate_on

end loop;

return result;

end;

function bin_string_element_to_std_logic_vector (inp : string; width, index :

integer)

return std_logic_vector

is

constant str_width : integer := width + 4;

constant inp_len : integer := inp'length;

constant num_elements : integer := (inp_len + 1)/str_width;

constant reverse_index : integer := (num_elements-1) - index;

variable left_pos : integer;

variable right_pos : integer;

variable vec : string(1 to inp'length);

variable result : std_logic_vector(width-1 downto 0);

begin

vec := inp;

result := (others => '0');

if (reverse_index = 0) and (reverse_index < num_elements) and (inp_len-3 >=

width) then

left_pos := 1;

right_pos := width + 3;

result := bin_string_to_std_logic_vector(vec(left_pos to right_pos));

end if;

if (reverse_index > 0) and (reverse_index < num_elements) and (inp_len-3 >=

width) then

left_pos := (reverse_index * str_width) + 1;

right_pos := left_pos + width + 2;

result := bin_string_to_std_logic_vector(vec(left_pos to right_pos));

end if;

return result;

end;

-- synopsys translate_off

function std_logic_vector_to_bin_string(inp : std_logic_vector)

return string

is

Page 217: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

210

variable vec : std_logic_vector(1 to inp'length);

variable result : string(vec'range);

begin

vec := inp;

for i in vec'range loop

result(i) := to_char(vec(i));

end loop;

return result;

end;

function std_logic_to_bin_string(inp : std_logic)

return string

is

variable result : string(1 to 3);

begin

result(1) := '0';

result(2) := 'b';

result(3) := to_char(inp);

return result;

end;

function std_logic_vector_to_bin_string_w_point(inp : std_logic_vector; bin_pt :

integer)

return string

is

variable width : integer := inp'length;

variable vec : std_logic_vector(width-1 downto 0);

variable str_pos : integer;

variable result : string(1 to width+3);

begin

vec := inp;

str_pos := 1;

result(str_pos) := '0';

str_pos := 2;

result(str_pos) := 'b';

str_pos := 3;

for i in width-1 downto 0 loop

if (((width+3) - bin_pt) = str_pos) then

result(str_pos) := '.';

str_pos := str_pos + 1;

end if;

result(str_pos) := to_char(vec(i));

str_pos := str_pos + 1;

end loop;

if (bin_pt = 0) then

result(str_pos) := '.';

end if;

return result;

end;

function real_to_bin_string(inp : real; width, bin_pt, arith : integer)

return string

is

variable result : string(1 to width);

variable vec : std_logic_vector(width-1 downto 0);

begin

Page 218: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

211

vec := real_to_std_logic_vector(inp, width, bin_pt, arith);

result := std_logic_vector_to_bin_string(vec);

return result;

end;

function real_to_string (inp : real) return string

is

variable result : string(1 to display_precision) := (others => ' ');

begin

result(real'image(inp)'range) := real'image(inp);

return result;

end;

-- synopsys translate_on

end conv_pkg;

library IEEE;

use IEEE.std_logic_1164.all;

package clock_pkg is

-- synopsys translate_off

signal int_clk : std_logic;

-- synopsys translate_on

end clock_pkg;

library unisim;

use unisim.vcomponents.all;

-- synopsys translate_on

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity srl17e is

generic (width : integer:=16;

latency : integer :=8);

port (clk : in std_logic;

ce : in std_logic;

d : in std_logic_vector(width-1 downto 0);

q : out std_logic_vector(width-1 downto 0));

end srl17e;

architecture structural of srl17e is

component SRL16E

port (D : in STD_ULOGIC;

CE : in STD_ULOGIC;

CLK : in STD_ULOGIC;

A0 : in STD_ULOGIC;

A1 : in STD_ULOGIC;

A2 : in STD_ULOGIC;

A3 : in STD_ULOGIC;

Q : out STD_ULOGIC);

end component;

attribute syn_black_box of SRL16E : component is true;

attribute fpga_dont_touch of SRL16E : component is "true";

component FDE

port(

Q : out STD_ULOGIC;

D : in STD_ULOGIC;

C : in STD_ULOGIC;

Page 219: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

212

CE : in STD_ULOGIC);

end component;

attribute syn_black_box of FDE : component is true;

attribute fpga_dont_touch of FDE : component is "true";

constant a : std_logic_vector(4 downto 0) :=

integer_to_std_logic_vector(latency-2,5,xlSigned);

signal d_delayed : std_logic_vector(width-1 downto 0);

signal srl16_out : std_logic_vector(width-1 downto 0);

begin

d_delayed <= d after 200 ps;

reg_array : for i in 0 to width-1 generate

srl16_used: if latency > 1 generate

u1 : srl16e port map(clk => clk,

d => d_delayed(i),

q => srl16_out(i),

ce => ce,

a0 => a(0),

a1 => a(1),

a2 => a(2),

a3 => a(3));

end generate;

srl16_not_used: if latency <= 1 generate

srl16_out(i) <= d_delayed(i);

end generate;

fde_used: if latency /= 0 generate

u2 : fde port map(c => clk,

d => srl16_out(i),

q => q(i),

ce => ce);

end generate;

fde_not_used: if latency = 0 generate

q(i) <= srl16_out(i);

end generate;

end generate;

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity synth_reg is

generic (width : integer := 8;

latency : integer := 1);

port (i : in std_logic_vector(width-1 downto 0);

ce : in std_logic;

clr : in std_logic;

clk : in std_logic;

o : out std_logic_vector(width-1 downto 0));

end synth_reg;

architecture structural of synth_reg is

component srl17e

generic (width : integer:=16;

latency : integer :=8);

port (clk : in std_logic;

ce : in std_logic;

Page 220: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

213

d : in std_logic_vector(width-1 downto 0);

q : out std_logic_vector(width-1 downto 0));

end component;

function calc_num_srl17es (latency : integer)

return integer

is

variable remaining_latency : integer;

variable result : integer;

begin

result := latency / 17;

remaining_latency := latency - (result * 17);

if (remaining_latency /= 0) then

result := result + 1;

end if;

return result;

end;

constant complete_num_srl17es : integer := latency / 17;

constant num_srl17es : integer := calc_num_srl17es(latency);

constant remaining_latency : integer := latency - (complete_num_srl17es * 17);

type register_array is array (num_srl17es downto 0) of

std_logic_vector(width-1 downto 0);

signal z : register_array;

begin

z(0) <= i;

complete_ones : if complete_num_srl17es > 0 generate

srl17e_array: for i in 0 to complete_num_srl17es-1 generate

delay_comp : srl17e

generic map (width => width,

latency => 17)

port map (clk => clk,

ce => ce,

d => z(i),

q => z(i+1));

end generate;

end generate;

partial_one : if remaining_latency > 0 generate

last_srl17e : srl17e

generic map (width => width,

latency => remaining_latency)

port map (clk => clk,

ce => ce,

d => z(num_srl17es-1),

q => z(num_srl17es));

end generate;

o <= z(num_srl17es);

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity synth_reg_reg is

generic (width : integer := 8;

latency : integer := 1);

port (i : in std_logic_vector(width-1 downto 0);

Page 221: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

214

ce : in std_logic;

clr : in std_logic;

clk : in std_logic;

o : out std_logic_vector(width-1 downto 0));

end synth_reg_reg;

architecture behav of synth_reg_reg is

type reg_array_type is array (latency-1 downto 0) of std_logic_vector(width -1

downto 0);

signal reg_bank : reg_array_type := (others => (others => '0'));

signal reg_bank_in : reg_array_type := (others => (others => '0'));

attribute syn_allow_retiming : boolean;

attribute syn_srlstyle : string;

attribute syn_allow_retiming of reg_bank : signal is true;

attribute syn_allow_retiming of reg_bank_in : signal is true;

attribute syn_srlstyle of reg_bank : signal is "registers";

attribute syn_srlstyle of reg_bank_in : signal is "registers";

begin

latency_eq_0: if latency = 0 generate

o <= i;

end generate latency_eq_0;

latency_gt_0: if latency >= 1 generate

o <= reg_bank(latency-1);

reg_bank_in(0) <= i;

loop_gen: for idx in latency-2 downto 0 generate

reg_bank_in(idx+1) <= reg_bank(idx);

end generate loop_gen;

sync_loop: for sync_idx in latency-1 downto 0 generate

sync_proc: process (clk)

begin

if clk'event and clk = '1' then

if ce = '1' then

reg_bank(sync_idx) <= reg_bank_in(sync_idx);

end if;

end if;

end process sync_proc;

end generate sync_loop;

end generate latency_gt_0;

end behav;

library unisim;

use unisim.vcomponents.all;

-- synopsys translate_on

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity single_reg_w_init is

generic (

width: integer := 8;

init_index: integer := 0;

init_value: bit_vector := b"0000"

);

port (

i: in std_logic_vector(width - 1 downto 0);

Page 222: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

215

ce: in std_logic;

clr: in std_logic;

clk: in std_logic;

o: out std_logic_vector(width - 1 downto 0)

);

end single_reg_w_init;

architecture structural of single_reg_w_init is

function build_init_const(width: integer;

init_index: integer;

init_value: bit_vector)

return std_logic_vector

is

variable result: std_logic_vector(width - 1 downto 0);

begin

if init_index = 0 then

result := (others => '0');

elsif init_index = 1 then

result := (others => '0');

result(0) := '1';

else

result := to_stdlogicvector(init_value);

end if;

return result;

end;

component fdre

port (

q: out std_ulogic;

d: in std_ulogic;

c: in std_ulogic;

ce: in std_ulogic;

r: in std_ulogic

);

end component;

attribute syn_black_box of fdre: component is true;

attribute fpga_dont_touch of fdre: component is "true";

component fdse

port (

q: out std_ulogic;

d: in std_ulogic;

c: in std_ulogic;

ce: in std_ulogic;

s: in std_ulogic

);

end component;

attribute syn_black_box of fdse: component is true;

attribute fpga_dont_touch of fdse: component is "true";

constant init_const: std_logic_vector(width - 1 downto 0)

:= build_init_const(width, init_index, init_value);

begin

fd_prim_array: for index in 0 to width - 1 generate

bit_is_0: if (init_const(index) = '0') generate

fdre_comp: fdre

port map (

Page 223: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

216

c => clk,

d => i(index),

q => o(index),

ce => ce,

r => clr

);

end generate;

bit_is_1: if (init_const(index) = '1') generate

fdse_comp: fdse

port map (

c => clk,

d => i(index),

q => o(index),

ce => ce,

s => clr

);

end generate;

end generate;

end architecture structural;

-- synopsys translate_off

library unisim;

use unisim.vcomponents.all;

-- synopsys translate_on

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

entity synth_reg_w_init is

generic (

width: integer := 8;

init_index: integer := 0;

init_value: bit_vector := b"0000";

latency: integer := 1

);

port (

i: in std_logic_vector(width - 1 downto 0);

ce: in std_logic;

clr: in std_logic;

clk: in std_logic;

o: out std_logic_vector(width - 1 downto 0)

);

end synth_reg_w_init;

architecture structural of synth_reg_w_init is

component single_reg_w_init

generic (

width: integer := 8;

init_index: integer := 0;

init_value: bit_vector := b"0000"

);

port (

i: in std_logic_vector(width - 1 downto 0);

ce: in std_logic;

clr: in std_logic;

clk: in std_logic;

Page 224: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

217

o: out std_logic_vector(width - 1 downto 0)

);

end component;

signal dly_i: std_logic_vector((latency + 1) * width - 1 downto 0);

signal dly_clr: std_logic;

begin

latency_eq_0: if (latency = 0) generate

o <= i;

end generate;

latency_gt_0: if (latency >= 1) generate

dly_i((latency + 1) * width - 1 downto latency * width) <= i

after 200 ps;

dly_clr <= clr after 200 ps;

fd_array: for index in latency downto 1 generate

reg_comp: single_reg_w_init

generic map (

width => width,

init_index => init_index,

init_value => init_value

)

port map (

clk => clk,

i => dly_i((index + 1) * width - 1 downto index * width),

o => dly_i(index * width - 1 downto (index - 1) * width),

ce => ce,

clr => dly_clr

);

end generate;

o <= dly_i(width - 1 downto 0);

end generate;

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

use work.conv_pkg.all;

entity inverter_61f85f0bd8 is

port (

ip : in std_logic_vector((16 - 1) downto 0);

op : out std_logic_vector((16 - 1) downto 0);

clk : in std_logic;

ce : in std_logic;

clr : in std_logic);

end inverter_61f85f0bd8;

architecture behavior of inverter_61f85f0bd8 is

signal ip_1_26: signed((16 - 1) downto 0);

type array_type_op_mem_22_20 is array (0 to (1 - 1)) of signed((16 - 1) downto 0);

signal op_mem_22_20: array_type_op_mem_22_20 := (

0 => "0000000000000000");

signal op_mem_22_20_front_din: signed((16 - 1) downto 0);

signal op_mem_22_20_back: signed((16 - 1) downto 0);

Page 225: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

218

signal op_mem_22_20_push_front_pop_back_en: std_logic;

signal internal_ip_12_1_bitnot: signed((16 - 1) downto 0);

begin

ip_1_26 <= std_logic_vector_to_signed(ip);

op_mem_22_20_back <= op_mem_22_20(0);

proc_op_mem_22_20: process (clk)

is

variable i: integer;

begin

if (clk'event and (clk = '1')) then

if ((ce = '1') and (op_mem_22_20_push_front_pop_back_en = '1')) then

op_mem_22_20(0) <= op_mem_22_20_front_din;

end if;

end if;

end process proc_op_mem_22_20;

internal_ip_12_1_bitnot <= std_logic_vector_to_signed(not

signed_to_std_logic_vector(ip_1_26));

op_mem_22_20_push_front_pop_back_en <= '0';

op <= signed_to_std_logic_vector(internal_ip_12_1_bitnot);

end behavior;

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

use work.conv_pkg.all;

entity logical_09cb361f41 is

port (

d0 : in std_logic_vector((16 - 1) downto 0);

d1 : in std_logic_vector((16 - 1) downto 0);

d2 : in std_logic_vector((16 - 1) downto 0);

y : out std_logic_vector((16 - 1) downto 0);

clk : in std_logic;

ce : in std_logic;

clr : in std_logic);

end logical_09cb361f41;

architecture behavior of logical_09cb361f41 is

signal d0_1_24: std_logic_vector((16 - 1) downto 0);

signal d1_1_27: std_logic_vector((16 - 1) downto 0);

signal d2_1_30: std_logic_vector((16 - 1) downto 0);

signal fully_2_1_bit: std_logic_vector((16 - 1) downto 0);

begin

d0_1_24 <= d0;

d1_1_27 <= d1;

d2_1_30 <= d2;

fully_2_1_bit <= d0_1_24 and d1_1_27 and d2_1_30;

y <= fully_2_1_bit;

end behavior;

library IEEE;

use IEEE.std_logic_1164.all;

Page 226: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

219

use IEEE.numeric_std.all;

use work.conv_pkg.all;

entity logical_76819af9a7 is

port (

d0 : in std_logic_vector((16 - 1) downto 0);

d1 : in std_logic_vector((16 - 1) downto 0);

y : out std_logic_vector((16 - 1) downto 0);

clk : in std_logic;

ce : in std_logic;

clr : in std_logic);

end logical_76819af9a7;

architecture behavior of logical_76819af9a7 is

signal d0_1_24: std_logic_vector((16 - 1) downto 0);

signal d1_1_27: std_logic_vector((16 - 1) downto 0);

signal fully_2_1_bit: std_logic_vector((16 - 1) downto 0);

begin

d0_1_24 <= d0;

d1_1_27 <= d1;

fully_2_1_bit <= d0_1_24 xor d1_1_27;

y <= fully_2_1_bit;

end behavior;

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

use work.conv_pkg.all;

entity constant_515f6b5526 is

port (

op : out std_logic_vector((16 - 1) downto 0);

clk : in std_logic;

ce : in std_logic;

clr : in std_logic);

end constant_515f6b5526;

architecture behavior of constant_515f6b5526 is

begin

op <= "0100000000000000";

end behavior;

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

use work.conv_pkg.all;

entity constant_9f5572ba51 is

port (

op : out std_logic_vector((16 - 1) downto 0);

clk : in std_logic;

Page 227: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

220

ce : in std_logic;

clr : in std_logic);

end constant_9f5572ba51;

architecture behavior of constant_9f5572ba51 is

begin

op <= "0000000000000000";

end behavior;

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

use work.conv_pkg.all;

entity logical_2a516dc919 is

port (

d0 : in std_logic_vector((16 - 1) downto 0);

d1 : in std_logic_vector((16 - 1) downto 0);

y : out std_logic_vector((16 - 1) downto 0);

clk : in std_logic;

ce : in std_logic;

clr : in std_logic);

end logical_2a516dc919;

architecture behavior of logical_2a516dc919 is

signal d0_1_24: std_logic_vector((16 - 1) downto 0);

signal d1_1_27: std_logic_vector((16 - 1) downto 0);

signal fully_2_1_bit: std_logic_vector((16 - 1) downto 0);

begin

d0_1_24 <= d0;

d1_1_27 <= d1;

fully_2_1_bit <= d0_1_24 and d1_1_27;

y <= fully_2_1_bit;

end behavior;

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

use work.conv_pkg.all;

entity logical_e23d6147c6 is

port (

d0 : in std_logic_vector((16 - 1) downto 0);

d1 : in std_logic_vector((16 - 1) downto 0);

d2 : in std_logic_vector((16 - 1) downto 0);

d3 : in std_logic_vector((16 - 1) downto 0);

d4 : in std_logic_vector((16 - 1) downto 0);

d5 : in std_logic_vector((16 - 1) downto 0);

d6 : in std_logic_vector((16 - 1) downto 0);

y : out std_logic_vector((16 - 1) downto 0);

clk : in std_logic;

Page 228: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

221

ce : in std_logic;

clr : in std_logic);

end logical_e23d6147c6;

architecture behavior of logical_e23d6147c6 is

signal d0_1_24: std_logic_vector((16 - 1) downto 0);

signal d1_1_27: std_logic_vector((16 - 1) downto 0);

signal d2_1_30: std_logic_vector((16 - 1) downto 0);

signal d3_1_33: std_logic_vector((16 - 1) downto 0);

signal d4_1_36: std_logic_vector((16 - 1) downto 0);

signal d5_1_39: std_logic_vector((16 - 1) downto 0);

signal d6_1_42: std_logic_vector((16 - 1) downto 0);

signal fully_2_1_bit: std_logic_vector((16 - 1) downto 0);

begin

d0_1_24 <= d0;

d1_1_27 <= d1;

d2_1_30 <= d2;

d3_1_33 <= d3;

d4_1_36 <= d4;

d5_1_39 <= d5;

d6_1_42 <= d6;

fully_2_1_bit <= d0_1_24 xor d1_1_27 xor d2_1_30 xor d3_1_33 xor d4_1_36 xor

d5_1_39 xor d6_1_42;

y <= fully_2_1_bit;

end behavior;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

-- Generated from Simulink block "decodificadorhamming/Hamming

Decoder/Codificacion/Err_loc"

entity err_loc_entity_545fb9d773 is

port (

ce_1: in std_logic;

clk_1: in std_logic;

in1: in std_logic_vector(15 downto 0);

in2: in std_logic_vector(15 downto 0);

in3: in std_logic_vector(15 downto 0);

out1: out std_logic_vector(15 downto 0);

out2: out std_logic_vector(15 downto 0);

out3: out std_logic_vector(15 downto 0);

out4: out std_logic_vector(15 downto 0);

out5: out std_logic_vector(15 downto 0);

out6: out std_logic_vector(15 downto 0);

out7: out std_logic_vector(15 downto 0)

);

end err_loc_entity_545fb9d773;

architecture structural of err_loc_entity_545fb9d773 is

signal ce_1_sg_x0: std_logic;

Page 229: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

222

signal clk_1_sg_x0: std_logic;

signal inverter1_op_net: std_logic_vector(15 downto 0);

signal inverter2_op_net: std_logic_vector(15 downto 0);

signal inverter_op_net: std_logic_vector(15 downto 0);

signal logical1_y_net_x0: std_logic_vector(15 downto 0);

signal logical21_y_net_x0: std_logic_vector(15 downto 0);

signal logical22_y_net_x0: std_logic_vector(15 downto 0);

signal logical23_y_net_x0: std_logic_vector(15 downto 0);

signal logical2_y_net_x0: std_logic_vector(15 downto 0);

signal logical3_y_net_x0: std_logic_vector(15 downto 0);

signal logical4_y_net_x0: std_logic_vector(15 downto 0);

signal logical5_y_net_x0: std_logic_vector(15 downto 0);

signal logical6_y_net_x0: std_logic_vector(15 downto 0);

signal logical_y_net_x0: std_logic_vector(15 downto 0);

begin

ce_1_sg_x0 <= ce_1;

clk_1_sg_x0 <= clk_1;

logical23_y_net_x0 <= in1;

logical22_y_net_x0 <= in2;

logical21_y_net_x0 <= in3;

out1 <= logical6_y_net_x0;

out2 <= logical5_y_net_x0;

out3 <= logical4_y_net_x0;

out4 <= logical3_y_net_x0;

out5 <= logical2_y_net_x0;

out6 <= logical1_y_net_x0;

out7 <= logical_y_net_x0;

inverter: entity work.inverter_61f85f0bd8

port map (

ce => ce_1_sg_x0,

clk => clk_1_sg_x0,

clr => '0',

ip => logical23_y_net_x0,

op => inverter_op_net

);

inverter1: entity work.inverter_61f85f0bd8

port map (

ce => ce_1_sg_x0,

clk => clk_1_sg_x0,

clr => '0',

ip => logical22_y_net_x0,

op => inverter1_op_net

);

inverter2: entity work.inverter_61f85f0bd8

port map (

ce => ce_1_sg_x0,

clk => clk_1_sg_x0,

clr => '0',

ip => logical21_y_net_x0,

Page 230: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

223

op => inverter2_op_net

);

logical: entity work.logical_09cb361f41

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => logical21_y_net_x0,

d1 => inverter1_op_net,

d2 => inverter_op_net,

y => logical_y_net_x0

);

logical1: entity work.logical_09cb361f41

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => inverter_op_net,

d1 => logical22_y_net_x0,

d2 => inverter2_op_net,

y => logical1_y_net_x0

);

logical2: entity work.logical_09cb361f41

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => logical23_y_net_x0,

d1 => inverter1_op_net,

d2 => inverter2_op_net,

y => logical2_y_net_x0

);

logical3: entity work.logical_09cb361f41

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => inverter_op_net,

d1 => logical21_y_net_x0,

d2 => logical22_y_net_x0,

y => logical3_y_net_x0

);

logical4: entity work.logical_09cb361f41

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => inverter2_op_net,

Page 231: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

224

d1 => logical22_y_net_x0,

d2 => logical23_y_net_x0,

y => logical4_y_net_x0

);

logical5: entity work.logical_09cb361f41

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => logical21_y_net_x0,

d1 => logical22_y_net_x0,

d2 => logical23_y_net_x0,

y => logical5_y_net_x0

);

logical6: entity work.logical_09cb361f41

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => logical23_y_net_x0,

d1 => inverter1_op_net,

d2 => logical21_y_net_x0,

y => logical6_y_net_x0

);

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

-- Generated from Simulink block "decodificadorhamming/Hamming

Decoder/Codificacion"

entity codificacion_entity_df5ebdb56d is

port (

ce_1: in std_logic;

clk_1: in std_logic;

in1: in std_logic_vector(15 downto 0);

in10: in std_logic_vector(15 downto 0);

in2: in std_logic_vector(15 downto 0);

in3: in std_logic_vector(15 downto 0);

in4: in std_logic_vector(15 downto 0);

in5: in std_logic_vector(15 downto 0);

in6: in std_logic_vector(15 downto 0);

in7: in std_logic_vector(15 downto 0);

in8: in std_logic_vector(15 downto 0);

in9: in std_logic_vector(15 downto 0);

logical1_x0: out std_logic_vector(15 downto 0);

logical2_x0: out std_logic_vector(15 downto 0);

logical3_x0: out std_logic_vector(15 downto 0);

logical4_x0: out std_logic_vector(15 downto 0);

Page 232: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

225

logical5_x0: out std_logic_vector(15 downto 0);

logical6_x0: out std_logic_vector(15 downto 0);

logical_x0: out std_logic_vector(15 downto 0)

);

end codificacion_entity_df5ebdb56d;

architecture structural of codificacion_entity_df5ebdb56d is

signal ce_1_sg_x1: std_logic;

signal clk_1_sg_x1: std_logic;

signal gateway_in1_net_x0: std_logic_vector(15 downto 0);

signal gateway_in2_net_x0: std_logic_vector(15 downto 0);

signal gateway_in3_net_x0: std_logic_vector(15 downto 0);

signal gateway_in4_net_x0: std_logic_vector(15 downto 0);

signal gateway_in5_net_x0: std_logic_vector(15 downto 0);

signal gateway_in6_net_x0: std_logic_vector(15 downto 0);

signal gateway_in_net_x0: std_logic_vector(15 downto 0);

signal logical1_y_net_x0: std_logic_vector(15 downto 0);

signal logical1_y_net_x1: std_logic_vector(15 downto 0);

signal logical21_y_net_x1: std_logic_vector(15 downto 0);

signal logical22_y_net_x1: std_logic_vector(15 downto 0);

signal logical23_y_net_x1: std_logic_vector(15 downto 0);

signal logical2_y_net_x0: std_logic_vector(15 downto 0);

signal logical2_y_net_x1: std_logic_vector(15 downto 0);

signal logical3_y_net_x0: std_logic_vector(15 downto 0);

signal logical3_y_net_x1: std_logic_vector(15 downto 0);

signal logical4_y_net_x0: std_logic_vector(15 downto 0);

signal logical4_y_net_x1: std_logic_vector(15 downto 0);

signal logical5_y_net_x0: std_logic_vector(15 downto 0);

signal logical5_y_net_x1: std_logic_vector(15 downto 0);

signal logical6_y_net_x0: std_logic_vector(15 downto 0);

signal logical6_y_net_x1: std_logic_vector(15 downto 0);

signal logical_y_net_x0: std_logic_vector(15 downto 0);

signal logical_y_net_x1: std_logic_vector(15 downto 0);

begin

ce_1_sg_x1 <= ce_1;

clk_1_sg_x1 <= clk_1;

gateway_in_net_x0 <= in1;

logical21_y_net_x1 <= in10;

gateway_in1_net_x0 <= in2;

gateway_in2_net_x0 <= in3;

gateway_in3_net_x0 <= in4;

gateway_in4_net_x0 <= in5;

gateway_in5_net_x0 <= in6;

gateway_in6_net_x0 <= in7;

logical23_y_net_x1 <= in8;

logical22_y_net_x1 <= in9;

logical1_x0 <= logical1_y_net_x1;

logical2_x0 <= logical2_y_net_x1;

logical3_x0 <= logical3_y_net_x1;

logical4_x0 <= logical4_y_net_x1;

logical5_x0 <= logical5_y_net_x1;

logical6_x0 <= logical6_y_net_x1;

Page 233: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

226

logical_x0 <= logical_y_net_x1;

err_loc_545fb9d773: entity work.err_loc_entity_545fb9d773

port map (

ce_1 => ce_1_sg_x1,

clk_1 => clk_1_sg_x1,

in1 => logical23_y_net_x1,

in2 => logical22_y_net_x1,

in3 => logical21_y_net_x1,

out1 => logical6_y_net_x0,

out2 => logical5_y_net_x0,

out3 => logical4_y_net_x0,

out4 => logical3_y_net_x0,

out5 => logical2_y_net_x0,

out6 => logical1_y_net_x0,

out7 => logical_y_net_x0

);

logical: entity work.logical_76819af9a7

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => gateway_in6_net_x0,

d1 => logical6_y_net_x0,

y => logical_y_net_x1

);

logical1: entity work.logical_76819af9a7

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => gateway_in5_net_x0,

d1 => logical5_y_net_x0,

y => logical1_y_net_x1

);

logical2: entity work.logical_76819af9a7

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => gateway_in4_net_x0,

d1 => logical4_y_net_x0,

y => logical2_y_net_x1

);

logical3: entity work.logical_76819af9a7

port map (

ce => '0',

clk => '0',

clr => '0',

Page 234: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

227

d0 => gateway_in3_net_x0,

d1 => logical3_y_net_x0,

y => logical3_y_net_x1

);

logical4: entity work.logical_76819af9a7

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => gateway_in2_net_x0,

d1 => logical2_y_net_x0,

y => logical4_y_net_x1

);

logical5: entity work.logical_76819af9a7

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => gateway_in1_net_x0,

d1 => logical1_y_net_x0,

y => logical5_y_net_x1

);

logical6: entity work.logical_76819af9a7

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => gateway_in_net_x0,

d1 => logical_y_net_x0,

y => logical6_y_net_x1

);

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

-- Generated from Simulink block "decodificadorhamming/Hamming

Decoder/Syndrome"

entity syndrome_entity_647f0da075 is

port (

gateway_in: in std_logic_vector(15 downto 0);

gateway_in1: in std_logic_vector(15 downto 0);

gateway_in2: in std_logic_vector(15 downto 0);

gateway_in3: in std_logic_vector(15 downto 0);

gateway_in4: in std_logic_vector(15 downto 0);

gateway_in5: in std_logic_vector(15 downto 0);

gateway_in6: in std_logic_vector(15 downto 0);

out10: out std_logic_vector(15 downto 0);

Page 235: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

228

out8: out std_logic_vector(15 downto 0);

out9: out std_logic_vector(15 downto 0)

);

end syndrome_entity_647f0da075;

architecture structural of syndrome_entity_647f0da075 is

signal constant1_op_net: std_logic_vector(15 downto 0);

signal constant_op_net: std_logic_vector(15 downto 0);

signal gateway_in1_net_x1: std_logic_vector(15 downto 0);

signal gateway_in2_net_x1: std_logic_vector(15 downto 0);

signal gateway_in3_net_x1: std_logic_vector(15 downto 0);

signal gateway_in4_net_x1: std_logic_vector(15 downto 0);

signal gateway_in5_net_x1: std_logic_vector(15 downto 0);

signal gateway_in6_net_x1: std_logic_vector(15 downto 0);

signal gateway_in_net_x1: std_logic_vector(15 downto 0);

signal logical10_y_net: std_logic_vector(15 downto 0);

signal logical11_y_net: std_logic_vector(15 downto 0);

signal logical12_y_net: std_logic_vector(15 downto 0);

signal logical13_y_net: std_logic_vector(15 downto 0);

signal logical14_y_net: std_logic_vector(15 downto 0);

signal logical15_y_net: std_logic_vector(15 downto 0);

signal logical16_y_net: std_logic_vector(15 downto 0);

signal logical17_y_net: std_logic_vector(15 downto 0);

signal logical18_y_net: std_logic_vector(15 downto 0);

signal logical19_y_net: std_logic_vector(15 downto 0);

signal logical1_y_net: std_logic_vector(15 downto 0);

signal logical20_y_net: std_logic_vector(15 downto 0);

signal logical21_y_net_x2: std_logic_vector(15 downto 0);

signal logical22_y_net_x2: std_logic_vector(15 downto 0);

signal logical23_y_net_x2: std_logic_vector(15 downto 0);

signal logical2_y_net: std_logic_vector(15 downto 0);

signal logical3_y_net: std_logic_vector(15 downto 0);

signal logical4_y_net: std_logic_vector(15 downto 0);

signal logical5_y_net: std_logic_vector(15 downto 0);

signal logical6_y_net: std_logic_vector(15 downto 0);

signal logical7_y_net: std_logic_vector(15 downto 0);

signal logical8_y_net: std_logic_vector(15 downto 0);

signal logical9_y_net: std_logic_vector(15 downto 0);

signal logical_y_net: std_logic_vector(15 downto 0);

begin

gateway_in_net_x1 <= gateway_in;

gateway_in1_net_x1 <= gateway_in1;

gateway_in2_net_x1 <= gateway_in2;

gateway_in3_net_x1 <= gateway_in3;

gateway_in4_net_x1 <= gateway_in4;

gateway_in5_net_x1 <= gateway_in5;

gateway_in6_net_x1 <= gateway_in6;

out10 <= logical21_y_net_x2;

out8 <= logical23_y_net_x2;

out9 <= logical22_y_net_x2;

constant1: entity work.constant_9f5572ba51

Page 236: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

229

port map (

ce => '0',

clk => '0',

clr => '0',

op => constant1_op_net

);

constant_x0: entity work.constant_515f6b5526

port map (

ce => '0',

clk => '0',

clr => '0',

op => constant_op_net

);

logical: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in6_net_x1,

y => logical_y_net

);

logical1: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in5_net_x1,

y => logical1_y_net

);

logical10: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in3_net_x1,

y => logical10_y_net

);

logical11: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in2_net_x1,

y => logical11_y_net

Page 237: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

230

);

logical12: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in1_net_x1,

y => logical12_y_net

);

logical13: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in_net_x1,

y => logical13_y_net

);

logical14: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in6_net_x1,

y => logical14_y_net

);

logical15: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in5_net_x1,

y => logical15_y_net

);

logical16: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in4_net_x1,

y => logical16_y_net

);

logical17: entity work.logical_2a516dc919

Page 238: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

231

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in3_net_x1,

y => logical17_y_net

);

logical18: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in2_net_x1,

y => logical18_y_net

);

logical19: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in1_net_x1,

y => logical19_y_net

);

logical2: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in4_net_x1,

y => logical2_y_net

);

logical20: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in_net_x1,

y => logical20_y_net

);

logical21: entity work.logical_e23d6147c6

port map (

ce => '0',

clk => '0',

Page 239: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

232

clr => '0',

d0 => logical_y_net,

d1 => logical1_y_net,

d2 => logical2_y_net,

d3 => logical3_y_net,

d4 => logical4_y_net,

d5 => logical5_y_net,

d6 => logical6_y_net,

y => logical21_y_net_x2

);

logical22: entity work.logical_e23d6147c6

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => logical7_y_net,

d1 => logical8_y_net,

d2 => logical9_y_net,

d3 => logical10_y_net,

d4 => logical11_y_net,

d5 => logical12_y_net,

d6 => logical13_y_net,

y => logical22_y_net_x2

);

logical23: entity work.logical_e23d6147c6

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => logical14_y_net,

d1 => logical15_y_net,

d2 => logical16_y_net,

d3 => logical17_y_net,

d4 => logical18_y_net,

d5 => logical19_y_net,

d6 => logical20_y_net,

y => logical23_y_net_x2

);

logical3: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in3_net_x1,

y => logical3_y_net

);

logical4: entity work.logical_2a516dc919

port map (

Page 240: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

233

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in2_net_x1,

y => logical4_y_net

);

logical5: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in1_net_x1,

y => logical5_y_net

);

logical6: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in_net_x1,

y => logical6_y_net

);

logical7: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant1_op_net,

d1 => gateway_in6_net_x1,

y => logical7_y_net

);

logical8: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

d0 => constant_op_net,

d1 => gateway_in5_net_x1,

y => logical8_y_net

);

logical9: entity work.logical_2a516dc919

port map (

ce => '0',

clk => '0',

clr => '0',

Page 241: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

234

d0 => constant_op_net,

d1 => gateway_in4_net_x1,

y => logical9_y_net

);

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

-- Generated from Simulink block "decodificadorhamming/Hamming Decoder"

entity hamming_decoder_entity_5b25379c01 is

port (

ce_1: in std_logic;

clk_1: in std_logic;

gateway_in: in std_logic_vector(15 downto 0);

gateway_in1: in std_logic_vector(15 downto 0);

gateway_in2: in std_logic_vector(15 downto 0);

gateway_in3: in std_logic_vector(15 downto 0);

gateway_in4: in std_logic_vector(15 downto 0);

gateway_in5: in std_logic_vector(15 downto 0);

gateway_in6: in std_logic_vector(15 downto 0);

codificacion: out std_logic_vector(15 downto 0);

codificacion_x0: out std_logic_vector(15 downto 0);

codificacion_x1: out std_logic_vector(15 downto 0);

codificacion_x2: out std_logic_vector(15 downto 0);

codificacion_x3: out std_logic_vector(15 downto 0);

codificacion_x4: out std_logic_vector(15 downto 0);

codificacion_x5: out std_logic_vector(15 downto 0)

);

end hamming_decoder_entity_5b25379c01;

architecture structural of hamming_decoder_entity_5b25379c01 is

signal ce_1_sg_x2: std_logic;

signal clk_1_sg_x2: std_logic;

signal gateway_in1_net_x2: std_logic_vector(15 downto 0);

signal gateway_in2_net_x2: std_logic_vector(15 downto 0);

signal gateway_in3_net_x2: std_logic_vector(15 downto 0);

signal gateway_in4_net_x2: std_logic_vector(15 downto 0);

signal gateway_in5_net_x2: std_logic_vector(15 downto 0);

signal gateway_in6_net_x2: std_logic_vector(15 downto 0);

signal gateway_in_net_x2: std_logic_vector(15 downto 0);

signal logical1_y_net_x2: std_logic_vector(15 downto 0);

signal logical21_y_net_x2: std_logic_vector(15 downto 0);

signal logical22_y_net_x2: std_logic_vector(15 downto 0);

signal logical23_y_net_x2: std_logic_vector(15 downto 0);

signal logical2_y_net_x2: std_logic_vector(15 downto 0);

signal logical3_y_net_x2: std_logic_vector(15 downto 0);

signal logical4_y_net_x2: std_logic_vector(15 downto 0);

signal logical5_y_net_x2: std_logic_vector(15 downto 0);

signal logical6_y_net_x2: std_logic_vector(15 downto 0);

signal logical_y_net_x2: std_logic_vector(15 downto 0);

Page 242: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

235

begin

ce_1_sg_x2 <= ce_1;

clk_1_sg_x2 <= clk_1;

gateway_in_net_x2 <= gateway_in;

gateway_in1_net_x2 <= gateway_in1;

gateway_in2_net_x2 <= gateway_in2;

gateway_in3_net_x2 <= gateway_in3;

gateway_in4_net_x2 <= gateway_in4;

gateway_in5_net_x2 <= gateway_in5;

gateway_in6_net_x2 <= gateway_in6;

codificacion <= logical_y_net_x2;

codificacion_x0 <= logical1_y_net_x2;

codificacion_x1 <= logical2_y_net_x2;

codificacion_x2 <= logical3_y_net_x2;

codificacion_x3 <= logical4_y_net_x2;

codificacion_x4 <= logical5_y_net_x2;

codificacion_x5 <= logical6_y_net_x2;

codificacion_df5ebdb56d: entity work.codificacion_entity_df5ebdb56d

port map (

ce_1 => ce_1_sg_x2,

clk_1 => clk_1_sg_x2,

in1 => gateway_in_net_x2,

in10 => logical21_y_net_x2,

in2 => gateway_in1_net_x2,

in3 => gateway_in2_net_x2,

in4 => gateway_in3_net_x2,

in5 => gateway_in4_net_x2,

in6 => gateway_in5_net_x2,

in7 => gateway_in6_net_x2,

in8 => logical23_y_net_x2,

in9 => logical22_y_net_x2,

logical1_x0 => logical1_y_net_x2,

logical2_x0 => logical2_y_net_x2,

logical3_x0 => logical3_y_net_x2,

logical4_x0 => logical4_y_net_x2,

logical5_x0 => logical5_y_net_x2,

logical6_x0 => logical6_y_net_x2,

logical_x0 => logical_y_net_x2

);

syndrome_647f0da075: entity work.syndrome_entity_647f0da075

port map (

gateway_in => gateway_in_net_x2,

gateway_in1 => gateway_in1_net_x2,

gateway_in2 => gateway_in2_net_x2,

gateway_in3 => gateway_in3_net_x2,

gateway_in4 => gateway_in4_net_x2,

gateway_in5 => gateway_in5_net_x2,

gateway_in6 => gateway_in6_net_x2,

out10 => logical21_y_net_x2,

out8 => logical23_y_net_x2,

Page 243: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

236

out9 => logical22_y_net_x2

);

end structural;

library IEEE;

use IEEE.std_logic_1164.all;

use work.conv_pkg.all;

-- Generated from Simulink block "decodificadorhamming"

entity decodificadorhamming is

port (

ce_1: in std_logic;

clk_1: in std_logic;

gateway_in: in std_logic_vector(15 downto 0);

gateway_in1: in std_logic_vector(15 downto 0);

gateway_in2: in std_logic_vector(15 downto 0);

gateway_in3: in std_logic_vector(15 downto 0);

gateway_in4: in std_logic_vector(15 downto 0);

gateway_in5: in std_logic_vector(15 downto 0);

gateway_in6: in std_logic_vector(15 downto 0);

gateway_out: out std_logic_vector(15 downto 0);

gateway_out1: out std_logic_vector(15 downto 0);

gateway_out2: out std_logic_vector(15 downto 0);

gateway_out3: out std_logic_vector(15 downto 0);

gateway_out4: out std_logic_vector(15 downto 0);

gateway_out5: out std_logic_vector(15 downto 0);

gateway_out6: out std_logic_vector(15 downto 0)

);

end decodificadorhamming;

architecture structural of decodificadorhamming is

signal ce_1_sg_x3: std_logic;

signal clk_1_sg_x3: std_logic;

signal gateway_in1_net: std_logic_vector(15 downto 0);

signal gateway_in2_net: std_logic_vector(15 downto 0);

signal gateway_in3_net: std_logic_vector(15 downto 0);

signal gateway_in4_net: std_logic_vector(15 downto 0);

signal gateway_in5_net: std_logic_vector(15 downto 0);

signal gateway_in6_net: std_logic_vector(15 downto 0);

signal gateway_in_net: std_logic_vector(15 downto 0);

signal gateway_out1_net: std_logic_vector(15 downto 0);

signal gateway_out2_net: std_logic_vector(15 downto 0);

signal gateway_out3_net: std_logic_vector(15 downto 0);

signal gateway_out4_net: std_logic_vector(15 downto 0);

signal gateway_out5_net: std_logic_vector(15 downto 0);

signal gateway_out6_net: std_logic_vector(15 downto 0);

signal gateway_out_net: std_logic_vector(15 downto 0);

begin

ce_1_sg_x3 <= ce_1;

clk_1_sg_x3 <= clk_1;

gateway_in_net <= gateway_in;

Page 244: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

237

gateway_in1_net <= gateway_in1;

gateway_in2_net <= gateway_in2;

gateway_in3_net <= gateway_in3;

gateway_in4_net <= gateway_in4;

gateway_in5_net <= gateway_in5;

gateway_in6_net <= gateway_in6;

gateway_out <= gateway_out_net;

gateway_out1 <= gateway_out1_net;

gateway_out2 <= gateway_out2_net;

gateway_out3 <= gateway_out3_net;

gateway_out4 <= gateway_out4_net;

gateway_out5 <= gateway_out5_net;

gateway_out6 <= gateway_out6_net;

hamming_decoder_5b25379c01: entity work.hamming_decoder_entity_5b25379c01

port map (

ce_1 => ce_1_sg_x3,

clk_1 => clk_1_sg_x3,

gateway_in => gateway_in_net,

gateway_in1 => gateway_in1_net,

gateway_in2 => gateway_in2_net,

gateway_in3 => gateway_in3_net,

gateway_in4 => gateway_in4_net,

gateway_in5 => gateway_in5_net,

gateway_in6 => gateway_in6_net,

codificacion => gateway_out6_net,

codificacion_x0 => gateway_out5_net,

codificacion_x1 => gateway_out4_net,

codificacion_x2 => gateway_out3_net,

codificacion_x3 => gateway_out2_net,

codificacion_x4 => gateway_out1_net,

codificacion_x5 => gateway_out_net

);

end structural;

Page 245: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

238

Page 246: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

239

REFERENCIAS:

1.http://www.cucei.udg.mx/~msruiz/comunicacion_movil/sesion2-3.pdf

2.http://www.rrppnet.com.ar/hiscomunicacion.htm

3. Jaime Sánchez García, Myriam Meza Mújica, “Redes celulares de

tercera generación: CDMA2000 y WCDMA”,Revista digital científica y tecnológica, Vol. 3, Art. 4, 2005,

http://redalyc.uaemex.mx/redalyc/pdf/730/73000304.pdf

4.http://catarina.udlap.mx/u_dl_a/tales/documentos/lem/lopez_g_j/capitulo7.pdf

5. Jorge Estudillo Ramírez, René Cumplido, “Integración de Redes y

Protocolos con SDR (Software Defined Radio)”, Reporte Técnico No. CCC-00-004, 2005, http://ccc.inaoep.mx/Reportes/CCC-05-004.pdf

6. Enrique Proaño R, Erick Ramírez T, Transmisores de radio basados en software, 2005,

http://clusterfie.epn.edu.ec/ibernal/html/CURSOS/Oct05Marzo06/Inalambricas/Trabajo1/TRaduccion/NewT5.doc

7. Patricio Lancellotti F,

http://www.federachi.cl/Comisiones/Tecnologica/radios_%20sofware.htm

8. Fernando Fernández de Villegas, “Equipos de Radio Definidos por

Software”, Revista CQ RadioAmateur, Edición española, nº 243 (marzo 2004), Documento "Software defined Radio modèle SDR-1000, de Luc

Favre (F6HJO-HB9ABB), http://www.flex-radio.com/articles_files/Technik SDR-1000-franz.pdf, Documento "A

software-Defined Radio for the masses, part 1", de Gerald

Youngglood (AC5OG), www.flex-radio.com/articles_files/SDRFMP1.pdf, http://www.ea1uro.com/sdr.html

9.http://elsitiodetelecomunicaciones.iespana.es/modulacion.htm

10.http://www.textoscientificos.com/redes/modulacion

11.http://usuarios.lycos.es/araure/modulacion.htm

12.http://www.isa.cie.uva.es/proyectos/codec/marco4.html

Page 247: IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA …tesis.ipn.mx/jspui/bitstream/123456789/6748/1/IMPLEMENTAFPGA.… · 4.1 Fase de salida contra la relación de tiempo para una

IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE PARA UN RADIO DEFINIDO POR SOFTWARE

240

13.http://www.electronicafacil.net/tutoriales/MODULACION-DIGITAL-

FSK-PSK-QAM.php

14. http://www.info-ab.uclm.es/asignaturas/42638/pdf/cap2.pdf

15. ETSI DTS/BRAN-0020003-2 v0.c: Broadband Radio Access Networks

(BRAN); HIPERLAN Type2; Interworking between HIPERLAN/2 and 3rd Generation Cellular and other Public systems, V0.c (2001-12).

16. http://filebox.vt.edu/users/tmagin/history.htm

17.http://ccc.inaoep.mx/fpgacentral/reconfig/2003/pdf/CR_ENC03_I.pdf

18. http://www.profesores.frc.utn.edu.ar/electronica/tecnicasdigitalesI/

Publicaciones/FPGA.pdf

19.http://legameda.blogspot.com/2008/01/12-estructura-de-la fpga.html