Advertisement
regzarr

LSIC - Frequency Divider

Nov 25th, 2024 (edited)
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module FrequencyDivider(
  2.     input clk_in,
  3.     input rst,
  4.     output reg clk_out
  5. );
  6.  
  7.     reg [4:0] counter;
  8.  
  9.     always @(posedge clk_in or negedge rst) begin
  10.         if (!rst) begin
  11.             counter <= 0;
  12.             clk_out <= 0;
  13.         end else begin
  14.             if (counter == 9) begin
  15.                 counter <= 0;
  16.                 clk_out <= ~clk_out;
  17.             end else begin
  18.                 counter <= counter + 1;
  19.             end
  20.         end
  21.     end
  22.  
  23. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement