Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

Arbitrary binary counter that counts to 800 and resets to zero

Status
Not open for further replies.

raidfibre

Newbie level 1
Joined
Jan 14, 2006
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,290
I am attempting to make an arbitrary counter that can, for example, count to 800 and reset to zero. Do I want a counter with an asynchronous reset or __ ? I'm a little confused. I have one that works but when I synthesize it I get a message that I have a gated clock. I will post my code for that tomorrow (it's on my laptop). But if anyone has a quick couple of words for me I would appreciate it.
Thanks a lot
--
MK
 

neoaspilet11

Full Member level 5
Joined
Sep 29, 2005
Messages
277
Helped
29
Reputation
56
Reaction score
8
Trophy points
1,298
Location
Cebu, Philippines
Activity points
4,048
binary counter

Hi,
I think you mean a presettable binary counter. If your max count is 800 your counter must be at least 10 - bit wide to give you a maximum possible count of 2^10 - 1. If you want to reset the count at 800. make a combination logic at the counter ouputs such that it will give a reset signal when the count is 800. All you need to do is build a single bit binary counter and cascade it 10 times.

Hope this help
 

Black Jack

Full Member level 4
Joined
Dec 2, 2003
Messages
236
Helped
14
Reputation
28
Reaction score
3
Trophy points
1,298
Location
UKRAINE
Activity points
1,817
Re: binary counter

raidfibre said:
I am attempting to make an arbitrary counter that can, for example, count to 800 and reset to zero. Do I want a counter with an asynchronous reset or __ ? I'm a little confused. I have one that works but when I synthesize it I get a message that I have a gated clock. I will post my code for that tomorrow (it's on my laptop). But if anyone has a quick couple of words for me I would appreciate it.
Thanks a lot
--
MK
I think that projects must be synchronous as possible. So you need synchronous counter and comparator with DFF at output. Inputs A of Comparator connect with outputs of Counter. Inputs B of Comparator is (Constant-1). Output of DFF connect with Synchronous Reset of Counter.
 

echo47

Advanced Member level 5
Joined
Apr 7, 2002
Messages
3,942
Helped
636
Reputation
1,270
Reaction score
88
Trophy points
1,328
Location
USA
Activity points
33,183
binary counter

When using FPGA, try to do everything synchronously.

You didn't say what should happen after the counter resets to zero.
Here's a Verilog counter that endlessly counts 0 to 800, 0 to 800, etc.
Code:
module top (clk, count);
  input             clk;
  output reg  [9:0] count=0;

  always @ (posedge clk) begin
    count <= (count == 800) ? 0 : count + 1;
  end
endmodule
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top