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.

Counter design problem !

Status
Not open for further replies.

hillten

Newbie level 3
Joined
Mar 10, 2006
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,302
Hi ! I am Hillten.

I want to design a large counter and it is compose from small counters (like 4-bit).

And I use two of the 4-bit counter, use first counter’s carry signal to enable next counter. But why it was increase at next clock. Please help me, Thanks!

The document is the simulation waveform and source code.
 

Generate carry one clk before will solve ur problem!
Here is an example...
Code:
module counter (
   // Outputs
   count, cy,
   // Inputs
   clk, reset_n, en
   );
   input clk, reset_n;
   input en;
   output [7:0] count;
   output       cy;
   count4 count4_0 (
                    // Outputs
                    .count              (count[3:0]),
                    .cy                 (cy_int),
                    // Inputs
                    .clk                (clk),
                    .reset_n            (reset_n),
                    .en                 (1'b1));
   count4 count4_1 (
                    // Outputs
                    .count              (count[7:4]),
                    .cy                 (cy),
                    // Inputs
                    .clk                (clk),
                    .reset_n            (reset_n),
                    .en                 (cy_int));   
endmodule // counter


module count4 (
   // Outputs
   count, cy,
   // Inputs
   clk, reset_n, en
   );
   input clk, reset_n;
   input en;
   output [3:0] count;
   output       cy;
   
   reg [3:0] count;
   assign    cy = &count;
   
   always @(posedge clk or negedge reset_n) begin
      if (!reset_n)
        count <= 0;
      else
        if (en)
          count <= count + 1;
   end
endmodule // count4
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top