Subversion Repositories pentevo

Rev

Blame | Last modification | View Log | Download | RSS feed | ?url?

  1. module pll28(
  2.     input   wire        clk,   // 28mhz
  3.     input   wire        rddat,
  4.     output  reg         rclk,
  5.     output  reg         rawr
  6.     );
  7.  
  8. reg [5:0] counter = 0;                    
  9. wire[5:0] delta = 27 - counter;
  10. wire[5:0] shift = { delta[5], delta[5], delta[4:1] }; // sign div
  11. wire[5:0] inc   = rawr_sr[1:0] == 2'b10 ? shift : 1;
  12.  
  13. reg [3:0] rawr_sr;
  14.  
  15. always @ (posedge clk)
  16. begin
  17.     rawr_sr <= { rawr_sr[2:0], rddat };
  18.     rawr <= !(rawr_sr[3] && !rawr_sr[0] ); // rawr 100ns
  19. end
  20.  
  21. always @ (posedge clk)
  22. begin              
  23.     if (counter < 55)
  24.         counter <= counter + inc;  
  25.     else          
  26.     begin            
  27.         counter <= 0;
  28.         rclk = ~rclk;  
  29.     end
  30.    
  31. end