Forum Discussion
Altera_Forum
Honored Contributor
8 years agoThis is the one with errors. If you guys read the errors it seems to be pretty clear that it is an error with arcsin function and the real number calculus, but if you compare the codes they have the same calculus and the only changes are the variables in the process. I do not know what I am doing wrong in this code. Please any help would be apreciate it.
Here are is the code:
library ieee;
use ieee.std_logic_1164.all;
use ieee.math_real.all;
use ieee.numeric_std.all;
entity estimulador is
port(--load: in std_logic;
--done,estado_prueba: out bit;
--datos: in std_logic_vector(7 downto 0);
clk: in std_logic;
salida: out unsigned (7 downto 0));
end estimulador;
architecture estimulador_arch of estimulador is
TYPE ROM IS ARRAY(0 TO 169) OF unsigned(7 DOWNTO 0);
TYPE LED IS ARRAY(0 TO 7) OF integer;
TYPE FRECUENCIA_REAL IS ARRAY(0 TO 13) OF real;
TYPE SINUSOIDE IS ARRAY(0 TO 167) OF integer;
constant num_led:LED:=(18,36,54,72,94,116,140,168);
constant freq_prueba:FRECUENCIA_REAL:=(0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5);
constant uno: unsigned:="00000001";
signal seudo_salida: unsigned(7 downto 0);
constant freq_proc: real:=1000000.0;
--------------------------------------------------------------------------
-------------------- FUNCTION FOR CREATING A ROM -------------------------
FUNCTION INIT_ROM RETURN ROM IS
VARIABLE romvar: ROM;
variable suma_salida: unsigned (7 downto 0):=(others => '0');
begin
for i in ROM'range loop
romvar(i):= suma_salida;
suma_salida:= suma_salida + uno;
end loop;
return romvar;
end;
--------------------------------------------------------------------------
CONSTANT rom_salida: ROM := INIT_ROM;
--------------------------------------------------------------------------
-------------- FUNCTION FOR READING FROM THE ROM CREATED -----------------
FUNCTION LEER_ROM (cont: integer) RETURN unsigned IS
variable salidat: unsigned(7 downto 0);
begin
salidat:= rom_salida(cont);
return salidat;
end;
--------------------------------------------------------------------------
---------- FUNCTION FOR CREATING AN ARRAY OF VALUES ----------------------
----------------- FOR THE SINUSOIDAL PATTERN -----------------------------
FUNCTION SIN_INIT (amplitud,frecuencia:integer) RETURN SINUSOIDE IS
variable tabla_sin:SINUSOIDE;
variable cantidad_led:integer:=num_led(amplitud);
variable cantidad_frec:real:=freq_prueba(frecuencia);
variable limite:integer:=cantidad_led/2-1;
variable calculo, diferencia:integer:=0;
begin
for i in 0 to limite loop
calculo:=integer((arcsin(real(i+1)/real(cantidad_led/2))/(2.0 * MATH_PI * cantidad_frec))*freq_proc);
tabla_sin(i):=calculo-diferencia;
tabla_sin(cantidad_led-1-i):=calculo-diferencia;
diferencia:=calculo;
end loop;
if(cantidad_led<168) then
for k in cantidad_led to 167 loop
tabla_sin(k):=0;
end loop;
end if;
return tabla_sin;
end;
-------------------------------------------------------------------------
signal sentido: boolean:=true;
signal seudodatos1: std_logic_vector(7 downto 0):="00000100";
signal seudodatos2: std_logic_vector(7 downto 0):="00000001";
signal seudodatos3: std_logic_vector(7 downto 0):="10000000";
signal comandos: std_logic_vector(7 downto 0);
begin
-- body of the architecture
PROCESS(clk)
variable amplitud_bit: std_logic_vector(2 downto 0);
variable frecuencia_bit: std_logic_vector(3 downto 0);
variable tipo_comando, tipo_prueba: std_logic_vector(1 downto 0);
variable mostrar, cnt, cnt_sac, recorrido, contador_sin: integer:=0;
variable paso_led, cant_led, offset, centro: integer;
variable primeravez: boolean:=true;
variable tabla_sinusoide:SINUSOIDE;
variable numero_led, frecuencia_prueba:integer;
variable contador_tramas: integer range 0 to 4;
begin
if(rising_edge(clk)) then
if(contador_tramas=0) then comandos<=seudodatos1;
elsif(contador_tramas=1) then comandos<=seudodatos2;
else comandos<=seudodatos3;
end if;
tipo_comando:=comandos(7)&comandos(0);
if(tipo_comando="00") then
contador_tramas:=1;
tipo_prueba:= seudodatos1(6)&seudodatos1(5);
amplitud_bit:= seudodatos1(4)&seudodatos1(3)&seudodatos1(2);
elsif(tipo_comando="01") then
contador_tramas:=2;
frecuencia_bit:= seudodatos2(6)&seudodatos2(5)&seudodatos2(4)&seudodatos2(3);
numero_led:=to_integer(unsigned(amplitud_bit));
frecuencia_prueba:=to_integer(unsigned(frecuencia_bit));
if(tipo_prueba="10") then
tabla_sinusoide:=SIN_INIT(numero_led,frecuencia_prueba);
contador_sin:=0;
paso_led:=tabla_sinusoide(contador_sin);
else
null;
-- I check some parameters in here. I "null it" for this publication because does not worth to analyze them
end if;
cant_led:=num_led(numero_led);
recorrido:=cant_led/2;
offset:=84;
centro:=84;
elsif(tipo_comando="10") then
cnt:=cnt+1;
if(cnt=paso_led) then
cnt:=0;
CASE tipo_prueba IS
WHEN "00" => null;
-- I check some parameters in here. I "null it" for this publication because does not worth to analyze them
WHEN "01" => null;
-- I check some parameters in here. I "null it" for this publication because does not worth to analyze them
WHEN OTHERS=>if(sentido=true) then
offset:=offset+1;
if(offset=centro+recorrido) then sentido<=false;
end if;
elsif(sentido=false) then
offset:=offset-1;
if(offset=centro-recorrido) then sentido<=true;
end if;
end if;
contador_sin:=contador_sin+1;
if(contador_sin=cant_led) then
contador_sin:=0;
end if;
paso_led:=tabla_sinusoide(contador_sin);
end CASE;
end if;
seudo_salida<= LEER_ROM(offset);
end if;
end if;
end process;
salida<=seudo_salida;
end estimulador_arch;
These are the errors: Error (10414): VHDL Unsupported Feature error at estimulador.vhd(73): cannot synthesize non-constant real objects or values. Error (10658): VHDL Operator error at estimulador.vhd(73): failed to evaluate call to operator ""/"" Error (10346): VHDL error at math_real.vhd(3302): formal port or parameter "X" must have actual or default value Error (10657): VHDL Subprogram error at estimulador.vhd(73): failed to elaborate call to subprogram "ARCSIN" Error (10658): VHDL Operator error at estimulador.vhd(73): failed to evaluate call to operator ""*"" Error (10657): VHDL Subprogram error at estimulador.vhd(128): failed to elaborate call to subprogram "SIN_INIT" Error (12152): Can't elaborate user hierarchy "estimulador:inst"