Altera_Forum
Honored Contributor
13 years agoVHDL problem: inputs and constants
Hi all,
I've a problem in VHDL. This code runs correctly:
library IEEE;
use IEEE.std_logic_1164.all;
entity CLOCK_SIM is
generic
(
constant FREQ : integer:=10000000;
constant DUTY : integer:=50
);
port
(
enable : in STD_LOGIC;
output : out STD_LOGIC
);
end CLOCK_SIM;
architecture CLOCK_SIM_ARCH of CLOCK_SIM is
begin
-- Processo principale
MainProcess : process
constant RDUTY : real:=real(DUTY)/100.0;
constant TCLKH : time:=1 sec*((1.0/real(FREQ))*RDUTY);
constant TCLKL : time:=1 sec*((1.0/real(FREQ))*(1.0-RDUTY));
begin
if enable='1' then
output<='1';
wait for TCLKH;
output<='0';
wait for TCLKL;
else
wait until enable='1';
end if;
end process MainProcess;
end CLOCK_SIM_ARCH;
but if I make a constant like an input:
library IEEE;
use IEEE.std_logic_1164.all;
entity pwm_DC is
generic
(
--constant FREQ : integer:=1000000;
constant DUTY : integer:=50
);
port
(
f : in integer;
enable : in STD_LOGIC;
output : out STD_LOGIC
);
end pwm_DC;
architecture pwm_DC_arch of pwm_DC is
signal FREQ : integer;
begin
FREQ <= f;
-- Processo principale
MainProcess : process
constant RDUTY : real:=real(DUTY)/100.0;
constant TCLKH : time:=1 sec*((1.0/real(FREQ))*RDUTY);
constant TCLKL : time:=1 sec*((1.0/real(FREQ))*(1.0-RDUTY));
begin
if enable='1' then
output<='1';
wait for TCLKH;
output<='0';
wait for TCLKL;
else
wait until enable='1';
end if;
end process MainProcess;
end pwm_DC_arch;
this is the error: # ** error: (vsim-3601) iteration limit reached at time 7 us. Can anyone help me?