欲檢測所述串行數據信號(DIN)的邊緣。我已經寫下面的代碼在其被成功運行VHDL但具有一個時鐘週期的延遲被檢測的邊緣即改變輸出與在每個邊緣一個clk_50mhz週期延遲產生的。任何人都可以幫助我毫不遲疑地檢測邊緣。謝謝。VHDL邊緣檢測
process (clk_50mhz)
begin
if clk_50mhz'event and clk_50mhz = '1' then
if (rst = '0') then
shift_reg <= (others => '0');
else
shift_reg(1) <= shift_reg(0);
shift_reg(0) <= din;
end if;
end if;
end process;
process (clk_50mhz)
begin
if clk_50mhz'event and clk_50mhz = '1' then
if rst = '0' then
change <= '0' ;
elsif(clk_enable_2mhz = '1') then
change <= shift_reg(0) xor shift_reg(1);
end if ;
end if ;
end process ;
當我改變了我的代碼下面我能夠檢測邊緣
process (clk_50mhz)
begin
if clk_50mhz'event and clk_50mhz = '1' then
if (RST = '0') then
shift_reg <= (others=>'0');
else
shift_reg(1) <= shift_reg(0);
shift_reg(0) <= din;
end if;
end if;
end process;
change <= shift_reg(1) xor din;
請注意,該頁面上提供的解決方案是用於檢測上升沿或下降沿,但不是兩者。 –
謝謝你的代碼Passepartout。我想檢測上升沿和下降沿。當我實現你所建議的din_delayed1與din相同的代碼時,所以沒有改變。 – user24883
你是什麼意思din_delayed1與din相同?它們相隔1個時鐘週期。 – Passepartout