Documentos de Académico
Documentos de Profesional
Documentos de Cultura
IMPLEMENTACIÓN EN FPGA
DE MÓDULOS DE
SOFTWARE PARA UN RADIO
DEFINIDO POR SOFTWARE
Alumnos
Nombre:
Asesor Metodológico
Asesor(es) Técnico(s)
Objetivo general. I
Objetivos Específicos. I
Justificación. II
Conclusiones 64
Glosario 65
Apéndice A 67
Apéndice B 68
Referencias 239
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
Figura 1.1 Áreas en formas hexagonales, con su estación móvil y los usuarios que se encuentra adentro de cada una
1.1 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
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
Diagrama de la decodificación, el mensaje original sale por Out2 y los bits de paridad que se le quitan al mensaje por
4.17 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
Objetivo General:
Objetivos Específicos:
I
Justificación
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
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
1.1 INTRODUCCIÓN
1
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
2
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
4
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
5
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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.
6
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
7
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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.
8
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
9
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
10
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
11
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
2.1 INTRODUCCIÓN
12
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
13
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
14
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
15
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
16
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
2.3 MODULACIÓN
17
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
19
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
2.4 DEMODULACIÓN
20
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
21
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
Figura 2.9. Fase de salida contra la relación de tiempo para una forma de onda
BPSK.
22
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
2.5 CODIFICACIÓN
23
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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.
Donde los Pij deben ser tales que la matriz generadora del código tenga
filas independientes y las ecuaciones de paridad sean iguales.
24
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
G = [Ik,k | P ]
c=m• G
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.
r=c+e
25
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
s = r • Ht
s = r • Ht = 0
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.
27
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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:
28
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
29
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
30
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
3.1 INTRODUCCIÓN.
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:
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.
31
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
3.2 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
32
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
3.3 ASPLD
3.4 PAL
33
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
3.5 FPGA
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.
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.
35
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
36
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
37
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
• Simuladores:
– Active HDL, ModelSim, Cadence, LAbView, Simulink (Matlab),
System Generator.
• Síntesis:
– FPGA Compiler, Synplicity, Leonardo.
• Ambientes integrados
– Xilinx ISE, Max Plus, Libero.
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.
38
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
39
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
40
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
Figura 4.1. Fase de salida contra la relación de tiempo para una forma de onda
BPSK.
41
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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.
42
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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.
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.
Generador de Bits
43
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
Señal modulada
Señal demodulada
44
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
45
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
46
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
47
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
48
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
49
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
Tabla 4.1 Tabla para determinar las salidas trt dependiendo el número de error
50
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
51
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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”:
52
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
53
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
Figura 4.20. Ventana del bloque System Generator para crear proyecto ISE.
Figura 4.21. Ventana del bloque System Generator generando proyecto ISE.
55
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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).
56
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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.
57
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
Figura 4.26. Ventana del código VHD generado por System Generator.
58
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
59
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
60
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
61
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
Figura 4.31. Después de cargar el archivo .bit se abre otra ventana para
seleccionar otro archivo.
62
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
63
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
CONCLUSIONES
64
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
GLOSARIO:
65
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
66
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
APÉNDICE A
67
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
APÉNDICE B
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)
68
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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)
69
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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)
70
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
71
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
72
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
73
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
74
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
75
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
76
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
77
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
78
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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';
79
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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);
80
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
81
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
82
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
83
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
84
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
85
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
86
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
87
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
88
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
89
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
90
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
91
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
92
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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));
93
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
94
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
95
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
96
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
97
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
98
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
99
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
library IEEE;
use IEEE.std_logic_1164.all;
use work.conv_pkg.all;
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;
100
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
begin
gateway_in_net <= gateway_in;
gateway_in1_net <= gateway_in1;
gateway_in2_net <= gateway_in2;
gateway_out <= 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;
101
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
-- 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;
102
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
103
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
104
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
105
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
106
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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)
107
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
108
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
109
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
110
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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,
111
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
112
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
113
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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,
114
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
115
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
116
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
117
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
118
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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);
119
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
120
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
121
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
122
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
123
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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);
124
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
125
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
126
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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);
127
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
128
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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);
129
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
130
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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"
);
131
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
132
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
133
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
134
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
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;
135
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
136
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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,
137
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
138
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
library IEEE;
use IEEE.std_logic_1164.all;
use work.conv_pkg.all;
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;
begin
gateway_in_net_x0 <= gateway_in;
gateway_in1_net_x0 <= gateway_in1;
gateway_in2_net_x0 <= gateway_in2;
out1 <= mux_y_net_x0;
139
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
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;
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;
140
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
141
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
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)
142
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
143
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
144
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
145
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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);
146
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
147
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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,
148
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
149
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
150
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
151
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
152
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
153
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
154
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
155
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
156
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
157
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
158
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
159
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
160
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
161
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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);
162
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
163
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
164
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
165
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
166
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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);
167
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
168
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
169
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
170
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
171
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
172
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
173
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
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;
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;
174
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
library IEEE;
use IEEE.std_logic_1164.all;
use work.conv_pkg.all;
entity hamming_encoder_entity_e8bb25a7c2 is
175
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
176
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
177
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
178
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
179
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
port map (
ce => '0',
clk => '0',
clr => '0',
d0 => constant1_op_net,
d1 => gateway_in2_net_x0,
y => logical2_y_net
);
180
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
181
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
d0 => logical28_y_net,
d1 => logical27_y_net,
d2 => logical26_y_net,
d3 => logical25_y_net,
y => logical29_y_net_x0
);
182
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
d1 => gateway_in3_net_x0,
y => logical33_y_net
);
183
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
d0 => constant_op_net,
d1 => gateway_in2_net_x0,
y => logical7_y_net
);
end structural;
library IEEE;
use IEEE.std_logic_1164.all;
use work.conv_pkg.all;
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;
184
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
end structural;
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;
185
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
186
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
187
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
188
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
189
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
190
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
191
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
192
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
193
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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)
194
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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');
195
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
196
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
197
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
: 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) -
198
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
(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);
199
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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);
200
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
201
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
202
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
203
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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);
204
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
205
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
-- 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) := '.';
206
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
207
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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.";
208
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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
209
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
210
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
211
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
212
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
213
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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);
214
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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 (
215
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
216
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
217
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
library IEEE;
use IEEE.std_logic_1164.all;
218
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
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;
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;
219
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
ce : in std_logic;
clr : in std_logic);
end constant_9f5572ba51;
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;
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;
220
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
ce : in std_logic;
clr : in std_logic);
end logical_e23d6147c6;
library IEEE;
use IEEE.std_logic_1164.all;
use work.conv_pkg.all;
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;
221
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
222
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
op => inverter2_op_net
);
223
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
d1 => logical22_y_net_x0,
d2 => logical23_y_net_x0,
y => logical4_y_net_x0
);
end structural;
library IEEE;
use IEEE.std_logic_1164.all;
use work.conv_pkg.all;
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);
224
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
225
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
226
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
d0 => gateway_in3_net_x0,
d1 => logical3_y_net_x0,
y => logical3_y_net_x1
);
end structural;
library IEEE;
use IEEE.std_logic_1164.all;
use work.conv_pkg.all;
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);
227
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
228
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
port map (
ce => '0',
clk => '0',
clr => '0',
op => constant1_op_net
);
229
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
);
230
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
port map (
ce => '0',
clk => '0',
clr => '0',
d0 => constant1_op_net,
d1 => gateway_in3_net_x1,
y => logical17_y_net
);
231
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
232
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
ce => '0',
clk => '0',
clr => '0',
d0 => constant1_op_net,
d1 => gateway_in2_net_x1,
y => logical4_y_net
);
233
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
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;
234
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
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;
235
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
end structural;
library IEEE;
use IEEE.std_logic_1164.all;
use work.conv_pkg.all;
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;
begin
ce_1_sg_x3 <= ce_1;
clk_1_sg_x3 <= clk_1;
gateway_in_net <= gateway_in;
236
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
end structural;
237
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
238
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
REFERENCIAS:
1.http://www.cucei.udg.mx/~msruiz/comunicacion_movil/sesion2-3.pdf
2.http://www.rrppnet.com.ar/hiscomunicacion.htm
4.http://catarina.udlap.mx/u_dl_a/tales/documentos/lem/lopez_g_j/cap
itulo7.pdf
7. Patricio Lancellotti F,
http://www.federachi.cl/Comisiones/Tecnologica/radios_%20sofware.ht
m
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
239
IMPLEMENTACIÓN EN FPGA DE MÓDULOS DE SOFTWARE
PARA UN RADIO DEFINIDO POR SOFTWARE
13.http://www.electronicafacil.net/tutoriales/MODULACION-DIGITAL-
FSK-PSK-QAM.php
14. http://www.info-ab.uclm.es/asignaturas/42638/pdf/cap2.pdf
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
240