SHARE
TWEET

Untitled

a guest Aug 18th, 2019 78 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 [$clog2(CLOCK_DIV_A) - 1:0] mTimeoutA;
  15.     bit mStateA;
  16.     assign oClockA = mStateA;
  17.     wire wTimedOutA = mTimeoutA == 64'd0;
  18.    
  19.     bit [$clog2(CLOCK_DIV_B) - 1:0] mTimeoutB;
  20.     bit mStateB;    
  21.     assign oClockB = mStateB;    
  22.     wire wTimedOutB = mTimeoutB == 64'd0;
  23.  
  24.     always @(posedge iClock, negedge iReset)
  25.     begin
  26.         if (iReset == '0)
  27.         begin
  28.             mTimeoutA <= CLOCK_DIV_A;
  29.             mStateA <= '0;
  30.             mTimeoutB <= CLOCK_DIV_B;                
  31.             mStateB <= '0;    
  32.  
  33.         end
  34.         else begin
  35.             if (wTimedOutA) begin
  36.                 mTimeoutA <= CLOCK_DIV_A;
  37.                 mStateA <= ~mStateA;
  38.             end
  39.             else begin
  40.                 mTimeoutA <= mTimeoutA - 64'd1;
  41.             end                                  
  42.            
  43.             if (wTimedOutB) begin
  44.                 mTimeoutB <= CLOCK_DIV_B;
  45.                 mStateB <= ~mStateB;
  46.             end
  47.             else begin
  48.                 mTimeoutB <= mTimeoutB - 64'd1;
  49.             end  
  50.         end              
  51.     end
  52.        
  53. endmodule
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top