AG32VF407 AGRV2K Verilog双边沿检测输出方波
<div class='showpostmsg'><article data-content="[{"type":"block","id":"igen-1692419794929","name":"paragraph","data":{},"nodes":[{"type":"text","id":"JrSJ-1692419794930","leaves":[{"text":"本次使用使用AG32VF407开发板中的FPGA,使用双clk的双边沿进行检测,同步输出方波","marks":[]}]}],"state":{}},{"type":"block","id":"hdgQ-1692419926915","name":"paragraph","data":{},"nodes":[{"type":"text","id":"vZuy-1692419926914","leaves":[{"text":"同时可以根据输出的方波检测clk的频率,以及双clk的相位关系,如下为verilog代码","marks":[]}]}],"state":{}},{"type":"block","id":"PX1Y-1692419794928","name":"code","data":{"language":"","theme":"default","wrap":false},"nodes":[{"type":"block","id":"0LDi-1692419794927","name":"code-line","data":{},"nodes":[{"type":"text","id":"Mi5o-1692419794926","leaves":[{"text":"`timescale 1ns / 1ns\r","marks":[]}]}]},{"type":"block","id":"KaXc-1692419795217","name":"code-line","data":{},"nodes":[{"type":"text","id":"g4Ps-1692419795216","leaves":[{"text":"\r","marks":[]}]}]},{"type":"block","id":"4NVL-1692419795219","name":"code-line","data":{},"nodes":[{"type":"text","id":"4xR9-1692419795218","leaves":[{"text":"module test(clk,ledout,pinout);\r","marks":[]}]}]},{"type":"block","id":"JnA4-1692419795221","name":"code-line","data":{},"nodes":[{"type":"text","id":"oGi3-1692419795220","leaves":[{"text":"\r","marks":[]}]}]},{"type":"block","id":"Ky0K-1692419795223","name":"code-line","data":{},"nodes":[{"type":"text","id":"58eO-1692419795222","leaves":[{"text":"input\tclk;\r","marks":[]}]}]},{"type":"block","id":"F67Y-1692419795225","name":"code-line","data":{},"nodes":[{"type":"text","id":"SAxJ-1692419795224","leaves":[{"text":"output ledout;\r","marks":[]}]}]},{"type":"block","id":"FfHr-1692419795227","name":"code-line","data":{},"nodes":[{"type":"text","id":"JsoK-1692419795226","leaves":[{"text":"reg ledout;\r","marks":[]}]}]},{"type":"block","id":"0KEC-1692419795229","name":"code-line","data":{},"nodes":[{"type":"text","id":"2QSc-1692419795228","leaves":[{"text":"output pinout;\r","marks":[]}]}]},{"type":"block","id":"M23K-1692419795231","name":"code-line","data":{},"nodes":[{"type":"text","id":"QcTx-1692419795230","leaves":[{"text":"\r","marks":[]}]}]},{"type":"block","id":"vZkm-1692419795233","name":"code-line","data":{},"nodes":[{"type":"text","id":"4tSg-1692419795232","leaves":[{"text":"pll\tpll1_inst (\r","marks":[]}]}]},{"type":"block","id":"ytCS-1692419795235","name":"code-line","data":{},"nodes":[{"type":"text","id":"9CYn-1692419795234","leaves":[{"text":"\t.areset ( 1'b0 ),\r","marks":[]}]}]},{"type":"block","id":"PeuR-1692419795237","name":"code-line","data":{},"nodes":[{"type":"text","id":"0eXT-1692419795236","leaves":[{"text":"\t.inclk0 ( clk ),\r","marks":[]}]}]},{"type":"block","id":"jYk2-1692419795239","name":"code-line","data":{},"nodes":[{"type":"text","id":"NjPQ-1692419795238","leaves":[{"text":"\t.c0 ( c0 ),\r","marks":[]}]}]},{"type":"block","id":"n70G-1692419795241","name":"code-line","data":{},"nodes":[{"type":"text","id":"ydHG-1692419795240","leaves":[{"text":"\t.c1 ( c1 )\r","marks":[]}]}]},{"type":"block","id":"m09Q-1692419795243","name":"code-line","data":{},"nodes":[{"type":"text","id":"GH4m-1692419795242","leaves":[{"text":"\t);\r","marks":[]}]}]},{"type":"block","id":"vCn9-1692419795245","name":"code-line","data":{},"nodes":[{"type":"text","id":"CLqz-1692419795244","leaves":[{"text":"\r","marks":[]}]}]},{"type":"block","id":"Ob7T-1692419795247","name":"code-line","data":{},"nodes":[{"type":"text","id":"CXr0-1692419795246","leaves":[{"text":"wire c0;\r","marks":[]}]}]},{"type":"block","id":"SUHD-1692419795249","name":"code-line","data":{},"nodes":[{"type":"text","id":"2HYT-1692419795248","leaves":[{"text":"wire c1;\r","marks":[]}]}]},{"type":"block","id":"k7nJ-1692419795251","name":"code-line","data":{},"nodes":[{"type":"text","id":"Fikf-1692419795250","leaves":[{"text":"\r","marks":[]}]}]},{"type":"block","id":"MKLU-1692419795253","name":"code-line","data":{},"nodes":[{"type":"text","id":"4leD-1692419795252","leaves":[{"text":"reg state1;\r","marks":[]}]}]},{"type":"block","id":"cEwy-1692419795255","name":"code-line","data":{},"nodes":[{"type":"text","id":"A8bO-1692419795254","leaves":[{"text":"reg state2;\r","marks":[]}]}]},{"type":"block","id":"r6KS-1692419795257","name":"code-line","data":{},"nodes":[{"type":"text","id":"2Yjf-1692419795256","leaves":[{"text":"\r","marks":[]}]}]},{"type":"block","id":"tnLd-1692419795259","name":"code-line","data":{},"nodes":[{"type":"text","id":"y4qm-1692419795258","leaves":[{"text":"initial begin\r","marks":[]}]}]},{"type":"block","id":"EmLW-1692419795261","name":"code-line","data":{},"nodes":[{"type":"text","id":"UZ26-1692419795260","leaves":[{"text":"state1 = 0;\r","marks":[]}]}]},{"type":"block","id":"AcGN-1692419795263","name":"code-line","data":{},"nodes":[{"type":"text","id":"u0ZJ-1692419795262","leaves":[{"text":"state2 = 1;\r","marks":[]}]}]},{"type":"block","id":"848u-1692419795265","name":"code-line","data":{},"nodes":[{"type":"text","id":"F7Hi-1692419795264","leaves":[{"text":"end\r","marks":[]}]}]},{"type":"block","id":"Jhdg-1692419795267","name":"code-line","data":{},"nodes":[{"type":"text","id":"pLWA-1692419795266","leaves":[{"text":"\r","marks":[]}]}]},{"type":"block","id":"Cpgi-1692419795269","name":"code-line","data":{},"nodes":[{"type":"text","id":"Dw6L-1692419795268","leaves":[{"text":"//根据输出的双边沿,输出方波\r","marks":[]}]}]},{"type":"block","id":"hIa9-1692419795271","name":"code-line","data":{},"nodes":[{"type":"text","id":"xvMT-1692419795270","leaves":[{"text":"always@(posedge c1) begin\r","marks":[]}]}]},{"type":"block","id":"EOld-1692419795273","name":"code-line","data":{},"nodes":[{"type":"text","id":"NsYY-1692419795272","leaves":[{"text":"\tstate1 <= ~state1;\r","marks":[]}]}]},{"type":"block","id":"wPLd-1692419795275","name":"code-line","data":{},"nodes":[{"type":"text","id":"qfeW-1692419795274","leaves":[{"text":"end\r","marks":[]}]}]},{"type":"block","id":"ne50-1692419795277","name":"code-line","data":{},"nodes":[{"type":"text","id":"19k1-1692419795276","leaves":[{"text":"\r","marks":[]}]}]},{"type":"block","id":"cKTG-1692419795279","name":"code-line","data":{},"nodes":[{"type":"text","id":"JO8Q-1692419795278","leaves":[{"text":"always@(negedge c1) begin\r","marks":[]}]}]},{"type":"block","id":"hjGM-1692419795281","name":"code-line","data":{},"nodes":[{"type":"text","id":"YFrQ-1692419795280","leaves":[{"text":"\tstate2 <= ~state2;\r","marks":[]}]}]},{"type":"block","id":"5DcI-1692419795283","name":"code-line","data":{},"nodes":[{"type":"text","id":"kVMr-1692419795282","leaves":[{"text":"end\r","marks":[]}]}]},{"type":"block","id":"tqEK-1692419795285","name":"code-line","data":{},"nodes":[{"type":"text","id":"Tloh-1692419795284","leaves":[{"text":"\r","marks":[]}]}]},{"type":"block","id":"iQS3-1692419795287","name":"code-line","data":{},"nodes":[{"type":"text","id":"jeKf-1692419795286","leaves":[{"text":"assign pinout = (state2 | state1) ? 1:0; \r","marks":[]}]}]},{"type":"block","id":"jV5p-1692419795289","name":"code-line","data":{},"nodes":[{"type":"text","id":"aehx-1692419795288","leaves":[{"text":"\r","marks":[]}]}]},{"type":"block","id":"wM83-1692419795291","name":"code-line","data":{},"nodes":[{"type":"text","id":"LsBu-1692419795290","leaves":[{"text":"//根据输入的双边沿,输出方波\r","marks":[]}]}]},{"type":"block","id":"a05o-1692419795293","name":"code-line","data":{},"nodes":[{"type":"text","id":"dXbH-1692419795292","leaves":[{"text":"assign pinout = clk? 0:1;\r","marks":[]}]}]},{"type":"block","id":"2nDB-1692419795295","name":"code-line","data":{},"nodes":[{"type":"text","id":"s4jR-1692419795294","leaves":[{"text":"\r","marks":[]}]}]},{"type":"block","id":"f4na-1692419795297","name":"code-line","data":{},"nodes":[{"type":"text","id":"Gp4M-1692419795296","leaves":[{"text":"endmodule\r","marks":[]}]}]},{"type":"block","id":"1Hzg-1692419795299","name":"code-line","data":{},"nodes":[{"type":"text","id":"luep-1692419795298","leaves":[{"text":"","marks":[]}]}]}],"state":{"language":"cpp"}},{"type":"block","id":"oggb-1692419794931","name":"paragraph","data":{},"nodes":[{"type":"text","id":"K09I-1692419794932","leaves":[{"text":"使用GPIO为,PB12合PB13,下图为示波器抓取的波形","marks":[]}]}],"state":{}},{"type":"block","id":"EdKQ-1692419826477","name":"image","data":{"version":1,"url":"https://note.youdao.com/yws/res/a/WEBRESOURCEe24639a8dab33eaef509effe44babffa","width":701,"height":488},"nodes":[],"state":{"loading":false,"renderSource":"https://note.youdao.com/yws/res/a/WEBRESOURCEe24639a8dab33eaef509effe44babffa","initialSize":{"width":701,"height":488}}},{"type":"block","id":"zuJP-1692419826481","name":"paragraph","data":{},"nodes":[{"type":"text","id":"pLGX-1692419826480","leaves":[{"text":"","marks":[]}]}],"state":{}}]"><p>本次使用使用AG32VF407开发板中的FPGA,使用双clk的双边沿进行检测,同步输出方波</p>
<p>同时可以根据输出的方波检测clk的频率,以及双clk的相位关系,如下为verilog代码</p>
<pre>
<code>`timescale 1ns / 1ns
module test(clk,ledout,pinout);
input clk;
output ledout;
reg ledout;
output pinout;
pll pll1_inst (
.areset ( 1'b0 ),
.inclk0 ( clk ),
.c0 ( c0 ),
.c1 ( c1 )
);
wire c0;
wire c1;
reg state1;
reg state2;
initial begin
state1 = 0;
state2 = 1;
end
//根据输出的双边沿,输出方波
always@(posedge c1) begin
state1 <= ~state1;
end
always@(negedge c1) begin
state2 <= ~state2;
end
assign pinout = (state2 | state1) ? 1:0;
//根据输入的双边沿,输出方波
assign pinout = clk? 0:1;
endmodule
</code></pre>
<p>使用GPIO为,PB12合PB13,下图为示波器抓取的波形</p>
<p> </p>
<p>视频</p>
<p><iframe allowfullscreen="true" frameborder="0" height="450" src="//player.bilibili.com/player.html?bvid=1kX4y1W7mQ&page=1" style="background:#eee;margin-bottom:10px;" width="700"></iframe><br />
</p>
</article>
</div><script> var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;" style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
if(parseInt(discuz_uid)==0){
(function($){
var postHeight = getTextHeight(400);
$(".showpostmsg").html($(".showpostmsg").html());
$(".showpostmsg").after(loginstr);
$(".showpostmsg").css({height:postHeight,overflow:"hidden"});
})(jQuery);
} </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script> <p>示波器抓取的方波波形边缘瞬间高脉冲应该不影响频率的检测</p>
Jacktang 发表于 2023-8-20 21:55
示波器抓取的方波波形边缘瞬间高脉冲应该不影响频率的检测
<p>不影响,本质时官方目前的内部晶振不准,我下一个帖子会说怎么改</p>
页:
[1]