LitchiCheng 发表于 2023-8-19 12:41

AG32VF407 AGRV2K Verilog双边沿检测输出方波

<div class='showpostmsg'><article data-content="[{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;igen-1692419794929&quot;,&quot;name&quot;:&quot;paragraph&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;JrSJ-1692419794930&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;本次使用使用AG32VF407开发板中的FPGA,使用双clk的双边沿进行检测,同步输出方波&quot;,&quot;marks&quot;:[]}]}],&quot;state&quot;:{}},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;hdgQ-1692419926915&quot;,&quot;name&quot;:&quot;paragraph&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;vZuy-1692419926914&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;同时可以根据输出的方波检测clk的频率,以及双clk的相位关系,如下为verilog代码&quot;,&quot;marks&quot;:[]}]}],&quot;state&quot;:{}},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;PX1Y-1692419794928&quot;,&quot;name&quot;:&quot;code&quot;,&quot;data&quot;:{&quot;language&quot;:&quot;&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;wrap&quot;:false},&quot;nodes&quot;:[{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;0LDi-1692419794927&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;Mi5o-1692419794926&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;`timescale 1ns / 1ns\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;KaXc-1692419795217&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;g4Ps-1692419795216&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;4NVL-1692419795219&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;4xR9-1692419795218&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;module test(clk,ledout,pinout);\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;JnA4-1692419795221&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;oGi3-1692419795220&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;Ky0K-1692419795223&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;58eO-1692419795222&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;input\tclk;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;F67Y-1692419795225&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;SAxJ-1692419795224&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;output  ledout;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;FfHr-1692419795227&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;JsoK-1692419795226&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;reg   ledout;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;0KEC-1692419795229&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;2QSc-1692419795228&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;output  pinout;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;M23K-1692419795231&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;QcTx-1692419795230&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;vZkm-1692419795233&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;4tSg-1692419795232&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;pll\tpll1_inst (\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;ytCS-1692419795235&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;9CYn-1692419795234&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\t.areset ( 1'b0 ),\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;PeuR-1692419795237&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;0eXT-1692419795236&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\t.inclk0 ( clk ),\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;jYk2-1692419795239&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;NjPQ-1692419795238&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\t.c0 ( c0 ),\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;n70G-1692419795241&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;ydHG-1692419795240&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\t.c1 ( c1 )\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;m09Q-1692419795243&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;GH4m-1692419795242&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\t);\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;vCn9-1692419795245&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;CLqz-1692419795244&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;Ob7T-1692419795247&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;CXr0-1692419795246&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;wire c0;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;SUHD-1692419795249&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;2HYT-1692419795248&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;wire c1;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;k7nJ-1692419795251&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;Fikf-1692419795250&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;MKLU-1692419795253&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;4leD-1692419795252&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;reg state1;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;cEwy-1692419795255&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;A8bO-1692419795254&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;reg state2;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;r6KS-1692419795257&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;2Yjf-1692419795256&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;tnLd-1692419795259&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;y4qm-1692419795258&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;initial begin\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;EmLW-1692419795261&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;UZ26-1692419795260&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;state1 = 0;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;AcGN-1692419795263&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;u0ZJ-1692419795262&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;state2 = 1;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;848u-1692419795265&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;F7Hi-1692419795264&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;end\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;Jhdg-1692419795267&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;pLWA-1692419795266&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;Cpgi-1692419795269&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;Dw6L-1692419795268&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;//根据输出的双边沿,输出方波\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;hIa9-1692419795271&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;xvMT-1692419795270&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;always@(posedge c1) begin\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;EOld-1692419795273&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;NsYY-1692419795272&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\tstate1 &lt;= ~state1;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;wPLd-1692419795275&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;qfeW-1692419795274&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;end\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;ne50-1692419795277&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;19k1-1692419795276&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;cKTG-1692419795279&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;JO8Q-1692419795278&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;always@(negedge c1) begin\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;hjGM-1692419795281&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;YFrQ-1692419795280&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\tstate2 &lt;= ~state2;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;5DcI-1692419795283&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;kVMr-1692419795282&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;end\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;tqEK-1692419795285&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;Tloh-1692419795284&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;iQS3-1692419795287&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;jeKf-1692419795286&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;assign pinout = (state2 | state1) ? 1:0; \r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;jV5p-1692419795289&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;aehx-1692419795288&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;wM83-1692419795291&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;LsBu-1692419795290&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;//根据输入的双边沿,输出方波\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;a05o-1692419795293&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;dXbH-1692419795292&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;assign pinout = clk? 0:1;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;2nDB-1692419795295&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;s4jR-1692419795294&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;f4na-1692419795297&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;Gp4M-1692419795296&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;endmodule\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;1Hzg-1692419795299&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;luep-1692419795298&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;&quot;,&quot;marks&quot;:[]}]}]}],&quot;state&quot;:{&quot;language&quot;:&quot;cpp&quot;}},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;oggb-1692419794931&quot;,&quot;name&quot;:&quot;paragraph&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;K09I-1692419794932&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;使用GPIO为,PB12合PB13,下图为示波器抓取的波形&quot;,&quot;marks&quot;:[]}]}],&quot;state&quot;:{}},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;EdKQ-1692419826477&quot;,&quot;name&quot;:&quot;image&quot;,&quot;data&quot;:{&quot;version&quot;:1,&quot;url&quot;:&quot;https://note.youdao.com/yws/res/a/WEBRESOURCEe24639a8dab33eaef509effe44babffa&quot;,&quot;width&quot;:701,&quot;height&quot;:488},&quot;nodes&quot;:[],&quot;state&quot;:{&quot;loading&quot;:false,&quot;renderSource&quot;:&quot;https://note.youdao.com/yws/res/a/WEBRESOURCEe24639a8dab33eaef509effe44babffa&quot;,&quot;initialSize&quot;:{&quot;width&quot;:701,&quot;height&quot;:488}}},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;zuJP-1692419826481&quot;,&quot;name&quot;:&quot;paragraph&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;pLGX-1692419826480&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;&quot;,&quot;marks&quot;:[]}]}],&quot;state&quot;:{}}]">
<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 &lt;= ~state1;
end

always@(negedge c1) begin
    state2 &lt;= ~state2;
end

assign pinout = (state2 | state1) ? 1:0;

//根据输入的双边沿,输出方波
assign pinout = clk? 0:1;

endmodule
</code></pre>

<p>使用GPIO为,PB12合PB13,下图为示波器抓取的波形</p>

<p> &nbsp;</p>

<p>视频</p>

<p><iframe allowfullscreen="true" frameborder="0" height="450" src="//player.bilibili.com/player.html?bvid=1kX4y1W7mQ&amp;page=1" style="background:#eee;margin-bottom:10px;" width="700"></iframe><br />
&nbsp;</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>

Jacktang 发表于 2023-8-20 21:55

<p>示波器抓取的方波波形边缘瞬间高脉冲应该不影响频率的检测</p>

LitchiCheng 发表于 2023-8-26 13:59

Jacktang 发表于 2023-8-20 21:55
示波器抓取的方波波形边缘瞬间高脉冲应该不影响频率的检测

<p>不影响,本质时官方目前的内部晶振不准,我下一个帖子会说怎么改</p>
页: [1]
查看完整版本: AG32VF407 AGRV2K Verilog双边沿检测输出方波