1/1
jaak
by jaak.fierens on Dec 4, 2011 |
jaak.fierens
Posts: 2 Joined: Nov 11, 2009 Last seen: Nov 11, 2012 |
||
I want to measure the frequency of a signal in verilog. How must I do it?
|
RE: jaak
by ragu on Dec 9, 2011 |
ragu
Posts: 29 Joined: Sep 12, 2011 Last seen: Sep 8, 2014 |
||
check below link its helpful to you.
http://vhdlguru.blogspot.com/2010/09/measure-time-periodfrequency-of-input.html |
RE: jaak
by jaak.fierens on Dec 12, 2011 |
jaak.fierens
Posts: 2 Joined: Nov 11, 2009 Last seen: Nov 11, 2012 |
||
Thanks a lot! I translated the file in verilog to measure frequency's between 1kHz and 5kHz. The main clock of my digilent board is 5O MHz. I don't use the error code, because the in_clock frequency won't be greater than the main clock.
module METING( input in_clock, input clk50M, input reset, output wire LED1, output wire LED2, output wire LED3, output wire LED4 ); reg [15:0] cnt; reg [15:0] p_cnt; reg [15:0] f_measurment; always @ (posedge clk50M) begin cnt if (reset) begin cnt end end always @ (posedge in_clock) begin if (p_cnt f_measurment end if (p_cnt > cnt) begin f_measurment end p_cnt end assign LED1 = (f_measurment>12000) ? 1 : 0; assign LED2 = (f_measurment>16000) ? 1 : 0; assign LED3 = (f_measurment>24000) ? 1 : 0; assign LED4 = (f_measurment>48000) ? 1 : 0; endmodule |
1/1