原创 VHDL写的RTL级利用LCELL实现的延时环(记录)

2023-9-5 14:50 766 4 4 分类: FPGA/CPLD 文集: QuartusII
  1. LIBRARY IEEE;
  2. USE IEEE.STD_LOGIC_1164.ALL;
  3. ENTITY forced_delay IS
  4. GENERIC (N : INTEGER := 20); --number of forced delay buffers
  5. PORT (
  6. din : IN STD_LOGIC;
  7. dout : OUT STD_LOGIC);
  8. END forced_delay;
  9. ARCHITECTURE arch OF forced_delay IS
  10. SIGNAL a:STD_LOGIC_VECTOR (N downto 1);
  11. COMPONENT LCELL
  12. PORT (
  13. a_in : IN STD_LOGIC;
  14. a_out : OUT STD_LOGIC);
  15. END COMPONENT;
  16. BEGIN
  17. LC_1: LCELL PORT MAP(a_in=>din,a_out=>a(1));
  18. Gen_delay : FOR i in 1 to N-1 GENERATE
  19. LC : LCELL PORT MAP(a_in=>a(i),a_out=>a(i+1));
  20. END GENERATE;
  21. dout<=a(N);
  22. END arch;
---------------------------------------------------------------------------
这是另一种写法:
  1. LIBRARY ieee;
  2. USE ieee.std_logic_1164.all;
  3. ENTITY pd IS
  4. PORT
  5. (
  6. pulse :in std_logic;
  7. pulse_d :out std_logic
  8. );
  9. end pd;
  10. architecture beha of pd is
  11. -- N gives the pulse delay multiplier. pulse_delay = N*lcell_delay
  12. -- N must be adjusted to be coherent to pulse_delay desired and lcell_delay of using device
  13. -- logic cell delay can be found in device performance documentation
  14. constant N : integer := 17;
  15. -- lcell array with N elements
  16. signal delay_line: std_logic_vector(N-1 downto 0);
  17. -- these attributes force synthesizer to keep our buffer alone
  18. -- this ensures that delay is the expected
  19. attribute keep: boolean;
  20. attribute keep of delay_line: signal is true;
  21. begin
  22. gen_delay:
  23. for i IN 1 TO N-1 generate
  24. delay_line(i) <= delay_line(i-1);
  25. end generate;
  26. delay_line(0) <= pulse;
  27. pulse_d <= delay_line(N-1);
  28. end beha;
PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
4
关闭 站长推荐上一条 /1 下一条