测试方波的频率计
module pinlvji (clk, rst_n, wave, zhankongbi, pinlv);input clk;
input rst_n;
input wave;
output reg zhankongbi;
output reg pinlv;
reg t_low_count;
reg t_high_count;
reg t_low;
reg t_high;
reg state;
always @ (*)
begin
zhankongbi = 100*t_high/(t_high + t_low);
pinlv = 1_000_000_000/(t_high*10 + t_low*10);
end
always @ (posedge clk)
begin
if (rst_n == 0)
begin
t_low <= 0;
t_high <= 0;
t_low_count <= 0;
t_high_count <= 0;
state <= 0;
end
else
begin
case (state)
0 : begin
if (wave == 1)
begin
t_high_count <= t_high_count + 1;
state <= 0;
end
else
begin
t_high <= t_high_count;
t_high_count <= 0;
state <= 1;
end
end
1 : begin
if (wave == 0)
begin
t_low_count <= t_low_count + 1;
state <= 1;
end
else
begin
t_low_count <= 0;
t_low <= t_low_count;
state <= 0;
end
end
default : state <= 0;
endcase
end
end
endmodule 有什么问题,留言或者联系奋斗的小孩QQ:746833924 测试方波的频率计 测试方波的频率计 测试方波的频率计 感谢楼主分享 6
页:
[1]