Altera_Forum
Honored Contributor
13 years agofrequency to voltage converter
Hey everyone,
I wrote a frequency to voltage converter and implementing it on a Altera Cyclone FPGA board( with an 64Mhz internal clock) It works perfectly until it reaches 32 Mhz, at 32 Mhz it starts to countdown( decreasing instead of increasing) Can someone please explain this weird thing? module measure( input wire signed [11:0] in, input clk, output wire signed [13:0] f ); reg [15:0] in_count; reg [15:0] out_count; reg [15:0] clk_count; reg clk_complete; initial begin in_count=16'b0000000000000000; out_count=16'b0000000000000000; clk_count=16'b0000000000000000; clk_complete=1'b0; end assign f[13:0]=({1'b0,out_count[15:5]}); always @(posedge clk) begin clk_count=clk_count+16'b0000000000000001; clk_complete=1'b0; if (clk_count==16'b1111111111111111) begin out_count<=in_count; clk_count<=16'b0000000000000000; clk_complete<=1'b1; end end always@ (posedge clk_complete or posedge in[11]) begin if (clk_complete==1'b1) begin in_count<=16'b0000000000000000; end else begin in_count<=in_count+16'b0000000000000001; end end endmodule Thanks in advance