Counter

Joined
May 10, 2007
Messages
2
Reaction score
0
Hello
I am new in writing VHDL code, and i need to write a code for a Counter thats work this way:
1. the counter take as input a number (X) between 0 and 2400
2. the counter has another clk input, and the counter count the Clk pulses
3. the counter check
if (clk pulses < number x)
stay HIGH
if (Clk pulses >= number x)
change to LOW
if (Clk Pulses = 2400)
reset Clk Pulses and change to HIGH
4. The counter should do this action nonstop
one more question: how can i count Clk pulses?
Thanks
Amirster
 
Last edited:
Joined
Jun 7, 2007
Messages
1
Reaction score
0
this does what you want

module counter(X, clk, reset, Q);
input [11:0] X;
input clk;
input reset;
output [11:0] Q;
reg [11:0] Q;
reg [11:0] q_int;
integer count;

always @(posedge clk) begin
count = count + 1;
if(reset) q_int <= 0;
else q_int <= q_int + 1;
end

always @(q_int)
begin
if(q_int == X) level = LOW;
end
endmodule


1. the counter take as input a number (X) between 0 and 2400
2. the counter has another clk input, and the counter count the Clk pulses
3. the counter check
if (clk pulses < number x)
stay HIGH
if (Clk pulses >= number x)
change to LOW
if (Clk Pulses = 2400)
reset Clk Pulses and change to HIGH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top