{"id":155,"date":"2024-06-02T08:04:44","date_gmt":"2024-06-02T00:04:44","guid":{"rendered":"http:\/\/blog.huanmie.fun\/?p=155"},"modified":"2024-06-06T15:34:48","modified_gmt":"2024-06-06T07:34:48","slug":"%e5%9f%ba%e4%ba%8everilog%e7%9a%84adc-0809%e6%a8%a1%e6%95%b0%e8%bd%ac%e6%8d%a2%e5%99%a8%e9%a9%b1%e5%8a%a8%e6%a8%a1%e5%9d%97","status":"publish","type":"post","link":"https:\/\/blog.huanmie.fun\/index.php\/2024\/06\/02\/%e5%9f%ba%e4%ba%8everilog%e7%9a%84adc-0809%e6%a8%a1%e6%95%b0%e8%bd%ac%e6%8d%a2%e5%99%a8%e9%a9%b1%e5%8a%a8%e6%a8%a1%e5%9d%97\/","title":{"rendered":"\u57fa\u4e8eVerilog\u7684ADC-0809\u6a21\u6570\u8f6c\u6362\u5668\u9a71\u52a8\u6a21\u5757"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>\u6a21\u5757\u7b80\u4ecb\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/strong><a href=\"https:\/\/so.csdn.net\/so\/search?q=ADC0809&amp;spm=1001.2101.3001.7020\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >ADC0809<\/a>\u00a0\u662f\u91c7\u7528CMOS \u5de5\u827a\u5236\u9020\u7684\u53cc\u5217\u76f4\u63d2\u5f0f\u5355\u72478 \u4f4dA\/D \u8f6c\u6362\u5668\u3002\uff08\u5206\u8fa8\u7387\uff09 \u5206\u8fa8\u73878 \u4f4d\uff0c\u7cbe\u5ea67 \u4f4d\uff0c\u5e268 \u4e2a\u6a21\u62df\u91cf\u8f93\u5165\u901a\u9053\uff0c\u6709\u901a\u9053\u5730\u5740\u8bd1\u7801\u9501\u5b58\u5668\uff0c\u8f93\u51fa\u5e26\u4e09\u6001\u6570\u636e\u9501\u5b58\u5668\u3002\u542f\u52a8\u4fe1\u53f7\u4e3a\u8109\u51b2\u542f\u52a8\u65b9\u5f0f\uff0c\u6700\u5927\u53ef\u8c03\u8282\u8bef\u5dee\u4e3a\u00b11LSB\u3002\uff08\u8f6c\u6362\u7cbe\u5ea6\uff09\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5f15\u811a\u529f\u80fd\u8bf4\u660e\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"589\" src=\"http:\/\/blog.huanmie.fun\/wp-content\/uploads\/2024\/06\/image-1024x589.png\" alt=\"\" class=\"wp-image-156\" srcset=\"https:\/\/blog.huanmie.fun\/wp-content\/uploads\/2024\/06\/image-1024x589.png 1024w, https:\/\/blog.huanmie.fun\/wp-content\/uploads\/2024\/06\/image-300x173.png 300w, https:\/\/blog.huanmie.fun\/wp-content\/uploads\/2024\/06\/image-768x442.png 768w, https:\/\/blog.huanmie.fun\/wp-content\/uploads\/2024\/06\/image-1536x884.png 1536w, https:\/\/blog.huanmie.fun\/wp-content\/uploads\/2024\/06\/image.png 1712w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5730\u5740\u7801\u4e0e\u8f93\u5165\u901a\u9053\u7684\u5bf9\u5e94\u5173\u7cfb\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td colspan=\"3\">\u5730\u5740\u7801<\/td><td>\u901a\u9053<\/td><td colspan=\"3\">\u5730\u5740\u7801<\/td><td>\u901a\u9053<\/td><\/tr><tr><td>A<\/td><td>B<\/td><td>C<\/td><td><\/td><td>A<\/td><td>B<\/td><td>C<\/td><td><\/td><\/tr><tr><td>0<\/td><td>0<\/td><td>0<\/td><td>IN0<\/td><td>1<\/td><td>0<\/td><td>0<\/td><td>IN4<\/td><\/tr><tr><td>0<\/td><td>0<\/td><td>1<\/td><td>IN1<\/td><td>1<\/td><td>0<\/td><td>1<\/td><td>IN5<\/td><\/tr><tr><td>0<\/td><td>1<\/td><td>0<\/td><td>IN2<\/td><td>1<\/td><td>1<\/td><td>0<\/td><td>IN6<\/td><\/tr><tr><td>0<\/td><td>1<\/td><td>1<\/td><td>IN3<\/td><td>1<\/td><td>1<\/td><td>1<\/td><td>IN7<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6838\u5fc3\u4ee3\u7801\u5b9e\u73b0\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"662\" height=\"415\" src=\"http:\/\/blog.huanmie.fun\/wp-content\/uploads\/2024\/06\/image-1.png\" alt=\"\" class=\"wp-image-157\" style=\"width:840px;height:auto\" srcset=\"https:\/\/blog.huanmie.fun\/wp-content\/uploads\/2024\/06\/image-1.png 662w, https:\/\/blog.huanmie.fun\/wp-content\/uploads\/2024\/06\/image-1-300x188.png 300w\" sizes=\"auto, (max-width: 662px) 100vw, 662px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>module ADC0809_Dirve\n#(\n    parameter clock_freq = 50_000_000,\n    div_value_width = ( ( clock_freq \/ 500_000 )\/2) &gt; 0 ? $clog2( ( clock_freq \/ 500_000 )\/2) : 1\n)(\n    input clk,\n    input rst,\n    input &#91;7:0] adc_data,\n    input &#91;2:0] adc_cs,\n    input EN,\n    input EOC,\/\/ADC0809\u8f6c\u6362\u7ed3\u675f\u4fe1\u53f7\n    output reg ADC_clk,\/\/ADC0809\u65f6\u949f\u4fe1\u53f7\n    output reg OE,\/\/ADC0809\u8f93\u51fa\u4f7f\u80fd\u4fe1\u53f7\n    output reg &#91;7:0] adc_result,\/\/ADC0809\u8f93\u51fa\u7ed3\u679c\n    output reg ADC_START,\/\/ADC0809\u542f\u52a8\u4fe1\u53f7\n    output reg &#91;2:0] adc_cs_out,\/\/ADC0809\u7247\u9009\u4fe1\u53f7\n    output reg adc_done_out,\/\/ADC0809\u8f6c\u6362\u7ed3\u675f\u4fe1\u53f7\n    output reg &#91;4:0]present_state\n);\n \n\/\/\u5206\u9891\u5668\uff08\u4e3aadc\u63d0\u4f9b\u65f6\u949f\uff09\n\/\/\u5206\u9891\u503c\u8ba1\u7b97\n    reg &#91;div_value_width:0] div_value;\n    reg &#91;div_value_width:0] div_cnt;\n    always@(posedge clk or negedge rst)\n    begin\n        if(!rst)\n            div_value &lt;= 0;\n        else \n            div_value &lt;= ( clock_freq \/ 500_000 )\/2;\n    end\n    always@(posedge clk or negedge rst)\n    begin\n        if(!rst) begin\n            ADC_clk &lt;= 0;\n            div_cnt &lt;= 0;\n        end\n        else if(EN) begin\n                if(div_cnt &gt;= div_value) begin\n                    ADC_clk &lt;= !ADC_clk;\n                    div_cnt &lt;= 0;\n                end\n                else begin\n                    ADC_clk &lt;= ADC_clk;\n                    div_cnt &lt;= div_cnt + 1;\n                end\n            end\n            else begin\n                ADC_clk &lt;= 0;\n                div_cnt &lt;= 0;\n            end\n    end\n \nwire delay;\nreg delay_en;\n\/\/ADC0809\u63a7\u5236\u5668\n\/\/reg &#91;4:0]present_state;\nreg &#91;4:0]next_state;\/\/\u5f53\u524d\u72b6\u6001\u548c\u4e0b\u4e00\u72b6\u6001\nparameter   Init    =   5'b00000,\/\/\u521d\u59cb\u72b6\u6001\n            Wait    =   5'b00001,\/\/\u7b49\u5f85\u72b6\u6001\n            cs_out  =   5'b00010,\/\/\u7247\u9009\n            adc_st  =   5'b00011,\/\/\u542f\u52a8\n            adc_done=   5'b00100;\/\/\u8bfb\u53d6\n            \n \nalways @ (posedge clk or negedge rst)\n    if(!rst)begin\/\/\u590d\u4f4d\n        present_state&lt;=Init;  \n    end\n    else\n        present_state&lt;=next_state;\nalways @ (*) begin\n    case (present_state)\n        Init:begin\n            OE = 1'b0;\n            adc_cs_out = 3'b000;\n            adc_result = 8'b00000000;\n            ADC_START  = 1'b1;\n            delay_en = 1'b0;\n            adc_done_out = 1'b0;\n            next_state=Wait;\n        end\n        Wait:begin\n            delay_en = 1'b0;\n            ADC_START = 1'b1;\n            adc_done_out = 1'b0;\n            OE = 1'b1;\n            if(EN)begin\n                next_state=cs_out;\n            end\n            else begin\n                next_state=Wait;\n            end\n        end\n        cs_out:begin\n            delay_en = 1'b1;\n           \n            adc_cs_out = adc_cs;\n            if(delay)begin\n                next_state=adc_st;\n            end\n            else begin\n                next_state=cs_out;\n            end\n        end\n        adc_st:begin\n            delay_en = 1'd0;\n            OE = 1'b1;\n            ADC_START = 1'b0;\n            if(EOC)begin\n                \n                next_state=adc_done;\n            end\n            else begin\n                next_state=adc_st;\n            end\n        end\n        adc_done:begin\n            OE = 1'b1;\n            ADC_START = 1'b1;\n            adc_done_out = 1'b1;\n            adc_result = adc_data;\n            next_state=Wait;\n        end\n        default: \n            next_state=Wait;\n\t\t  \n    endcase\nend\n \n\/\/\u4f8b\u5316timer\u6a21\u5757\ntimer timer_delay(\n    .timeout(delay),\n    .clk(clk),\n    .rst(!rst),\n    .en(delay_en)\n);\nendmodule<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6a21\u5757\u7b80\u4ecb\uff1a \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ADC0809\u00a0\u662f\u91c7\u7528CMOS \u5de5\u827a\u5236\u9020\u7684\u53cc\u5217\u76f4\u63d2\u5f0f\u5355\u72478 \u4f4dA\/D \u8f6c\u6362\u5668\u3002\uff08\u5206\u8fa8\u7387\uff09 \u5206\u8fa8\u73878 \u4f4d &#8230;<\/p>\n","protected":false},"author":1,"featured_media":157,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[3],"tags":[],"class_list":["post-155","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-fpga"],"_links":{"self":[{"href":"https:\/\/blog.huanmie.fun\/index.php\/wp-json\/wp\/v2\/posts\/155","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.huanmie.fun\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.huanmie.fun\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.huanmie.fun\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.huanmie.fun\/index.php\/wp-json\/wp\/v2\/comments?post=155"}],"version-history":[{"count":2,"href":"https:\/\/blog.huanmie.fun\/index.php\/wp-json\/wp\/v2\/posts\/155\/revisions"}],"predecessor-version":[{"id":165,"href":"https:\/\/blog.huanmie.fun\/index.php\/wp-json\/wp\/v2\/posts\/155\/revisions\/165"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.huanmie.fun\/index.php\/wp-json\/wp\/v2\/media\/157"}],"wp:attachment":[{"href":"https:\/\/blog.huanmie.fun\/index.php\/wp-json\/wp\/v2\/media?parent=155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.huanmie.fun\/index.php\/wp-json\/wp\/v2\/categories?post=155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.huanmie.fun\/index.php\/wp-json\/wp\/v2\/tags?post=155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}