找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 65|回复: 0

[求助] 问一个关于dpll的问题

[复制链接]

17

主题

0

回帖

95

积分

实习生

积分
95
发表于 2024-3-27 08:43:26 | 显示全部楼层 |阅读模式
在其他论坛上下了一个有问题的dpll程序,由于以前没有设计过pll,所以现在连port的意义及用处都不明白,所以想请各位介绍一下,谢谢。
程序如下:
  1. Library ieee;
  2. use IEEE.std_logic_1164.all;
  3. use IEEE.std_logic_arith.all;
  4. use IEEE.std_logic_unsigned.all;
  5. entity dpll is
  6.   port(
  7.     datain:   in  std_logic;            -- raw data input
  8.     clock:    in  std_logic;            -- 64*bit clock
  9.     rx_clock: out std_logic;            -- recovered rx clock
  10.     dataout:  out std_logic;            -- received data output
  11.     clrdcd:   in  std_logic;            -- clear dcd when 8 ones are detected in hdlcdec
  12.     dcd:      out std_logic);           -- data carrier detect output
  13. end dpll;
  14. architecture behaviour of dpll is
  15.   signal counter: std_logic_vector(4 downto 0);   -- counter 0..31
  16.   signal dcd_cntr: std_logic_vector(5 downto 0);  -- counter 0..127
  17.   signal edge: std_logic;                         -- edge detector output: data decision changed
  18.   signal dly_data: std_logic;                     -- delayed data for edge detector
  19.   signal ql: std_logic;                           -- late clock
  20.   signal qe: std_logic;                           -- early clock
  21.   signal enable: std_logic;                       -- gets toggled every clock or when clock has to be adjusted
  22.   signal increment: std_logic;
  23.   signal decrement: std_logic;
  24.   signal clear_dcd: std_logic;
  25.   signal reset_dcd: std_logic;
  26. begin
  27. --
  28. -- recovered rx clock for followning stages
  29. --
  30. rx_clock <= counter(4);
  31. process(clock,clrdcd,reset_dcd)
  32. begin
  33.   if (clock'event and clock='1' ) then
  34.     clear_dcd <= reset_dcd or clrdcd;
  35.   end if;
  36. end process;
  37. --
  38. -- clock in new data
  39. --
  40. process(clock,datain)
  41. begin
  42.   if (clock'event and clock='1' ) then
  43.     dataout <= datain;
  44.   end if;
  45. end process;
  46. --
  47. -- rx clock counter
  48. --
  49. process(clock,enable,clrdcd)
  50.   begin
  51. --if ( clrdcd='1') then                      -- reset for illegal data at hdlcdec
  52. --    counter <= (others => '0');
  53.   if (clock'event and clock='1' ) then
  54.     if (enable='1') then
  55.       counter <= counter+1;                  -- increase counter
  56.     else
  57.       counter <= counter;     
  58.     end if;  
  59.   end if;
  60. end process;
  61. --
  62. -- set early and late clocks
  63. --
  64. process(counter)
  65. begin
  66. if (counter="10000" or counter ="01111" ) then
  67.     ql <= '0';
  68.     qe <= '0';
  69.   elsif (counter(4)='1') then  -- late clock when counter > 32
  70.     ql <= '1';
  71.     qe <= '0';
  72.   else
  73.     ql <= '0';                 -- early clock when counter < 31
  74.     qe <= '1';
  75. end if;
  76. end process;
  77. --
  78. -- adjst rx clock
  79. -- this is done by changing the enable signal for the rx clock counter
  80. -- enable gets toggled every clock event. It gets set additionally when
  81. -- the clock counter should be incremented and cleared when clock should
  82. -- be decremented.
  83. --
  84. process(clock,enable,clrdcd)
  85.   begin
  86. --  if ( clrdcd='1') then
  87. --    enable<='0';
  88. --    increment <='0';
  89. --    decrement <='0';
  90.   if (clock'event and clock='1') then
  91.     if (qe='1' and edge='1') then
  92.       increment <='1';                      -- increment clock when edge detect
  93.     end if;                                 -- during early clock
  94.     if (ql='1' and edge='1') then
  95.       decrement <='1';                      -- decrement clock when edge detect
  96.     end if;                                 -- during late clock
  97.     if (enable ='1') then
  98.       if (increment ='1') then
  99.         increment <='0';                    -- clear after one increment step
  100.         enable <='1';
  101.       else
  102.         enable <='0';
  103.       end if;
  104.     else
  105.       if (decrement ='1') then
  106.         decrement<='0';                     -- clear after one decrement step
  107.         enable <= '0';
  108.       else
  109.         enable <='1';      
  110.       end if;  
  111.     end if;  
  112.   end if;
  113. end process;
  114. --
  115. -- dcd detection
  116. --
  117. process(clock,edge,counter,clear_dcd)
  118. begin
  119.   if ( clear_dcd='1') then
  120.     dcd_cntr<= (others => '0');   
  121.     dcd <= '0';
  122.     reset_dcd <='0';
  123.   elsif (counter(4)'event and counter(4)='0') then  
  124.     if ( edge='0' ) then                    -- sample at rising edge, if no data change increase counter
  125.       if (dcd_cntr = 63) then
  126.         dcd <= '1';                         -- assert dcd if dcd counter is at max
  127.         dcd_cntr <= dcd_cntr;
  128.       else
  129.         dcd <= '0';
  130.         dcd_cntr <= dcd_cntr+1;
  131.       end if;      
  132.     else
  133.       reset_dcd <='1';
  134.     end if;
  135.   end if;
  136. end process;
  137. --
  138. -- edge detector, input data has changed
  139. --
  140. process(clock,datain)
  141.   begin
  142.     if (clock'event and clock='1') then
  143.       edge <= dly_data xor datain;
  144.       dly_data <= datain;
  145.     end if;
  146. end process;
  147. end behaviour;
复制代码
EDA1024论坛免责声明
请勿上传侵权资料及软件! 如果发现资料侵权请及时联系,联系邮件: fenxin@fenchip.com QQ: 2322712906. 我们将在最短时间内删除。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|EDA1024技术论坛

GMT+8, 2024-5-3 02:50 , Processed in 0.041181 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表