我试图用VHDL(Xilinx ISE + ISim)中的Spartan 3e板卡生成皮秒PWM信号。VHDL-PWM奇怪的行为和物理上限/下限
library ieee;
use ieee.std_logic_1164.all;
entity pwm is
port(clk : in std_logic;
pwm_out : buffer std_logic);
end entity;
architecture rtl of pwm is
begin
process (clk)
variable count : integer range 0 to 50000;
variable duty_cycle : integer range 0 to 50000;
variable flag : integer range 0 to 1;
begin
if (rising_edge(clk)) then
count := count+1;
if (count = duty_cycle) then
pwm_out <= '1';
end if;
if (count = 50000) then
pwm_out <= '0';
count := 0;
if(flag = 0) then
duty_cycle := duty_cycle+50;
else
duty_cycle := duty_cycle-50;
end if;
if(duty_cycle = 50000) then
flag := 1;
elsif(duty_cycle = 0) then
flag := 0;
end if;
end if;
end if;
end process;
end rtl;
我使用全球时钟(C9)的嵌入式50Mhz,但仿真显示了一个奇怪的行为;从0ps到1000000ps,clk(时钟)和pwm_out(输出)似乎始终处于高电平状态,并且在ISim下的时域中的clk和pwm_out都没有1000000ps后。
我想要做的是调查和解决这种行为,然后增加输出频率(pwm_out)。另外,我想了解有多快(上升/下降时间和频率)可以产生脉冲(物理限制)。
我希望有经验的用户提供一些指导。
我想我发现了这个问题,在仿真中没有从C9提供的时钟,因此clk的状态总是相同的。仍在寻找增加频率的方法。 – y33t