Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module DualClockDivider(
  2.     input wire iReset,
  3.     input wire iClock,
  4.     output bit oClockA,
  5.     output bit oClockB);
  6.    
  7.     parameter CLOCK_OUT_A = 64'd15;
  8.     parameter CLOCK_OUT_B = 64'd1;
  9.     parameter CLOCK_INPUT = 64'd100000000;
  10.    
  11.     parameter CLOCK_DIV_A = CLOCK_INPUT / (CLOCK_OUT_A*64'd2);
  12.     parameter CLOCK_DIV_B = CLOCK_INPUT / (CLOCK_OUT_B*64'd2);
  13.        
  14.     bit [63:0] mTimeoutA = CLOCK_DIV_A;
  15.     bit [63:0] mTimeoutB = CLOCK_DIV_B;
  16.     bit mStateA = '0;
  17.     bit mStateB = '0;
  18.    
  19.     assign oClockA = mStateA;
  20.     assign oClockB = mStateB;
  21.  
  22.     always @(posedge iClock)
  23.     begin
  24.         if (iReset == '0)
  25.         begin
  26.             mTimeoutA <= CLOCK_DIV_A;
  27.             mTimeoutB <= CLOCK_DIV_B;                
  28.             mStateA <= '0;
  29.             mStateB <= '0;
  30.         end
  31.         else begin      
  32.             if (mTimeoutA == 64'd0) begin
  33.                 mStateA <= ~mStateA;
  34.                 mTimeoutA <= CLOCK_DIV_A;
  35.             end
  36.             else begin
  37.                 mTimeoutA <= mTimeoutA - 64'd1;
  38.             end                                  
  39.            
  40.             if (mTimeoutB == 64'd0) begin
  41.                 mStateB <= ~mStateB;
  42.                 mTimeoutB <= CLOCK_DIV_B;
  43.             end
  44.             else begin
  45.                 mTimeoutB <= mTimeoutB - 64'd1;
  46.             end  
  47.         end                                
  48.     end
  49.        
  50. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement