robertzhan
Newbie level 4

Dear all,
I'd like to make a routine to have a delay for PWM signal, about several microsecond, just like the hold on function. But it emerges the following error:
Error: VHDL error at soft_switching.vhd(70): can't infer register for signal "p01:counter[0]" because signal does not hold its value outside clock edge
I don't know why. Hope for your suggestions.
If it can't do like this, how to make a routine to realize the function of several us delay for the input PWM signal.
Thank you in advance.
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_unsigned.all;
-- Entity Declaration
ENTITY soft_switching IS
-- {{ALTERA_IO_BEGIN}} DO NOT REMOVE THIS LINE!
PORT
(
pwm : IN STD_LOGIC;
ilt : IN STD_LOGIC;
clk : IN STD_LOGIC;
pwm_delay : OUT STD_LOGIC;
tab : OUT STD_LOGIC;
tl : OUT STD_LOGIC
);
-- {{ALTERA_IO_END}} DO NOT REMOVE THIS LINE!
END soft_switching;
-- Architecture Body
ARCHITECTURE soft_switching_architecture OF soft_switching IS
--SIGNAL counter : integer := 0;
SIGNAL flag : bit;
SIGNAL pwm_temp : STD_LOGIC;
BEGIN
p01: process(clk,pwm) is
variable counter : integer :=0;
begin
case pwm is
when '1' =>
loop1: loop
if (clk'event AND clk = '1' AND clk'last_value = '0') then
counter := counter + 1;
end if;
exit loop1 when counter = 20;
END loop loop1;
pwm_delay <= '1';
counter := 0;
when '0' =>
loop2: loop
if (clk'event AND clk = '1' AND clk'last_value = '0') then
counter := counter + 1;
end if;
exit loop2 when counter = 20;
END loop loop2;
pwm_delay <= '0';
counter := 0;
end case;
end process p01;
END soft_switching_architecture;
I'd like to make a routine to have a delay for PWM signal, about several microsecond, just like the hold on function. But it emerges the following error:
Error: VHDL error at soft_switching.vhd(70): can't infer register for signal "p01:counter[0]" because signal does not hold its value outside clock edge
I don't know why. Hope for your suggestions.
If it can't do like this, how to make a routine to realize the function of several us delay for the input PWM signal.
Thank you in advance.
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_unsigned.all;
-- Entity Declaration
ENTITY soft_switching IS
-- {{ALTERA_IO_BEGIN}} DO NOT REMOVE THIS LINE!
PORT
(
pwm : IN STD_LOGIC;
ilt : IN STD_LOGIC;
clk : IN STD_LOGIC;
pwm_delay : OUT STD_LOGIC;
tab : OUT STD_LOGIC;
tl : OUT STD_LOGIC
);
-- {{ALTERA_IO_END}} DO NOT REMOVE THIS LINE!
END soft_switching;
-- Architecture Body
ARCHITECTURE soft_switching_architecture OF soft_switching IS
--SIGNAL counter : integer := 0;
SIGNAL flag : bit;
SIGNAL pwm_temp : STD_LOGIC;
BEGIN
p01: process(clk,pwm) is
variable counter : integer :=0;
begin
case pwm is
when '1' =>
loop1: loop
if (clk'event AND clk = '1' AND clk'last_value = '0') then
counter := counter + 1;
end if;
exit loop1 when counter = 20;
END loop loop1;
pwm_delay <= '1';
counter := 0;
when '0' =>
loop2: loop
if (clk'event AND clk = '1' AND clk'last_value = '0') then
counter := counter + 1;
end if;
exit loop2 when counter = 20;
END loop loop2;
pwm_delay <= '0';
counter := 0;
end case;
end process p01;
END soft_switching_architecture;