我已经编写了VHDL代码以生成0.8 us的脉冲。我的输入时钟是50Mhz。现在我想延迟2个脉冲
entity singlepulse is
Port ( clk : in STD_LOGIC;
Rst : in STD_LOGIC;
P_out : out STD_LOGIC);
end singlepulse;
architecture Behavioral of singlepulse is
signal count : Integer range 0 to 1000000000;
begin
process(clk, rst)
begin
if (rst = '1') then
P_out <= '0';
count <= 0;
elsif (rising_edge(clk)) then
count <= count + 1;
if (count < 40) then
P_out <= '1';
else
p_out <= '0';
end if;
elsif (falling_edge(clk)) then
if (count <= 40) then
p_out <= '1';
else
p_out <= '0';
end if;
end if;
end process;
end Behavioral;
我想给这个产生的0.8 us脉冲延迟2 us。但我不知道从哪里开始以及如何开始。
如果这很愚蠢,请原谅我,这是我在vhdl中的第三天,希望能对您有所帮助。
答案 0 :(得分:1)
在注释中注意到,您的代码中存在几个问题:
如果要在复位释放后给我们2个脉冲,则只需在计数器介于100和140之间时提高输出即可:
architecture Behavioral of singlepulse is
signal count : Integer range 0 to 1000000000;
begin
process(clk, rst)
begin
if (rst = '1') then
p_out <= '0';
count <= 0;
elsif (rising_edge(clk)) then
if (count < 100) then -- Wait 2 us
count <= count + 1;
p_out <= '0';
elsif (count < 140) then -- Pulse of 0.8 us
count <= count + 1;
p_out <= '1';
else -- Stop incrementing counter to avoid new pulse
p_out <= '0';
end if;
end process;
end Behavioral;