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.

Help: anyone can post me counter in verilog

Status
Not open for further replies.

choonlle

Full Member level 2
Joined
Jul 18, 2006
Messages
126
Helped
20
Reputation
40
Reaction score
1
Trophy points
1,298
Location
AFRICA
Activity points
2,025
i need 2 digit counter
00 until 99 and repeat
using state machine...with RTL



Thanks



By,
cllee
 

Here it goes!! For this simple counter No need to have Statemachine!


Code:
module bcd_count(clk, reset, ce, count);
   input clk, reset;
   input ce;  // count enable 
   output [7:0] count; // two digit bcd counter
   reg [7:0] count;

   always @(posedge clk or posedge reset) begin
      if (reset) begin
         count <= 7'h00;
      end else begin
         if (ce)
           if (count[3:0] == 9) begin
              count[3:0] <= 0;
              if (count[7:4] == 9)
                count[7:4] <= 0;
              else
                count[7:4] <= count[7:4] + 1;
           end else begin
              count[3:0] <= count[3:0] + 1;
           end
      end // else: !if(reset)
   end // always @ (posedge clk or posedge reset)
endmodule // bcd_count
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top