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.

a verilog program to count the number of pulses within a time interval

Status
Not open for further replies.

shalu mariya

Newbie level 3
Joined
Dec 6, 2012
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,300
hi...every one...
can anyone help me with a verilog program for counting the number of pulses within a particular time period??say 1 ms..actully i am working on an encoder and i wanted to count its pulses to calculate the speed of my dc motor....
thank you
 

Can't give you the code, but the algorithm is pretty straight forward.

Have a timer give you a 1 ms wide pulse. Use that pulse as the enable signal for a counter; when the enable goes high, start counting; when the enable goes low, you've got your answer.
 
Can't give you the code, but the algorithm is pretty straight forward.

Have a timer give you a 1 ms wide pulse. Use that pulse as the enable signal for a counter; when the enable goes high, start counting; when the enable goes low, you've got your answer.

thank you so much sir...that was really helpful....:smile::smile:
the following program was the one i created for a 50MHz FPGA .


"module first_counter(
clock,
reset,
counter_out);
input clock;
input reset;
output [7:0] counter_out;
integer a=50000;

wire clock;
wire reset;
reg [7:0] counter_out;
always@(posedge clock)
begin
a=a-1;
if(a!=1'b0)
begin
if( reset==1'b1)
begin
counter_out<=#1 8'b00000000;
end
else
begin
counter_out<=#1 counter_out+1;
end
end
else
a<=50000
end
endmodule"

could you please verify the code...
thankyou
 

Hi,

the Verilog code you wrote will just count up at each rising edge of the 'clock' signal, irrespective of the frequency of the 'clock' waveform. Is this what you want? Your question seems a little bit different, isn't it?

Cheers
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top