Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

divide by n(5,7...) counter

Status
Not open for further replies.

logic_gate

Newbie level 1
Joined
Oct 3, 2006
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,289
hello,

can anyone please give me some idea about the divide by N(odd:5,7,9,11) counter. I need to design using verilog.

thanks
 

If you are looking for a generic solution then checkout
8254 chip documentation. If you need specific solution
then look for binary counter designs. eg. if you need divide by 5
design a counter which will count from 0 to 4 in bianary, generally
the MSB or second MSB of bianary counter will provide you the
required divided clk output.
Hope This help!
 

Here is the generic divided clock generated module!
This will generate nere 50% clock for odd value of divider
as in 8254.
Hope this helps!
Code:
module divider(
   // Outputs
   output_clk, 
   // Inputs
   clk, reset_n, divide
   );
   input clk, reset_n;
   output output_clk;
   input [7:0] divide;
   reg         output_clk;
   reg [7:0]   counter;
   wire        ld = (divide[0]) ?  ((output_clk) ?  (counter == 1) : (counter == 0))
                                           : (counter == 1);
   always @(posedge clk or negedge reset_n) begin
      if (!reset_n) begin
         counter <= 0;
         output_clk <= 1'b0;
      end else begin
         if (ld) begin
            output_clk <= ~output_clk ;
            counter <= {1'b0,divide[7:1]};
         end else
           counter <= counter - 1;
      end
   end      
endmodule // divider


module test();
   reg                  clk;       
   reg [7:0]            divide;    
   reg                  reset_n;   

   wire                 output_clk;
   divider divider(
                   // Outputs
                   .output_clk          (output_clk),
                   // Inputs
                   .clk                 (clk),
                   .reset_n             (reset_n),
                   .divide              (divide[7:0]));
   initial begin
      $dumpfile("wave.vcd");
      $dumpvars();
      clk = 0; reset_n = 0; divide = 5;
      #33 reset_n = 1;
      #500 divide = 10 
      #500 divide = 9;
      #500 divide = 11;
      #500 divide = 4; 
      #500 $finish;	
   end
   always #5 clk = ~clk;
endmodule // test
 

Please find the code here.
**broken link removed**
 

Here is a more analog+digital approach.

This is for a divide by 3 circuit
Double the frequency and divide by 6. Multiplying can be done with a RC circuit and a XOR gate. Divide by 6 with 3 flip-flops and a XOR gate.
This circuit will give a 50% duty cycle.

It can be done with the following circuit.
div3.jpg

To divide by 5, increase the amount of flip-flops to 5. For 7 ff's to 7 etc.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top