Advertisement
Guest User

clock_3

a guest
May 3rd, 2015
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module divisor_3(clk,clk_out);
  2.  
  3.  input clk;
  4.  output reg clk_out=0;
  5.  reg [1:0] Count;
  6.  reg [1:0] a=0;
  7.  
  8.  always@(*)begin
  9.  if (Count<2'b10)
  10.   a=Count+1;
  11.  else
  12.  a=0;
  13.  end
  14.  
  15.  
  16.  always@(posedge clk)begin
  17.   Count<=a;
  18.  end
  19.  
  20.  always@(posedge clk)begin
  21.   if (Count==2'b10)
  22.    clk_out<=~clk_out;
  23.   else
  24.    clk_out<=clk_out;
  25.   end
  26.  
  27.  
  28.  
  29. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement