{"id":3024,"date":"2022-03-27T19:28:14","date_gmt":"2022-03-27T11:28:14","guid":{"rendered":"http:\/\/139.9.1.231\/?p=3024"},"modified":"2024-05-23T21:39:50","modified_gmt":"2024-05-23T13:39:50","slug":"fpgayolo","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/03\/27\/fpgayolo\/","title":{"rendered":"FPGA\u2014YOLO"},"content":{"rendered":"\n\n\n<p>device = &#8220;xcvu3p-ffvc1517-2-e&#8221;<\/p>\n\n\n\n<p>\u53c2\u8003\uff1a<\/p>\n\n\n\n<p>https:\/\/thedatabus.io\/convolver<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/sumanth-kalluri\/cnn_hardware_acclerator_for_fpga\">https:\/\/github.com\/sumanth-kalluri\/cnn_hardware_acclerator_for_fpga<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/thedatabus.io\/archive\">https:\/\/thedatabus.io\/archive<\/a><\/p>\n\n\n\n<h2>1\u3001\u7f51\u7edc\u7ed3\u6784\u5206\u6790\uff1a<\/h2>\n\n\n\n<p class=\"has-light-pink-background-color has-background\"> <a href=\"https:\/\/github.com\/coldlarry\/YOLOv3-complete-pruning\">YOLOv3<\/a> \u7684\u526a\u679d\u91cf\u5316\uff1a<\/p>\n\n\n\n<p class=\"has-dark-gray-color has-light-gray-background-color has-text-color has-background\"><a href=\"https:\/\/github.com\/coldlarry\/YOLOv3-complete-pruning\">https:\/\/github.com\/coldlarry\/YOLOv3-complete-pruning<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" width=\"406\" height=\"1024\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-67-406x1024.png\" alt=\"\" class=\"wp-image-3091\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-67-406x1024.png 406w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-67-119x300.png 119w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-67.png 416w\" sizes=\"(max-width: 406px) 100vw, 406px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-resized is-style-default\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/yolov3-tiny-497x1024.jpg\" alt=\"\" class=\"wp-image-3025\" width=\"497\" height=\"1024\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/yolov3-tiny-497x1024.jpg 497w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/yolov3-tiny-146x300.jpg 146w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/yolov3-tiny.jpg 713w\" sizes=\"(max-width: 497px) 100vw, 497px\" \/><figcaption>\u8bf4\u660e\uff1a\u6700\u540e\u4e00\u5c4275\u8f93\u51fa\u901a\u9053<\/figcaption><\/figure>\n\n\n\n<p>\u8f93\u51fa\u4e3a\u5355\u4e2a\u901a\u9053\uff1a<strong>\u4e0a\u8ff0\u8fc7\u7a0b\u4e2d\uff0c\u6bcf\u4e00\u4e2a\u5377\u79ef\u6838\u7684\u901a\u9053\u6570\u91cf\uff0c\u5fc5\u987b\u8981\u6c42\u4e0e\u8f93\u5165\u901a\u9053\u6570\u91cf\u4e00\u81f4\uff0c\u56e0\u4e3a\u8981\u5bf9\u6bcf\u4e00\u4e2a\u901a\u9053\u7684\u50cf\u7d20\u503c\u8981\u8fdb\u884c\u5377\u79ef\u8fd0\u7b97\uff0c\u6240\u4ee5\u6bcf\u4e00\u4e2a\u5377\u79ef\u6838\u7684\u901a\u9053\u6570\u91cf\u5fc5\u987b\u8981\u4e0e\u8f93\u5165\u901a\u9053\u6570\u91cf\u4fdd\u6301\u4e00\u81f4<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic3.zhimg.com\/v2-c67c5dab624da0904b34b2cb674ed6d2_r.jpg\" alt=\"preview\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic2.zhimg.com\/v2-d40e48b85e19b2d16c86eee901870755_r.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p><em><strong>\u591a\u901a\u9053<\/strong><\/em>\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic2.zhimg.com\/v2-8e2add9b9d3422019dfec3048e66e1a9_r.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" width=\"875\" height=\"816\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-66.png\" alt=\"\" class=\"wp-image-3089\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-66.png 875w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-66-300x280.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-66-768x716.png 768w\" sizes=\"(max-width: 875px) 100vw, 875px\" \/><\/figure>\n\n\n\n<p>\u8f93\u5165 416*416*3 = 519,168 \u4e2a\u503c<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">conv0 \uff1a input_height=418 \u539f\u56e0\uff1a\u8fd9\u91cc\u662f\u505a1\u7684\u586b\u5145\uff0c\u6240\u4ee5 \u6700\u7ec8\u8f93\u5165\u662f 416+2 =418<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> conv_0_param={.kernel_dim=3,\n                          .pad=1,\n                          .input_channel=3,\n                          .input_width=418,\n                          .input_height=418,\n                          .output_channel=16,\n                          .output_width=416,\n                          .output_height=416};<\/code><\/pre>\n\n\n\n<p>16*3\u4e2a\u5377\u79ef\u6838\uff1a\u4e00\u517116*3*9\u4e2a\u5377\u79ef\u6838\u53c2\u6570 +16\u4e2abias == \u300b <strong>432+16<\/strong> \u4e2a\u53c2\u6570<\/p>\n\n\n\n<p>\u8f93\u51fa\uff1a 416 *416* 16  \u4e2a\u503c\uff0c\u5373<strong>2768896<\/strong>\u4e2a\u8f93\u51fa<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">conv1 \uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>conv_1_param={.kernel_dim=3,\n                          .pad=1,\n                          .input_channel=16,\n                          .input_width=210,\n                          .input_height=210,\n                          .output_channel=32,\n                          .output_width=208,\n                          .output_height=208};<\/code><\/pre>\n\n\n\n<p>\u4e00\u5171 32*16\u4e2a\u5377\u79ef\u6838 4608\u4e2a\u5377\u79ef\u6838\u6743\u91cd\u53c2\u6570\uff0c36\u4e2abias\u53c2\u6570<\/p>\n\n\n\n<p>\u8be5\u5c42\u8f93\u51fa\uff1a 208 *208* 32  = 1384448<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\"> conv2 \uff1a <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>conv_2_param={.kernel_dim=3,\n                          .pad=1,\n                          .input_channel=32,\n                          .input_width=106,\n                          .input_height=106,\n                          .output_channel=64,\n                          .output_width=104,\n                          .output_height=104};<\/code><\/pre>\n\n\n\n<p> \u4e00\u5171  64 *32\u4e2a\u5377\u79ef\u6838 18432\u4e2a\u5377\u79ef\u6838\u6743\u91cd\u53c2\u6570\uff0c64\u4e2abias\u53c2\u6570 <\/p>\n\n\n\n<p>\u8be5\u5c42\u8f93\u51fa\uff1a 104 *104*64 = 692224<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">conv3\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>conv_3_param={.kernel_dim=3,\n                          .pad=1,\n                          .input_channel=64,\n                          .input_width=54,\n                          .input_height=54,\n                          .output_channel=128,\n                          .output_width=52,\n                          .output_height=52};\n<\/code><\/pre>\n\n\n\n<p> \u4e00\u5171  128*64\u4e2a\u5377\u79ef\u6838 73728\u4e2a\u5377\u79ef\u6838\u6743\u91cd\u53c2\u6570\uff0c128\u4e2abias\u53c2\u6570  <\/p>\n\n\n\n<p>\u8be5\u5c42\u8f93\u51fa\uff1a 52 *52*128 = 346112<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">conv4:  256*128*9= 294912 \u4e2a\u5377\u79ef\u6838\u6743\u91cd\u53c2\u6570 \uff0c256\u4e2a\u504f\u7f6e\uff0c  \u8f93\u51fa\uff1a26*26*256=173056<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>conv_4_param={.kernel_dim=3,\n                          .pad=1,\n                          .input_channel=128,\n                          .input_width=28,\n                          .input_height=28,\n                          .output_channel=256,\n                          .output_width=26,\n                          .output_height=26};<\/code><\/pre>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">conv5\uff1a256*512*9 = 1179648\u4e2a\u5377\u79ef\u6838\u6743\u91cd    512 \u4e2abias\uff0c    \u8f93\u51fa\uff1a13*13*512=86528<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">conv6\uff1a512*1024*9=4718592\u4e2a\u5377\u79ef\u6838\u6743\u91cd\uff0c1024\u4e2abias\uff0c\u8f93\u51fa\uff1a13*13*1024=173056<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">conv7\uff1a1024*256*1 =262144\u4e2a\u5377\u79ef\u5c42\u6743\u91cd\uff0c256\u4e2abias\uff0c\u8f93\u51fa\uff1a13*13*256=43264<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">conv8\uff1a256*512*9 =1179648 \u4e2a\u5377\u79ef\u5c42\u6743\u91cd \uff0c512\u4e2abias \u8f93\u51fa\uff1a13*13*512=86528<\/p>\n\n\n\n<p>\u4e0a\u9762\u7684\u5377\u79ef\u5c42\uff1a\u540e\u9762\u7d27\u8ddf\u4e00\u4e2abatchnormal\u5c42<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">CONV 9 and 12 have no batch norm layer<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">conv9 : \u6700\u540e\u4e00\u5c42\uff1a512*255*1=130560\u4e2a\u5377\u79ef\u6743\u91cd\uff0c255\u4e2abias\uff0c 13*13*255= 43095<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">conv10:   256*128*1=32768\u4e2a\u6743\u91cd   128\u4e2abias         \u8f93\u51fa13*13*128=21632<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">conv11:  384*256*3 =305280 \u4e2a\u53c2\u6570  256\u4e2abias     \u8f93\u51fa26*26*256=173056<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">conv12:  256*255*1=65280\u4e2a\u6743\u91cd   255\u4e2abias  \u8f93\u51fa26*26*255 = 172380<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wight= &#091;448,4608,36,18432,64,73728,128,294912,256,1179648,512,4718592,1024,262144,256,1179648 ,512,130560,255,32768,128,305280,256,65280,255]\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>out\uff1a &#091; 519168,2768896,1384448, 692224,346112,173056,86528,173056,43264,86528,43095,21632,173056,172380]<\/code><\/pre>\n\n\n\n<p>\u6c47\u603b\uff1a8269730\u4e2awight(\uff08\u516b\u767e\u591a\u4e07\uff09    \u8f93\u51fa\u7ed3\u679c\u4e2d\u6700\u5927 2768896\uff0c\u6700\u5c0f21632<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" width=\"1018\" height=\"895\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-68.png\" alt=\"\" class=\"wp-image-3092\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-68.png 1018w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-68-300x264.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-68-768x675.png 768w\" sizes=\"(max-width: 1018px) 100vw, 1018px\" \/><\/figure>\n\n\n\n<h2>\u6570\u636e\u4f4d\u5bbd\uff1a<\/h2>\n\n\n\n<p>        \u5728\u5b9a\u70b9\u5b9e\u73b0\u4e2d\uff0c\u9996\u5148\u786e\u5b9a\u6574\u6570\u548c\u5c0f\u6570\u90e8\u5206\u4f7f\u7528\u4e86\u591a\u5c11\u4f4d\u662f\u5f88\u91cd\u8981\u7684\u3002\u5bf9\u4e8e\u7ebf\u6027\u91cf\u5316\uff0c\u6574\u6570\u7684\u4f4d\u5bbd\u5ea6\u4e0e\u6781\u503c\u4ee5\u53ca\u662f\u5426\u4f1a\u53d1\u751f\u6ea2\u51fa\u6709\u5173\u3002\u53e6\u4e00\u65b9\u9762\uff0c\u5206\u6570\u90e8\u5206\u7684\u957f\u5ea6\u5f71\u54cd\u91cf\u5316\u8bef\u5dee\u3002\u6b64\u5916\uff0c\u91cf\u5316\u7684\u6b65\u957f\u5c06\u5f71\u54cd\u6570\u636e\u7684\u5206\u5e03\u3002\u5bf9\u4e8e\u4e0d\u540c\u7684\u7f51\u7edc\u7c7b\u578b\uff0c\u5e94\u5728\u6bd4\u7279\u5bbd\u5ea6\u548c\u7f51\u7edc\u7cbe\u5ea6\u4e4b\u95f4\u8fdb\u884c\u5f7b\u5e95\u7684\u6743\u8861\u3002<\/p>\n\n\n\n<p>\u5728\u5b9a\u70b9\u5b9e\u73b0\u4e2d\uff0c\u9996\u5148\u786e\u5b9a\u6574\u6570\u548c\u5c0f\u6570\u90e8\u5206\u4f7f\u7528\u4e86\u591a\u5c11\u4f4d\u662f\u5f88\u91cd\u8981\u7684\u3002\u5bf9\u4e8e\u7ebf\u6027\u91cf\u5316\uff0c\u6574\u6570\u7684\u4f4d\u5bbd\u5ea6\u4e0e\u6781\u503c\u4ee5\u53ca\u662f\u5426\u4f1a\u53d1\u751f\u6ea2\u51fa\u6709\u5173\u3002\u53e6\u4e00\u65b9\u9762\uff0c\u5206\u6570\u90e8\u5206\u7684\u957f\u5ea6\u5f71\u54cd\u91cf\u5316\u8bef\u5dee\u3002\u6b64\u5916\uff0c\u91cf\u5316\u7684\u6b65\u957f\u5c06\u5f71\u54cd\u6570\u636e\u7684\u5206\u5e03\u3002\u5bf9\u4e8e\u4e0d\u540c\u7684\u7f51\u7edc\u7c7b\u578b\uff0c\u5e94\u5728\u6bd4\u7279\u5bbd\u5ea6\u548c\u7f51\u7edc\u7cbe\u5ea6\u4e4b\u95f4\u8fdb\u884c\u5f7b\u5e95\u7684\u6743\u8861\u3002<\/p>\n\n\n\n<p>\u5c31\u603b\u6bd4\u7279\u800c\u8a00\uff0c2\u7684\u5e42\u6b21\u66f4\u53ef\u53d6\u3002\u4e3a\u4e86\u786e\u5b9a\u5408\u9002\u7684\u6bd4\u7279\u5bbd\u5ea6\uff0c\u5728\u5305\u542b5000\u5e45\u56fe\u50cf\u7684COCO2014-val5k\u6570\u636e\u96c6\u4e0a\u8fdb\u884c\u4e86\u5b9e\u9a8c\u3002\u4e0b\u8868\u603b\u7ed3\u4e86\u6240\u6709\u5377\u79ef\u5c42\u7684\u6570\u636e\u5206\u5e03\u3002\u5f88\u660e\u663e\uff0c\u6240\u6709\u8f93\u5165\u548c\u8f93\u51fa\u7684\u7edd\u5bf9\u503c\u90fd\u5c0f\u4e8e128\u3002\u8fd9\u610f\u5473\u7740\u5728\u4e0d\u9020\u6210\u4efb\u4f55\u6ea2\u51fa\u7684\u60c5\u51b5\u4e0b\uff0c\u4e3a\u6709\u7b26\u53f7\u6574\u6570\u90e8\u5206\u5206\u914d8\u4f4d\u5c31\u8db3\u591f\u4e86\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" width=\"878\" height=\"165\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-60.png\" alt=\"\" class=\"wp-image-3064\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-60.png 878w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-60-300x56.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-60-768x144.png 768w\" sizes=\"(max-width: 878px) 100vw, 878px\" \/><\/figure>\n\n\n\n<p>\u5c1d\u8bd5\u4f7f\u75288\u4f4d\u8868\u793a\u6574\u6570\u90e8\u5206\uff0c\u53e6\u59168\u4f4d\u8868\u793a\u5c0f\u6570\u3002\u5efa\u7acb\u4e86\u8f6f\u4ef6\u5b9a\u70b9\u4eff\u771f\u7cfb\u7edf\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" width=\"570\" height=\"498\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-62.png\" alt=\"\" class=\"wp-image-3067\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-62.png 570w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-62-300x262.png 300w\" sizes=\"(max-width: 570px) 100vw, 570px\" \/><\/figure>\n\n\n\n<p>\u56e0\u6b64\u9009\u62e916bit\u5b58\u50a8\u6743\u91cd\u4ee5\u53ca16bit\u7684\u6570\u636e\u6743\u91cd\uff0c\u4e24\u8005\u90fd\u753116\u4f4d\u5b9a\u70b9\u6570\u5b57\u8868\u793a\u3002\u5bf9\u4e8e\u5377\u79ef\u7a97\u53e3\u7684\u7ed3\u679c\uff0c\u91c7\u752832\u4f4d\u4ee5\u51cf\u5c11\u53ef\u80fd\u7684\u6ea2\u51fa\uff0c\u5e76\u63d0\u4f9b\u66f4\u9ad8\u7684\u7d2f\u79ef\u7cbe\u5ea6\u3002\u901a\u8fc7\u5b9e\u65bd\u5b9a\u70b9\u4f18\u5316\uff0c\u6570\u636e\u5bbd\u5ea6\u4ece32\u4f4d\u538b\u7f29\u523016\u4f4d\uff0c\u4ece\u800c\u5b9e\u73b0\u66f4\u9ad8\u6548\u7684DMA\u4f20\u8f93\u3002\u6b64\u5916\uff0c\u4f7f\u7528\u5b9a\u70b9\u8868\u793a\u4e3a\u5ef6\u8fdf\u548c\u8d44\u6e90\u5e26\u6765\u4e86\u5b9e\u5b9e\u5728\u5728\u7684\u597d\u5904\u3002<\/p>\n\n\n\n<h2>\u6fc0\u6d3b\u51fd\u6570\u5b9e\u73b0\uff1a<\/h2>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u5b98\u65b9 float leaky_activate(float x){return (x&gt;0) ? x : .1*x;}<\/p>\n\n\n\n<p>\u4f7f\u7528\u52a8\u6001\u5b9a\u70b9\u91cf\u5316\u65f6\uff0c\u6fc0\u6d3b\u51fd\u6570 Leaky ReLU \u4e5f\u8981\u8fdb\u884c\u76f8\u5e94\u7684\u91cf\u5316\u64cd\u4f5c\u3002\u5f53\u4f4d\u5bbd bw \u4e3a 16 \u65f6\uff0c\u4f7f\u7528\u4e0e 0xccc \u76f8\u4e58\u548c\u53f3\u79fb 15 \u4f4d\u7684\u5b9a\u70b9\u8fd0\u7b97\u6765\u62df\u5408\u4e0e 0.1 \u76f8\u4e58\u7684\u64cd\u4f5c\u3002\u91cf\u5316\u540e\u7684 Leaky ReLU \u5982\u4e0b\u6240\u793a\uff1a<br>                                       \ud835\udc53\u2032(\ud835\udc65) = (\ud835\udc65 &lt; 0)? (\ud835\udc65 \u2217 0xccc) \u226b 15: \ud835\udc65 <\/p>\n\n\n\n<h2>\u5408\u5e76 Batch Normalisation<\/h2>\n\n\n\n<p>OLOv3 tiny\u4e2d\u7684\u5927\u591a\u6570\u5377\u79ef\u5c42\u5728\u6fc0\u6d3b\u524d\u90fd\u4f1a\u8fdb\u884c\u6279\u91cf\u5f52\u4e00\u5316\u3002\u4f7f\u7528\u4e00\u4e9b\u6570\u5b66\u6280\u672f\u6d88\u9664\u6279\u6b21\u6807\u51c6\u5316\u662f\u5b89\u5168\u7684\u3002\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u5f97\u5230\u4ee5\u4e0b\u65b9\u7a0b\u5f0f\u3002<\/p>\n\n\n\n<div class=\"wp-block-image is-style-default\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-65.png\" alt=\"\" class=\"wp-image-3077\" width=\"525\" height=\"264\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-65.png 924w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-65-300x151.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-65-768x386.png 768w\" sizes=\"(max-width: 525px) 100vw, 525px\" \/><\/figure><\/div>\n\n\n\n<p>w&#8217;0ij\u548cb&#8217;j\u662f\u65b0\u7684\u6743\u91cd\u548c\u504f\u5dee\u3002\u56e0\u4e3a\u8fd9\u79cd\u8f6c\u6362\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u4e4b\u524d\u5b8c\u6210,\u6d6e\u70b9\u8ba1\u7b97\u8fc7\u7a0b\u4e2d\u7684\u4e00\u4e9b\u53ef\u5ffd\u7565\u7684\u7cbe\u5ea6\u635f\u5931\u5916\u3002\u5408\u5e76\u6279\u6b21\u5f52\u4e00\u5316\u4e5f\u4f1a\u5f71\u54cd\u6743\u91cd\u7684\u5206\u5e03\u3002<\/p>\n\n\n\n<h2><strong>\u4e8c\u7ef4\u5377\u79ef\uff1a<\/strong><\/h2>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">2D \u5377\u79ef\u662f\u4e00\u79cd\u91c7\u7528\u6743\u91cd\u5185\u6838\uff08\u6216\u7a97\u53e3\u6216\u77e9\u9635\uff09\u5e76\u4f7f\u7528\u8fd9\u4e9b\u6743\u91cd\uff08\u6b64\u77e9\u9635\u4e2d\u7684\u503c\uff09\u4ee5\u67d0\u79cd\u65b9\u5f0f\u4fee\u6539\u8f93\u5165\u56fe\u50cf\uff08\u6216\u7279\u5f81\u56fe\u6216\u6fc0\u6d3b\u56fe\uff09\u7684\u64cd\u4f5c\uff0cpad \u9ed8\u8ba4\u88650\u64cd\u4f5c<\/p>\n\n\n\n<h2 id=\"activation-function\">\u6fc0\u6d3b\u51fd\u6570<\/h2>\n\n\n\n<p>\u5728\u795e\u7ecf\u7f51\u7edc\u4e2d\u7684\u5404\u79cd\u6570\u5b66\u7ebf\u6027\u8fd0\u7b97\u4e4b\u95f4\u5f15\u5165\u4e86\u6fc0\u6d3b\u51fd\u6570\uff0c\u76ee\u7684\u662f\u4e3a\u6574\u4e2a\u7f51\u7edc\u5f15\u5165\u975e\u7ebf\u6027\u3002\u6ca1\u6709\u5b83\uff0c\u6574\u4e2a\u795e\u7ecf\u7f51\u7edc\u5c06\u7b80\u5316\u4e3a\u5355\u4e2a\u7ebf\u6027\u51fd\u6570\uff0c\u6211\u4eec\u90fd\u77e5\u9053\u8fd9\u6837\u7684\u51fd\u6570\u4e0d\u8db3\u4ee5\u6a21\u62df\u4efb\u4f55\u590d\u6742\u7684\u4e1c\u897f\uff0c\u5fd8\u8bb0\u50cf\u56fe\u50cf\u8bc6\u522b\u8fd9\u6837\u7684\u4e1c\u897f\u3002<\/p>\n\n\n\n<p>\u6587\u732e\u4e2d\u6709\u591a\u79cd\u7528\u4e8e\u6b64\u76ee\u7684\u7684\u51fd\u6570\uff0c\u4f46\u6700\u5e38\u7528\uff08\u4e5f\u662f\u7b2c\u4e00\u4e2a\uff09\u4f7f\u7528\u7684\u51fd\u6570\u662f ReLu\uff08\u6574\u6d41\u7ebf\u6027\u5355\u5143\uff09\u548c Tanh\uff08\u53cc\u66f2\u6b63\u5207\uff09\u51fd\u6570\u3002<\/p>\n\n\n\n<h2>\u6c60\u5316\u51fd\u6570<\/h2>\n\n\n\n<p>\u6c60\u5316\u672c\u8d28\u4e0a\u662f\u4e00\u79cd\u201c\u4e0b\u91c7\u6837\u201d\u64cd\u4f5c\uff0c\u65e8\u5728\u51cf\u5c11\u6570\u636e\u5728\u7f51\u7edc\u4e2d\u4f20\u64ad\u65f6\u7684\u53c2\u6570\u6570\u91cf\u548c\u590d\u6742\u6027\u3002\u6b64\u8fc7\u7a0b\u6d89\u53ca\u5728\u8f93\u5165\u4e0a\u8fd0\u884c\u201c\u6c60\u5316\u7a97\u53e3\u201d\u5e76\u4f7f\u7528\u67d0\u79cd\u7b97\u6cd5\u51cf\u5c0f\u8f93\u5165\u7684\u5927\u5c0f\u3002\u5230\u76ee\u524d\u4e3a\u6b62\uff0c\u6700\u5e38\u89c1\u7684\u7b97\u6cd5\u662f Max &#8211; Pooling \u548c Average &#8211; Pooling\u3002<\/p>\n\n\n\n<p>\u6700\u5927\u6c60\u5316\u2014\u2014\u5728\u8fd9\u79cd\u65b9\u6cd5\u4e2d\uff0c\u6211\u4eec\u53ea\u4fdd\u7559\u843d\u5165\u6c60\u5316\u7a97\u53e3\u7684\u6240\u6709\u503c\u4e2d\u7684\u6700\u5927\u503c\uff0c\u5e76\u4e22\u5f03\u5176\u4ed6\u503c\u3002<\/p>\n\n\n\n<p>\u5e73\u5747\u6c60\u5316 &#8211; \u5728\u6b64\u65b9\u6cd5\u4e2d\uff0c\u8ba1\u7b97\u6c60\u5316\u7a97\u53e3\u5185\u6240\u6709\u5143\u7d20\u7684\u5e73\u5747\u503c\uff0c\u5e76\u4fdd\u7559\u8be5\u503c\u800c\u4e0d\u662f\u6240\u6709\u503c\u3002<\/p>\n\n\n\n<h2>upsaming \u4e0a\u91c7\u6837\uff1a<\/h2>\n\n\n\n<p><code>torch.nn.functional.upsample<\/code>  <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nearest \u91c7\u6837<\/pre>\n\n\n\n<p>yolov3 \u4e2d\u7684\u4e0a\u91c7\u6837\u5c42\u4f7f\u7528\u7684\u662f2*2\u4e0a\u91c7\u6837\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized is-style-default\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-69.png\" alt=\"\" class=\"wp-image-3094\" width=\"348\" height=\"176\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-69.png 490w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-69-300x152.png 300w\" sizes=\"(max-width: 348px) 100vw, 348px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>import torch\nfrom torch import nn\ninput = torch.arange(1, 5, dtype=torch.float32).view(1, 1, 2, 2)\ninput\n\n\ntensor(&#091;&#091;&#091;&#091;1., 2.],\n          &#091;3., 4.]]]])\n \n\nm = nn.Upsample(scale_factor=2, mode='nearest')\nm(input)\n\u8fd4\u56de\uff1a\n\ntensor(&#091;&#091;&#091;&#091;1., 1., 2., 2.],\n          &#091;1., 1., 2., 2.],\n          &#091;3., 3., 4., 4.],\n          &#091;3., 3., 4., 4.]]]])\n\n<\/code><\/pre>\n\n\n\n<h3>\u6700\u90bb\u8fd1\u63d2\u503c\u7b97\u6cd5<\/h3>\n\n\n\n<p>\u9996\u5148\u5047\u8bbe\u539f\u56fe\u662f\u4e00\u4e2a\u50cf\u7d20\u5927\u5c0f\u4e3aW*H\u7684\u56fe\u7247\uff0c\u7f29\u653e\u540e\u7684\u56fe\u7247\u662f\u4e00\u4e2a\u50cf\u7d20\u5927\u5c0f\u4e3aw*h\u7684\u56fe\u7247\uff0c\u8fd9\u65f6\u5019\u6211\u4eec\u662f\u5df2\u77e5\u539f\u56fe\u4e2d\u6bcf\u4e2a\u50cf\u7d20\u70b9\u4e0a\u7684\u50cf\u7d20\u503c\uff08\u5373\u7070\u5ea6\u503c\u7b49\uff09\u7684\uff08\u26a0\ufe0f\u50cf\u7d20\u70b9\u5bf9\u5e94\u50cf\u7d20\u503c\u7684\u5750\u6807\u90fd\u662f\u6574\u6570\uff09\u3002\u8fd9\u4e2a\u65f6\u5019\u5df2\u77e5\u7f29\u653e\u540e\u6709\u4e00\u4e2a\u50cf\u7d20\u70b9\u4e3a(x,y)\uff0c\u60f3\u8981\u5f97\u5230\u8be5\u50cf\u7d20\u70b9\u7684\u50cf\u7d20\u503c\uff0c\u90a3\u4e48\u5c31\u8981\u6839\u636e\u7f29\u653e\u6bd4\u4f8b\u53bb\u67e5\u770b\u5176\u5bf9\u5e94\u7684\u539f\u56fe\u7684\u50cf\u7d20\u70b9\u7684\u50cf\u7d20\u503c\uff0c\u7136\u540e\u5c06\u8be5\u50cf\u7d20\u503c\u8d4b\u503c\u7ed9\u8be5\u7f29\u653e\u540e\u56fe\u7247\u7684\u50cf\u7d20\u70b9(x,y)<\/p>\n\n\n\n<p>\u7f29\u653e\u516c\u5f0f\u4e3a\uff1a<\/p>\n\n\n\n<ul><li>\u6839\u636e\u6a2a\u8f74\uff0c\u5373\u5bbd\u53ef\u5f97\uff1aX\/x = W\/w<\/li><li>\u6839\u636e\u7eb5\u8f74\uff0c\u5373\u9ad8\u53ef\u5f97\uff1aY\/y = H\/h<\/li><li>\u90a3\u4e48\u80fd\u591f\u5f97\u5230 f\uff08X,Y\uff09= f( W\/w * x, H\/h *y)<\/li><\/ul>\n\n\n\n<p>\u56e0\u6b64\u8fd9\u4e2a\u65f6\u5019\u7f29\u653e\u540e\u7684\u56fe\u7247\u50cf\u7d20\u70b9(x,y)\u7684\u50cf\u7d20\u503c\u5c31\u5bf9\u5e94\u7740\u539f\u56fe\u50cf\u7d20\u70b9( W\/w * x, H\/h *y)\u7684\u50cf\u7d20\u503c<\/p>\n\n\n\n<p>\u4f46\u662f\u8fd9\u4e2a\u65f6\u5019\u4f1a\u51fa\u73b0\u4e00\u4e2a\u95ee\u9898\u5c31\u662f\u56e0\u4e3a\u7f29\u653e\u6bd4\u4f8b\u7684\u539f\u56e0\uff0c\u4f1a\u5bfc\u81f4\u50cf\u7d20\u70b9( W\/w * x, H\/h *y)\u4e2d\u7684\u503c\u4e0d\u662f\u6574\u6570\uff0c\u90a3\u4e48\u5c31\u4e0d\u77e5\u9053\u5e94\u8be5\u5bf9\u5e94\u7684\u662f\u54ea\u4e2a\u50cf\u7d20\u70b9\u7684\u50cf\u7d20\u503c<\/p>\n\n\n\n<p>\u8fd9\u4e2a\u65f6\u5019\u6700\u90bb\u8fd1\u63d2\u503c\u7b97\u6cd5\u4f7f\u7528\u7684\u65b9\u6cd5\u5c31\u662f\u56db\u820d\u4e94\u5165\u6cd5\uff0c\u8868\u793a\u4e3a[.],\u6240\u4ee5\u50cf\u7d20\u503cf(x,y) = f( [W\/w * x],&nbsp; [H\/h *y])<\/p>\n\n\n\n<p>\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5982\u679c\u539f\u56fe\u4e3a5*5\uff0c\u7f29\u653e\u540e\u7684\u56fe\u4e3a3*3\uff0c\u90a3\u4e48\u7f29\u653e\u540e\u7684\u56fe\u7684\u50cf\u7d20\u70b9(1,1)\u5bf9\u5e94\u7684\u5c31\u662f\u539f\u56fe\u4e2d([5\/3 * 1], [5\/3 * 1]) = ([0.6], [0.6]) = (1,1) \u50cf\u7d20\u70b9\u5bf9\u5e94\u7684\u50cf\u7d20\u503c<\/p>\n\n\n\n<p>\u8fd9\u79cd\u65b9\u6cd5\u7684\u597d\u5904\u5c31\u662f\u7b80\u5355\uff0c\u4f46\u662f\u574f\u5904\u5c31\u662f\u592a\u8fc7\u7c97\u66b4\uff0c\u4f1a\u7f3a\u5931\u7cbe\u5ea6\uff0c\u9020\u6210\u7f29\u653e\u540e\u7684\u56fe\u50cf\u7070\u5ea6\u4e0a\u7684\u4e0d\u8fde\u7eed\uff0c\u5728\u53d8\u5316\u5730\u65b9\u53ef\u80fd\u51fa\u73b0\u660e\u663e\u952f\u9f7f\u72b6\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a\uff08\u5de6\u539f\u56fe\uff0c\u53f3\u7f29\u653e\u540e\uff09<\/p>\n\n\n\n<h3>\u7d2f\u52a0\u5c42accumulate\uff1a<\/h3>\n\n\n\n<p>\u5728yolo\u4e2d\u5b58\u5728\u7d2f\u52a0\u64cd\u4f5c\uff1aconv\u5c42 \u7684\u8f93\u51fa\u4e0e\u53e6\u5916\u4e00\u4e2aconv\u5c42\u8f93\u51fa\u52a0\u548c\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" width=\"479\" height=\"96\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-70.png\" alt=\"\" class=\"wp-image-3101\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-70.png 479w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-70-300x60.png 300w\" sizes=\"(max-width: 479px) 100vw, 479px\" \/><\/figure>\n\n\n\n<h2>yolo\u8f93\u51fa\u5c42<\/h2>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/so.csdn.net\/so\/search?q=yoloV3&amp;spm=1001.2101.3001.7020\" target=\"_blank\">yolo<\/a>\u5728\u7ecf\u8fc7\u591a\u4e2a\u5377\u79ef\u548c\u4e0a\u91c7\u6837\u4e4b\u540e\u6700\u7ec8\u5f97\u5230\u7684\u662f2\u4e2a\u4e2a\u5377\u79ef\u7ed3\u679c\uff0813*13*255\uff0c26*26*255\uff09\uff0c\u6bcf\u4e00\u4e2a\u5377\u79ef\u7ed3\u679c\u7684\u957f\u548c\u5bbd\u5206\u522b\u662f\uff0813&#215;13,26&#215;26),\u6df1\u5ea6\u4fe1\u606f\u662f [4(box\u4fe1\u606f)+1(\u7269\u4f53\u5224\u522b\u4fe1\u606f)+80(classNum\u7f6e\u4fe1\u5ea6)] *3(\u6bcf\u4e2a\u70b9\u4e0a\u9762\u8ba1\u7b97\u51e0\u4e2aanchor)<\/p>\n\n\n\n<p>\u5bf9\u4e8e\u5177\u6709Gh\u00d7Gw\u00d7Nin\u8f93\u5165\u7684YoLO\u5c42\uff0c\u5b83\u5c06\u539f\u59cb\u56fe\u50cf\u5212\u5206\u4e3a Gh\u00d7Gw \u7f51\u683c\u3002\u901a\u9053\u6570n\u7b49\u4e8e\uff084 +1+C\uff09\u00d7B\uff0c\u5176\u4e2dB\u8868\u793a\u5728\u4e00\u4e2a\u7f51\u683c\u4e2d\u53ef\u4ee5\u68c0\u6d4b\u5230\u591a\u5c11\u4e2a\u5bf9\u8c61\uff0cC\u8868\u793a\u5bf9\u8c61\u7c7b\u522b\u7684\u6570\u91cf\u3002\u5728YOLOv3 tiny\u4e2d\uff0cB\u8bbe\u7f6e\u4e3a3\uff0cCOCO\u6570\u636e\u96c6\u4e2d\u670980\u4e2a\u7c7b\uff08c=80\uff09.<\/p>\n\n\n\n<p> \u56e0\u6b64\uff0cYLO\u5c42\u7684\u8f93\u5165\u5177\u6709255\u7684\u6052\u5b9a\u503c\uff0c\u8fd9\u8fdb\u4e00\u6b65\u5206\u4e3a3\u7ec4\uff08 \u8868\u793a\u5728\u4e00\u4e2a\u7f51\u683c\u4e2d\u53ef\u4ee5\u68c0\u6d4b 3\u79cd\u5bf9\u8c61\uff09\u3002\u5728\u6bcf\u7ec4\u4e2d\uff0c4\u4e2a\u901a\u9053\u63d0\u4f9b\u5173\u4e8e\u8fb9\u754c\u6846\u7684\u4fe1\u606f\uff0c1\u4e2a\u901a\u9053\u8868\u793a\u5bf9\u8c61\u5206\u6570\uff0c\u5176\u4f5980\u4e2a\u901a\u9053\u8868\u793a\u5355\u4e2a\u7c7b\u5206\u6570\u3002Yolo\u5c42\u5728\u6240\u6709\u901a\u9053\u4e0a\u4f7f\u7528Sigmod\u6fc0\u6d3b\u51fd\u6570\uff0c\u9664\u4e86\u8868\u793a\u8fb9\u754c\u6846\u5bbd\u5ea6\u548c\u9ad8\u5ea6\u7684\u901a\u9053\u4ee5\u5916\u3002\u5173\u952e\u5728\u4e8e\u6307\u5b9a\u54ea\u4e9b\u901a\u9053\u5e94\u8be5\u901a\u8fc7sigmoid\u51fd\u6570\uff0c\u54ea\u4e9b\u901a\u9053\u5e94\u8be5\u4e0d\u88ab\u89e6\u53ca\u3002\u89e3\u51b3\u65b9\u6848\u662f\u63d0\u4f9b\u4e00\u4e2a\u8868\uff0c\u5176\u4e2d\u6bcf\u4e2a\u4f4d\u90fd\u8868\u793a\u662f\u5426\u5e94\u8f6c\u6362\u901a\u9053\u3002<\/p>\n\n\n\n<p>\u6700\u7ec8\u5f97\u5230\u7684\u8fb9\u6846\u5750\u6807\u503c\u662fbx,by,bw,bh\u5373\u8fb9\u754c\u6846bbox\u76f8\u5bf9\u4e8efeature map\u7684\u4f4d\u7f6e\u548c\u5927\u5c0f\uff0c\u662f\u6211\u4eec\u9700\u8981\u7684\u9884\u6d4b\u8f93\u51fa\u5750\u6807\u3002\u4f46<strong>\u7f51\u7edc\u5b9e\u9645\u4e0a\u7684\u5b66\u4e60\u76ee\u6807\u662ftx,ty,tw,th\u8fd9\uff14\u4e2a\u504f\u79fb\u91cf\uff08<\/strong>offsets<strong>\uff09<\/strong>\uff0c\u5176\u4e2d<strong>tx,ty<\/strong>\u662f\u9884\u6d4b\u7684\u5750\u6807\u504f\u79fb\u503c\uff0c<strong>tw,th<\/strong>\u662f\u5c3a\u5ea6\u7f29\u653e\uff0c\u6709\u4e86\u8fd9\uff14\u4e2aoffsets\uff0c\u81ea\u7136\u53ef\u4ee5\u6839\u636e\u56fe2\u7684\u516c\u5f0f\u53bb\u6c42\u5f97\u771f\u6b63\u9700\u8981\u7684bx,by,bw,bh\uff14\u4e2a\u5750\u6807\u3002bx\uff0cby\u662f\u9884\u6d4b\u6846\u4e2d\u5fc3\u5750\u6807\uff0cbw\uff0cbh\u662f\u9884\u6d4b\u6846\u7684\u5bbd\u9ad8<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-77.png\" alt=\"\" class=\"wp-image-3159\" width=\"196\" height=\"176\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-77.png 435w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-77-300x270.png 300w\" sizes=\"(max-width: 196px) 100vw, 196px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-81.png\" alt=\"\" class=\"wp-image-3179\" width=\"338\" height=\"38\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-81.png 694w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-81-300x34.png 300w\" sizes=\"(max-width: 338px) 100vw, 338px\" \/><\/figure><\/div>\n\n\n\n<p>\u5176\u4e2d \\(C_{x}  C_{y}\\)<strong>\u662f feature map\u4e0aanchor box\u7684\u5bbd\u548c\u9ad8<\/strong>, \\(t_{y}, t_{w}  t_{z}  t_{x}\\)\u662f 4\u4e2a\u901a\u9053\u63d0\u4f9b\u5173\u4e8e\u8fb9\u754c\u6846\u7684\u4fe1\u606f <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"232\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-79-1024x232.png\" alt=\"\" class=\"wp-image-3176\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-79-1024x232.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-79-300x68.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-79-768x174.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-79.png 1093w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Cx,Cy\u662ffeature map\u4e2dgrid cell\u7684\u5de6\u4e0a\u89d2\u5750\u6807\uff0c\u5728yolov3\u4e2d\u6bcf\u4e2agrid cell\u5728feature map\u4e2d\u7684\u5bbd\u548c\u9ad8\u5747\u4e3a1\u3002\u5982\u56fe3\u7684\u60c5\u5f62\u65f6\uff0c\u8fd9\u4e2abbox\u8fb9\u754c\u6846\u7684\u4e2d\u5fc3\u5c5e\u4e8e\u7b2c\u4e8c\u884c\u7b2c\u4e8c\u5217\u7684grid cell\uff0c\u5b83\u7684\u5de6\u4e0a\u89d2\u5750\u6807\u4e3a(1,1)\uff0c\u6545Cx=1,Cy=1\u3002Pw\u3001Ph\u662f\u9884\u8bbe\u7684anchor box\u6620\u5c04\u5230feature map\u4e2d\u7684\u5bbd\u548c\u9ad8\uff0c\u5728yolov3.cfg\u6587\u4ef6\u4e2d\u7684anchor box\u539f\u672c\u8bbe\u5b9a\u662f\u76f8\u5bf9\u4e8e416*416\u5750\u6807\u7cfb\u4e0b\u7684\u5750\u6807\uff0c\u4ee3\u7801\u4e2d\u662f\u628acfg\u4e2d\u8bfb\u53d6\u7684\u5750\u6807\u9664\u4ee5stride\u598232\u6620\u5c04\u5230feature map\u5750\u6807\u7cfb\u4e2d\u3002<\/p>\n\n\n\n<p> yolov3.cfg\u6587\u4ef6\u4e2d\u7684anchor box \uff1a<\/p>\n\n\n\n<p>anchors = 10,14, &nbsp;23,27, &nbsp;37,58, &nbsp;81,82, &nbsp;135,169, &nbsp;344,319<\/p>\n\n\n\n<p>\u95ee\u9898\uff1aanchor box\u4f5c\u7528\u7684\u8be6\u7ec6\u63cf\u8ff0\u3002<br>\u89e3\u7b54\uff1aYOLO3\u4e3a\u6bcf\u79cdFPN\u9884\u6d4b\u7279\u5f81\u56fe\uff0813*13,26*26,52*52\uff09\u8bbe\u5b9a3\u79cdanchor box\uff0c\u603b\u5171\u805a\u7c7b\u51fa9\u79cd\u5c3a\u5bf8\u7684anchor box\u3002\u5728COCO\u6570\u636e\u96c6\u8fd99\u4e2aanchor box\u662f\uff1a(10&#215;13)\uff0c(16&#215;30)\uff0c(33&#215;23)\uff0c(30&#215;61)\uff0c(62&#215;45)\uff0c(59&#215;119)\uff0c(116&#215;90)\uff0c(156&#215;198)\uff0c(373&#215;326)\u3002\u5206\u914d\u4e0a\uff0c\u5728\u6700\u5c0f\u768413*13\u7279\u5f81\u56fe\u4e0a\u7531\u4e8e\u5176\u611f\u53d7\u91ce\u6700\u5927\u6545\u5e94\u7528\u6700\u5927\u7684anchor box (116&#215;90)\uff0c(156&#215;198)\uff0c(373&#215;326)\uff0c\uff08\u8fd9\u51e0\u4e2a\u5750\u6807\u662f\u9488\u5bf9416*416\u4e0b\u7684\uff0c\u5f53\u7136\u8981\u9664\u4ee532\u628a\u5c3a\u5ea6\u7f29\u653e\u523013*13\u4e0b\uff09\uff0c\u9002\u5408\u68c0\u6d4b\u8f83\u5927\u7684\u76ee\u6807\u3002\u4e2d\u7b49\u768426*26\u7279\u5f81\u56fe\u4e0a\u7531\u4e8e\u5176\u5177\u6709\u4e2d\u7b49\u611f\u53d7\u91ce\u6545\u5e94\u7528\u4e2d\u7b49\u7684anchor box (30&#215;61)\uff0c(62&#215;45)\uff0c(59&#215;119)\uff0c\u9002\u5408\u68c0\u6d4b\u4e2d\u7b49\u5927\u5c0f\u7684\u76ee\u6807\u3002\u8f83\u5927\u768452*52\u7279\u5f81\u56fe\u4e0a\u7531\u4e8e\u5176\u5177\u6709\u8f83\u5c0f\u7684\u611f\u53d7\u91ce\u6545\u5e94\u7528\u6700\u5c0f\u7684anchor box(10&#215;13)\uff0c(16&#215;30)\uff0c(33&#215;23)\uff0c\u9002\u5408\u68c0\u6d4b\u8f83\u5c0f\u7684\u76ee\u6807\u3002\u540cFaster-Rcnn\u4e00\u6837\uff0c\u7279\u5f81\u56fe\u7684\u6bcf\u4e2a\u50cf\u7d20\uff08\u5373\u6bcf\u4e2agrid\uff09\u90fd\u4f1a\u6709\u5bf9\u5e94\u7684\u4e09\u4e2aanchor box\uff0c\u598213*13\u7279\u5f81\u56fe\u7684\u6bcf\u4e2agrid\u90fd\u6709\u4e09\u4e2aanchor box (116&#215;90)\uff0c(156&#215;198)\uff0c(373&#215;326)\uff08\u8fd9\u51e0\u4e2a\u5750\u6807\u9700\u9664\u4ee532\u7f29\u653e\u5c3a\u5bf8\uff09\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1002\" height=\"776\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-82.png\" alt=\"\" class=\"wp-image-3183\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-82.png 1002w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-82-300x232.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-82-768x595.png 768w\" sizes=\"(max-width: 1002px) 100vw, 1002px\" \/><\/figure>\n\n\n\n<h2>\u5377\u79ef\uff1a<\/h2>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">yolo\u5377\u79ef\u9ed8\u8ba4\u88650<\/p>\n\n\n\n<p>         \u4e3b\u8981\u601d\u60f3\u662f\u6784\u5efa\u4e00\u4e2a\u9ad8\u5ea6\u6d41\u6c34\u7ebf\u7684\u6d41\u5f0f\u67b6\u6784\uff0c\u5176\u4e2d\u5904\u7406\u6a21\u5757\u4e0d\u5fc5\u5728\u4efb\u4f55\u65f6\u95f4\u70b9\u505c\u6b62\u3002\u5373\u5377\u79ef\u5668\u7684\u4efb\u4f55\u90e8\u5206\u90fd\u4e0d\u4f1a\u7b49\u5f85\u4efb\u4f55\u5176\u4ed6\u90e8\u5206\u5b8c\u6210\u5176\u5de5\u4f5c\u5e76\u63d0\u4f9b\u7ed3\u679c\u3002\u6bcf\u4e2a\u9636\u6bb5\u5728\u6bcf\u4e2a\u65f6\u949f\u5468\u671f\u7684\u8f93\u5165\u7684\u4e0d\u540c\u90e8\u5206\u4e0a\u8fde\u7eed\u6267\u884c\u6574\u4e2a\u5de5\u4f5c\u7684\u4e00\u5c0f\u90e8\u5206\u3002\u8fd9\u4e0d\u4ec5\u4ec5\u662f\u8be5\u8bbe\u8ba1\u7684\u4e00\u4e2a\u7279\u70b9\uff0c\u5b83\u662f\u4e00\u79cd\u79f0\u4e3a\u201c\u6d41\u6c34\u7ebf\u201d\u7684\u4e00\u822c\u539f\u5219\uff0c\u5e7f\u6cdb\u7528\u4e8e\u5c06\u5927\u578b\u8ba1\u7b97\u8fc7\u7a0b\u5206\u89e3\u4e3a\u66f4\u5c0f\u7684\u6b65\u9aa4\uff0c\u5e76\u63d0\u9ad8\u6574\u4e2a\u7535\u8def\u53ef\u4ee5\u8fd0\u884c\u7684\u6700\u9ad8\u9891\u7387\u3002<\/p>\n\n\n\n<ul><li>\u8bbe\u8ba1\u4f7f\u7528 MAC\uff08\u4e58\u6cd5\u548c\u7d2f\u52a0\uff09\u5355\u5143\uff0c\u65e8\u5728\u5c06\u8fd9\u4e9b\u64cd\u4f5c\u6620\u5c04\u5230 FPGA \u7684 DSP \u6a21\u5757\u3002\u5b9e\u73b0\u8fd9\u4e00\u70b9\u5c06\u4f7f\u4e58\u6cd5\u548c\u52a0\u6cd5\u8fd0\u7b97\u66f4\u5feb\uff0c\u5e76\u4e14\u6d88\u8017\u66f4\u5c11\u7684\u529f\u7387\uff0c\u56e0\u4e3a\u200b\u200b DSP \u6a21\u5757\u662f\u5728\u786c\u5b8f\u4e2d\u5b9e\u73b0\u7684\u3002\u4e5f\u5c31\u662f\u8bf4\uff0cDSP \u6a21\u5757\u5df2\u7ecf\u4ee5\u6700\u6709\u6548\u7684\u65b9\u5f0f\u5408\u6210\u3001\u653e\u7f6e\u548c\u8def\u7531\u5230 FPGA \u8bbe\u5907\u4e0a\u7684\u7845\u7247\u4e2d\uff0c\u8fd9\u4e0e\u4e00\u822c IP \u6a21\u5757\u4e0d\u540c\uff0c\u540e\u8005\u53ea\u5411\u60a8\u63d0\u4f9b\u7ecf\u8fc7\u8bd5\u9a8c\u548c\u6d4b\u8bd5\u7684 RTL \u4ee3\u7801\u5e76\u4e14\u53ef\u4ee5\u5408\u6210\u968f\u5fc3\u6240\u6b32\u3002<\/li><li>\u5377\u79ef\u5668\u53ea\u4e0d\u8fc7\u662f\u4e00\u7ec4 MAC \u5355\u5143\u548c\u4e00\u4e9b\u79fb\u4f4d\u5bc4\u5b58\u5668\uff0c\u5f53\u5b83\u4eec\u63d0\u4f9b\u6b63\u786e\u7684\u8f93\u5165\u65f6\uff0c\u5728\u56fa\u5b9a\u6570\u91cf\u7684\u65f6\u949f\u5468\u671f\u540e\u8f93\u51fa\u5377\u79ef\u7684\u7ed3\u679c<\/li><\/ul>\n\n\n\n<ul><li>\u8f93\u5165\u7279\u5f81\u56fe\uff08\u56fe\u50cf\uff09\u7684\u5927\u5c0f\u662f\u4e00\u4e2a\u7ef4\u5ea6<code>NxN<\/code>\uff0c\u6211\u4eec\u7684\u5185\u6838\uff08\u8fc7\u6ee4\u5668\/\u7a97\u53e3\uff09\u662f\u7ef4\u5ea6<code>KxK<\/code>\u3002\u663e\u7136\u53ef\u4ee5\u7406\u89e3\uff0c\u5373<code>K &lt; N<\/code>.<\/li><li><code>s<\/code>\u8868\u793a\u7a97\u53e3\u5728\u7279\u5f81\u56fe\u4e0a\u79fb\u52a8\u7684\u6b65\u5e45\u503c\u3002<\/li><li>\u6211\u4eec\u8fd8\u6709\u4e00\u4e9b\u4fe1\u53f7\uff0c\u4f8b\u5982<code>valid_conv<\/code>\u548c<code>end_conv<\/code>\u4fe1\u53f7\uff0c\u5b83\u4eec\u544a\u8bc9\u5916\u754c\u8fd9\u4e2a\u5377\u79ef\u5668\u6a21\u5757\u7684\u8f93\u51fa\u662f\u5426\u6709\u6548\u3002\u4f46\u662f\u4e3a\u4ec0\u4e48\u5377\u79ef\u5668\u9996\u5148\u4f1a\u4ea7\u751f\u65e0\u6548\u7684\u7ed3\u679c\u5462\uff1f\u7a97\u53e3\u5728\u8f93\u5165\u7684\u7279\u5b9a\u884c\u4e0a\u5b8c\u6210\u79fb\u52a8\u540e\uff0c\u5b83\u4f1a\u7ee7\u7eed\u73af\u7ed5\u5230\u4e0b\u4e00\u884c\uff0c\u4ece\u800c\u521b\u5efa\u65e0\u6548\u8f93\u51fa\u3002\u53ef\u4ee5\u907f\u514d\u5728\u73af\u7ed5\u671f\u95f4\u8fdb\u884c\u8ba1\u7b97\uff0c\u4f46\u8fd9\u9700\u8981\u6211\u4eec\u505c\u6b62\u6d41\u6c34\u7ebf\uff0c\u8fd9\u8fdd\u53cd\u4e86\u6211\u4eec\u7684\u6d41\u5f0f\u8bbe\u8ba1\u539f\u5219\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u53ea\u662f\u5728\u4fe1\u53f7\u7684\u5e2e\u52a9\u4e0b\u4e22\u5f03\u6211\u4eec\u8ba4\u4e3a\u65e0\u6548\u7684\u8f93\u51fa<code>valid conv<\/code>\u3002<\/li><\/ul>\n\n\n\n<p>\u5177\u4f53\u6d41\u7a0b\uff1a <\/p>\n\n\n\n<p>\u4e0b\u4e00\u6b21\u4ecea1\u5f00\u59cb\u8f93\u5165\uff0c\u8f93\u51fa \u8f93\u51fa = w0*a01+ w1*a2 + w2*a3 + w3*a5 + w4*a6 + w5*a7 + w6*a9 + w7*a10 + w8*a11 <\/p>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><img src=\"https:\/\/thedatabus.io\/static\/convolver-c77524c06470fc0f38cc9cbeb59a6e5a.gif\" alt=\"\u5377\u79ef\u52a8\u753b\"\/><\/figure>\n\n\n\n<p>\u8f93\u51fa = w0*a0 + w1*a1 + w2*a2 + w3*a4 + w4*a5 + w5*a6 + w6*a8 + w7*a9 + w8*a10<\/p>\n\n\n\n<p>\u8fd9\u79cd\u67b6\u6784\u7684\u4f18\u70b9\uff1a<\/p>\n\n\n\n<ul><li>\u8f93\u5165\u7279\u5f81\u56fe\u53ea\u9700\u53d1\u9001\u4e00\u6b21\uff08\u5373\u5b58\u50a8\u7684\u6fc0\u6d3b\u5fc5\u987b\u4ece\u5185\u5b58\u4e2d\u8bbf\u95ee\u4e00\u6b21\uff09\uff0c\u4ece\u800c\u5927\u5927\u51cf\u5c11\u4e86\u5185\u5b58\u8bbf\u95ee\u65f6\u95f4\u548c\u5b58\u50a8\u9700\u6c42\u3002\u79fb\u4f4d\u5bc4\u5b58\u5668\u4e3a\u5148\u524d\u8bbf\u95ee\u7684\u503c\u521b\u5efa\u4e00\u79cd\u672c\u5730\u7f13\u5b58\u3002<\/li><li>\u53ef\u4ee5\u4f7f\u7528\u6b64\u67b6\u6784\u8ba1\u7b97\u4efb\u4f55\u5927\u5c0f\u8f93\u5165\u7684\u5377\u79ef\uff0c\u800c\u65e0\u9700\u7531\u4e8e\u8ba1\u7b97\u80fd\u529b\u4f4e\u800c\u4e2d\u65ad\u8f93\u5165\u6216\u5c06\u5176\u4e34\u65f6\u5b58\u50a8\u5728\u5176\u4ed6\u5730\u65b9<\/li><li>\u5bf9\u4e8e\u4e00\u4e9b\u9700\u8981\u66f4\u5927\u6b65\u5e45\u7684\u5947\u5f02\u67b6\u6784\uff0c\u6b65\u5e45\u503c\u4e5f\u53ef\u4ee5\u66f4\u6539\u3002<\/li><\/ul>\n\n\n\n<p>\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np \nfrom scipy import signal\n\nksize = 3      \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t#ksize x ksize convolution kernel\nim_size = 4   \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t#im_size x im_size input activation map\n\ndef strideConv(arr, arr2, s): \t\t\t\t\t\t\t\t\t\t\t  #the function that performs the 2D convolution\n    return signal.convolve2d(arr, arr2&#091;::-1, ::-1], mode='valid')&#091;::s, ::s]\n\nkernel =  np.arange(0,ksize*ksize,1).reshape((ksize,ksize))                   #the kernel is a matrix of increasing numbers\nact_map = np.arange(0,im_size*im_size,1).reshape((im_size,im_size))           #the activation map is a matrix of increasin numbers\n\nconv = strideConv(act_map,kernel,1)\nprint(kernel)\nprint(act_map)\nprint(conv) <\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" width=\"349\" height=\"363\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-71.png\" alt=\"\" class=\"wp-image-3107\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-71.png 349w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-71-288x300.png 288w\" sizes=\"(max-width: 349px) 100vw, 349px\" \/><\/figure>\n\n\n\n<p><strong>\u5355\u4e2a\u52a0\u6cd5\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>module mac_manual #(\n\tparameter N = 16,\n    parameter Q = 12\n    )(\n    input clk,sclr,ce,\n    input &#091;N-1:0] a,\n    input &#091;N-1:0] b,\n    input &#091;N-1:0] c,\n    output reg &#091;N-1:0] p\n    );\n\n<strong>always@<\/strong>(posedge clk,posedge sclr)\n begin\n    if(sclr)\n    begin\n        p&lt;=0;\n    end\n    else if(ce)\n    begin\n        p &lt;= (a*b+c);                   \/\/performs the multiply accumulate operation\n    end\n end\nendmodule\n\n\n\u5377\u79ef\u4e2d\u7684\u504f\u7f6e\uff1a\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic2.zhimg.com\/v2-89feb22fbdb50d910575ebce8b59cf59_r.jpg\" alt=\"preview\"\/><\/figure>\n\n\n\n<p>\u591a\u5377\u79ef\u6838\u7684\u504f\u7f6e\uff1a\u540c\u4e00\u4e2a\u901a\u9053\u7684\u5377\u79ef\u6838\u5171\u7528\u4e00\u4e2a\u504f\u7f6e\u3002\u6bcf\u4e2a\u5377\u79ef\u6838\u5377\u79ef\u540e\u7684\u7ed3\u679c+bias<\/p>\n\n\n\n<p><a href=\"https:\/\/cs231n.github.io\/assets\/conv-demo\/index.html\">https:\/\/cs231n.github.io\/assets\/conv-demo\/index.html<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"839\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-18-1024x839.png\" alt=\"\" class=\"wp-image-4656\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-18-1024x839.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-18-300x246.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-18-768x630.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-18.png 1232w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 id=\"the-format\">\u5b9a\u70b9\u8868\u793a\uff1a<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"524\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-73-1024x524.png\" alt=\"\" class=\"wp-image-3123\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-73-1024x524.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-73-300x154.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-73-768x393.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-73-1536x786.png 1536w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-73.png 1815w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u5b9a\u70b9\u6570\u5b57\u662f\u5c0f\u6570\u70b9\u4f4d\u7f6e\u4fdd\u6301\u56fa\u5b9a\u7684\u6570\u5b57\uff0c\u4e0e\u6570\u5b57\u6240\u4ee3\u8868\u7684\u503c\u65e0\u5173\u3002\u4e0e\u6d6e\u70b9\u6570\u76f8\u6bd4\uff0c\u8fd9\u4f7f\u5f97\u5b9a\u70b9\u6570\u66f4\u6613\u4e8e\u7406\u89e3\u4ee5\u53ca\u5728\u786c\u4ef6\u4e2d\u5b9e\u73b0\u3002\u4e0e\u6d6e\u70b9\u8fd0\u7b97\u76f8\u6bd4\uff0c\u5b9a\u70b9\u8fd0\u7b97\u4f7f\u7528\u7684\u8d44\u6e90\u4e5f\u5c11\u5f97\u591a\u3002\u5f53\u7136\uff0c\u6240\u6709\u8fd9\u4e9b\u90fd\u9700\u8981\u6743\u8861\u3002\u6d6e\u70b9\u8fd0\u7b97\u53ef\u4ee5\u4e3a\u7279\u5b9a\u4f4d\u5bbd\u63d0\u4f9b\u6bd4\u5b9a\u70b9\u8fd0\u7b97\u66f4\u9ad8\u7684\u7cbe\u5ea6\u3002\u5f53\u6211\u4eec\u4f7f\u7528\u4e8c\u8fdb\u5236\u70b9\u4f4d\u4e8e\u56fa\u5b9a\u4f4d\u7f6e\u7684\u6570\u5b57\u65f6\uff0c\u6211\u4eec\u4f1a\u5728\u91cf\u5316\u566a\u58f0\u65b9\u9762\u53d7\u5230\u6253\u51fb\uff0c\u5c3d\u7ba1\u8be5\u6570\u5b57\u8868\u793a\u5e45\u5ea6\u3002<\/p>\n\n\n\n<div class=\"wp-block-image is-style-default\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-72.png\" alt=\"\" class=\"wp-image-3116\" width=\"386\" height=\"226\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-72.png 536w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-72-300x176.png 300w\" sizes=\"(max-width: 386px) 100vw, 386px\" \/><\/figure><\/div>\n\n\n\n<!--nextpage-->\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2>Acc\u7d2f\u52a0\u6a21\u5757<\/h2>\n\n\n\n<p>\u5173\u952e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wire  outconv &#091;0:N*k*k-1];\nreg &#091;16:0] presum;\nwire &#091;16:0] cout;\ngenerate\n\tgenvar l;\n\tfor(l=0;l&lt;k*k;l=l+1)\n\tbegin\n        convolver #(9'h004,9'h003,1) uut (\n\t\t.clk(clk), \n\t\t.ce(ce), \n\t\t.weight1(weight1), \n\t\t.global_rst(global_rst), \n\t\t.activation(activation), \n\t\t.conv_op(outconv&#091;N*l +: N]), \n\t\t.end_conv(end_conv), \n\t\t.valid_conv(valid_conv)\n\t);\n        fadd ui(.a(outconv&#091;N*l +: N]),        \/\/this i of ui won't be replaced\n                        .b(mid),\n                        .cout(cout),\n                        );\t\t\n\tend\t\nassign mid = cout;\nendgenerate\n\nmodule fadd( \n    input &#091;15:0] a, &#091;15:0] b;\n    output &#091;16:0] cout);\n    assign cout = a+b; \n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/_20220409175243-1-e1649498064148-1024x768.jpg\" alt=\"\" class=\"wp-image-3674\" width=\"806\" height=\"604\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/_20220409175243-1-e1649498064148-1024x768.jpg 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/_20220409175243-1-e1649498064148-300x225.jpg 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/_20220409175243-1-e1649498064148-768x576.jpg 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/_20220409175243-1-e1649498064148-1536x1152.jpg 1536w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/_20220409175243-1-e1649498064148.jpg 1706w\" sizes=\"(max-width: 806px) 100vw, 806px\" \/><\/figure>\n\n\n\n<!--nextpage-->\n\n\n\n<h1 class=\"has-text-align-center\">FIFO\u5b66\u4e60\uff1a<\/h1>\n\n\n\n\n\n<p class=\"has-light-pink-background-color has-background\">1\u3001\u53c2\u8003\u7f51\u7ad9 \uff1a<a href=\"https:\/\/blog.csdn.net\/alangaixiaoxiao?type=blog\">https:\/\/blog.csdn.net\/alangaixiaoxiao?type=blog<\/a><\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">2\u3001FIFO  <a href=\"https:\/\/blog.csdn.net\/alangaixiaoxiao\/article\/details\/81432144?spm=1001.2014.3001.5502\">https:\/\/blog.csdn.net\/alangaixiaoxiao\/article\/details\/81432144?spm=1001.2014.3001.5502<\/a><\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">3\u3001Verilog \u6709\u7b26\u53f7\u6570\u4e0e\u65e0\u7b26\u53f7\u6570\u8fd0\u7b97  <a href=\"https:\/\/blog.csdn.net\/alangaixiaoxiao\/article\/details\/106209193?spm=1001.2014.3001.5502\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/blog.csdn.net\/alangaixiaoxiao\/article\/details\/106209193?spm=1001.2014.3001.5502<\/a><\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">4\u3001HLS\u5b9e\u73b0YOLO\u795e\u7ecf\u7f51\u7edc\u7cfb\u5217\uff08\u4e00\uff09<a href=\"https:\/\/blog.csdn.net\/alangaixiaoxiao\/article\/details\/104634089?spm=1001.2014.3001.5502\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/blog.csdn.net\/alangaixiaoxiao\/article\/details\/104634089?spm=1001.2014.3001.5502<\/a><\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">5\u3001yolov3\u4ece\u5934\u5b9e\u73b0\uff08\u4e94\uff09&#8211; yolov3\u7f51\u7edc\u5757<a href=\"https:\/\/blog.csdn.net\/m0_43609475\/article\/details\/107984633\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/blog.csdn.net\/m0_43609475\/article\/details\/107984633<\/a><\/p>\n\n\n\n<h2>\u4e00\u3001FIFO\u7b80\u4ecb<\/h2>\n\n\n\n<p class=\"has-light-blue-background-color has-background\">\u3000\u3000FIFO\u662f\u82f1\u6587First In First Out \u7684\u7f29\u5199\uff0c\u662f\u4e00\u79cd\u5148\u8fdb\u5148\u51fa\u7684\u6570\u636e\u7f13\u5b58\u5668\uff0c\u5b83\u4e0e\u666e\u901a\u5b58\u50a8\u5668\u7684\u533a\u522b\u662f\u6ca1\u6709\u5916\u90e8\u8bfb\u5199\u5730\u5740\u7ebf\uff0c\u8fd9\u6837\u4f7f\u7528\u8d77\u6765\u975e\u5e38\u7b80\u5355\uff0c\u4f46\u7f3a\u70b9\u5c31\u662f\u53ea\u80fd\u987a\u5e8f\u5199\u5165\u6570\u636e\uff0c\u987a\u5e8f\u7684\u8bfb\u51fa\u6570\u636e\uff0c\u5176\u6570\u636e\u5730\u5740\u7531\u5185\u90e8\u8bfb\u5199\u6307\u9488\u81ea\u52a8\u52a01\u5b8c\u6210\uff0c\u4e0d\u80fd\u50cf\u666e\u901a\u5b58\u50a8\u5668\u90a3\u6837\u53ef\u4ee5\u7531\u5730\u5740\u7ebf\u51b3\u5b9a\u8bfb\u53d6\u6216\u5199\u5165\u67d0\u4e2a\u6307\u5b9a\u7684\u5730\u5740\u3002<\/p>\n\n\n\n<p>\u7528\u90141\uff1a<\/p>\n\n\n\n<p>\u3000\u3000\u5f02\u6b65FIFO\u8bfb\u5199\u5206\u522b\u91c7\u7528\u76f8\u4e92\u5f02\u6b65\u7684\u4e0d\u540c\u65f6\u949f\u3002\u5728\u73b0\u4ee3\u96c6\u6210\u7535\u8def\u82af\u7247\u4e2d\uff0c\u968f\u7740\u8bbe\u8ba1\u89c4\u6a21\u7684\u4e0d\u65ad\u6269\u5927\uff0c\u4e00\u4e2a\u7cfb\u7edf\u4e2d\u5f80\u5f80\u542b\u6709\u6570\u4e2a\u65f6\u949f\uff0c\u591a\u65f6\u949f\u57df\u5e26\u6765\u7684\u4e00\u4e2a\u95ee\u9898\u5c31\u662f\uff0c\u5982\u4f55\u8bbe\u8ba1\u5f02\u6b65\u65f6\u949f\u4e4b\u95f4\u7684\u63a5\u53e3\u7535\u8def\u3002\u5f02\u6b65FIFO\u662f\u8fd9\u4e2a\u95ee\u9898\u7684\u4e00\u79cd\u7b80\u4fbf\u3001\u5feb\u6377\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u4f7f\u7528\u5f02\u6b65FIFO\u53ef\u4ee5\u5728\u4e24\u4e2a\u4e0d\u540c\u65f6\u949f\u7cfb\u7edf\u4e4b\u95f4\u5feb\u901f\u800c\u65b9\u4fbf\u5730\u4f20\u8f93\u5b9e\u65f6\u6570\u636e\u3002<\/p>\n\n\n\n<p>\u7528\u90142\uff1a<\/p>\n\n\n\n<p>\u3000\u3000\u5bf9\u4e8e\u4e0d\u540c\u5bbd\u5ea6\u7684\u6570\u636e\u63a5\u53e3\u4e5f\u53ef\u4ee5\u7528FIFO\uff0c\u4f8b\u5982\u5355\u7247\u673a\u4f4d8\u4f4d\u6570\u636e\u8f93\u51fa\uff0c\u800cDSP\u53ef\u80fd\u662f16\u4f4d\u6570\u636e\u8f93\u5165\uff0c\u5728\u5355\u7247\u673a\u4e0eDSP\u8fde\u63a5\u65f6\u5c31\u53ef\u4ee5\u4f7f\u7528FIFO\u6765\u8fbe\u5230\u6570\u636e\u5339\u914d\u7684\u76ee\u7684\u3002<\/p>\n\n\n\n<p>\u4e8c\u3001\u5206\u7c7b<\/p>\n\n\n\n<p>\u3000\u3000\u540c\u6b65FIFO\u662f\u6307\u8bfb\u65f6\u949f\u548c\u5199\u65f6\u949f\u4e3a\u540c\u4e00\u4e2a\u65f6\u949f\uff0c\u5728\u65f6\u949f\u6cbf\u6765\u4e34\u65f6\u540c\u65f6\u53d1\u751f\u8bfb\u5199\u64cd\u4f5c\uff1b<\/p>\n\n\n\n<p>\u3000\u3000\u5f02\u6b65FIFO\u662f\u6307\u8bfb\u5199\u65f6\u949f\u4e0d\u4e00\u81f4\uff0c\u8bfb\u5199\u65f6\u949f\u662f\u4e92\u76f8\u72ec\u7acb\u7684\u3002<\/p>\n\n\n\n<p>\u4e09\u3001FIFO\u7684\u5e38\u89c1\u53c2\u6570<\/p>\n\n\n\n<ul><li>FIFO\u7684\u5bbd\u5ea6\uff1a\u5373FIFO\u4e00\u6b21\u8bfb\u5199\u64cd\u4f5c\u7684\u6570\u636e\u4f4d\uff1b<\/li><li>FIFO\u7684\u6df1\u5ea6\uff1a\u6307\u7684\u662fFIFO\u53ef\u4ee5\u5b58\u50a8\u591a\u5c11\u4e2aN\u4f4d\u7684\u6570\u636e\uff08\u5982\u679c\u5bbd\u5ea6\u4e3aN\uff09\u3002<\/li><li>\u6ee1\u6807\u5fd7\uff1aFIFO\u5df2\u6ee1\u6216\u5c06\u8981\u6ee1\u65f6\u7531FIFO\u7684\u72b6\u6001\u7535\u8def\u9001\u51fa\u7684\u4e00\u4e2a\u4fe1\u53f7\uff0c\u4ee5\u963b\u6b62FIFO\u7684\u5199\u64cd\u4f5c\u7ee7\u7eed\u5411FIFO\u4e2d\u5199\u6570\u636e\u800c\u9020\u6210\u6ea2\u51fa\uff08overflow\uff09\u3002<\/li><li>\u7a7a\u6807\u5fd7\uff1aFIFO\u5df2\u7a7a\u6216\u5c06\u8981\u7a7a\u65f6\u7531FIFO\u7684\u72b6\u6001\u7535\u8def\u9001\u51fa\u7684\u4e00\u4e2a\u4fe1\u53f7\uff0c\u4ee5\u963b\u6b62FIFO\u7684\u8bfb\u64cd\u4f5c\u7ee7\u7eed\u4eceFIFO\u4e2d\u8bfb\u51fa\u6570\u636e\u800c\u9020\u6210\u65e0\u6548\u6570\u636e\u7684\u8bfb\u51fa\uff08underflow\uff09\u3002<\/li><li>\u8bfb\u65f6\u949f\uff1a\u8bfb\u64cd\u4f5c\u6240\u9075\u5faa\u7684\u65f6\u949f\uff0c\u5728\u6bcf\u4e2a\u65f6\u949f\u6cbf\u6765\u4e34\u65f6\u8bfb\u6570\u636e\u3002<\/li><li>\u5199\u65f6\u949f\uff1a\u5199\u64cd\u4f5c\u6240\u9075\u5faa\u7684\u65f6\u949f\uff0c\u5728\u6bcf\u4e2a\u65f6\u949f\u6cbf\u6765\u4e34\u65f6\u5199\u6570\u636e\u3002<\/li><\/ul>\n\n\n\n<ol type=\"1\"><li>\u8bfb\u5199\u6307\u9488\u7684\u5de5\u4f5c\u539f\u7406<\/li><\/ol>\n\n\n\n<p>\u3000\u3000\u8bfb\u6307\u9488\uff1a\u603b\u662f\u6307\u5411\u4e0b\u4e00\u4e2a\u5c06\u8981\u88ab\u5199\u5165\u7684\u5355\u5143\uff0c\u590d\u4f4d\u65f6\uff0c\u6307\u5411\u7b2c1\u4e2a\u5355\u5143(\u7f16\u53f7\u4e3a0)\u3002<\/p>\n\n\n\n<p>\u3000\u3000\u5199\u6307\u9488\uff1a\u603b\u662f\u6307\u5411\u5f53\u524d\u8981\u88ab\u8bfb\u51fa\u7684\u6570\u636e\uff0c\u590d\u4f4d\u65f6\uff0c\u6307\u5411\u7b2c1\u4e2a\u5355\u5143(\u7f16\u53f7\u4e3a0)<\/p>\n\n\n\n<ol type=\"1\"><li>FIFO\u7684\u201c\u7a7a\u201d\/\u201c\u6ee1\u201d\u68c0\u6d4b<\/li><\/ol>\n\n\n\n<p>\u3000\u3000FIFO\u8bbe\u8ba1\u7684\u5173\u952e\uff1a\u4ea7\u751f\u53ef\u9760\u7684FIFO\u8bfb\u5199\u6307\u9488\u548c\u751f\u6210FIFO\u201c\u7a7a\u201d\/\u201c\u6ee1\u201d\u72b6\u6001\u6807\u5fd7\u3002<\/p>\n\n\n\n<p>\u3000\u3000\u5f53\u8bfb\u5199\u6307\u9488\u76f8\u7b49\u65f6\uff0c\u8868\u660eFIFO\u4e3a\u7a7a\uff0c\u8fd9\u79cd\u60c5\u51b5\u53d1\u751f\u5728\u590d\u4f4d\u64cd\u4f5c\u65f6\uff0c\u6216\u8005\u5f53\u8bfb\u6307\u9488\u8bfb\u51faFIFO\u4e2d\u6700\u540e\u4e00\u4e2a\u5b57\u540e\uff0c\u8ffd\u8d76\u4e0a\u4e86\u5199\u6307\u9488\u65f6<\/p>\n\n\n\n<p>\u5f53\u8bfb\u5199\u6307\u9488\u518d\u6b21\u76f8\u7b49\u65f6\uff0c\u8868\u660eFIFO\u4e3a\u6ee1\uff0c\u8fd9\u79cd\u60c5\u51b5\u53d1\u751f\u5728\uff0c\u5f53\u5199\u6307\u9488\u8f6c\u4e86\u4e00\u5708\uff0c\u6298\u56de\u6765(wrapped around)\u53c8\u8ffd\u4e0a\u4e86\u8bfb\u6307\u9488<\/p>\n\n\n\n<p>\u4e3a\u4e86\u533a\u5206\u5230\u5e95\u662f\u6ee1\u72b6\u6001\u8fd8\u662f\u7a7a\u72b6\u6001\uff0c\u53ef\u4ee5\u91c7\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<p>\u3000  \u65b9\u6cd51\uff1a\u5728\u6307\u9488\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u989d\u5916\u7684\u4f4d(extra bit)\uff0c\u5f53\u5199\u6307\u9488\u589e\u52a0\u5e76\u8d8a\u8fc7\u6700\u540e\u4e00\u4e2aFIFO\u5730\u5740\u65f6\uff0c\u5c31\u5c06\u5199\u6307\u9488\u8fd9\u4e2a\u672a\u7528\u7684MSB\u52a01\uff0c\u5176\u5b83\u4f4d\u56de\u96f6\u3002\u5bf9\u8bfb\u6307\u9488\u4e5f\u8fdb\u884c\u540c\u6837\u7684\u64cd\u4f5c\u3002\u6b64\u65f6\uff0c\u5bf9\u4e8e\u6df1\u5ea6\u4e3a2n\u7684FIFO\uff0c\u9700\u8981\u7684\u8bfb\/\u5199\u6307\u9488\u4f4d\u5bbd\u4e3a(n+1)\u4f4d\uff0c\u5982\u5bf9\u4e8e\u6df1\u5ea6\u4e3a8\u7684FIFO\uff0c\u9700\u8981\u91c7\u75284bit\u7684\u8ba1\u6570\u5668\uff0c0000\uff5e1000\u30011001\uff5e1111\uff0cMSB\u4f5c\u4e3a\u6298\u56de\u6807\u5fd7\u4f4d\uff0c\u800c\u4f4e3\u4f4d\u4f5c\u4e3a\u5730\u5740\u6307\u9488\u3002<\/p>\n\n\n\n<ul><li>\u5982\u679c\u4e24\u4e2a\u6307\u9488\u7684MSB\u4e0d\u540c\uff0c\u8bf4\u660e\u5199\u6307\u9488\u6bd4\u8bfb\u6307\u9488\u591a\u6298\u56de\u4e86\u4e00\u6b21\uff1b\u5982r_addr=0000,\u800cw_addr = 1000,\u4e3a\u6ee1\u3002<\/li><li>\u5982\u679c\u4e24\u4e2a\u6307\u9488\u7684MSB\u76f8\u540c\uff0c\u5219\u8bf4\u660e\u4e24\u4e2a\u6307\u9488\u6298\u56de\u7684\u6b21\u6570\u76f8\u7b49\u3002\u5176\u4f59\u4f4d\u76f8\u7b49\uff0c\u8bf4\u660eFIFO\u4e3a\u7a7a\uff1b<\/li><\/ul>\n\n\n\n<p>tb\u6d4b\u8bd5\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>module tb_fifo_top;\n\n  \/\/inputs \n  reg clk;\n  reg rst;\n  reg &#091;7:0] din;\n  reg wr_en;\n  reg rd_en;\n\n  \/\/outputs \n  wire &#091;7:0] dout;\n  wire full;\n  wire almost_full;\n  wire empty;\n  wire almost_empty;\n  wire &#091;3:0] data_count;\n  wire prog_full;\n  wire prog_empty;\n\n  \/\/ Instantiate the Unit Under Test (UUT) \n  fifo_top uut (\n      .clk(clk),\n      .rst(rst),\n      .din(din),\n      .wr_en(wr_en),\n      .rd_en(rd_en),\n      .dout(dout),\n      .full(full),\n      .almost_full(almost_full),\n      .empty(empty),\n      .almost_empty(almost_empty),\n      .data_count(data_count),\n      .prog_full(prog_full),\n      .prog_empty(prog_empty)  );\n\n  initial begin\n      \/\/ Initialize Inputs \n      clk = 0;\n      rst = 0;\n      din = 0;\n      wr_en = 0;\n      rd_en = 0;\n\n      \/\/ Wait 100 ns for global reset to finish \n      #100; \n\n      \/\/ Add stimulus here \n\n  end\n  always #10 clk = ~clk ;\n\nendmodule<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"535\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-2-1024x535.png\" alt=\"\" class=\"wp-image-3430\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-2-1024x535.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-2-300x157.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-2-768x402.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-2.png 1289w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u4eff\u771f\u5206\u6790\uff1a<\/p>\n\n\n\n<p>\u5728 100 ns \u65f6\u523b\u540e\uff0cempty \u4fe1\u53f7 \u548c almost_empty \u4fe1\u53f7\u56e0\u4e3a FIFO \u4e3a\u7a7a\uff0c\u6240\u4ee5\u4e3a\u9ad8\u7535\u5e73\u6709\u6548\u3002\u4f46\u6211\u4eec\u53ef\u4ee5\u89c2\u5bdf\u5230 full \u4ee5\u53ca almost full \u4fe1\u53f7\u786e\u4ecd\u7136\u4fdd\u6301\u9ad8\u7535\u5e73\uff0c\u5b9e\u9645\u4e0a\u6b64\u65f6\uff0cFIFO \u663e\u7136\u6ca1\u6709\u6ee1\uff0c\u6240\u4ee5\u8fd9\u4e24\u4e2a\u4fe1\u53f7\u662f\u4e0d\u6b63\u786e\u7684\u3002\u4ed6\u4eec\u9700\u8981\u4e00\u6bb5\u65f6\u95f4\uff0c\u4e5f\u5c31\u662f\u76f4\u5230 260 ns \u65f6\u523b\uff0c\u6062\u590d\u5230\u6b63\u5e38\u7684\u4f4e\u7535\u5e73\uff0c\u8fd9\u8bf4\u660e\u8fd9\u4e24\u4e2a\u72b6\u6001\u4fe1\u53f7\u5728\u590d\u4f4d\u540e\u9700\u8981\u4e00\u6bb5\u65f6\u95f4\u624d\u80fd\u6062\u590d\u6b63\u5e38\u3002<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u4f9d\u6b21\u5411 FIFO \u5199\u5165 16 \u4e2a\u6570\u636e\uff0c\u518d\u4f9d\u6b21\u8bfb\u53d6\u3002FIFO \u7684\u6df1\u5ea6\u4e3a 16\u3002\u6211\u4eec\u901a\u8fc7\u7f16\u5199 testbench\uff0c\u8fde\u7eed\u4ea7\u751f 16 \u6b21 wr_en \u5199\u6709\u6548\u4fe1\u53f7\uff0c\u5e76\u6bcf\u6b21 wr_en \u5199\u6709\u6548\u65f6\uff0c\u5199\u5165\u6570\u636e\u52a0\u4e00\u3002\u5ef6\u8fdf\u4e00\u6bb5\u65f6\u5019\u540e\uff0c\u518d\u8fde\u7eed\u4ea7\u751f 16 \u6b21 rd_en \u8bfb\u6709\u6548\u4fe1\u53f7\uff0c\u5c06\u4e4b\u524d\u5199\u5165\u7684\u6570\u636e\u5168\u6570\u8bfb\u53d6\u51fa\u6765\u3002<\/p>\n\n\n\n<p>\u9996\u5148\u6765\u770b\u4e09\u4e2a\u7a7a\u72b6\u6001\u4fe1\u53f7\u3002<\/p>\n\n\n\n<p>\u7b2c\u4e00\u4e2a\u7a7a\u72b6\u6001\u4fe1\u53f7\uff0c\u5728\u7b2c\u4e00\u4e2a wr_en \u4fe1\u53f7\u7ed3\u675f\u540e\u7684\u7b2c\u4e00\u4e2a\u65f6\u949f\u4e0a\u5347\u6cbf\u7f6e\u4f4e\u3002almost_empty \u4fe1\u53f7\u5728\u7b2c\u4e8c\u4e2a\u5199\u4f7f\u80fd\u4fe1\u53f7\u540e\u7684\u65f6\u949f\u4e0a\u5347\u6cbf\u7f6e\u4f4e\uff0c\u4ee3\u8868\u6b64\u65f6 FIFO \u4e2d\u5df2\u7ecf\u6709\u8d85\u8fc7\u4e00\u4e2a\u6570\u636e\u3002\u800c prog_empty \u6211\u4eec\u81ea\u5b9a\u4e49\u7684\u201c\u51e0\u4e4e\u201d\u7a7a\u4fe1\u53f7\uff0c\u5728\u5199\u5165\u4e09\u4e2a\u6570\u636e\u540e\u7f6e\u4f4e\uff0c\u56e0\u4e3a\u6211\u4eec\u8bbe\u7f6e\u7684\u81ea\u5b9a\u4e49\u9608\u503c\u662f 2\uff0cFIFO \u4e2d\u6709\u8d85\u8fc7\u4e24\u4e2a\u6570\u636e\u540e\u4fe1\u53f7\u4e0d\u518d\u6709\u6548\u3002\u4e0d\u8fc7\u6211\u4eec\u53ef\u4ee5\u89c2\u5bdf\u5230\u53ef\u7f16\u7a0b\u4fe1\u53f7\u548c\u539f\u751f\u4fe1\u53f7\u76f8\u6bd4\u6709\u4e00\u4e2a\u5468\u671f\u7684\u5ef6\u65f6\uff0c\u5982\u679c\u5bf9\u5468\u671f\u654f\u611f\u7684\u5e94\u7528\u5e94\u5f53\u6ce8\u610f\u5230\u8fd9\u4e2a\u5c0f\u5c0f\u7684\u5468\u671f\u65f6\u5ef6\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>full \u6ee1\u4fe1\u53f7\u548c empty \u4fe1\u53f7\u7684\u7279\u6027\u5b8c\u5168\u76f8\u540c\uff0c\u6211\u4eec\u6765\u770b\u4e0b full \u4fe1\u53f7\u7684\u7f6e\u9ad8\u4e0e\u7f6e\u4f4e\u7684\u8fc7\u7a0b\u3002\u5728\u590d\u4f4d\u4e00\u6bb5\u65f6\u95f4\u540e\uff0cfull \u4fe1\u53f7\u6062\u590d\u6b63\u5e38\u3002\u5f53\u5199\u5165\u7b2c 14 \u4e2a\u6570\u636e\u540e\uff0cprog_full \u4fe1\u53f7\u7f6e\u8d77\u3002\u5199\u5165\u7b2c15 \u4e2a\u6570\u636e\u540e\uff0c\u5728\u5199\u6709\u6548\u4fe1\u53f7\u9ad8\u7535\u5e73\u4e4b\u540e\u7684\u7b2c\u4e00\u4e2a\u4e0a\u5347\u6cbf\uff0calmost_full \u4fe1\u53f7\u7f6e\u8d77\u3002\u6700\u540e\u662f full \u4fe1\u53f7\uff0cprog_full \u4fe1\u53f7\u4ecd\u7136\u6709\u4e00\u4e2a\u65f6\u949f\u7684\u5ef6\u8fdf\u3002<\/p>\n\n\n\n<p>FIFO \u63d0\u4f9b\u4e86\u4e00\u7ec4\u63a5\u53e3\u7528\u4e8e\u663e\u793a\u5f53\u524d FIFO \u4e2d\u7684\u6570\u636e\u4e2a\u6570\u3002\u5728\u7b2c\u4e00\u4e2a\u6570\u636e\u5199\u5165\u540e\uff0cdata_count \u5c31\u53d8\u5316\u4e3a 1\uff0c\u4e4b\u540e\u6bcf\u5199\u5165\u4e00\u4e2a\u6570\u636e\u589e\u957f 1 \u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u9700\u8981\u8bb0\u5f55\u5199\u5165 FIFO \u7684\u6570\u636e\u6570\u91cf\uff0c\u6bd4\u5982\u6211\u4eec\u9700\u8981\u5728 FIFO \u4e2d\u7f13\u5b58\u4e00\u5e27 16 byte \u957f\u7684\u6570\u636e\uff0c\u6211\u4eec\u7684 FIFO \u51fa\u4e8e\u591a\u5e27\u6570\u636e\u7f13\u51b2\u7684\u9700\u6c42\uff0c\u6df1\u5ea6\u80af\u5b9a\u8fdc\u5927\u4e8e\u4e00\u5e27\u6570\u636e\u7684\u957f\u5ea6\uff0c\u90a3\u4e48\u6211\u4eec\u663e\u7136\u65e0\u6cd5\u4f9d\u9760\u7a7a\uff0c\u6ee1\u4fe1\u53f7\u8fdb\u884c\u5224\u65ad\u3002\u4e00\u65b9\u9762\u53ef\u4ee5\u81ea\u5df1\u4f7f\u7528\u903b\u8f91\u5bf9\u5199\u4f7f\u80fd\u8fdb\u884c\u8ba1\u6570\uff0c\u6216\u8005\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 FIFO \u6838\u63d0\u4f9b\u7684\u8ba1\u6570\u529f\u80fd\uff0c\u8be5\u529f\u80fd\u6211\u6ca1\u6709\u9a8c\u8bc1\u8fc7\uff0c\u4f46\u5728\u540c\u6b65\u7684\u60c5\u51b5\u4e0b\uff0c\u6570\u636e\u8ba1\u6570\u5e94\u8be5\u662f\u5b8c\u5168\u51c6\u786e\u7684\u3002<\/p>\n\n\n\n<p>\u503c\u5f97\u6ce8\u610f\u7684\u662f\u5728\u5199\u5165\u7b2c 16 \u4e2a\u6570\u636e\u540e\uff0c\u8ba1\u6570\u8f93\u51fa\u53d8\u4e3a 0 \uff0c\u8fd9\u662f\u4e2a\u5c0f\u5931\u8bef\uff0c\u56e0\u4e3a\u6211\u4eec\u7684\u56db\u4f4d\u8ba1\u6570\u503c\u663e\u7136\u5728\u8bb0\u5f55 16 \u65f6\u6ea2\u51fa\u4e86\uff0c\u56e0\u6b64\u6211\u4eec\u4e00\u822c\u9700\u8981 log2(\u6df1\u5ea6) + 1 \u4f4d\u5bbd\u7684\u8ba1\u6570\u503c\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>\u8bfb\u5ef6\u8fdf\u4e0e First Word Fall Through \u7279\u6027<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic1.zhimg.com\/v2-4c2a23f06e2b54fc92bce2d2c65a7420_r.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u7b2c\u4e00\u884c\u662f\u8bfb\u53d6\u7684\u6570\u636e\uff0c\u7b2c\u4e8c\u884c\u662f\u8bfb\u4f7f\u80fd\u4fe1\u53f7\uff0c\u6700\u540e\u4e00\u884c\u662f\u65f6\u949f\u3002\u6211\u4eec\u4ece\u7b2c\u4e8c\u4e2a\u8bfb\u4f7f\u80fd\u4fe1\u53f7\u6765\u770b\u4f1a\u6bd4\u8f83\u6e05\u6670\uff0c\u56e0\u4e3a\u6570\u636e\u901a\u9053\u7684\u590d\u4f4d\u503c\u662f 0x0\uff0c\u4f46\u7b2c\u4e00\u4e2a\u5199\u5165\u7684\u6570\u636e\u4e5f\u662f 0x0,\u6240\u4ee5\u7b2c\u4e00\u4e2a\u8bfb\u4f7f\u80fd\u4fe1\u53f7\u770b\u4e0d\u592a\u6e05\u6670\u3002\u7b2c\u4e8c\u4e2a\u8bfb\u4f7f\u80fd\u4fe1\u53f7\u5728\u9ec4\u7ebf\u5904\u7684\u65f6\u949f\u4e0a\u5347\u6cbf\u7f6e\u8d77\uff0c\u76f4\u5230\u4e0b\u4e00\u4e2a\u65f6\u949f\u4e0a\u5347\u6cbf\uff0c\u6570\u636e 0x01 \u624d\u4f1a\u51fa\u73b0\u5728\u6570\u636e\u7ebf\u4e0a\uff0c\u8fd9\u5c31\u662f\u8bfb\u4fe1\u53f7\u65f6\u7684\u4e00\u4e2a\u65f6\u949f\u5ef6\u8fdf\uff0c\u4e00\u4e2a\u65f6\u949f\u7684\u957f\u5ea6\u662f\u76f8\u5bf9\u4e8e\u8bfb\u4f7f\u80fd\u6709\u6548\u7684\u7b2c\u4e00\u4e2a\u65f6\u949f\u4e0a\u5347\u6cbf\u800c\u8a00\u3002<\/p>\n\n\n\n<p>1\u4e2a\u65f6\u949f\u7684\u56fa\u5b9a\u5ef6\u8fdf\u5bf9\u4e8e\u7b80\u5355\u7684\u540c\u6b65\u7cfb\u7edf\u6765\u8bf4\u95ee\u9898\u4e0d\u5927\uff0c\u53ea\u8981\u5728\u8bfb\u4fe1\u53f7\u6709\u6548\u4e4b\u540e\u56fa\u5b9a\u5ef6\u8fdf\u4e00\u4e2a\u5468\u671f\u518d\u8bfb\u53d6\u6216\u8005\u4f7f\u7528\u8bfb\u6570\u636e\u7ebf\u4e0a\u7684\u6570\u636e\u5373\u53ef\u3002\u6bd4\u5982\u4f7f\u7528\u72b6\u6001\u673a\u65f6\uff0c\u5728\u4e0a\u4e00\u4e2a\u72b6\u6001\u7f6e\u8d77\u8bfb\u6709\u6548\uff0c\u7b49\u5230\u4e0b\u4e00\u4e2a\u72b6\u6001\u518d\u8bfb\u53d6\u6570\u636e\u3002<\/p>\n\n\n\n<p>\u90a3\u4e48\u6709\u6ca1\u6709\u529e\u6cd5\u6d88\u9664\u8fd9\u4e2a\u5ef6\u8fdf\uff0c\u8fd9\u5c31\u53c8\u8981\u8bf4\u8bf4\u6211\u4eec\u4e0a\u7bc7\u4e2d\u914d\u7f6e ip \u6838\u65f6\u89c1\u5230\u7684 First Word Fall Through \u7279\u6027\u3002<\/p>\n\n\n\n<p><strong>\u8be5\u7279\u6027\u7684\u4e3b\u8981\u529f\u80fd\u662f\uff0c\u54ea\u6015\u4f60\u8fd8\u6ca1\u9001\u51fa\u8bfb\u4f7f\u80fd\u4fe1\u53f7\uff0c\u6211\u5c31\u628aFIFO \u4e2d\u4e0b\u4e00\u4e2a\u6570\u636e\u51c6\u5907\u5230\u6570\u636e\u7ebf\u4e0a\u3002\u6bd4\u5982 FIFO \u4e2d\u6709\u4e24\u4e2a\u6570\u636e 0x1,0x2,\u5f53\u4f60\u4ec0\u4e48\u90fd\u8fd8\u6ca1\u505a\u65f6\uff0c\u8bfb\u6570\u636e\u7ebf\u4e0a\u5df2\u7ecf\u662f 0x1\u4e86\uff0c\u5f53\u4f60\u8bfb\u53d6\u4e00\u4e2a\u6570\u636e\u540e\uff0c\u6570\u636e\u7ebf\u4e0a\u5c31\u53d8\u6210\u4e86 0x2 \u2014\u2014\u4e0b\u4e00\u4e2a\u7b49\u5f85\u8bfb\u53d6\u7684\u6570\u636e\u3002\u4f46\u6ce8\u610f\u5230\u4e3a\u4e86\u5b9e\u73b0\u8fd9\u4e2a\u7279\u6027\uff0cFIFO \u771f\u6b63\u7684\u6df1\u5ea6\u5df2\u7ecf\u6269\u5c55\u4e3a 18 \u4f4d\u3002\uff08\u90a3\u4e48\u8ba1\u6ee1\uff0c\u8ba1\u7a7a\u662f\u6309\u7167 18 \u4f4d\u8fd8\u662f 16 \u4f4d\u5462\uff1f\uff09\u3002<\/strong><\/p>\n\n\n\n<p><strong>\u5f53\u6211\u4eec\u5199\u6ea2\u51fa\u4f1a\u600e\u6837\uff0c\u662f\u629b\u5f03\u6700\u65e9\u7684\u6570\u636e\u8fd8\u662f\u65e0\u89c6\u6700\u65b0\u7684\u6570\u636e\uff1f<\/strong><\/p>\n\n\n\n<p>FIFO \u4f7f\u7528\u4e2d\u6700\u9700\u8981\u6ce8\u610f\u7684\u95ee\u9898\u5728\u4e8e\u6ea2\u51fa\uff0c\u6211\u4eec\u9700\u8981\u501f\u52a9\u7a7a\/\u6ee1\u4fe1\u53f7\u6765\u5224\u5b9a FIFO \u7684\u72b6\u6001\uff0c\u5c3d\u91cf\u907f\u514d FIFO \u7684\u8bfb\u5199\u6ea2\u51fa\u3002\u4f46\u5982\u679c\u6211\u4eec\u5199\u6ea2\u51fa\u4e86\u4f1a\u600e\u6837\uff1f<\/p>\n\n\n\n<p>\u6211\u4eec\u5411\u6df1\u5ea6\u4e3a 16 \uff08\u5f00\u542f First Word Fall Through \u7279\u6027\u540e\u5b9e\u9645\u6df1\u5ea6\u4e3a 18 \uff09\u7684FIFO \uff0c\u4e00\u53e3\u6c14\u5199 20 \u4e2a\u6570\u636e\u548c\u4f7f\u80fd\u4fe1\u53f7\u3002\u5f53\u6211\u4eec\u8bfb\u53d6 20 \u4e2a\u4fe1\u53f7\u65f6\uff0c\u6211\u4eec\u662f\u4f1a\u8bfb\u5230\u524d 20 \u4e2a\uff0c\u8fd8\u662f\u540e 20\u4e2a\u6570\u636e\uff1f<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic4.zhimg.com\/v2-b28ef702d0a107d76a4ac05524fd8fc7_r.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u7b54\u6848\u662f\u524d 18 \u4e2a\u6570\u636e\uff0c\u8bfb\u53d6\u5230\u7684\u6700\u540e\u4e00\u4e2a\u6570\u636e\u662f 0x66 \uff0c\u5728 0x66 \u4e4b\u540e\u7684\u4e24\u4e2a\u5199\u5165\u6570\u636e 0x00 \u548c 0x78 \u5e76\u6ca1\u6709\u8fdb\u5165 FIFO\u3002<\/p>\n\n\n\n<p>\u6240\u4ee5\u7ed3\u8bba\u662f FIFO \u5728\u5199\u6ee1\u4e4b\u540e\uff0c\u4f1a\u4fdd\u8bc1\u4e4b\u524d\u5199\u5165\u7684\u6570\u636e\uff0c\u800c\u62d2\u7edd\u65b0\u5199\u5165\u7684\u6570\u636e\u3002\u53e6\u5916\uff0c\u80fd\u591f\u5bb9\u7eb3\u7684\u6570\u636e\u5e76\u4e0d\u662f\u540d\u4e49\u4e0a\u7684 FIFO \u6df1\u5ea6\uff0c\u800c\u662f IP \u6838\u914d\u7f6e\u754c\u9762\u663e\u793a\u7684\u5b9e\u9645\u6df1\u5ea6\uff0c\u672c\u4f8b\u4e2d\u662f 18 \u3002<\/p>\n\n\n\n<p>\u6570\u636e\u56e0\u4e3a FIFO \u5199\u6ee1\u800c\u4e22\u5931\uff0c\u5f88\u6709\u53ef\u80fd\u9020\u6210\u4e25\u91cd\u7684\u7cfb\u7edf\u95ee\u9898\uff0c\u9700\u8981\u8ba4\u771f\u9009\u53d6\u5408\u9002\u7684 FIFO \u6df1\u5ea6\u3002<\/p>\n\n\n\n<p><strong>\u5f53\u6211\u4eec\u7684 FIFO \u6ca1\u6709\u6570\u636e\uff0c\u4f46\u5934\u94c1\u786c\u8981\u8bfb\u53d6\u4f1a\u600e\u6837\uff1f<\/strong><\/p>\n\n\n\n<p>\u5728\u5199\u5165 16 \u4e2a\u6570\u636e\u540e\uff0c\u6211\u4eec\u95f2\u6765\u65e0\u4e8b\uff0c\u51b3\u5b9a\u8bfb\u53d6\u4e2a 20 \u6b21\u6570\u636e\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic3.zhimg.com\/v2-f4db41443aec3bcee31fc6032ecd1662_r.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u4f60\u8bfb\u53d6\u5230\u4e86 16 \u4e2a\u6570\u636e\uff0c\u5e76\u6ca1\u6709\u4ec0\u4e48\u7279\u522b\u7684\u4e8b\u60c5\u53d1\u751f\u3002<\/p>\n\n\n\n<p><strong>\u5f53\u6211\u4eec\u540c\u65f6\u8bfb\u5199\u4f1a\u600e\u6837\uff1f<\/strong><\/p>\n\n\n\n<p>\u5f53 FIFO \u6ca1\u6709\u6570\u636e\u65f6\uff0c\u5728\u5f00\u542f Fall Through \u7684\u60c5\u51b5\u4e0b\uff0c\u540c\u65f6\u8bfb\u53d6\u548c\u5199\u5165\u6570\u636e\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic1.zhimg.com\/v2-297b891e3ff167f63c863c27452bb7c4_r.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u53ef\u4ee5\u53d1\u73b0\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5b58\u5728\u95ee\u9898\uff1a<\/p>\n\n\n\n<p>\u5728\u524d\u4e09\u4e2a\u8bfb\u4f7f\u80fd\u5468\u671f\uff0c\u8bfb\u53d6\u5230\u7684\u90fd\u662f FIFO \u4e2d\u7684\u521d\u59cb\u503c 0x00\uff0c\u76f4\u5230\u7b2c 3 \u4e2a\u8bfb\u4f7f\u80fd\u4fe1\u53f7\uff0c\u624d\u8bfb\u53d6\u5230 FIFO \u4e2d\u7684\u7b2c\u4e00\u4e2a\u6570\u636e 0x80,\u6700\u7ec8 16 \u4e2a\u8bfb\u4f7f\u80fd\u4fe1\u53f7\u5b9e\u9645\u4e0a\u53ea\u8bfb\u5230\u4e86 14 \u4e2a\u6709\u6548\u6570\u636e\u3002<\/p>\n\n\n\n<p>\u4f46\u5982\u679c\u5148\u5199\u5165 3 \u4e2a\u6570\u636e\u540e\uff0c\u518d\u540c\u65f6\u8bfb\u5199<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic3.zhimg.com\/v2-b51ed8be4f128385e416ab849a39e9be_r.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u6b64\u65f6\u5c31\u4e0d\u4f1a\u51fa\u73b0\u95ee\u9898\uff0c\u6240\u4ee5\u5f00\u542f Fall Through \u7684\u60c5\u51b5\u4e0b\uff0c\u524d 2 \u4e2a\u5468\u671f\u662f\u65e0\u6cd5\u8bfb\u53d6\u6570\u636e\u7684\uff0c\u4f46\u5728\u4e4b\u540e\u7684\u65f6\u949f\u4e2d\uff0c\u540c\u65f6\u8bfb\u53d6\u4e5f\u662f\u4e0d\u4f1a\u6709\u95ee\u9898\u7684\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic3.zhimg.com\/v2-66db06f4e8e26f3402ee38d04b618aa2_r.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u6ca1\u6709\u5f00\u542fFall Through \u7684\u60c5\u51b5\u4e0b\uff0c\u7b2c\u4e00\u4e2a\u8bfb\u4f7f\u80fd\u4f1a\u56e0\u4e3a\u4e00\u4e2a\u5468\u671f\u7684\u8bfb\u5ef6\u8fdf\u65e0\u6cd5\u8bfb\u5230\u6570\u636e\u3002\u4e5f\u5c31\u662f\u8bf4\u4f1a\u5c11\u8bfb\u53d6\u4e00\u4e2a\u6570\u636e\u3002<\/p>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>BRAM \u5b66\u4e60 <\/h2>\n\n\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u77e5\u4e4e\uff1a<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\"><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/51600261\">https:\/\/zhuanlan.zhihu.com\/p\/51600261<\/a><\/p>\n\n\n\n<h2>1\u3001BRAM<\/h2>\n\n\n\n<p>       RAM -&gt; Ramdom Access Memory \uff0c\u968f\u673a\u5b58\u53d6\u5b58\u50a8\u5668\u3002\u4f55\u4e3a\u968f\u673a\u5b58\u53d6\u3002\u4e3e\u4e2a\u4e0d\u51c6\u786e\u7684\u4f8b\u5b50\uff1a\u548c\u4e0a\u7bc7\u6587\u7ae0\u4e2d\u7684 FIFO \u8fdb\u884c\u5bf9\u6bd4\u3002\u5bf9\u4e8e FIFO \u6765\u8bf4\uff0c\u53ea\u6709\u8bfb\u5199\u4e24\u4e2a\u64cd\u4f5c\uff0c\u53ea\u80fd<strong>\u987a\u5e8f<\/strong>\u8bfb\u5199\u3002\u4f46\u5bf9\u4e8e RAM \u6765\u8bf4\uff0c\u540c\u6837\u7684\u8bfb\u5199\u64cd\u4f5c\uff0c\u7528\u6237\u53ef\u4ee5\u5728\u8bfb\u5199\u65f6<strong>\u6307\u5b9a\u8bfb\u5199\u7684\u5730\u5740<\/strong>\uff0c\u5b9e\u73b0\u5bf9\u6574\u4e2a\u5b58\u50a8\u5668\u7684<strong>\u4e71\u5e8f\uff08\u968f\u673a\uff09<\/strong>\u8bfb\u5199\u8bbf\u95ee\u3002<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">BRAM -&gt; Block RAM\uff0c\u82b1\u540d\uff1a\u5757 RAM\u3002<\/p>\n\n\n\n<p>FPGA \u4e2d\u6709\u4e24\u79cd RAM \u8d44\u6e90\uff0c\u53e6\u4e00\u79cd RAM \u8d44\u6e90\u4e3a Distributed RAM\uff0cDistributed RAM \u7ecf\u8fc7\u7efc\u5408\u5de5\u5177\u7efc\u5408\uff0c\u901a\u8fc7\u591a\u7ea7 LUT \u67e5\u627e\u8868\u8d44\u6e90\u7ea7\u8054\u5b9e\u73b0\uff0c\u90a3\u4e48\u4e00\u4e2a Distributed RAM \u53ef\u80fd\uff08\u7efc\u5408\u5de5\u5177\u5b9e\u9645\u5e94\u8be5\u4e0d\u4f1a\uff09\u662f\u7531\u5929\u5357\u5730\u5317\uff0c\u76f8\u9694\u5f88\u8fdc\u7684 LUT \u7ea7\u8054\u5b9e\u73b0\u7684\uff0c\u6545\u540d\u5206\u5e03\u5f0f\u3002\u5206\u5e03\u5f0f RAM \u53ef\u4ee5\u5229\u7528\u4e30\u5bcc\u7075\u6d3b\u7684 LUT \u8d44\u6e90\uff0c\u53ef\u4ee5\u6839\u636e\u4f7f\u7528\u60c5\u51b5\u7075\u6d3b\u914d\u7f6e\uff0c\u9002\u5408\u5bf9 RAM \u5ef6\u8fdf\u8981\u6c42\u4e0d\u9ad8\u7684\u573a\u5408\uff0c\u6bd5\u7adf\u5e76\u4e0d\u662f&#8221;\u771f\u6b63&#8221;\u7684 RAM\u3002\uff08\u5176\u5b9e\u7269\u7406\u4e0a\u4e5f\u662f\u771f\u6b63\u7684 RAM\uff0c\u4f46\u4e0d\u662f\u4e13\u7528\u7684\uff09<\/p>\n\n\n\n<p>\u90a3\u4e48 Block RAM \u76f8\u6bd4\u5206\u5e03\u5f0f RAM\uff0c\u5c31\u662f\u4e00\u4f4d<strong>\u4e13\u4e1a<\/strong>\u9009\u624b\u4e86\uff0cBRAM \u662f FPGA \u5382\u5546\u5728\u903b\u8f91\u8d44\u6e90\u4e4b\u5916\uff0c\u7ed9 FPGA \u52a0\u5165\u7684\u4e13\u7528 RAM \u5757\u8d44\u6e90\u3002\u76f8\u6bd4\u5206\u5e03\u5f0f RAM\uff0cRAM \u5757\u5185\u90e8\u4ee5\u53ca\u4e0e\u903b\u8f91\u8d44\u6e90\u4e4b\u95f4\u7ecf\u8fc7\u7279\u610f\u7684\u5e03\u5c40\u5e03\u7ebf\uff0c\u4f7f BRAM \u5177\u6709\u5f88\u9ad8\u7684\u8fd0\u884c\u901f\u5ea6\uff0c\u786e\u5b9a\u7684\u4f4e\u5ef6\u8fdf\u5468\u671f\uff0c\u4f46\u6709\u9650\u7684\u8d44\u6e90\u6570\u91cf\u3002<\/p>\n\n\n\n<h2>vivado IP\u6838<\/h2>\n\n\n\n<p>\u5728 Vivado \u4e2d\uff0c\u4f7f\u7528 BRAM Memory Generator \u53ef\u89c6\u5316\u5de5\u5177\u751f\u6210 BRAM ip \u6838\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7\u5728 Ip catlog \u4e2d\u641c\u7d22 BRAM\uff0c\u5c31\u53ef\u4ee5\u6253\u5f00 Generator<\/p>\n\n\n\n<p>\u5757\/\u5206\u5e03\u5f0f RAM \u6709\u72ec\u7acb\u7684\u751f\u6210\u5de5\u5177\u3002\u53ef\u4ee5\u4ece AXI4 \u4e00\u680f\u4e86\u89e3\u5230\u8be5 IP \u5bf9 AXI4 \u534f\u8bae\u7684\u652f\u6301\u60c5\u51b5\u3002\u652f\u6301 AXI4,AXI4-Lite,AXI-Stream \u6216\u8005\u4e0d\u652f\u6301\u3002<\/p>\n\n\n\n<h3>Native \u63a5\u53e3<\/h3>\n\n\n\n<ul><li>Native \u63a5\u53e3\u5206\u4e3a\u4e09\u7c7b\uff1a<\/li><\/ul>\n\n\n\n<p>\u65f6\u949f\uff0c\u590d\u4f4d\u4fe1\u53f7<br>\u8bfb\u5199\u5730\u5740\u4e0e\u6570\u636e<br>\u5199\u4f7f\u80fd\u4e0e RAM \u4f7f\u80fd<\/p>\n\n\n\n<p><br>\u590d\u4f4d\u4fe1\u53f7\u662f\u53ef\u9009\u7684\u3002<\/p>\n\n\n\n<p>\u8bfb\u5199\u5730\u5740\u7684\u5bbd\u5ea6\u53ef\u4ee5\u57fa\u4e8e RAM \u7684\u6df1\u5ea6\uff0clog2(\u6df1\u5ea6)\uff0c\u4e5f\u53ef\u4ee5\u56fa\u5b9a\u4e3a 32 \u4f4d\u3002<\/p>\n\n\n\n<p>RAM \u5199\u4f7f\u80fd\u6709\u6548\u65f6\uff0c\u53ef\u4ee5\u5199\u5165\u6570\u636e\u3002\u5728\u4f7f\u7528<strong> always enable<\/strong> \u6a21\u5f0f\u4e0b\uff0c\u8bfb\u53d6\u5728\u6bcf\u4e2a\u65f6\u949f\u4e0a\u5347\u6cbf\u6709\u6548\uff0c\u4e0d\u9700\u8981\u989d\u5916\u7684\u4f7f\u80fd\u4fe1\u53f7\u3002\u4e0d\u7136\u7684\u8bdd RAM \u5728\u8bfb\u5199\u65f6\u90fd\u9700\u8981 ena \u4f7f\u80fd\u4fe1\u53f7\u6709\u6548\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic4.zhimg.com\/v2-bef57a630e35a9c21acac609e732a5a7_r.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<h3>Memory \u7c7b\u578b<\/h3>\n\n\n\n<p>\u603b\u4f53\u4e0a Memory \u6309\u7167\u7c7b\u578b\u53ef\u4ee5\u5206\u4e3a RAM \u548c ROM\uff0cROM \u9884\u7f6e\u4e86\u6570\u636e\uff0c\u5728\u4f7f\u7528\u4e2d\u53ea\u80fd\u88ab\u8bfb\u53d6\uff0c\u4e0d\u80fd\u5199\u5165\uff0cROM \u5b9e\u73b0\u7684\u7269\u7406\u7ed3\u6784\u4e0e RAM \u7c7b\u4f3c\uff0c\u76f8\u5f53\u4e8e\u4e00\u4e2a\u53ea\u80fd\u8bfb\u53d6\u7684 \u201dRAM\u201d\u3002\u4e00\u822c\u7528\u4e8e\u5b58\u653e\u4e00\u4e9b\u56fa\u5b9a\u7684\u53c2\u6570\uff0c\u6bd4\u5982 FIR \u6ee4\u6ce2\u5668\u7684\u53c2\u6570\u7b49\u7b49\uff0c\u5728\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u53ea\u9700\u8981\u8bfb\u53d6\uff0c\u4e0d\u9700\u8981\u4e5f\u4e0d\u80fd\u4fee\u6539\u3002<\/p>\n\n\n\n<p>\u6309\u7167\u7aef\u53e3\u7684\u6570\u91cf\u6709\u5355\u7aef\u53e3\u4ee5\u53ca\u53cc\u7aef\u53e3\u4e4b\u5206\uff0c\u53cc\u7aef\u53e3\u6765\u81ea\u4e8e\u540c\u65f6\u5bf9 RAM \u8fdb\u884c\u8bfb\u5199\u7684\u9700\u6c42\u3002\u4e00\u8fb9\u5c06\u7b49\u5f85\u5904\u7406\u7684\u6570\u636e\u4ece\u7aef\u53e3 A \u8f93\u5165 RAM\uff0c\u53e6\u4e00\u7aef\u53e3 B \u8bfb\u53d6\u6570\u636e\u8fdb\u884c\u5904\u7406\uff0c\u53ef\u4ee5\u5b9e\u73b0\u9ad8\u6548\u7684\u6570\u636e\u6d41\u5f0f\u5904\u7406\uff0c\u5c24\u5176\u9002\u7528\u4e8e\u56fe\u50cf\u7684\u884c\u7f13\u5b58\u5904\u7406\u3002\u53cc\u7aef\u53e3 RAM \u76f8\u8f83\u4e8e FIFO \uff0c\u6709\u53ef\u4ee5\u6620\u5c04\u5730\u5740\u4ee5\u53ca\u591a\u6b21\u91cd\u590d\u5229\u7528\u6570\u636e\u7684\u4f18\u52bf\u3002\u5728\u65b0\u7684\u6570\u636e\u5199\u5165\u4e4b\u524d\uff0c\u53ef\u4ee5\u591a\u6b21\u4ece\u4e00\u6307\u5b9a\u4f4d\u7f6e\u8bfb\u53d6\u65e7\u6570\u636e\u3002\u53cc\u7aef\u53e3 RAM \u53c8\u53ef\u4ee5\u5206\u4e3a Simple\/Ture \u53cc\u7aef\u53e3<\/p>\n\n\n\n<h3>\u8bfb\u5199\u51b2\u7a81\u907f\u514d<\/h3>\n\n\n\n<p>\u5bf9\u4e8e\u4e00\u4e2a RAM \u7684\u8bfb\u5199\u65f6\u5e8f\u6765\u8bf4\uff0c\u5199\u5165\u65f6\uff0c\u5199\u4f7f\u80fd\u6709\u6548\uff0c\u5199\u5165 din \u7aef\u53e3\u4e0a\u7684\u6570\u636e\u5230 addr \u7aef\u53e3\u5730\u5740\u4e2d\u3002\u8bfb\u53d6\u65f6\uff0c\u76f4\u63a5\u4ece dout \u7aef\u53e3\u4e0a\u83b7\u5f97\u8f93\u51fa addr \u5730\u5740\u4e0a\u7684\u6570\u636e\u3002\u90a3\u4e48\u5f53\u5199\u4f7f\u80fd\u6709\u6548\u65f6\uff0c\u7528\u6237\u540c\u65f6\u8fdb\u884c\u8bfb\u53d6\u64cd\u4f5c\uff0c\u8bfb\u53d6\u5230\u65b0\u6570\u636e\u8fd8\u662f\u65e7\u6570\u636e\u3002\u8fd9\u53d6\u51b3\u4e8e RAM \u7684\u5de5\u4f5c\u6a21\u5f0f\u3002<\/p>\n\n\n\n<p>\u5de5\u4f5c\u6a21\u5f0f\u5206\u4e3a\u4e09\u7c7b\uff1a\u5199\u4f18\u5148\uff0c\u8bfb\u4f18\u5148\u4ee5\u53ca no change\u3002<\/p>\n\n\n\n<p>\u5199\u4f18\u5148\uff0c\u5728\u8bfb\u5199\u65f6\u949f\u5f02\u6b65\u7684\u60c5\u51b5\u4e0b\uff0c\u63a8\u8350\u4f7f\u7528\u3002\u8be5\u6a21\u5f0f\u4f1a\u4fdd\u8bc1\u5199\u64cd\u4f5c\u4f18\u5148\u53d1\u751f\u3002<\/p>\n\n\n\n<p>\u8bfb\u4f18\u5148\uff0c\u8be5\u6a21\u5f0f\u4ee5\u6d88\u8017\u66f4\u591a BRAM \u8d44\u6e90\u7684\u524d\u63d0\u4e0b\uff0c\u4fdd\u8bc1\u6bcf\u6b21\u8bfb\u64cd\u4f5c\u8bfb\u53d6\u5230\u7684\u90fd\u662f\u5148\u524d\u7684\u6570\u636e\u3002\u8f93\u5165\u6570\u636e\u4f1a\u9996\u5148\u88ab\u7f13\u5b58\uff0c\u4e0e\u6b64\u540c\u65f6\u5728\u8f93\u51fa\u603b\u7ebf\u4e0a\u8f93\u51fa\u5148\u524d\u503c\uff0c\u4e00\u4e2a\u5468\u671f\u7684\u5ef6\u8fdf\u4e4b\u540e\uff0c\u518d\u8f93\u51fa\u8f93\u5165\u6570\u636e\u3002<\/p>\n\n\n\n<p>\u5199\u5165\u671f\u95f4\u6570\u636e\u4e0d\u53d8\uff0c\u8be5\u6a21\u5f0f\u5f88\u201c\u4f5b\u6027\u201d\uff0c\u5728\u5199\u5165\u671f\u95f4\u6570\u636e\u4e0d\u53d8\uff0c\u5bf9\u8bfb\u5199\u51b2\u7a81\u4e0d\u95fb\u4e0d\u95ee\uff0c\u4f46\u4f18\u70b9\u5728\u4e8e\u8282\u7ea6 BRAM \u529f\u8017\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic4.zhimg.com\/v2-bef57a630e35a9c21acac609e732a5a7_r.jpg\" alt=\"\u6b64\u56fe\u7247\u7684alt\u5c5e\u6027\u4e3a\u7a7a\uff1b\u6587\u4ef6\u540d\u4e3av2-bef57a630e35a9c21acac609e732a5a7_r.jpg\"\/><\/figure>\n\n\n\n<p>\u53e6\u5916\u91cd\u8981\u7684\u4e00\u70b9\u662f\u914d\u7f6e RAM \u7684\u8f93\u51fa\u5bc4\u5b58\u5668\u3002\u5171\u6709\u4e24\u4e2a\u9009\u9879 Primitive \/ Core Output Register\u3002\u4e24\u4e2a\u9009\u9879\u53ef\u4ee5\u5404\u81ea\u9009\u62e9\uff0c\u90fd\u662f\u4e3a\u8f93\u51fa\u7aef\u6dfb\u52a0\u4e00\u7ea7\u5bc4\u5b58\u5668\uff0c\u4e0d\u540c\u5728\u4e8e\u524d\u8005\u5728 Port \u5185\u90e8\u6dfb\u52a0\u5bc4\u5b58\u5668\uff0c\u800c\u540e\u8005\u662f\u5728 Port \u5916\u90e8\u6dfb\u52a0\u5bc4\u5b58\u5668\u3002\u81ea\u7136\u800c\u7136\uff0c\u6bcf\u4e00\u7ea7\u7684\u5bc4\u5b58\u5668\u90fd\u4f1a\u589e\u52a0\u4e00\u4e2a\u5468\u671f\u7684\u8bfb\u5ef6\u8fdf\uff0c\u4ece\u521d\u59cb\u7684 1 \u5468\u671f\u8bfb\u5ef6\u8fdf\uff0c\u6700\u9ad8\u53ef\u4ee5\u589e\u52a0\u5230 3 \u5468\u671f\u8bfb\u5ef6\u8fdf\u3002<\/p>\n\n\n\n<p>\u6dfb\u52a0\u5bc4\u5b58\u5668\u867d\u7136\u4f1a\u589e\u52a0\u5ef6\u8fdf\u5468\u671f\u6570\uff0c\u56e0\u4e3a\u8f93\u51fa\u4fe1\u53f7\u7ecf\u8fc7\u4e86\u6253\u62cd\uff0c\u4f46\u53ef\u4ee5\u51cf\u5c11\u65f6\u949f\u5230\u6570\u636e\u65f6\u95f4\uff08\u5373\u4ece\u65f6\u949f\u4e0a\u5347\u6cbf\u5f00\u59cb\uff0c\u76f4\u5230\u6570\u636e\u51fa\u73b0\u5728\u8f93\u51fa\u7aef\u53e3\u4e0a\u7684\u65f6\u95f4\uff09\uff0c\u6539\u5584\u65f6\u5e8f\u3002<\/p>\n\n\n\n<h3>\u5f00\u59cb\u4eff\u771f<\/h3>\n\n\n\n<p>\u5bf9\u4e8e\u5355\u7aef\u53e3\uff0c\u53ea\u6709\u4e00\u4e2a\u5730\u5740addra\uff0c\u5f53wea=1\u65f6\uff0c\u7528\u4e8e\u5199\u6570\u636e\u5730\u5740\uff0c\u5f53wea==0\u65f6\u7528\u4e8e\u8bfb\u5730\u5740\u3002<\/p>\n\n\n\n<p>\u9996\u5148\uff0c\u6211\u4eec\u89c2\u5bdf RAM \u7684\u8bfb\u5ef6\u8fdf\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic3.zhimg.com\/80\/v2-bdce080e0a8250e56077e221c617d13e_1440w.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u5c06\u4f7f\u80fd\u7aef ena \u7f6e\u9ad8\uff0c\u901a\u8fc7\u7f6e\u9ad8\u5199\u4f7f\u80fd\u4fe1\u53f7 wea \u4e00\u4e2a\u5468\u671f\uff0c\u5728\u65f6\u949f\u4e0a\u5347\u6cbf\u5b8c\u6210\u4e00\u6b21\u5199\u5165\u64cd\u4f5c\u3002\u53ef\u4ee5\u89c2\u5bdf\u5230\uff0c\u5730\u5740\u603b\u7ebf\u5199\u5165 0x1\uff0c\u5728\u65f6\u949f\u4e0a\u5347\u6cbf\u5230\u6765\u4e4b\u524d\u51c6\u5907\u597d\u4e86\u4f7f\u80fd\u4fe1\u53f7\u548c\u5730\u5740\u4fe1\u53f7\u3002\u65f6\u949f\u6cbf\u4e0a\u5347\u6cbf\u5230\u6765\u540e\uff0c\u5b8c\u6210\u4e00\u6b21\u5199\u5165\u64cd\u4f5c\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic2.zhimg.com\/v2-4dd23995c4a4ba1345b76b8ba7c8273d_r.jpg\" alt=\"\"\/><figcaption>\u5c06\u4f7f\u80fd\u4fe1\u53f7\u548c\u5730\u5740\u5728\u65f6\u949f\u4e0a\u5347\u6cbf\u5230\u6765\u4e4b\u524d\u51c6\u5907\u597d<\/figcaption><\/figure>\n\n\n\n<p>\u5728\u5b8c\u6210\u4e86\u5bf9\u5730\u5740 0x01 \u7684\u5199\u5165\u540e\uff0c\u5c31\u53ef\u4ee5\u901a\u8fc7\u8bfb\u53d6\u5730\u5740 0x01 \u6765\u89c2\u5bdf BRAM \u7684\u8bfb\u5ef6\u8fdf\u4e86\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic3.zhimg.com\/v2-3515eabb0ec1bcf3355fa4d763c63c52_r.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u8fd9\u5f20\u4eff\u771f\u56fe\u4e2d\uff0c\u8bfb\u53d6\u5730\u5740\u4e3a 0x01\uff0c\u53ef\u4ee5\u89c2\u5bdf\u5230\u5728\u65f6\u949f\u4e0a\u5347\u6cbf\u5230\u6765\u540e\uff0c\u7ecf\u8fc7\u4e86 100ps \u7684\u5ef6\u8fdf\u4e4b\u540e\uff0c0x01 \u5730\u5740\u4e0a\u7684\u6570\u636e 0xbbbb \u51fa\u73b0\u5728 dout \u4e0a\u3002<\/p>\n\n\n\n<p>\u8fd9 100ps \u7684\u5ef6\u8fdf\u610f\u5473\uff0c\u5982\u679c\u7528\u6237\u903b\u8f91\u5728\u5c06\u5730\u5740\u51c6\u5907\u597d\u540e\u4e4b\u540e\u7684\u7b2c\u4e00\u4e2a\u4e0a\u5347\u6cbf\u8bfb\u53d6\u6570\u636e\uff0c\u90a3\u4e48\u8bfb\u53d6\u5230\u7684\u6570\u636e\u5c31\u662f\u9519\u8bef\u7684\uff0c\u5fc5\u987b\u7b49\u5f85\u4e0b\u4e00\u4e2a\u65f6\u949f\u4e0a\u5347\u6cbf\u624d\u80fd\u591f\u8fdb\u884c\u8bfb\u53d6\u3002\u4ece\u4e0b\u56fe\u624b\u518c\u4e2d\u7684\u65f6\u5e8f\u8bf4\u660e\u4e5f\u53ef\u4ee5\u770b\u5230\u8fd9\u4e2a\u5ef6\u8fdf\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic3.zhimg.com\/v2-568d116ac307101847d54c28f2ec069e_r.jpg\" alt=\"\"\/><figcaption>Latch \u4ee3\u8868\u662f primitive \u7684\u8f93\u51fa\uff0creg1 \u4ee3\u8868\u7684\u662f\u7ecf\u8fc7\u4e00\u7ea7\u8f93\u51fa\u5bc4\u5b58\u5668\u540e\u7684\u8f93\u51fa<\/figcaption><\/figure>\n\n\n\n<p>ena \u4f7f\u80fd\u7aef\u4e3a\u4f4e\u65f6\uff0c\u4f1a\u5931\u80fd RAM \u7684\u8bfb\u5199\u64cd\u4f5c\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic3.zhimg.com\/v2-145fa82503279aedf2d07df599ce019a_r.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>ena \u4fe1\u53f7\u7f6e\u4f4e\u4e4b\u524d\uff0c\u5199\u64cd\u4f5c\u5b8c\u6210\uff0c\u4f46\u8bfb\u64cd\u4f5c\u88ab\u5931\u80fd\u3002<\/p>\n\n\n\n<h3>\u53cc\u7aef\u53e3RAM<\/h3>\n\n\n\n<p>\u5728\u5355\u7aef\u53e3 RAM \u4e2d\uff0c\u901a\u5e38\u7684\u5e94\u7528\u53ef\u80fd\u662f\uff0c\u5148\u8fdb\u884c\u4e00\u7cfb\u5217\u5199\u5165\uff0c\u518d\u8fdb\u884c\u4e00\u7cfb\u5217\u8bfb\u53d6\uff0c\u5faa\u73af\u53cd\u590d\u3002\u4f46\u4e5f\u53ef\u4ee5\u5bf9\u4e00\u4e2a\u5730\u5740\uff0c\u5199\u5165\uff0c\u8bfb\u53d6\uff0c\u5730\u5740\u9012\u589e\uff0c\u518d\u5faa\u73af\u53cd\u590d\u3002\u8fd9\u6837\u7684\u64cd\u4f5c\u7c7b\u4f3c FIFO\uff0c\u610f\u4e49\u4e0d\u5927\u3002<\/p>\n\n\n\n<p>\u5355\u7aef\u53e3 BRAM \u7684\u5e94\u7528\u4e3b\u8981\u7528\u4e8e\u7f13\u5b58\uff0c\u6bd4\u5982\u9700\u8981\u7f13\u5b58\u4e00\u4e9b\u6570\u636e\uff0c\u9996\u5148\u5c06\u6240\u6709\u6570\u636e\u653e\u5165 RAM \u4e2d\uff0c\u4e4b\u540e\u6839\u636e\u9700\u8981\u4ece\u4e0d\u540c\u7684\u5730\u5740\u4e2d\u53d6\u51fa\u6570\u636e\u8fdb\u884c\u8fd0\u7b97\u6216\u8005\u5904\u7406\u3002\u5355\u7aef\u53e3\u9002\u5408\u8bfb\u53d6\u548c\u5199\u5165\u5206\u65f6\u8fdb\u884c\u7684\u5e94\u7528\u3002\u5728\u8fd9\u7c7b\u5e94\u7528\u4e2d\uff0c\u4e0d\u4f1a\u4ea4\u9519\u8fdb\u884c\u8bfb\u53d6\u5199\u5165\u3002<\/p>\n\n\n\n<p>\u8fde\u7eed\u7684\u5199\u5165\uff0c\u8bfb\u53d6\u64cd\u4f5c\u53ef\u4ee5\u4f7f\u7528\u53cc\u7aef\u53e3\u7684 RAM \u5b9e\u73b0\uff0c\u53cc\u7aef\u53e3 RAM \u6709\u5404\u79cd\u72ec\u7acb\u7684\u5730\u5740\u901a\u9053\u548c\u6570\u636e\u901a\u9053\uff0c\u53ef\u9009\u5404\u81ea\u72ec\u7acb\u7684\u65f6\u949f\u3002<\/p>\n\n\n\n<p>\u53cc\u7aef\u53e3 RAM \u7684\u5e94\u7528\u5f88\u5e7f\u6cdb\uff0c\u8fd9\u91cc\u4e3e\u4e00\u4e2a\u56fe\u50cf\u5904\u7406\u4e2d\u7684\u4f8b\u5b50\u3002<\/p>\n\n\n\n<p>\u5728\u56fe\u50cf\u5904\u7406\u4e2d\uff0c\u56fe\u50cf\u5377\u79ef\u662f\u4e00\u9879\u57fa\u672c\u7684\u64cd\u4f5c\u3002\u5377\u79ef\u64cd\u4f5c\u4e2d\uff0c\u9700\u8981\u5728\u5c06\u65b0\u6570\u636e\u7f13\u5b58\u5230 RAM \u4e2d\u7684\u540c\u65f6\uff0c\u4ece RAM \u4e2d\u53d6\u51fa\u65e7\u6570\u636e\u8fdb\u884c\u5377\u79ef\u8fd0\u7b97\u3002\u8fd9\u65f6\u5019\u8bfb\u5199\u903b\u8f91\u63a7\u5236\u662f\u5206\u5f00\uff0c\u53cc\u7aef\u53e3\u63d0\u4f9b\u4e24\u5957\u8bfb\u5199\u63a7\u5236\u63a5\u53e3\uff0c\u9002\u5408\u8fd9\u7c7b\u8bfb\u5199\u903b\u8f91\u76f8\u72ec\u7acb\u7684\u573a\u5408\u3002\u4f46\u9700\u8981\u6ce8\u610f\u7684\u662f\u8bfb\u5199\u51b2\u7a81\u95ee\u9898\uff0c\u5728\u56fe\u50cf\u5377\u79ef\u64cd\u4f5c\u4e2d\uff0c\u901a\u8fc7\u5c06\u5199\u5730\u5740\u56fa\u5b9a\u4e3a\u8bfb\u5730\u5740- 0x2\uff0c\u89e3\u51b3\u51b2\u7a81\u95ee\u9898\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3>\u53cc\u7aef\u53e3\u5de5\u4f5c\u6a21\u5f0f<\/h3>\n\n\n\n<p>\u8fd9\u91cc\u901a\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff0c\u6bd4\u8f83\u4e86 no change \uff0cread first \u4ee5\u53ca write first\u5de5\u4f5c\u6a21\u5f0f\u3002<\/p>\n\n\n\n<p>\u9996\u5148\u662f<strong>&nbsp;no change \u6a21\u5f0f<\/strong>\uff0c\u5728\u5199\u5165\u671f\u95f4\uff0c\u8f93\u51fa\u4fdd\u6301\u4e0d\u53d8\uff0c\u6240\u8c13 no change\u3002\u8f93\u51fa\u7aef\u53e3\u4e0a\u539f\u672c\u4e3a\u5730\u5740 0 \u7684\u6570\u636e\uff1a0xaaaa,\u5f53\u5730\u5740 1 \u548c\u5730\u5740 2 \u5f00\u59cb\u5199\u5165\u65f6\uff0c\u8f93\u51fa\u7aef\u53e3\u4fdd\u6301\u4e0d\u53d8\uff0c\u5728\u5199\u5165\u7ed3\u675f\u65f6\u523b\uff0c\u672c\u6765\u7ecf\u8fc7 1 \/2\u4e2a\u5468\u671f\u7684\u5ef6\u8fdf\uff0c\u5e94\u8be5\u8f93\u51fa\u5730\u5740 1 \/2\u4e0a\u7684\u503c\uff1a0x1111\/0x2222\uff0c\u4f46\u662f\u90fd\u6ca1\u6709\uff0c\u8f93\u51fa\u7aef\u53e3\u4fdd\u6301\u5199\u5165\u53d1\u751f\u4e4b\u524d\u7684\u5730\u5740 0 \u7684\u6570\u636e\uff1a0xaaaa\u3002<\/p>\n\n\n\n<p>\u51e1\u662f\u5199\u5165\u671f\u95f4\uff0c\u8f93\u51fa\u4fdd\u6301\u4e0d\u53d8\u3002<\/p>\n\n\n\n<p>\u53ea\u5728\u5199\u5165\u7ed3\u675f\u540e\uff0c\u7ecf\u8fc7 1 \u4e2a\u5468\u671f\uff0c\u8f93\u51fa\u5730\u5740 3 \u4e0a\u7684\u6570\u636e:0x3333 \u3002\u53ef\u89c1\uff0c\u8be5\u6a21\u5f0f\u7684\u7279\u70b9\u5c31\u662f\u5728\u5199\u5165\u65f6\uff0c\u4fdd\u6301\u8f93\u51fa\u7aef\u53e3\u4e0d\u53d8\uff0c\u4f46\u4f1a\u5728\u8bfb\u5199\u51b2\u7a81\u671f\u95f4\uff0c\u65e0\u6cd5\u8bfb\u5230\u5730\u5740 1 \u548c\u5730\u5740 2 \u4e0a\u7684\u6b63\u786e\u6570\u636e\uff0c\u8bfb\u5230\u7684\u90fd\u662f\u9519\u8bef\u7684\u6570\u636e 0xaaaa,\u5730\u5740 0 \u4e0a\u7684\u6570\u636e\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic4.zhimg.com\/v2-041e1e7ae4d57d8540d01d65a9a4255f_r.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic3.zhimg.com\/v2-ead2b2474949159e1a2d2cb1a00be0c6_r.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u63a5\u4e0b\u6765\u662f write first&nbsp;<strong>\u5199\u4f18\u5148\u6a21\u5f0f<\/strong>\uff0c\u53ef\u4ee5\u770b\u5230\u8be5\u6a21\u5f0f\u4e0b\uff0c\u5199\u6570\u636e\u548c\u5c06\u6570\u636e\u8f93\u51fa\u5230\u8f93\u51fa\u603b\u7ebf\u4e0a\u662f\u540c\u65f6\u8fdb\u884c\u7684\u3002\u5728\u5411\u5730\u5740 1 \u548c\u5730\u5740 2 \u5199\u5165\u6570\u636e\u7684\u540c\u65f6\uff0c\u5728\u5bf9\u5e94\u65f6\u523b\uff0c\u7ecf\u8fc7\u4e00\u4e2a\u5468\u671f\u5ef6\u8fdf\u540e\uff0c\u4ecd\u7136\u6b63\u786e\u5730\u8f93\u51fa\u4e86\u5730\u5740 1 \u548c\u5730\u5740 2 \u4e2d\uff0c\u4f46\u6ce8\u610f\uff0c\u8f93\u51fa\u7684\u662f\u521a\u5199\u5165\u7684\u65b0\u503c\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic3.zhimg.com\/v2-b536a08f0dc97da1d719f2e656a502d6_r.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic1.zhimg.com\/v2-8fe7455af9f036550c445454e816b530_r.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u6700\u540e\u662f&nbsp;<strong>read first \u8bfb\u4f18\u5148\u6a21\u5f0f<\/strong>\uff0c\u4ece\u65f6\u5e8f\u4e0a\u6765\u770b\uff0c\u8bfb\u4f18\u5148\u6a21\u5f0f\u548c\u5199\u4f18\u5148\u6a21\u5f0f\u7c7b\u4f3c\uff0c\u540c\u6837\u63a5\u6536\u8f93\u5165\u7684\u540c\u65f6\uff0c\u6309\u7167\u65f6\u5e8f\u5c06\u6570\u636e\u8f93\u51fa\uff0c\u4f46\u4e0d\u540c\u5728\u4e8e\uff0c\u5199\u4f18\u5148\u6a21\u5f0f\u8f93\u51fa\u7684\u662f\u5199\u5165\u7684\u65b0\u503c\uff0c\u800c\u8bfb\u4f18\u5148\u6a21\u5f0f\u8f93\u51fa\u7684\u662f\u5728\u5199\u64cd\u4f5c\u53d1\u751f\u4e4b\u524d\u7684\u65e7\u503c\uff0c\u8fd9\u79cd\u4e0d\u540c\uff0c\u5b9e\u9645\u4e0a\u662f\u901a\u8fc7\u5c06\u65e7\u503c\u7f13\u5b58\u5b9e\u73b0\u7684\u3002\u4e0b\u56fe\u4e2d 0xbbbb,0xcccc \u5206\u522b\u4e3a\u5730\u5740 0x1,0x2 \u4e2d\u539f\u6709\u7684\u65e7\u503c\uff0c\u5728\u5411\u5730\u5740 0x1,0x2 \u5199\u5165\u65b0\u503c\uff0c\u5b83\u4eec\u5728dout \u4e0a\u88ab\u8f93\u51fa\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic3.zhimg.com\/v2-098f2e047bff62f180297dccedb78126_r.jpg\" alt=\"\"\/><figcaption>read first \u6a21\u5f0f<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic2.zhimg.com\/v2-39ab558758c9ba0a69a9f2f5410f700d_r.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<!--nextpage-->\n\n\n\n<h1>\u5377\u79ef\u3001\u7a97\u53e3\u8fd0\u7b97\u4e4b\u6ed1\u52a8\u7a97\u53e3\u6a21\u5757\u8bbe\u8ba1<\/h1>\n\n\n\n\n\n<p>&nbsp;&nbsp; &nbsp; \u5728\u56fe\u50cf\u5904\u7406\u4e2d\uff0c\u5377\u79ef\u3001\u7a97\u53e3\u8fd0\u7b97\u662f\u975e\u5e38\u57fa\u7840\u4e14\u5e38\u7528\u7684\u64cd\u4f5c\u3002\u8fd9\u4e9b\u57fa\u4e8e\u56fe\u50cf\u6ed1\u52a8\u7a97\u53e3\u7684\u8fd0\u7b97\u975e\u5e38\u9002\u5408\u5728FPGA\u4e2d\u8fdb\u884c\u6d41\u6c34\u7ebf\u5b9e\u65f6\u9ad8\u6548\u5904\u7406\uff0c\u4e5f\u662fFPGA\u56fe\u50cf\u7b97\u6cd5\u5b9e\u73b0\u7684\u4e00\u4e2a\u70ed\u70b9\u3002\u5176\u4e2d\uff0c\u6700\u57fa\u7840\u7684\u5de5\u4f5c\u5c31\u662f\u5728FPGA\u4e2d\u8bbe\u8ba1\u4e00\u4e2a\u6ed1\u52a8\u7a97\u53e3\u6a21\u5757\u3002<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u8bbe\u8ba1\u4e00\u4e2a\u5b8c\u5907\u7684\u6ed1\u52a8\u7a97\u53e3\u6a21\u5757\u9996\u5148\u8981\u89e3\u51b3\u4ee5\u4e0b3\u4e2a\u95ee\u9898\uff1a<\/p>\n\n\n\n<ul><li>\u56fe\u50cf\u884c\u7f13\u5b58\u673a\u5236<\/li><li>\u884c\u3001\u573a\u7b49\u540c\u6b65\u4fe1\u53f7\u7684\u5ef6\u8fdf<\/li><li>\u56fe\u50cf\u8fb9\u754c\u7684\u6269\u5c55<\/li><\/ul>\n\n\n\n<h2><strong>\u56fe\u50cf\u884c\u7f13\u5b58\u673a\u5236<\/strong> <\/h2>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u67092\u79cd\u5b9e\u73b0\u65b9\u6848\uff1a<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \uff081\uff09\u4f7f\u7528FIFO\u6216RAM\u6309\u884c\u7f13\u5b58\u56fe\u50cf\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\u7f51\u4e0a\u5f88\u591a\u7684\u535a\u5ba2\u548c\u6559\u7a0b\u90fd\u662f\u91c7\u7528\u8fd9\u79cd\u65b9\u6848\u3002\u4f8b\u5982\uff0c\u751f\u62103\u00d73\u7684\u7a97\u53e3\u9700\u8981\u7f13\u5b582\u884c\u56fe\u50cf\uff0c\u6d88\u80172\u4e2aFIFO\/RAM\uff0cFIFO\/RAM\u6700\u7ec8\u90fd\u662f\u6d88\u8017FPGA\u7684\u5757\u5b58\u50a8\u8d44\u6e90\uff0c\u6d88\u8017\u91cf\u4e0e\u7f13\u5b58\u884c\u6570\u6210\u6b63\u6bd4\u3002\u6bcf\u4e2aFIFO\/RAM\u90fd\u9700\u8981\u901a\u8fc7\u903b\u8f91\u5355\u72ec\u63a7\u5236\u8bfb\u5199\u3002FIFO\/RAM\u90fd\u53ef\u5728FPGA\u5f00\u53d1\u8f6f\u4ef6\u4e2d\u4f8b\u5316IP\u6838\u5b9e\u73b0\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/img-blog.csdnimg.cn\/20200811125344367.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L01taWtlclI=,size_16,color_FFFFFF,t_70\" alt=\"\"\/><\/figure>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \uff082\uff09\u4f7f\u7528\u5355\u4e2aRAM\u7f13\u5b58\u6240\u6709\u884c<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u4f8b\u5982\uff0c3\u00d73\u7684\u7a97\u53e3\u901a\u8fc71\u4e2aRAM\u7f13\u5b582\u884c\u56fe\u50cf\u3002\u8fd9\u79cd\u65b9\u6848\u67092\u4e2a\u4f18\u70b9\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u9996\u5148\uff0c\u53ef\u4ee5\u7b80\u5316\u903b\u8f91\u8bbe\u8ba1\uff0c\u56e0\u4e3a\u65e0\u8bba\u9700\u8981\u7f13\u5b58\u591a\u5c11\u884c\u56fe\u50cf\uff0cFPGA\u90fd\u53ea\u9700\u8981\u64cd\u4f5c1\u4e2aRAM\u7684\u8bfb\u5199\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u53e6\u5916\uff0c\u5145\u5206\u5229\u7528FPGA\u5757\u5b58\u50a8\u5668\u4f4d\u5bbd\u548c\u6df1\u5ea6\u7684\u53ef\u53d8\u6027\u3002\u5f53\u4f4d\u5bbd\u548c\u603b\u7f13\u5b58\u91cf\u5728\u5355\u4e2a\u5757\u5b58\u50a8\u5668\u7684\u8303\u56f4\u5185\uff0c\u5219\u4ec5\u4f7f\u75281\u4e2a\u5757\u5b58\u50a8\u5668\u5c31\u53ef\u4ee5\u7f13\u5b58\u591a\u884c\u56fe\u50cf\uff0c\u4ece\u800c\u964d\u4f4e\u5757\u5b58\u50a8\u5668\u8d44\u6e90\u7684\u6d88\u8017\uff0c\u5c24\u5176\u662f\u5f53\u7a97\u53e3\u5c3a\u5bf8\u8f83\u5927\u65f6\u6548\u679c\u660e\u663e\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u4f8b\u5982\uff0cXilinx 7\u7cfb\u5217FPGA\u7684\u5757\u5b58\u50a8\u5668block ram\u53ef\u914d\u7f6e\u4e3a1K\u00d736bit\u7684\u6a21\u5f0f\uff0c\u53ef\u4ee5\u7f13\u5b584\u884c\u50cf\u7d20\u6df1\u5ea6\u4e3a8bit\uff0c\u5bbd\u4e3a1024\u7684\u56fe\u50cf\uff0c\u5b9e\u73b05\u00d75\u6ed1\u52a8\u7a97\u53e3\u7684\u884c\u7f13\u5b58\u30022\u4e2a1K\u00d736bit\u6a21\u5f0f\u7684block ram\u5c31\u53ef\u4ee5\u6700\u591a\u7f13\u5b589\u884c8bit\u00d71024\u7684\u56fe\u50cf\uff0c\u4ee5\u6b64\u7c7b\u63a8\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u6240\u4ee5\uff0c\u63a8\u8350\u4f7f\u7528\u8fd9\u79cd\u65b9\u6848\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/img-blog.csdnimg.cn\/20200811125434566.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L01taWtlclI=,size_16,color_FFFFFF,t_70\" alt=\"\"\/><\/figure>\n\n\n\n<h2><strong>\u884c\u3001\u573a\u7b49\u540c\u6b65\u4fe1\u53f7\u7684\u5ef6\u8fdf<\/strong><\/h2>\n\n\n\n<p>\u7531\u4e8e\u6ed1\u52a8\u7a97\u53e3\u884c\u7f13\u5b58\u673a\u5236\u7684\u5b58\u5728\uff0c\u6ed1\u52a8\u7a97\u53e3\u7684\u8f93\u51fa\u76f8\u5bf9\u4e8e\u56fe\u50cf\u7684\u8f93\u5165\u5b58\u5728\u4e00\u90e8\u5206\u56fa\u5b9a\u884c\u6570\u7684\u5ef6\u65f6\uff0c\u5176\u5bf9\u5e94\u7684\u884c\u3001\u573a\u540c\u6b65\u4fe1\u53f7\u4e5f\u9700\u8981\u4e0e\u4e4b\u4fdd\u6301\u4e00\u81f4\u7684\u5ef6\u65f6\u3002\u4f8b\u5982\uff0c3\u00d73\u6ed1\u52a8\u7a97\u53e3\u7684\u8f93\u51fa\u81f3\u5c11\u4f1a\u5ef6\u65f61\u884c\u56fe\u50cf\u7684\u65f6\u95f4\uff0c5\u00d75\u7a97\u53e3\u8f93\u51fa\u81f3\u5c11\u5ef6\u65f62\u884c\u56fe\u50cf\uff0c\u4ee5\u6b64\u7c7b\u63a8\uff0c\u81f3\u5c11\u5ef6\u65f6(\u7a97\u53e3\u5c3a\u5bf8-1)\/2\u884c\u56fe\u50cf\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u540c\u6b65\u4fe1\u53f7\u7684\u5ef6\u65f6\u65b9\u6cd5\u901a\u5e38\u67092\u79cd\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \uff081\uff09\u4e0e\u884c\u7f13\u5b58\u65b9\u5f0f\u7c7b\u4f3c\uff0c\u901a\u8fc7FIFO\u6216RAM\u5c06\u8f93\u5165\u7684\u540c\u6b65\u4fe1\u53f7\u6574\u4f53\u5ef6\u65f6\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u8fd9\u79cd\u65b9\u6848\u7684\u4f18\u70b9\u5728\u4e8e\uff0c\u8f93\u5165\u548c\u8f93\u51fa\u540c\u6b65\u4fe1\u53f7\u53ef\u4ee5\u4fdd\u6301\u5b8c\u5168\u4e00\u81f4\u3002\u7f3a\u70b9\u662f\u9700\u8981\u6d88\u8017\u989d\u5916\u7684FPGA\u5757\u5b58\u50a8\u8d44\u6e90\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \uff082\uff09\u901a\u8fc7\u903b\u8f91\u751f\u6210\u5ef6\u65f6\u7684\u540c\u6b65\u4fe1\u53f7\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u8fd9\u6837\u4e0d\u9700\u8981\u6d88\u8017FPGA\u5757\u5b58\u50a8\u8d44\u6e90\uff0c\u4f46\u662f\u9700\u8981\u8bbe\u8ba1\u5355\u72ec\u7684\u903b\u8f91\uff0c\u800c\u4e14\u4e5f\u65e0\u6cd5\u4fdd\u8bc1\u8f93\u51fa\u548c\u8f93\u5165\u540c\u6b65\u4fe1\u53f7\u5b8c\u5168\u4e00\u81f4\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u5bf9\u4e8e\u5927\u591a\u6570\u5e94\u7528\u573a\u666f\uff0c\u8f93\u5165\u548c\u8f93\u51fa\u540c\u6b65\u4fe1\u53f7\u4e0d\u4e00\u81f4\u5e76\u4e0d\u5f71\u54cd\u6570\u636e\u6d41\u548c\u5904\u7406\u7ed3\u679c\uff0c\u5bf9\u4e8eFPGA\u800c\u8a00\u5757\u5b58\u50a8\u5668\u8d44\u6e90\u6bd4\u903b\u8f91\u8d44\u6e90\u66f4\u7a00\u7f3a\u3002\u56e0\u6b64\uff0c\u5b9e\u9645\u5e94\u7528\u4e2d\u7b2c2\u79cd\u65b9\u6cd5\u66f4\u4e3a\u5e38\u7528\u3002\u5982\u679c\u5bf9\u540c\u6b65\u4fe1\u53f7\u65f6\u5e8f\u6709\u4e25\u683c\u8981\u6c42\uff0c\u90a3\u53ea\u80fd\u91c7\u7528\u7b2c1\u79cd\u65b9\u6848\u3002<\/p>\n\n\n\n<h2><strong>\u56fe\u50cf\u8fb9\u754c\u7684\u6269\u5c55<\/strong><\/h2>\n\n\n\n<h3><strong> \u8fb9\u754c\u6269\u5c55\u539f\u7406<\/strong><\/h3>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u56fe\u50cf\u5377\u79ef\u6216\u7a97\u53e3\u8fd0\u7b97\uff0c\u5728\u6d89\u53ca\u56fe\u50cf4\u5468\u8fb9\u754c\u70b9\u4f4d\u7f6e\u7684\u6ed1\u52a8\u7a97\u53e3\u4f1a\u51fa\u73b0\u90e8\u5206\u50cf\u7d20\u70b9\u7f3a\u5931\uff0c\u9700\u8981\u8fdb\u884c\u7279\u6b8a\u5904\u7406\u3002\u5e38\u7528\u7684\u7b56\u7565\u5305\u62ec\u5ffd\u7565\uff0c\u8865\u56fa\u5b9a\u503c\uff0c\u8fb9\u754c\u590d\u5236\uff0c\u8fb9\u754c\u955c\u50cf\u7b49\u7b49\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" src=\"https:\/\/img-blog.csdnimg.cn\/20200811125626216.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L01taWtlclI=,size_16,color_FFFFFF,t_70\" alt=\"\" width=\"241\" height=\"236\"\/><\/figure><\/div>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \uff081\uff09\u5ffd\u7565<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u5c31\u662f\u4e0d\u5bf9\u6ed1\u52a8\u7a97\u53e3\u4e2d\u7f3a\u5931\u7684\u50cf\u7d20\u70b9\u8fdb\u884c\u5904\u7406\uff0c\u76f4\u63a5\u7528\u6765\u8fdb\u884c\u8ba1\u7b97\uff0c\u7531\u4e8e\u7f3a\u5931\u50cf\u7d20\u70b9\u5bf9\u5e94\u7684FPGA\u89e6\u53d1\u5668\u53ef\u80fd\u4e3a\u4efb\u610f\u503c\uff0c\u6240\u4ee5\u8fb9\u754c\u50cf\u7d20\u70b9\u533a\u57df\u7684\u8fd0\u7b97\u7ed3\u679c\u4f1a\u53d7\u5230\u5f71\u54cd\u3002\u4f46\u5bf9\u4e8e\u5c0f\u7a97\u53e3\u6765\u8bf4\uff0c\u5f71\u54cd\u8f83\u5c0f\uff0c\u4e0d\u5bb9\u6613\u5bdf\u89c9\uff0c\u53ef\u4ee5\u91c7\u7528\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \uff082\uff09\u8865\u56fa\u5b9a\u503c<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u540c\u6837\u4f1a\u76f4\u63a5\u5f71\u54cd\u8fb9\u754c\u50cf\u7d20\u70b9\u533a\u57df\u7684\u8fd0\u7b97\u7ed3\u679c\u3002\u4f46\u5bf9\u4e8e\u5c0f\u7a97\u53e3\u6216\u8005\u67d0\u4e9b\u7279\u5b9a\u573a\u666f\u6765\u8bf4\uff0c\u4e5f\u53ef\u4ee5\u91c7\u7528\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \uff083\uff09\u8fb9\u754c\u590d\u5236<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u5c31\u662f\u76f4\u63a5\u590d\u52364\u4e2a\u8fb9\u754c\u7684\u50cf\u7d20\u70b9\u5230\u7f3a\u5931\u7684\u4f4d\u7f6e\uff0c\u5bf9\u5e94\u7684\u884c\u5217\u4f4d\u7f6e\u7f3a\u591a\u5c11\u4e2a\u5c31\u590d\u5236\u591a\u5c11\u6b21\u3002\u8fd9\u662f\u6700\u5e38\u7528\u7684\u4e00\u79cd\u65b9\u6cd5\uff0cmatlab\u548copencv\u91cc\u4e5f\u7ecf\u5e38\u88ab\u4f7f\u7528\u3002\u8fd9\u79cd\u65b9\u5f0f\u5bf9\u8fb9\u754c\u70b9\u7684\u8ba1\u7b97\u7ed3\u679c\u5f71\u54cd\u5f88\u5c0f\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" src=\"https:\/\/img-blog.csdnimg.cn\/20200811125648407.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L01taWtlclI=,size_16,color_FFFFFF,t_70\" alt=\"\" width=\"382\" height=\"375\"\/><\/figure><\/div>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \uff084\uff09\u8fb9\u754c\u955c\u50cf<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u5c31\u662f\u4ee5\u8fb9\u754c\u4e3a\u5bf9\u79f0\u8f74\uff0c\u4ee5\u955c\u50cf\u7684\u65b9\u5f0f\u590d\u5236\u8fb9\u754c\u533a\u57df\u7684\u50cf\u7d20\u70b9\u3002\u8fd9\u79cd\u65b9\u5f0f\u540c\u6837\u5bf9\u8fb9\u754c\u70b9\u7684\u8ba1\u7b97\u7ed3\u679c\u5f71\u54cd\u5f88\u5c0f\uff0c\u5728matlab\u548copencv\u91cc\u4e5f\u4f1a\u88ab\u4f7f\u7528\u3002<\/p>\n\n\n\n<p>&nbsp; \u5728FPGA\u4e2d\u8fdb\u884c\u8fb9\u754c\u50cf\u7d20\u70b9\u6269\u5c55\u67092\u79cd\u65b9\u5f0f\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \uff081\uff09\u52a8\u6001\u6269\u5c55\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u5c31\u662f\u5f53\u7a97\u53e3\u5728\u8fb9\u754c\u6ed1\u52a8\u65f6\uff0c\u52a8\u6001\u8865\u5168\u7f3a\u5931\u7684\u50cf\u7d20\u70b9\uff0c\u6574\u4e2a\u64cd\u4f5c\u662f\u5728\u539f\u56fe\u4e0a\u76f4\u63a5\u8fdb\u884c\u7684\u3002\u8fd9\u79cd\u65b9\u6cd5\u6709\u4e2a\u660e\u663e\u7684\u7f3a\u70b9\uff0c\u5f53\u7a97\u53e3\u6bd4\u8f83\u5927\u65f6\uff0c\u52a8\u6001\u8865\u5168\u90e8\u5206\u4f1a\u4f7f\u7528\u5f88\u591a\u7ec4\u5408\u903b\u8f91\uff0c\u8d44\u6e90\u6d88\u8017\u91cf\u5927\uff0c\u4e14\u4e0d\u5229\u4e8e\u65f6\u5e8f\u6536\u655b\uff0c\u4e00\u822c\u4e0d\u63a8\u8350\u4f7f\u7528\u8fd9\u79cd\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \uff082\uff09\u5148\u6269\u5c55\u540e\u6ed1\u52a8\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u5c31\u662f\u5148\u5bf9\u56fe\u50cf\u8fdb\u884c\u8fb9\u754c\u6269\u5c55\uff0c\u7136\u540e\u5728\u6269\u5c55\u540e\u7684\u56fe\u50cf\u4e0a\u8fdb\u884c\u6ed1\u52a8\u7a97\u53e3\u8f93\u51fa\u3002\u8fb9\u754c\u6269\u5c55\u9700\u8981\u5728\u56fe\u50cf\u8fdb\u884c\u884c\u7f13\u5b58\u65f6\u5b8c\u6210\u3002\u8fd9\u79cd\u65b9\u5f0f\u5728\u6ed1\u52a8\u7a97\u53e3\u751f\u6210\u65f6\u65e0\u9700\u5bf9\u8fb9\u754c\u50cf\u7d20\u70b9\u4f5c\u5224\u65ad\u548c\u5904\u7406\uff0c\u4e0d\u9700\u8981\u6d88\u8017\u903b\u8f91\u8d44\u6e90\u3002\u7f3a\u70b9\u662f\uff0c\u8fb9\u754c\u6269\u5c55\u4f1a\u589e\u5927\u8f93\u5165\u56fe\u50cf\u7684\u5c3a\u5bf8\uff0c\u540c\u65f6\u6539\u53d8\u8f93\u5165\u884c\u3001\u573a\u540c\u6b65\u4fe1\u53f7\u7684\u65f6\u5e8f\u5173\u7cfb\uff0c\u884c\u95f4\u548c\u5e27\u95f4\u7684\u6d88\u9690\u671f\u88ab\u538b\u7f29\u3002\u5982\u679c\u7a97\u53e3\u5c3a\u5bf8\u8f83\u5927\u6216\u8f93\u5165\u56fe\u50cf\u6d88\u9690\u65f6\u95f4\u8f83\u77ed\uff0c\u5bfc\u81f4\u6269\u5c55\u7684\u5217\u6570\u8d85\u8fc7\u884c\u95f4\u6d88\u9690\u65f6\u95f4\uff0c\u6216\u56fe\u50cf\u4e0b\u65b9\u6269\u5c55\u7684\u884c\u6570\u8d85\u8fc7\u4e86\u5e27\u95f4\u6d88\u9690\u65f6\u95f4\uff0c\u5219\u65e0\u6cd5\u4f7f\u7528\u8fd9\u79cd\u65b9\u6848\u3002\u4f46\u662f\u5728\u7edd\u5927\u591a\u6570\u573a\u666f\u4e0b\uff0c\u7b2c\u8fd9\u79cd\u65b9\u6848\u5b8c\u5168\u53ef\u7528\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u4eceFPGA\u5b9e\u73b0\u89d2\u5ea6\u548c\u7a97\u53e3\u8fd0\u7b97\u7ed3\u679c\u800c\u8a00\uff0c\u8fb9\u754c\u590d\u5236\u662f\u6700\u4f73\u7684\u9009\u62e9\u3002\u65e2\u80fd\u4fdd\u8bc1\u8fd0\u7b97\u7ed3\u679c\uff0c\u53c8\u4fbf\u4e8e\u5728FPGA\u4e2d\u5b9e\u73b0\u3002\u8fb9\u754c\u955c\u50cf\u65b9\u6cd5\u7531\u4e8e\u955c\u50cf\u590d\u5236\u673a\u5236\u8bbe\u8ba1\u66f4\u4e3a\u590d\u6742\uff0c\u4f1a\u6d88\u8017\u66f4\u591a\u7684FPGA\u8d44\u6e90\uff0c\u56e0\u6b64\u4e0d\u4f5c\u4e3a\u9996\u9009\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp; \u6ed1\u52a8\u7a97\u53e3\u6a21\u5757\u5728FPGA\u56fe\u50cf\u7b97\u6cd5\u5b9e\u73b0\u4e2d\u4f1a\u88ab\u7ecf\u5e38\u4f7f\u7528\uff0c\u82e5\u5c06\u5176\u8bbe\u8ba1\u6210\u4e00\u4e2a\u901a\u7528\u6a21\u5757\uff0c\u5219\u53ef\u4ee5\u6709\u6548\u63d0\u9ad8\u4ee3\u7801\u7f16\u5199\u6548\u7387\u3002\u8bbe\u8ba1\u6210\u901a\u7528\u6a21\u5757\u65f6\u53ef\u4ee5\u8003\u8651\u4ee5\u4e0b\u51e0\u4e2a\u529f\u80fd\u7684\u5b9e\u73b0\u3002<\/p>\n\n\n\n<ul><li>\u50cf\u7d20bit\u4f4d\u5bbd\u53ef\u914d\u7f6e<\/li><li>\u7a97\u53e3\u5927\u5c0f\u53ef\u914d\u7f6e\uff0c\u4e14\u957f\u5bbd\u5c3a\u5bf8\u53ef\u4e0d\u540c<\/li><li>\u8f93\u5165\u56fe\u50cf\u5c3a\u5bf8\u53ef\u52a8\u6001\u6539\u53d8<\/li><li>\u884c\u7f13\u5b58\u6240\u6d88\u8017\u7684\u5b58\u50a8\u8d44\u6e90\u91cf\u53ef\u914d\u7f6e<\/li><li>\u652f\u6301\u5355\u65f6\u949f\u5468\u671f\u591a\u4e2a\u76f8\u90bb\u50cf\u7d20\u70b9\u5e76\u884c\u8f93\u5165\u8f93\u51fa\uff0c\u4e14\u5e76\u884c\u50cf\u7d20\u70b9\u6570\u53ef\u914d\u7f6e<\/li><\/ul>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>Verilog\u5173\u4e8esigned\u3001\u6709\u7b26\u53f7\u6570\u3001\u7b97\u6570\u79fb\u4f4d\u3001$signed()\u7684\u4f7f\u7528<\/h2>\n\n\n\n<p>\u5173\u4e8e<a href=\"https:\/\/so.csdn.net\/so\/search?q=signed&amp;spm=1001.2101.3001.7020\" target=\"_blank\" rel=\"noreferrer noopener\">signed<\/a>\u3001\u6709\u7b26\u53f7\u6570\u3001\u7b97\u6570\u5de6\u79fb\u3001\u7b97\u6570\u53f3\u79fb\u3001$signed()\u3001$unsigned()\u7684\u7406\u89e3\u3002<\/p>\n\n\n\n<p>1\u3001signed\u53ef\u4ee5\u548creg\u548cwire\u8054\u5408\u4f7f\u7528\uff0c\u7528\u4e8e\u5b9a\u4e49\u6709\u7b26\u53f7\u6570\u3002\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528\u8d1f\u7684\u5341<a href=\"https:\/\/so.csdn.net\/so\/search?q=%E8%BF%9B%E5%88%B6&amp;spm=1001.2101.3001.7020\" target=\"_blank\" rel=\"noreferrer noopener\">\u8fdb\u5236<\/a>\u6570\u8d4b\u503c\u7ed9\u6709\u7b26\u53f7\u6570\uff0c\u5728\u7535\u8def\u4e2d\u662f\u6309\u8be5\u6570\u503c\u7684\u8865\u7801\u5f62\u5f0f\u5b58\u50a8\u7684\u3002\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wire signed a;\nassign a = -8'd1;\n<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528display\u663e\u793aa\u7684<a href=\"https:\/\/so.csdn.net\/so\/search?q=%E4%BA%8C%E8%BF%9B%E5%88%B6&amp;spm=1001.2101.3001.7020\" target=\"_blank\" rel=\"noreferrer noopener\">\u4e8c\u8fdb\u5236<\/a>=11111111\uff0c\u5341\u8fdb\u5236= -1\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$display(\"signed a =%b=%d\",a,a);\t\t \/\/signed a =11111111=         -1\n<\/code><\/pre>\n\n\n\n<p>2\u3001\u4f7f\u7528signed\u5b9a\u4e49\u7684\u7c7b\u578b\uff0c\u505a\u52a0\u6cd5\u6216\u4e58\u6cd5\u65f6\uff0c\u5bf9\u64cd\u4f5c\u6570\u6269\u4f4d\u5904\u7406\u65f6\u9ad8\u4f4d\u8865\u7b26\u53f7\u4f4d\uff1b\u5373\u8d1f\u6570\u88651\uff0c\u6b63\u6570\u88650\uff1b\u4e0d\u4f7f\u7528signed\u7684\u65e0\u7b26\u53f7\u7c7b\u578b\uff0c\u9ad8\u4f4d\u9ed8\u8ba4\u88650\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>reg signed &#091;7:0]a,b;\nwire signed &#091;8:0]sum1;\nreg &#091;7:0] c,d;\nwire &#091;8:0]sum2;\ninitial\nbegin \n  a = -8'd1;\n  b = 8'd2;\n  c = 8'b1000_0001;\n  d = 8'b0000_0010;\nend\nassign sum1 = a+b;\nassign sum2 = a+b;\n<\/code><\/pre>\n\n\n\n<p>\u5176\u4e2d\u6709\u7b26\u53f7\u8ba1\u7b97\u65f6\uff0c\u5728\u7535\u8def\u4e2da=1111_1111\uff0cb=0000_0010\uff1bsum1\u6bd4a\u548cb\u591a1bit\uff0c\u5728\u52a0\u6cd5\u7ed3\u6784\u4e2da\u6269\u4f4d\u4e3a1_1111_1111\uff0cb\u6269\u4f4d\u4e3a0_0000_0010\uff0c\u76f8\u52a0\u4e3a10_0000_0001\uff0c\u4fdd\u75599bit\u540esum1=1=0_0000_0001\u3002<br>\u800c\u5728\u65e0\u7b26\u53f7\u8ba1\u7b97\u65f6\uff0cc\u548cd\u5206\u522b\u6269\u4f4d\u4e3a0_1000_0001\u548c0_0000_0010\uff0c\u76f8\u52a0\u4fdd\u75599bit\u540esum2=131=010000011\u3002<br>\u7efc\u5408\u540e\u7ed3\u6784\u5982\u4e0b\u56fe\uff1a<br><img src=\"https:\/\/img-blog.csdnimg.cn\/20200722020639735.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3N6c2ZhdGU=,size_16,color_FFFFFF,t_70\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" class=\"\"><br><strong>\u6709\u7b26\u53f7\u6570signed\u548c\u65e0\u7b26\u53f7\u6570\u6700\u91cd\u8981\u7684\u533a\u522b\u5c31\u662f\u5982\u4f55\u6269\u4f4d\uff0c\u65e0\u7b26\u53f7\u6570\u662f\u6dfb0\uff0c\u6709\u7b26\u53f7\u6570\u65f6\u6dfb\u52a0\u7b26\u53f7\u4f4d<\/strong><\/p>\n\n\n\n<p>3\u3001&nbsp;<code>$signed<\/code>\u548c<code>$unsigned<\/code>\u3002\u9996\u5148\u660e\u786e\u8fd9\u4e24\u4e2a\u8bed\u53e5\u662f\u53ef\u7efc\u5408\u7684\u3002<code>$signed(c)<\/code>\u662f\u4e00\u4e2afunction\uff0c\u5c06\u65e0\u7b26\u53f7\u6570c\u8f6c\u5316\u4e3a\u6709\u7b26\u53f7\u6570\u8fd4\u56de\uff0c\u4e0d\u6539\u53d8c\u7684\u7c7b\u578b\u548c\u5185\u5bb9\u3002\u63a5\u4e0a\u8ff0\u4ee3\u7801\u5386\u7a0b\uff1a$unsigned\u540c\u7406\u3002<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">4\u3001\u7b97\u6570\u53f3\u79fb&gt;&gt;&gt;\u548c\u903b\u8f91\u53f3\u79fb\u3002<br>\u5bf9\u4e8e\u65e0\u7b26\u53f7\u6570\uff0c&gt;&gt;\u548c&gt;&gt;&gt;\u6ca1\u6709\u533a\u522b\uff0c\u90fd\u662f\u6309\u4f4d\u53f3\u79fb\uff0c\u5de6\u4fa7\u8865\u96f6\u3002<br>\u6709\u7b26\u53f7\u6570\u7684\u903b\u8f91\u53f3\u79fb&gt;&gt;\u4e0e\u65e0\u7b26\u53f7\u6570\u4e00\u6837\uff0c\u5c06\u6240\u6709\u4f4d\u6574\u4f53\u53f3\u79fb\uff0c\u5de6\u4fa7\u8865\u96f6\u3002<br>\u800c<strong>\u6709\u7b26\u53f7\u6570\u7684\u7b97\u6570\u53f3\u79fb&gt;&gt;&gt;<\/strong>\uff0c\u5de6\u4fa7\u6269\u4f4d\u7b26\u53f7\u4f4d\uff0c\u5982\u53f3\u79fbn\u4f4d\uff0c\u5219\u5de6\u4fa7\u589e\u52a0n\u4e2a\u7b26\u53f7\u4f4d\uff0c\u53f3\u4fa7\u5220\u9664n\u4f4d\uff0c\u5373\u8fdb\u884c\u9664n\u8fd0\u7b97\u3002\u8be6\u89c1\u4e0b\u8ff0\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>reg  signed &#091;7:0]a;\na=8'b1000_0010;\t\t\t\/\/\u5373a=-126.\na=a&gt;&gt;&gt;2;\t\t\t\t\/\/a=1110_0000\t\uff0c\u5373a=-32\uff0c\u96644\u8fd0\u7b97\nb=8'b0000_1000;\t\t\t\/\/\u5373b=8\nb=b&gt;&gt;&gt;1;\t\t\t\t\/\/b=0000_0100\uff0c\u5373b=4\uff0c\u96642\u8fd0\u7b97<\/code><\/pre>\n\n\n\n<p>x=12&#8217;b1000110  x[0] \u662f\u6700\u4f4e\u4f4d\uff0c\u548cpython\u76f8\u53cd<\/p>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>\u6fc0\u6d3b\u51fd\u6570 fpga\u5b9e\u73b0<\/h2>\n\n\n\n\n\n<p>\u6fc0\u6d3b\u51fd\u6570\u662f\u4e3a\u4e86\u5b9e\u73b0\u591a\u5c42\u795e\u7ecf\u7f51\u7edc\u800c\u5f15\u5165\u7684\u975e\u7ebf\u6027\u51fd\u6570\uff0c\u800c\u4e0d\u662f\u6700\u7ec8\u5f97\u5230\u7ebf\u6027\u51fd\u6570\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" src=\"https:\/\/thedatabus.io\/static\/relu-dce994569b1e17e8715cd3091d5de432.png\" alt=\"\u70ed\u9732\" width=\"439\" height=\"247\"\/><figcaption>relu\u6fc0\u6d3b<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u6ce8\u610f\uff1a\u7531\u4e8e RELU \u51fd\u6570\u7684\u8f93\u51fa\u6839\u636e\u8f93\u5165\u7684\u7b26\u53f7\u800c\u6709\u6240\u4e0d\u540c\uff0c\u56e0\u6b64\u53ea\u6709\u5f53\u6211\u4eec\u5f00\u59cb\u4f7f\u7528\u6709\u7b26\u53f7\u6570\u5b57\u800c\u4e0d\u4ec5\u4ec5\u662f\u6574\u6570\u65f6\uff0c\u5b83\u624d\u80fd\u5728\u786c\u4ef6\u4e2d\u5b9e\u73b0\u3002\u7136\u800c\uff0c\u6b63\u8d1f\u7684\u6982\u5ff5\u53ea\u662f\u8f6f\u4ef6\u5c42\u9762\u7684\u4e00\u4e2a\u6570\u5b66\u6982\u5ff5\u3002\u5728\u786c\u4ef6\u4e2d\uff0c\u6ca1\u6709\u8d1f\u6570\u8fd9\u6837\u7684\u4e1c\u897f\u3002\u4e00\u5207\u90fd\u53ea\u662f\u4e00\u5b9a\u4f4d\u6570\u7684\u5bc4\u5b58\u5668\uff08\u5728\u6211\u4eec\u7684\u4f8b\u5b50\u4e2d\u662f 32 \u4f4d\uff09\u3002\u4f46\u662f\uff0c\u6709\u7b26\u53f7\u4e8c\u8fdb\u5236\u8868\u793a\u7b49\u6982\u5ff5\u5141\u8bb8\u6211\u4eec\u5728\u786c\u4ef6\u4e2d\u5b9e\u73b0\u6b63\u6570\u548c\u8d1f\u6570\u7684\u6982\u5ff5\u3002\u5f53\u7136\uff0c\u5728\u5b9e\u9645\u786c\u4ef6\u4e4b\u4e0a\u8fd8\u9700\u8981\u53e6\u4e00\u5c42\uff0c\u4ee5\u4fbf\u89e3\u91ca\u8fd9\u4e9b\u6570\u5b57\u7684\u7b26\u53f7\u5e76\u6839\u636e\u9700\u8981\u4f7f\u7528\u5b83\u4eec\u3002<\/p>\n\n\n\n<h3 id=\"implementing-the-relu-function-in-verilog\">\u5728 Verilog \u4e2d\u5b9e\u73b0 ReLu \u51fd\u6570<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/file: relu.v\n`timescale 1ns \/ 1ps\nmodule relu(\n    input &#091;31:0] din_relu,\n    output &#091;31:0] dout_relu\n    );\n    assign dout_relu = (din_relu&#091;31] == 0)? din_relu : 0;   \/\/if the sign bit is high, send zero on the output else send the input\nendmodule\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"148\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-3-1024x148.png\" alt=\"\" class=\"wp-image-3470\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-3-1024x148.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-3-300x43.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-3-768x111.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-3.png 1212w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3> \u5728 Verilog \u4e2d\u5b9e\u73b0 leakrelu\u51fd\u6570 \uff080.125\uff09<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>`timescale 1ns \/ 1ps\nmodule leakrelu(\n    input signed&#091;31:0]  din_relu,\n    output signed&#091;31:0]  dout_relu\n    );\n    parameter N = 0;\/\/\u901a\u8fc7\u53f3\u79fb\u4f4d\u5b9e\u73b0\u96642\u7684\u5e42\u64cd\u4f5c\n    assign dout_relu = (din_relu&#091;31] == 0)? din_relu:din_relu&gt;&gt;&gt;N;   \/\/if the sign bit is high, send zero on the output else send the input\nendmodule\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"157\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-4-1024x157.png\" alt=\"\" class=\"wp-image-3472\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-4-1024x157.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-4-300x46.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-4-768x118.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-4.png 1206w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>\u96642\u64cd\u4f5c<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"144\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-5-1024x144.png\" alt=\"\" class=\"wp-image-3477\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-5-1024x144.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-5-300x42.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-5-768x108.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-5.png 1217w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>\u96648\u64cd\u4f5c\uff08*.125\uff09<\/figcaption><\/figure>\n\n\n\n<h2> \u5728 Verilog \u4e2d\u5b9e\u73b0sigmod<\/h2>\n\n\n\n<p><a href=\"https:\/\/blog.csdn.net\/kebu12345678\/article\/details\/81673111\">https:\/\/blog.csdn.net\/kebu12345678\/article\/details\/81673111<\/a><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-6.png\" alt=\"\" class=\"wp-image-3482\" width=\"225\" height=\"121\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-6.png 457w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-6-300x161.png 300w\" sizes=\"(max-width: 225px) 100vw, 225px\" \/><\/figure><\/div>\n\n\n\n<p>\u53c2\u8003\u8bba\u6587 \uff1a\u795e\u7ecf\u7f51\u7edc\u6fc0\u6d3b\u51fd\u6570\u53ca\u5176\u5bfc\u6570\u7684\uff26\uff30\uff27\uff21\u5b9e\u73b0   \u4f5c\u8005\uff1a\u5f20\u667a\u660e\u3000\u5f20\u4ec1\u6770<\/p>\n\n\n\n<p>      \u91c7\u7528\u6298\u7ebf\u659c\u7387\u4e3a2\u7684\u6b21\u5e42\u7684\u5206\u6bb5\u7ebf\u6027\u903c\u8fd1\u65b9\u6cd5\u5b9e\u73b0\u6fc0\u6d3b\u51fd\u6570\uff08sigmoid\u51fd\u6570\uff09\u53ca\u5176\u5bfc\u6570\u7684\u6620\u5c04\u3002\u8be5\u65b9\u6cd5\u5728FPGA\u5b9e\u73b0\u65f6\u4e0d\u9700\u8981\u4f7f\u7528\u786c\u4ef6\u4e58\u6cd5\u5668\uff0c\u800c\u4e14\u53ef\u4ee5\u8282\u7ea6\u5927\u91cf\u7684RAM\u5355\u5143\u3002\u7531\u4e8e\u795e\u7ecf\u7f51\u7edc\u7684\u5e76\u884c\u8ba1\u7b97\u9700\u8981\u6d88\u8017\u5927\u91cf\u7684\u786c\u4ef6\u4e58\u6cd5\u5668\u548cRAM\uff0c\u56e0\u6b64\uff0c\u4e0e\u5176\u4ed6\u65b9\u6cd5\u76f8\u6bd4\uff0c\u8be5\u65b9\u6cd5\u4e3a\u6574\u4e2a\u795e\u7ecf\u7f51\u7edc\u7684FPGA\u5b9e\u73b0\u6709\u6548\u5730\u8282\u7701\u4e86\u5927\u91cf\u5b9d\u8d35\u7684FPGA\u8d44\u6e90\uff0c\u53ef\u4ee5\u8f83\u597d\u5730\u5e94\u7528\u5728BP\u795e\u7ecf\u7f51\u7edc\u7684\u5728\u7ebf\u8bad\u7ec3\u4e2d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u8f93\u516516\u4f4d\uff0c\u6700\u9ad8\u4f4d\u4e3a\u7b26\u53f7\u4f4d\uff0c\u6574\u6570\u53603\u4f4d\uff0c\u5c0f\u6570\u536012\u4f4d\uff1b\u8f93\u51fa16\u4f4d\uff0c\u6700\u9ad8\u4f4d\u4e3a\u7b26\u53f7\u4f4d\uff0c\u5c0f\u6570\u536015\u4f4d\n\nmodule sigmoid(clk,rst,a,b\n    );\n \ninput clk;\ninput rst;\ninput &#091;15:0] a;\n \noutput&#091;15:0] b;\nreg&#091;15:0] b;\nreg&#091;15:0] a_reg;\n \nalways@(posedge clk)\nbegin\n    if(rst)\n    b=0;\n    else\n    begin\n        if(a&#091;15]==0)\n        begin\n            b&#091;15:12]=4'b0000;\n            case(a&#091;14:12])\n            3'b000:b&#091;11:0]=12'b100000000000+(a&#091;11:0]&gt;&gt;2);\/\/\u52a0\u53f7\u7684\u4f18\u5148\u7ea7\u5927\u4e8e\u79fb\u4f4d\u8fd0\u7b97\u7684\u4f18\u5148\u7ea7\uff0c\u8bb0\u5f97\u52a0\u62ec\u53f7\n            3'b001:b&#091;11:0]=12'b110000000000+(a&#091;11:0]&gt;&gt;3);\n            3'b010:b&#091;11:0]=12'b111000000000+(a&#091;11:0]&gt;&gt;4);\n            3'b011:b&#091;11:0]=12'b111100000000+(a&#091;11:0]&gt;&gt;5);\n            3'b100:b&#091;11:0]=12'b111110000000+(a&#091;11:0]&gt;&gt;6);\n            3'b101:b&#091;11:0]=12'b111111000000+(a&#091;11:0]&gt;&gt;7);\n            3'b110:b&#091;11:0]=12'b111111100000+(a&#091;11:0]&gt;&gt;8);\n            3'b111:b&#091;11:0]=12'b111111110000+(a&#091;11:0]&gt;&gt;9);\n            endcase\n            b=b&lt;&lt;3;\/\/\u8f93\u516516\u4f4d\uff0c\u6700\u9ad8\u4f4d\u4e3a\u7b26\u53f7\u4f4d\uff0c\u6574\u6570\u53603\u4f4d\uff0c\u5c0f\u6570\u536012\u4f4d\uff1b\u8f93\u51fa16\u4f4d\uff0c\u6700\u9ad8\u4f4d\u4e3a\u7b26\u53f7\u4f4d\uff0c\u5c0f\u6570\u536015\u4f4d\n        end\n        else\n        begin\n            a_reg=~a+1;\/\/\u53d6a\u7684\u7edd\u5bf9\u503c\n            b&#091;15:12]=4'b0000;\n            case(a_reg&#091;14:12])\n            3'b000:b&#091;11:0]=12'b100000000000+(a_reg&#091;11:0]&gt;&gt;2);\n            3'b001:b&#091;11:0]=12'b110000000000+(a_reg&#091;11:0]&gt;&gt;3);\n            3'b010:b&#091;11:0]=12'b111000000000+(a_reg&#091;11:0]&gt;&gt;4);\n            3'b011:b&#091;11:0]=12'b111100000000+(a_reg&#091;11:0]&gt;&gt;5);\n            3'b100:b&#091;11:0]=12'b111110000000+(a_reg&#091;11:0]&gt;&gt;6);\n            3'b101:b&#091;11:0]=12'b111111000000+(a_reg&#091;11:0]&gt;&gt;7);\n            3'b110:b&#091;11:0]=12'b111111100000+(a_reg&#091;11:0]&gt;&gt;8);\n            3'b111:b&#091;11:0]=12'b111111110000+(a_reg&#091;11:0]&gt;&gt;9);\n            endcase\n            b=b&lt;&lt;3;\/\/\u8f93\u516516\u4f4d\uff0c\u6700\u9ad8\u4f4d\u4e3a\u7b26\u53f7\u4f4d\uff0c\u6574\u6570\u53603\u4f4d\uff0c\u5c0f\u6570\u536012\u4f4d\uff1b\u8f93\u51fa16\u4f4d\uff0c\u6700\u9ad8\u4f4d\u4e3a\u7b26\u53f7\u4f4d\uff0c\u5c0f\u6570\u536015\u4f4d\n            b&#091;14:0]=~b&#091;14:0]+1;\/\/f(x)=1-f(-x)      \n        end\n    end\n \nend\nendmodule<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"972\" height=\"209\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-11.png\" alt=\"\" class=\"wp-image-3630\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-11.png 972w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-11-300x65.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-11-768x165.png 768w\" sizes=\"(max-width: 972px) 100vw, 972px\" \/><\/figure>\n\n\n\n<h3 id=\"implementing-hyperbolic-tangent-in-verilog\">\u5728 Verilog \u4e2d\u5b9e\u73b0\u53cc\u66f2\u6b63\u5207<\/h3>\n\n\n\n<p>Tanh \u662f\u53e6\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u548c\u5e7f\u6cdb\u4f7f\u7528\u7684\u6fc0\u6d3b\u51fd\u6570\u3002\u5b83\u53ea\u662f\u4e00\u4e2a\u7f29\u653e\u7684 sigmoid\uff0c\u5e76\u4e14\u5177\u6709\u4e00\u4e9b\u975e\u5e38\u6709\u7528\u7684\u5c5e\u6027\u3002\u8fd9\u662f\u8fd9\u4e2a\u51fd\u6570\u7684\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/thedatabus.io\/static\/tanh-af3705ed857bbfe0bc94adf78a1a4514.jpg\" alt=\"tanh\"\/><\/figure>\n\n\n\n<p>\u5728\u786c\u4ef6\u5b9e\u73b0\u65b9\u9762\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b9e\u73b0\u8fd9\u79cd\u975e\u7ebf\u6027\u51fd\u6570\u3002\u4f8b\u5982\uff1a<\/p>\n\n\n\n<ul><li><strong>\u7b80\u5355\u67e5\u627e\u8868<\/strong>\uff0c\u6070\u597d\u662f\u5b9e\u73b0\u4e00\u4e2a\u529f\u80fd\u7684\u6700\u7b80\u5355\u3001\u6700\u5feb\u7684\u65b9\u6cd5\uff0c\u4f46\u5728\u9700\u8981\u975e\u5e38\u9ad8\u7684\u7cbe\u5ea6\u65f6\u4e5f\u5360\u7528\u4e86\u5927\u91cf\u8d44\u6e90\u3002<\/li><li><strong>\u5e26\u6709\u63d2\u503c\u7684\u67e5\u627e\u8868<\/strong>\uff0c\u8fd9\u4e5f\u662f\u4e00\u79cd\u57fa\u4e8e\u67e5\u627e\u8868\u7684\u65b9\u6cd5\uff0c\u4f46\u4f7f\u7528\u4e00\u4e9b\u989d\u5916\u7684\u7b97\u672f\u6765\u6539\u5584\u7ed3\u679c\uff0c\u8d85\u51fa\u4e3a\u67e5\u627e\u8868\u672c\u8eab\u5206\u914d\u7684\u7cbe\u5ea6\u3002\u8fd8\u6709\u4e00\u4e9b\u65b9\u6cd5\u4f7f\u7528\u4e24\u4e2a\u67e5\u627e\u8868\uff0c\u4e00\u4e2a\u5177\u6709\u7c97\u7c92\u5ea6\u503c\uff0c\u53e6\u4e00\u4e2a\u5177\u6709\u7ec6\u7c92\u5ea6\u503c\uff0c\u8fd9\u4e9b\u503c\u88ab\u6dfb\u52a0\u5230\u521d\u59cb\u8fd1\u4f3c\u503c\u4e0a\u3002<\/li><li><strong>CORDIC<\/strong>\uff0c\u8fd9\u662f\u53e6\u4e00\u79cd\u975e\u5e38\u6d41\u884c\u7684\u65b9\u6cd5\uff0c\u5e7f\u6cdb\u7528\u4e8e\u5927\u591a\u6570\u9700\u8981\u975e\u7ebf\u6027\u51fd\u6570\uff08\u5982\u6b63\u5f26\u3001sqrt\u3001tanh \u7b49\uff09\u7684 DSP \u5e94\u7528\u7a0b\u5e8f\u4e2d\u3002\u8fd9\u662f\u4e00\u79cd\u975e\u5e38\u4f18\u96c5\u7684\u65b9\u6cd5\uff0c\u5b83\u4f7f\u7528\u57fa\u672c\u7684\u79fb\u4f4d\u52a0\u6cd5\u7535\u8def\u6765\u5b9e\u73b0\u975e\u5e38\u597d\u7684\u7ed3\u679c\u3002\u60a8\u53ef\u4ee5\u9605\u8bfb<a rel=\"noreferrer noopener\" href=\"https:\/\/zipcpu.com\/dsp\/2017\/08\/30\/cordic.html\" target=\"_blank\">\u8fd9\u7bc7<\/a>\u6587\u7ae0\u4ee5\u4e86\u89e3 CORDIC \u7684\u826f\u597d\u5b9e\u73b0\u3002\u5927\u591a\u6570 FPGA \u4f9b\u5e94\u5546\u8fd8\u4e3a CORDIC \u5355\u5143\u63d0\u4f9b\u5c01\u88c5\u7684 IP \u5757\u3002<\/li><li><strong>\u6cf0\u52d2\u7ea7\u6570\u548c\u591a\u9879\u5f0f\u903c\u8fd1<\/strong>\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u4f7f\u7528\u4e09\u89d2\u51fd\u6570\u7684\u4f20\u7edf\u591a\u9879\u5f0f\u903c\u8fd1\uff0c\u5e76\u5c1d\u8bd5\u5728\u8fd9\u4e9b\u591a\u9879\u5f0f\u4e2d\u5b9e\u73b0\u9ad8\u9636\u53d8\u91cf\u3002<\/li><li><strong>DCT \u63d2\u503c\u548c\u66f4\u590d\u6742\u7684\u65b9\u6cd5<\/strong>\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u4f7f\u7528\u66f4\u4e13\u4e1a\u7684\u65b9\u6cd5\u6765\u5b9e\u73b0\u6240\u9700\u7684\u7cbe\u786e\u7cbe\u5ea6\u548c\u8d44\u6e90\u4f7f\u7528\u3002<a rel=\"noreferrer noopener\" href=\"https:\/\/deepai.org\/publication\/accurate-and-efficient-hyperbolic-tangent-activation-function-on-fpga-using-the-dct-interpolation-filter\" target=\"_blank\">\u672c\u6587<\/a>\u5c55\u793a\u4e86\u4e00\u79cd\u8fd9\u6837\u7684\u65b9\u6cd5\u3002<\/li><\/ul>\n\n\n\n<h4 id=\"simple-table-lookup\"><a href=\"https:\/\/thedatabus.io\/activation-function#simple-table-lookup\"><\/a>\u7b80\u5355\u7684\u8868\u67e5\u627e<\/h4>\n\n\n\n<ul><li>\u5bf9\u4e8e\u8fd9\u4e2a\u5b9e\u73b0\uff0c\u6211\u4eec\u53ef\u4ee5\u5229\u7528 Tanh \u51fd\u6570\u7684\u5bf9\u79f0\u6027\uff0c\u5373\u6211\u4eec\u53ea\u9700\u8981\u5b58\u50a8\u4e0e\u51fd\u6570\u7684\u6b63\u76f8\u5173\u7684\u503c\uff0c\u5e76\u4e14\u7531\u4e8e\u8d1f\u8f93\u5165\u7684\u51fd\u6570\u8f93\u51fa\u53ea\u662f\u955c\u50cf\uff0c\u6211\u4eec\u53ef\u4ee5\u8f93\u51fa\u76f8\u540c\u7684\u503c\u4ee5\u4ed6\u4eec\u7684 2 \u7684\u8865\u7801\u683c\u5f0f\u3002<\/li><li>\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5229\u7528\u7684\u53e6\u4e00\u4e2a\u5c5e\u6027\u662f Tanh \u51fd\u6570\u5728\u8d85\u8fc7\u67d0\u4e2a\u8f93\u5165\u503c\u540e\u9971\u548c\u5230 1\uff08\u6216\u5728\u53e6\u4e00\u4fa7\u4e3a -1\uff09\u3002\u5728\u51c6\u786e\u5ea6\u6ca1\u6709\u4efb\u4f55\u663e\u7740\u635f\u5931\u7684\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u4e3a\u9ad8\u4e8e\u9608\u503c\u7684\u8f93\u5165\u8f93\u51fa 1\uff08\u6216 -1\uff09\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u4e0d\u5fc5\u5c06\u51fd\u6570\u503c\u5b58\u50a8\u5728\u67e5\u627e\u8868\u4e2d\u4ee5\u67e5\u627e\u9ad8\u4e8e\u9608\u503c\u7684\u8f93\u5165\u3002\u6211\u4f7f\u7528\u8f93\u5165\u503c 3\uff08\u6216 -3\uff09\u4f5c\u4e3a\u6b64\u9608\u503c\uff0c\u56e0\u4e3a<em>tanh(3) = 0.9950547536867305<\/em>&nbsp;\u5e76\u4e14\u5bf9\u4e8e\u9ad8\u4e8e 3\uff08\u6216\u4f4e\u4e8e -3\uff09\u7684\u6240\u6709\u8f93\u5165\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u5c06\u8f93\u51fa\u89c6\u4e3a 1\uff08\u6216 -1\uff09 .<\/li><li>\u5bf9\u4e8e\u8fd9\u4e2a\u5b9e\u73b0\uff0c\u6211\u4f7f\u7528\u4e86\u4e00\u4e2a\u5177\u6709 1024 \u4e2a\u4f4d\u7f6e\u7684 RAM\uff0c\u6bcf\u4e2a\u4f4d\u7f6e\u90fd\u4fdd\u5b58 16 \u4f4d\u6570\u636e\uff0c\u4ee5\u5b9e\u73b0\u67e5\u627e\u8868\u3002\u8fd9\u610f\u5473\u7740\u6211\u4eec\u5c06\u6709 10 \u4e2a\uff08= log2(1024)\uff09\u5730\u5740\u4f4d\u6765\u8bbf\u95ee\u8fd9\u4e2a ram\u3002\u4f46\u662f\u6211\u4eec\u7684\u76f8\u4f4d\u8f93\u5165\u5c06\u662f\u4e00\u4e2a 16 \u4f4d\u7684\u5b9a\u70b9\u6570\u3002\u90a3\u4e48\u6211\u4eec\u5982\u4f55\u9009\u62e9 10 \u4e2a\u7279\u5b9a\u7684\u4f4d\u6765\u5bfb\u5740\u8fd9\u4e2a ram\uff1f<\/li><\/ul>\n\n\n\n<p>\u4ee5\u4e0b\u662f tanh \u51fd\u6570\u7684 (3,12) \u683c\u5f0f\u7684 16 \u4f4d\u5b9a\u70b9\u8f93\u5165\u793a\u4f8b\uff1a<\/p>\n\n\n\n<p><code>reg [15:0] phase = 16'b0_001_011000100101<\/code><\/p>\n\n\n\n<p>\u5728\u8fd9\uff0c<\/p>\n\n\n\n<ul><li>MSB ( phase[15] ) \u662f\u7b26\u53f7\u4f4d\uff0c\u5b83\u5c06\u544a\u8bc9\u6211\u4eec\u662f\u8f93\u51fa\u76f4\u63a5\u503c\u8fd8\u662f 2 \u7684\u8865\u7801\u5f62\u5f0f\u3002<\/li><li>\u63a5\u4e0b\u6765\u7684\u4e09\u4e2a MSB \u4ee3\u8868\u8fd9\u4e2a\u6570\u5b57\u7684\u6574\u6570\u90e8\u5206\u3002\u7531\u4e8e\u6211\u4eec\u53ea\u5173\u5fc3\u5e45\u5ea6\u5c0f\u4e8e 3 \u7684\u6570\u5b57\uff0c\u5982\u679c\u7b2c\u4e8c\u4e2a MSB ( phase[14] ) \u5f88\u9ad8\uff08\u5bf9\u4e8e\u4e00\u4e2a\u6b63\u6570\uff09\uff0c\u5b83\u544a\u8bc9\u6211\u4eec\u8fd9\u4e2a\u6570\u5b57\u7684\u5e45\u5ea6\u5927\u4e8e 3 \u5e76\u4e14\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u8f93\u51fa 1 \u3002\u5426\u5219\uff0c\u6211\u4eec\u53ef\u4ee5\u4ece\u8868\u4e2d\u8f93\u51fa\u503c\u3002<\/li><li>\u63a5\u4e0b\u6765\u7684 10 \u4e2a MSB\uff08\u9636\u6bb5 [13:4]\uff09\u5c06\u7528\u4f5c\u67e5\u627e\u8868\u7684\u8f93\u5165\u3002\u662f\u7684\uff0c\u6211\u4eec\u5c06\u4e22\u5931 LSB\uff08phase[3:0]\uff09\u4e2d\u7684\u4fe1\u606f\uff0c\u4f46\u5982\u679c\u6211\u4eec\u4e5f\u60f3\u4f7f\u7528\u5b83\u4eec\uff0c\u6211\u4eec\u9700\u8981\u4e00\u4e2a 16 \u500d\u5927\u7684\u67e5\u627e\u8868\u3002\u53ea\u8981\u6211\u4eec\u7684\u5e94\u7528\u7a0b\u5e8f\u83b7\u5f97\u5408\u7406\u7684\u51c6\u786e\u6027\uff0c\u6211\u4eec\u5c31\u4e0d\u5fc5\u62c5\u5fc3\u3002\u518d\u5f80\u4e0b\uff0c\u6211\u4eec\u5c06\u7814\u7a76\u4e00\u79cd\u4e5f\u5229\u7528\u8fd9\u4e9b LSB \u7684\u6280\u672f\u3002<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code> `timescale 1ns \/ 1ps\n    module tanh_lut #(\n        parameter AW = 10, \/\/AW will be based on the size of the ROM we can afford in our design.\n                           \/\/in the best case AW = N;\n        parameter DW = 16,\n        parameter N = 16,\n        parameter Q = 12\n        )(\n        input clk,\n        input &#091;AW-1:0] phase,\n        output &#091;DW-1:0] tanh\n       );\n     reg &#091;AW-1:0] addr_reg;\n  (* ram_style = \"block\" *)reg &#091;DW-1:0] mem &#091;1&lt;&lt;AW-1:0];  \/\/ram_style can be 'block' or 'distributed' \t\t\t\t\t\t\t\t\t                    \/\/ based on the utilization and other\n                                                          \/\/requirements in the project\n    initial \n    begin\n        $readmemb(\"tanh_data.mem\",mem); \/\/loading data into our RAM via a file\n    end\n        \n    always@(posedge clk)\n    begin\n        addr_reg &lt;= phase&#091;AW-1:0];\n    end\n        \n    assign tanh = mem&#091;addr_reg];\n<\/code><\/pre>\n\n\n\n<h4 id=\"lookup-table-with-linear-interpolation\">\u5177\u6709\u7ebf\u6027\u63d2\u503c\u7684\u67e5\u627e\u8868<\/h4>\n\n\n\n<p>\u7ebf\u6027\u63d2\u503c\u6280\u672f\u662f\u6570\u5b66\u4e2d\u5e38\u7528\u7684\u6280\u5de7\uff0c\u7528\u4e8e\u5728\u6570\u636e\u4e2d\u6ca1\u6709\u8db3\u591f\u7684\u5206\u8fa8\u7387\u65f6\u6539\u8fdb\u503c\u7684\u8fd1\u4f3c\u503c\u3002\u5373\uff0c\u5f53\u60a8\u60f3\u8981\u4e24\u4e2a\u8fde\u7eed\u6570\u636e\u70b9\u4e4b\u95f4\u7684\u79bb\u6563\u51fd\u6570\u7684\u503c\u65f6\uff0c\u60a8\u53ef\u4ee5\u7ed8\u5236\u4e00\u6761\u8fde\u63a5\u8fd9\u4e24\u4e2a\u70b9\u7684\u76f4\u7ebf\uff0c\u5e76\u5c06\u60a8\u7684\u8f93\u51fa\u8fd1\u4f3c\u4e3a\u8be5\u7ebf\u4e0a\u7684\u67d0\u4e2a\u4f4d\u7f6e\u3002\u8fd9\u663e\u7740\u63d0\u9ad8\u4e86\u6211\u4eec\u51fd\u6570\u7684\u51c6\u786e\u6027\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/thedatabus.io\/static\/interp-3e147cb0b91d07e52d4e44494b2e2924.jpg\" alt=\"\u7ebf\u6027\u63d2\u503c\"\/><\/figure>\n\n\n\n<p>\u73b0\u5728\uff0c\u4e3a\u4e86\u89e3\u91ca\u8fd9\u4e2a\u60f3\u6cd5\uff0c\u770b\u770b\u4e0a\u9762\u7684\u56fe\u7247\u3002\u5047\u8bbe<strong>a&nbsp;<sub>i<\/sub><\/strong>\u548c<strong>a&nbsp;<sub>i+1<\/sub><\/strong>\u662f\u4e24\u4e2a\u8fde\u7eed\u7684\u70b9\uff0c\u6211\u4eec\u77e5\u9053\u51fd\u6570 f(a&nbsp;<sub>i<\/sub>&nbsp;) \u548c f(a&nbsp;<sub>i+1<\/sub>&nbsp;) \u7684\u503c\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5728\u6211\u4eec\u7684\u4f8b\u5b50\u4e2d\uff0c\u8fd9\u4e9b\u662f RAM \u4e2d\u7684\u4e24\u4e2a\u6761\u76ee\uff0c\u7528\u4e8e\u4e24\u4e2a\u8fde\u7eed\u70b9\u7684 Tanh \u503c\u3002<\/p>\n\n\n\n<p>\u5047\u8bbe\u6211\u4eec\u8981\u5728<strong>a&nbsp;<sub>i+\u03b1<\/sub><\/strong>\u70b9\u627e\u5230\u51fd\u6570\u7684\u503c\uff0c \u5176\u4e2d<strong>\u03b1<\/strong>\u662f\u5c0f\u4e8e 1 \u7684\u5c0f\u6570\u503c\u3002\u8fd9\u544a\u8bc9\u6211\u4eec\uff0c\u6211\u4eec\u9700\u8981\u4e24\u4e2a\u5df2\u77e5\u70b9\u4e4b\u95f4\u7684 f(x) \u503c\uff0c\u56e0\u4e3a\u6211\u4eec\u6ca1\u6709\u5173\u4e8e\u8fd9\u4e24\u4e2a\u70b9\u4e4b\u95f4\u66f2\u7ebf\u7684\u5b9e\u9645\u5f62\u72b6\u7684\u4fe1\u606f\uff0c\u4e00\u79cd\u8fd1\u4f3c\u7684\u65b9\u6cd5\u662f\u5047\u8bbe\u4e24\u4e2a\u5df2\u77e5\u70b9\u3002<sub>\u901a\u8fc7\u4f7f\u7528\u57fa\u672c\u7684\u7ebf\u6027\u6570\u5b66\uff0c\u6211\u4eec\u53ef\u4ee5\u627e\u51fa\u5bf9\u5e94\u4e8e x = a i+\u03b1<\/sub>\u7684\u76f4\u7ebf\u4e0a\u7684\u70b9\u7684\u503c\u3002<\/p>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u731c\u5230\uff0c\u8fd9\u4e2a\u8fd1\u4f3c\u503c\u662f f(&nbsp;<strong>a&nbsp;<sub>i<\/sub><\/strong>&nbsp;) + x( (f(&nbsp;<strong>a&nbsp;<sub>i+1<\/sub><\/strong>&nbsp;) &#8211;&nbsp;<strong>a&nbsp;<sub>i<\/sub><\/strong>&nbsp;)\/1 ) = xf(&nbsp;<strong>a&nbsp;<sub>i<\/sub><\/strong>&nbsp;) + (1-x)f(&nbsp;<strong>a&nbsp;<sub>i+ 1<\/sub><\/strong>&nbsp;) \u4ea7\u751f\u7684\u8bef\u5dee\u4e3a xf(&nbsp;<strong>a&nbsp;<sub>i<\/sub><\/strong>&nbsp;) + (1-x)f(&nbsp;<strong>a&nbsp;<sub>i+1<\/sub><\/strong>&nbsp;) &#8211; f(&nbsp;<strong>a&nbsp;<sub>i+\u03b1<\/sub><\/strong>&nbsp;)<\/p>\n\n\n\n<p>\u8fd9\u4e2a\u7ed3\u679c\u5c06\u6bd4\u67e5\u627e\u8868\u4e2d\u7684\u521d\u59cb\u8fd1\u4f3c\u503c\u76f8\u5bf9\u66f4\u51c6\u786e\u3002<strong>\u5728\u6211\u4eec\u7684\u4f8b\u5b50\u4e2d\uff0c \u03b1<\/strong>\u7684\u503c\u5c06\u6765\u81ea\u5728\u5b9e\u9645\u67e5\u627e\u8868\u4e2d\u88ab\u5ffd\u7565\u7684\u5269\u4f59 4 \u4e2a LSB\u3002\u4e0b\u9762\u662f\u8fd9\u79cd\u65b9\u6cd5\u7684\u4ee3\u7801\uff1a<\/p>\n\n\n\n<p>\u6ce8\u610f\uff1a\u6211\u6b63\u5728\u4e3a 16 \u4f4d\u5bbd\u7684\u6570\u636e\u8def\u5f84\u7f16\u5199\u4ee3\u7801\u3002ie N = 16 \u5982\u679c\u60a8\u4e00\u76f4\u5728\u9605\u8bfb\u672c\u7cfb\u5217\u7684\u5176\u4ed6\u6587\u7ae0\u3002\u4f46\u662f\uff0c\u5b83\u53ef\u4ee5\u975e\u5e38\u53c2\u6570\u5316\u4ee5\u4f7f\u7528\u4efb\u4f55\u4f4d\u5bbd\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>`timescale 1ns \/ 1ps\nmodule tanh_lut #(\n    parameter AW = 10, \/\/AW will be based on the size of the ROM we can afford in our design.\n                       \/\/in the best case AW = N;\n    parameter DW = 16,\n    parameter N = 16,\n    parameter Q = 12\n    )(\n    input clk,\n    input &#091;N-1:0] phase,\n    output &#091;DW-1:0] tanh\n    );\n    \n    reg &#091;9:0] addra_reg;\n    reg &#091;9:0] addrb_reg;\n    wire &#091;15:0] tanha;\n    wire &#091;15:0] tanhb;\n    wire ovr1,ovr2;\n\n    wire &#091;15:0] frac,one_minus_frac;\n    wire &#091;15:0] A1,A2;\n    wire &#091;15:0] one;\n    wire &#091;DW-1:0] tanh_temp;\n\n    \n    (* ram_style = \"block\" *)reg &#091;15:0] mem &#091;1&lt;&lt;10-1:0];  \/\/ram_style can be 'block' or 'distributed' based on the\n                                                            \/\/utilization and other requirements in the project\n    \n    initial \n    begin\n        $readmemb(\"tanh_data.mem\",mem); \/\/loading our RAM via a file\n    end\n    \n    <strong>always@<\/strong>(posedge clk)\n    begin\n        addra_reg &lt;= phase&#091;9:0];\n        addrb_reg &lt;= phase&#091;9:0] + 1'b1;\n    end\n\n    assign tanha = mem&#091;addra_reg];\n    assign tanhb = mem&#091;addrb_reg];\n    \n    assign frac = {'d0,phase&#091;N-AW-'d2-1:0]}; \/\/rest of the LSBs that were not accounted for owing to the limited ROM size\n    assign one = 16'b0001000000000000;       \/\/'d1 in (N,Q) = (3,12) format\n    assign one_minus_frac = one - frac;\n    \n    \/\/qmult is the fixed point multiplier module, visit the fixed point arithmetic\n    \/\/article further in the series to learn of its exact operation\n    qmult #(N,Q) mul1 (tanha,frac,A1,ovr1);              \/\/calculates x*f(Ai)\n    qmult #(N,Q) mul2 (tanhb,one_minus_frac,A2,ovr2);    \/\/calculates (1-x)*f(Ai+1)\n    \n    assign tanh_temp = A1 + A2;    \/\/ linear interpolation formula: x*Ai + (1-x)*Ai+1\n    \n    \/\/now, if the phase input is above 3 or below -3 then we just output 1, otherwise we output the calculated value\n    \/\/we also check for the sign, if the phase is negative, we return 2's complemented version of the calculated value\n    assign tanh = (phase &#091;N-1]) ? (phase&#091;N-2] ? (16'b1111000000000000) : (~tanh_temp + 1'b1)) :(phase&#091;N-2] ? (16'b0001000000000000):(tanh_temp));\n    \nendmodule<\/code><\/pre>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>FPGA upsame \u6700\u90bb\u8fd1\u63d2\u503c\u5b9e\u73b0\uff08\u5f85\u505a\uff09<\/h2>\n\n\n\n<p>\u4e8c\u500d\u653e\u5927\u7684\u7b80\u6613\u5b9e\u73b0\u65b9\u6cd5<\/p>\n\n\n\n<p>\u5982\u679c\u4e00\u526f\u56fe\u50cf\u7684\u5bbd\u5ea6\u9700\u8981\u53d8\u4e3a\u539f\u5148\u7684\u4e00\u534a\uff0c\u8981\u600e\u4e48\u505a\uff1f\u5f88\u7b80\u5355\uff0c\u964d\u91c7\u6837\u5c31\u884c\uff0c\u5047\u5982\u539f\u5148\u4e00\u884c\u50cf\u7d20\u662f1\u30012\u30013\u30014\u30015\u30016\u30017\u30018\uff0c\u90a3\u4e48\u964d\u91c7\u6837\u540e\u5c31\u662f 1\u30013\u30015\u30017 \u62162\u30014\u30016\u30018\uff0c\u884c\u5bbd\u5c31\u53d8\u6210\u4e00\u534a\u4e86\u3002\u9ad8\u5ea6\u53d8\u4e3a\u539f\u5148\u4e00\u534a\u4e5f\u662f\u4e00\u6837\u7684\u9053\u7406\uff0c\u90a3\u4e48\u4e8c\u500d\u7f29\u5c0f\u5c31\u662f\u884c\u5217\u90fd\u964d\u91c7\u6837\u5c31\u884c\u3002\u90a3\u4e48\u4e8c\u500d\u653e\u5927\u5c31\u53ef\u4ee5\u53cd\u8fc7\u6765\u60f3\uff0c\u6bcf 1\/2 \u884c\u8bfb\u4e24\u6b21\uff0c\u6bcf\u4e00\u6574\u884c\u518d\u91cd\u8bfb\u4e00\u6b21\u3002\u76f4\u63a5\u7528 ram \u5c31\u80fd\u5b9e\u73b0\u4e86\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"225\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-9-1024x225.png\" alt=\"\" class=\"wp-image-3619\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-9-1024x225.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-9-300x66.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-9-768x169.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-9-1536x337.png 1536w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-9.png 1575w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u8fd9\u6837\u4e00\u5e45 4&#215;2 \u7684\u56fe\u7247\u5c31\u4e8c\u500d\u653e\u5927\u4e3a 8&#215;4 \u4e86\uff0c\u7406\u8bba\u5b58\u5728\uff0c\u5b9e\u8df5\u5f00\u59cb\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"264\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-10-1024x264.png\" alt=\"\" class=\"wp-image-3620\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-10-1024x264.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-10-300x77.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-10-768x198.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-10-1536x397.png 1536w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-10.png 1905w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u53c2\u8003\uff1a<\/p>\n\n\n\n<p><a href=\"https:\/\/www.cnblogs.com\/yiquwange\/p\/14811277.html\">https:\/\/www.cnblogs.com\/yiquwange\/p\/14811277.html<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>\u6c60\u5316\u5c42<\/h2>\n\n\n\n<p>ooler \u662f\u8fd9\u4e2a\u8bbe\u8ba1\u4e2d\u5b9e\u73b0 Max Pooling \u64cd\u4f5c\u7684\u90e8\u5206\u3002\u4e0b\u9762\u7684\u52a8\u753b\u5411\u60a8\u5c55\u793a\u4e86\u6700\u5927\u6c60\u64cd\u4f5c\u662f\u4ec0\u4e48\u3002\u57fa\u672c\u4e0a\uff0c\u5b83\u662f\u4e00\u79cd\u5728\u795e\u7ecf\u7f51\u7edc\u7684\u5404\u4e2a\u9636\u6bb5\u5bf9\u6570\u636e\u8fdb\u884c\u4e0b\u91c7\u6837\u7684\u7279\u6b8a\u65b9\u6cd5\uff0c\u4ee5\u51cf\u5c11\u6d89\u53ca\u7684\u53c2\u6570\u6570\u91cf\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/thedatabus.io\/static\/pooler-1507011297705ba002d1bc519177e987.gif\" alt=\"\u6c60\u5316\u52a8\u753b\"\/><\/figure>\n\n\n\n<p>\u6211\u4eec\u9700\u8981\u8bb0\u4f4f\u7684\u4e00\u4e2a\u8bbe\u8ba1\u65b9\u9762\u662f\uff0c\u6c60\u5316\u5668\u4e5f\u88ab\u8bbe\u8ba1\u4e3a\u6d41\u6c34\u7ebf\u6d41\u5f0f\u67b6\u6784\uff0c\u4ee5\u8865\u5145<a href=\"https:\/\/thedatabus.io\/convolver\">Convolver<\/a>\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u4ece\u5377\u79ef\u5668\u51fa\u6765\u7684\u6570\u636e\u53ef\u4ee5\u5728\u6bcf\u4e2a\u65f6\u949f\u5468\u671f\u8fde\u7eed\u8f93\u5165\u5230\u6c60\u5316\u5668\u4e2d\uff0c\u5e76\u4e14\u8f93\u51fa\u4f1a\u5728\u4e00\u5b9a\u6570\u91cf\u7684\u65f6\u949f\u5468\u671f\u540e\u51fa\u73b0\uff0c\u8fd9\u4e2a\u8f93\u51fa\u5c06\u662f\u8f93\u5165\u7684\u4e0b\u91c7\u6837\u7248\u672c\u3002\u5373\u5377\u79ef\u5668\u7684\u8f93\u51fa\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"911\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-14-1024x911.png\" alt=\"\" class=\"wp-image-3690\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-14-1024x911.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-14-300x267.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-14-768x683.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-14.png 1027w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u53ef\u4ee5\u7406\u89e3\u7684\u662f\uff0cMax pooler \u7684\u8f93\u51fa\u5e94\u8be5\u662f\u5176\u8f93\u5165\u5927\u5c0f\u7684\u4e00\u5c0f\u90e8\u5206\u3002\u8fd9\u53d6\u51b3\u4e8e\u6c60\u5316\u7a97\u53e3\u7684\u5927\u5c0f\u3002\u7136\u800c\uff0c\u5927\u591a\u6570\u5e38\u7528\u7684\u795e\u7ecf\u7f51\u7edc\u6ca1\u6709\u5927\u4e8e 2X2 \u7ef4\u5ea6\u7684\u6c60\u5316\u7a97\u53e3\uff0c\u56e0\u4e3a\u4efb\u4f55\u5927\u4e8e\u8be5\u7ef4\u5ea6\u7684\u64cd\u4f5c\u90fd\u4f1a\u53d8\u5f97\u8fc7\u4e8e\u7834\u574f\u6027\u5e76\u5bfc\u81f4\u4fe1\u606f\u5927\u91cf\u4e22\u5931\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"297\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-12-1024x297.png\" alt=\"\" class=\"wp-image-3680\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-12-1024x297.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-12-300x87.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-12-768x223.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-12.png 1190w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><em>valid_op<\/em>\u4fe1\u53f7\u4ec5\u5728\u6b63\u786e\u7684\u8f93\u51fa\u5904\u53d8\u4e3a\u9ad8\u7535\u5e73\u3002\u5373\u7a97\u53e3\u4e2d\u7684\u6700\u5927\u503c<\/p>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>FPGA\u5927\u89c4\u6a21\u52a0\u6cd5\u6811\u7684\u5b9e\u73b0<\/h2>\n\n\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u601d\u8def\uff1agenerate \u751f\u6210 n \u4e2a\u6570\uff0c\u5bf9n\u4e2a\u6570\u6c42\u548c\uff0c\u5c06v1\u4e2d\u7684 mult_w[i]  \u6539\u4e3a\u6211\u4eec\u5e76\u884cN\u4e2aconv\u7684\u8f93\u51fa reg[N-1:0] out[16:0]<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/blog.csdn.net\/wangbowj123\/article\/details\/105607708?spm=1001.2101.3001.6650.2&amp;utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-2.pc_relevant_antiscanv2&amp;depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-2.pc_relevant_antiscanv2&amp;utm_relevant_index=3\" target=\"_blank\">\u53c2\u8003\u535a\u5ba2<\/a>1<\/p>\n\n\n\n<p><a href=\"https:\/\/blog.csdn.net\/jiang1960034308\/article\/details\/118078073?spm=1001.2101.3001.6650.3&amp;utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-3.pc_relevant_default&amp;depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-3.pc_relevant_default&amp;utm_relevant_index=4\" target=\"_blank\" rel=\"noreferrer noopener\">\u53c2\u8003\u535a\u5ba22<\/a><\/p>\n\n\n\n<p>github <\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/raiker\/tarsier\/blob\/master\/src\/AdderTree.sv\" target=\"_blank\" rel=\"noreferrer noopener\">\u65e0pipeline\u7684\u6709\u7b26\u53f7\u6570\u5e76\u884c\u52a0\u6cd5\u6811<\/a> <\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/raiker\/tarsier\/blob\/master\/src\/AdderTreePipelined.sv\">\u6709pipeline\u7684\u6709\u7b26\u53f7\u6570\u5e76\u884c\u52a0\u6cd5\u6811 <\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/raiker\/tarsier\/blob\/master\/src\/UnsignedAdderTree.sv\" data-type=\"URL\" target=\"_blank\" rel=\"noreferrer noopener\">\u65e0pipeline\u7684\u65e0\u7b26\u53f7\u6570\u5e76\u884c\u52a0\u6cd5\u6811<\/a> <\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/raiker\/tarsier\/blob\/master\/src\/UnsignedAdderTreePipelined.sv\" target=\"_blank\" rel=\"noreferrer noopener\">\u6709pipeline\u7684\u65e0\u7b26\u53f7\u6570\u5e76\u884c\u52a0\u6cd5\u6811<\/a><\/p>\n\n\n\n<p>&nbsp;       \u4e4b\u524d\u5728\u8bbe\u8ba1\u4e2d\u9047\u5230\u8fc71\u4e2a\u95ee\u9898\uff0c\u5982\u4f55\u5728<a rel=\"noreferrer noopener\" href=\"https:\/\/so.csdn.net\/so\/search?q=verilog&amp;spm=1001.2101.3001.7020\" target=\"_blank\">verilog<\/a>\u4e2d\u5e76\u884c\u5b9e\u73b0\u5927\u91cf\u6570\u636e\uff08\u51e0\u5341\u3001\u51e0\u767e\u4e2a\u751a\u81f3\u66f4\u591a\uff09\u7684\u52a0\u6cd5\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p>&nbsp;\u6700\u76f4\u63a5\u60f3\u5230\u7684\u65b9\u6cd5\u4e00\u822c\u4f1a\u7c7b\u4f3c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>reg &#091;7:0]  \ndata &#091;N - 1 : 0]; \nwire&#091;M:0]  \nsum; assign sum = data&#091;0] + data&#091;1] + ... + data&#091;N-1];<\/code><\/pre>\n\n\n\n<p class=\"has-text-align-left\">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\u8fd9\u79cd\u65b9\u6cd5\u672c\u8eab\u6ca1\u6709\u95ee\u9898\uff0c\u4f46\u662f\u968f\u7740N\u4e0d\u65ad\u589e\u5927\uff0c\u4ee3\u7801\u91cf\u4e5f\u4f1a\u968f\u4e4b\u4e0d\u65ad\u589e\u52a0\uff0c\u800c\u4e14\u5f88\u5bb9\u6613\u5199\u9519\u3002&nbsp;\u53e6\u5916\uff0c\u52a0\u6cd5\u662f\u7ec4\u5408\u903b\u8f91\uff0c\u4e3a\u4e86\u63d0\u9ad8\u65f6\u5e8f\u6027\u80fd\uff0c\u9700\u8981\u5728\u82e5\u5e72\u4e2a\u6570\u7684\u52a0\u6cd5\u7ed3\u679c\u4e4b\u540e\u63d2\u5165\u4e00\u7ea7register\uff0c\u8fdb\u884cpipeline\u8bbe\u8ba1\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u6309\u7167\u4e0a\u9762\u90a3\u79cd\u65b9\u5f0f\u5199\u4ee3\u7801\u91cf\u5c31\u66f4\u5927\u4e86\u3002&nbsp;\u540e\u6765\u53c8\u60f3\u5230\u7528generate for\u8bed\u53e5\uff0c\u4ee3\u7801\u91cf\u540c\u6837\u5f88\u5927\u3002<\/p>\n\n\n\n<p>\u5728\u9879\u76ee\u8fc7\u7a0b\u4e2d\u9700\u8981\u7528<a rel=\"noreferrer noopener\" href=\"https:\/\/so.csdn.net\/so\/search?q=FPGA&amp;spm=1001.2101.3001.7020\" target=\"_blank\">FPGA<\/a>\u5728\u5c3d\u91cf\u5c11\u7684\u65f6\u949f\u5468\u671f\u5185\u5b9e\u73b0\u591a\u4e2a\u6570\u636e\u76f8\u52a0\u3002\u5982\u679c\u76f4\u63a5\u7528\u7ec4\u5408\u7684\u5f62\u5f0f\u5b9e\u73b0\u5ef6\u8fdf\u592a\u9ad8\uff0c\u5360\u7528\u8d44\u6e90\u4e5f\u592a\u591a\uff0c\u56e0\u6b64\u8003\u8651\u57fa\u4e8e\u6d41\u6c34\u7ebf\u7684\u5e76\u884c\u52a0\u6cd5\u6811\u6765\u5b9e\u73b0\u591a\u4e2a\u6570\u636e\u76f8\u52a0<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u4e0a\u8ff0\u7a0b\u5e8f\u90fd\u662f\u4f7f\u7528system verilog\u8bbe\u8ba1\u7684\uff0c\u5176\u4e2d\u6700\u7cbe\u9ad3\u7684\u4e00\u4e2a\u601d\u60f3\u5c31\u662f\u6a21\u5757\u7684\u9012\u5f52\u8c03\u7528\u3002\u4ec5\u901a\u8fc71\u4e2a\u6a21\u5757\u5c31\u53ef\u4ee5\u5b9e\u73b0\u4efb\u610fbit\u4f4d\u5bbd\uff0c\u4efb\u610f\u6570\u91cf\u7684\u6570\u636e\u8fdb\u884c\u5e76\u884c\u52a0\u6cd5\u8ba1\u7b97\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img src=\"https:\/\/img-blog.csdnimg.cn\/20200418231705142.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdib3dqMTIz,size_16,color_FFFFFF,t_70\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\"\/><\/figure><\/div>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u4e3b\u8981\u539f\u7406\u4e3a\uff1a\u901a\u8fc7N\u5206\u6cd5\uff0c\u5c06\u8f93\u5165\u6570\u636e\u5206\u6210N\u7ec4\uff0c\u6bcf\u4e00\u7ec4\u9012\u5f52\u8c03\u7528\u6a21\u5757\u81ea\u8eab\uff0c\u7136\u540e\u5728\u9012\u5f52\u8c03\u7528\u7684\u6a21\u5757\u91cc\u518d\u7ee7\u7eed\u5206\u4e3aN\u7ec4\u2026\u2026\u4e0d\u65ad\u91cd\u590d\uff0c\u76f4\u5230\u6700\u540e\u5206\u89e3\u4e3aX\u7ec4N\u4e2a\u6570\u7684\u52a0\u6cd5\u6216\u5355\u4e2a\u6570\uff0c\u7c7b\u4f3c\u4e8e\u4e8c\u53c9\u6811\u7684\u7ed3\u6784\u3002\u7136\u540e\u8ba1\u7b97\u8fc7\u7a0b\u5c31\u662f\u4ece\u4e8c\u53c9\u6811\u7684\u6700\u5e95\u5c42\u9010\u5c42\u5411\u4e0a\u8fdb\u884c\uff0c\u76f4\u5230\u8fbe\u5230\u6700\u9876\u5c42\u5f97\u51fa\u6700\u540e\u7684\u8ba1\u7b97\u7ed3\u679c\u3002\u540c\u65f6\uff0c\u5728\u6bcf\u5c42N\u53c9\u6811\u7684\u8282\u70b9\u90fd\u63d2\u51651\u7ea7pipeline register\uff0c\u76f8\u5f53\u4e8e\u6bcfN\u4e2a\u6570\u7684\u52a0\u6cd5\u903b\u8f91\u540e\u90fd\u63d2\u51651\u7ea7pipeline register\u3002\u8fd9\u79cd\u8bbe\u8ba1\u7ed3\u6784\u53ef\u79f0\u4e4b\u4e3a\u5e76\u884c\u52a0\u6cd5\u6811\u3002<\/p>\n\n\n\n<h2>\u7248\u672c1\uff1a<\/h2>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">         \u4e3a\u4e86\u8fdb\u4e00\u6b65\u589e\u52a0\u5e76\u884c\u6027\uff0c\u52a0\u6cd5\u6811\u7ed3\u6784\u91c7\u7528\u4e8c\u53c9\u6811\u3002\u5373\uff0c\u5bf9\u6bcf2\u4e2a\u5b50\u8282\u70b9\u8fdb\u884c\u6c42\u548c\u3002\u6700\u7ec8\u5f97\u5230\u4e00\u4e2a\u90e8\u5206\u548c\u3002\u5b9e\u73b0\u65b9\u5f0f\u662f\u5199\u4e00\u4e2a\u52a0\u6cd5\u5668\u6a21\u5757\uff0c\u518d\u5199\u4e00\u4e2a<a rel=\"noreferrer noopener\" href=\"https:\/\/so.csdn.net\/so\/search?q=%E4%B9%98%E6%B3%95%E5%99%A8&amp;spm=1001.2101.3001.7020\" target=\"_blank\">\u4e58\u6cd5\u5668<\/a>\u6a21\u5757\uff08\u6a21\u62dfconv\u5c42\uff09\uff0c\u4e4b\u540e\u518d\u5199\u4e00\u4e2a\u603b\u4f53\u7684\u6a21\u5757\u5c06\u8fd9\u4e9b\u4e58\u6cd5\u5668\u548c\u52a0\u6cd5\u5668\u8fdb\u884c\u7ed3\u5408\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u52a0\u6cd5\u5668\u6a21\u5757\nmodule adder(\n\tinput clk,\n\tinput rst_n,\n\tinput &#091;15 : 0] a,\n\tinput &#091;15 : 0] b,\n\tinput &#091;15 : 0] c,\n\toutput &#091;15 : 0] result\n);\nreg &#091;15 : 0] result_reg;\n\nassign result = result_reg;\nalways @ (posedge clk or negedge rst_n)\nbegin\n\tif(!rst_n)\n\t\tresult_reg &lt;= 16'b0;\n\telse\n\tbegin\n\t\tresult_reg &lt;= a + b ;\n\tend\nend \n\nendmodule\n<\/code><\/pre>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u65e0\u6d41\u6c34\u7ebf\u52a0\u6cd5\u5668\u6811\uff1a\u5b9e\u73b0\u76848\u4e2a\u8f93\u5165\uff0c\u4e09\u7ea7\u52a0\u6cd5\u6811\uff1a\u5b9e\u73b0\u4e861\u52308\u7684\u5e73\u65b9\u548c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>module add_module(\ninput clk,\n\tinput rst_n,\n\toutput &#091;15 : 0]result\n    );\n\nreg &#091;15 : 0] result_reg;\nwire &#091;15:0] mult_w &#091;7:0];\n\nwire &#091;15:0] adder_w &#091;3 : 0];\nreg &#091;15:0] num_reg &#091;7:0];\nwire &#091;15:0] second &#091;1:0];\n\n\n\ngenvar i;\ngenerate\n\tfor(i = 0; i &lt; 8; i = i + 1)\n\tbegin: mults\n\t\tmult\n\t\tu_mult(\n\t\t\t.clk(clk),\n\t\t\t.rst_n(rst_n),\n\t\t\t.a(num_reg&#091;i]),\n\t\t\t.b(num_reg&#091;i]),\n\t\t\t.result(mult_w&#091;i])\n\t\t);\n\tend \n\nendgenerate\n\ngenvar j;\ngenerate\n\tfor(j = 0; j &lt; 4; j = j + 1)\n\tbegin: adders\n\t\tadder\n\t\tu1_adder(\n\t\t\t.clk(clk),\n\t\t\t.rst_n(rst_n),\n\t\t\t.a(mult_w&#091;j * 2 + 0]),\n\t\t\t.b(mult_w&#091;j * 2 + 1]),\n\t\t\t.result(adder_w&#091;j])\n\t\t);\n\tend\nendgenerate\n\n\ngenvar k;\ngenerate\n\tfor(k = 0; k &lt; 2; k = k + 1)\n\tbegin: adders_2\n\t\tadder\n\t\tu2_adder(\n\t\t\t.clk(clk),\n\t\t\t.rst_n(rst_n),\n\t\t\t.a(adder_w&#091;k * 2 + 0]),\n\t\t\t.b(adder_w&#091;k * 2 + 1]),\n\t\t\t.result(second&#091;k])\n\t\t);\n\tend\nendgenerate\nadder\nfin_adder(\n\t.clk(clk),\n\t.rst_n(rst_n),\n\t.a(second&#091;0]),\n\t.b(second&#091;1]),\n\t.result(result)\n);\n\ninteger s;\nalways@(posedge clk)\nbegin\n    if(!rst_n)\n    begin\n        result_reg &lt;= 16'b0;\n        for(s = 0; s &lt; 8; s = s + 1)\n        begin\n            num_reg&#091;s] &lt;= 16'd0;\n        end\n    end\n    else\n    begin\n        \n    end\nend\n\ngenvar l;\ngenerate\n    for(l = 0; l &lt; 8; l = l + 1)\n    begin:nums\n        always@(posedge clk or posedge rst_n)\n        begin\n            if(rst_n)\n                num_reg&#091;l] &lt;= l + 1;\n        end\n    end\nendgenerate\nendmodule<\/code><\/pre>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; \u6700\u540e\u5728FPGA\u786c\u4ef6\u4e0a\u9a8c\u8bc1\u901a\u8fc7\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"295\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-22-1024x295.png\" alt=\"\" class=\"wp-image-3827\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-22-1024x295.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-22-300x86.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-22-768x221.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-22.png 1039w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><em>num_reg \u542b\u67098\u4e2a16\u4f4d\u5bc4\u5b58\u5668<\/em>\uff0c<em>result\u8f93\u51fa204\uff0c\u8868\u793a 1-8\u7684\u5e73\u65b9\u548c<\/em><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2><strong>\u8fdb\u9636\u7248\u672c1\uff1a\u65e0\u6d41\u6c34\u7ebf\u6709\u7b26\u53f7\u52a0\u6cd5\u6811\u7684\u5b9e\u73b0+\u53c2\u6570\u5316\u8f93\u5165\u4e2a\u6570\u548c\u6570\u636e\u4f4d\u5bbd<\/strong><\/h2>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u53c2\u6570\u5316\uff1a\u6c42lenght\u4e2a\u4f4d\u5bbd\u4e3adata_width\u7684\u6570\u7684\u548c\u3002  lenght   data_width \u53ef\u914d\u7f6e <\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u601d\u8def\uff1a\u5728 lenght &gt;1\u65f6\uff0c\u5c06 data_width \u4e2a\u6570\u5206\u4e3a\u4e24\u5757\uff0c\u6bcf\u5757\u5206\u522b\u9012\u5f52\u4f8b\u5316\u4e00\u4e2a\u540c\u6837\u7684\u5b50\u6a21\u5757\uff0c\u6a21\u5757\u7684\u8f93\u51fa\u4e3a\u4e24\u4e2a\u5b50\u6a21\u5757\u8f93\u51fa\u7684\u548c\uff1b\u5728 lenght ==1\u65f6\uff0c\u9012\u5f52\u7ec8\u6b62\uff0c\u6a21\u5757\u7684\u8f93\u51fa\u7b49\u4e8e\u8f93\u5165\u3002 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\nmodule AdderTree_v1(in_addends, out_sum);\n\nparameter data_width = 8;  \/\/\u8f93\u5165\u7684\u6570\u636e\u5bbd\u5ea6\nparameter lenght = 4; \/\/\u8f93\u5165\u7684\u6570\u636e\u4e2a\u6570\n\nlocalparam out_width = data_width + $clog2(lenght);\nlocalparam lenght_A = lenght \/ 2;\nlocalparam lenght_B = lenght - lenght_A;\nlocalparam out_width_A = data_width + $clog2(lenght_A);\nlocalparam out_width_B = data_width + $clog2(lenght_B);\n\ninput signed &#091;data_width*lenght-1:0] in_addends;\noutput signed &#091;out_width-1:0] out_sum;\n\ngenerate\n    \/\/\u7ec8\u6b62\u6761\u4ef6\n\tif (lenght == 1) begin\n\t\tassign out_sum = in_addends;\n\tend else begin\n\t\twire signed &#091;out_width_A-1:0] sum_a;\n\t\twire signed &#091;out_width_B-1:0] sum_b;\n\t\t\n\t\treg signed &#091;data_width*lenght_A-1:0] addends_a;\n\t\treg signed &#091;data_width*lenght_B-1:0] addends_b;\n\t\t\n\t\talways@(*) begin\n            addends_a = in_addends&#091;data_width*lenght_A-1:0];\n            addends_b = in_addends&#091;data_width*lenght-1:data_width*lenght_A];\n\t\tend\n\t\t\n\t\t\/\/divide set into two chunks, conquer\n\t\t\/\/\u6a21\u5757\u7684\u9012\u5f52\u8c03\u7528\n\t\tAdderTree_v1 #(\n\t\t\t.data_width(data_width),\n\t\t\t.lenght(lenght_A)\n\t\t) subtree_a (\n\t\t\t.in_addends(addends_a),\n\t\t\t.out_sum(sum_a)\n\t\t);\n\t\t\n\t\tAdderTree_v1 #(\n\t\t\t.data_width(data_width),\n\t\t\t.lenght(lenght_B)\n\t\t) subtree_b (\n\t\t\t.in_addends(addends_b),\n\t\t\t.out_sum(sum_b)\n\t\t);\n\t\t\n\t\tassign out_sum = sum_a + sum_b;\n\tend\nendgenerate\n\nendmodule<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"177\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-23-1024x177.png\" alt=\"\" class=\"wp-image-3855\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-23-1024x177.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-23-300x52.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-23-768x132.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-23.png 1166w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><em>in_addends[31:0] \u8f93\u5165 {-1,-2,-3,-4},\u8f93\u51fa\uff1a out_sum<\/em>  <\/p>\n\n\n\n<p><strong>\u7535\u8def\u56fe<\/strong>\uff1a\u5e76\u884c\u8ba1\u7b97\u9ad8\u4f4d\u4e24\u6570\u7684\u548c\u4e0e\u4f4e\u4f4d\u4e24\u6570\u7684\u548c\uff0c\u518d\u5c06\u6240\u5f97\u7ed3\u679c\u76f8\u52a0\uff0c\u6ca1\u6709\u4ea7\u751f\u591a\u4f59\u7684\u903b\u8f91\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/img-blog.csdnimg.cn\/20210621023342887.PNG?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2ppYW5nMTk2MDAzNDMwOA==,size_16,color_FFFFFF,t_70#pic_center\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\"\/><\/figure>\n\n\n\n<h2> <strong>\u8fdb\u9636\u7248\u672c2\uff1a\u57fa\u4e8e\u6d41\u6c34\u7ebf\u6709\u7b26\u53f7\u52a0\u6cd5\u6811\u7684\u5b9e\u73b0+\u53c2\u6570\u5316\u8f93\u5165\u4e2a\u6570\u548c\u6570\u636e\u4f4d\u5bbd<\/strong> <\/h2>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u4f7f\u7528\u6d41\u6c34\u7ebf\u52a0\u6cd5\u5668\u6811\uff1a\u5f53\u5f85\u6c42\u548c\u7684\u6570\u636e\u8f83\u591a\u65f6\uff0c\u5f80\u5f80\u9700\u8981\u5728\u52a0\u6cd5\u5668\u4e4b\u95f4\u63d2\u5165\u5bc4\u5b58\u5668\u5f62\u6210\u6d41\u6c34\u7ebf\u3002<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u601d\u8def\uff1a\u5c1d\u8bd5\u5c06\u7ec4\u5408\u903b\u8f91<\/p>\n\n\n\n<p>assign out_sum = sum_a + sum_b;<\/p>\n\n\n\n<p>\u4fee\u6539\u4e3a\u65f6\u5e8f\u903b\u8f91\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>always@(posedge clk)begin\n\tout_sum &lt;=  sum_a + sum_b;\nend\n<\/code><\/pre>\n\n\n\n<p class=\"has-light-pink-background-color has-background\"> \u51fa\u73b0\u7684\u95ee\u98981<\/p>\n\n\n\n<p>     \u4f46\u662f\u8fd9\u6837\u7f16\u8bd1\u5668\u4f1a\u62a5\u9519\uff0c\u56e0\u4e3a\u6211\u5728\u540c\u4e00\u4e2a\u6a21\u5757\u4e2d\u65e2\u628aout_sum\u5f53\u505awire\u7c7b\u578b\u6765\u7528\uff0c\u53c8\u628a\u5b83\u5f53\u505areg\u7c7b\u578b\u6765\u7528\u3002<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u89e3\u51b3\u529e\u6cd5 \uff1a\u5b9a\u4e49\u4e00\u4e2a reg\u7c7b\u578b out_sum_buf  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>reg signed &#091;OUT_WIDTH-1:0] out_sum_buf;\n\nassign out_sum = out_sum_buf;\n\nalways@(posedge clk)begin\n    out_sum_buf &lt;= sum_a + sum_b;\nend<\/code><\/pre>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u51fa\u73b0\u7684\u95ee\u98982<\/p>\n\n\n\n<p>\u5982\u679clenght\u662f2\u7684\u6574\u6570\u6b21\u5e42\uff0c\u8fd9\u6837\u5c31\u8db3\u591f\u4e86\u3002\u4f46\u662f\u5f53 lenght \u4e0d\u662f2\u7684\u6574\u6570\u6b21\u5e42\u65f6\uff0c\u5c31\u4f1a\u51fa\u73b0\u4e0b\u9762\u8fd9\u79cd\u60c5\u51b5\uff08 lenght ==3\uff09\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/img-blog.csdnimg.cn\/20210623011659966.PNG?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2ppYW5nMTk2MDAzNDMwOA==,size_16,color_FFFFFF,t_70#pic_center\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"251\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-25-1024x251.png\" alt=\"\" class=\"wp-image-3908\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-25-1024x251.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-25-300x74.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-25-768x188.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-25.png 1167w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>\u8f93\u51fa<\/figcaption><\/figure>\n\n\n\n<p>\u5f53lenght\u4e0d\u662f2\u7684\u6574\u6570\u6b21\u5e42\u65f6\uff0c\u6bcf\u6761\u8def\u5f84\u4e0a\u7684\u52a0\u6cd5\u5668\u6570\u76ee\u53ef\u80fd\u4f1a\u4e0d\u540c\u3002\u5728\u7eaf\u7ec4\u5408\u903b\u8f91\u4e2d\uff0c\u5b83\u4f1a\u5bfc\u81f4\u8f93\u51fa\u4ea7\u751f\u6bdb\u523a\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5728\u8f93\u51fa\u7aef\u52a0\u4e00\u7ea7\u5bc4\u5b58\u5668\u5c06\u5176\u53bb\u9664\u3002\u800c\u5728\u65f6\u5e8f\u903b\u8f91\u4e2d\uff0c\u5982\u679c\u6211\u4eec\u53ea\u662f\u7b80\u5355\u5730\u5728\u6bcf\u4e2a\u52a0\u6cd5\u5668\u540e\u9762\u63d2\u4e00\u4e2a\u5bc4\u5b58\u5668\uff0c\u4f1a\u76f4\u63a5\u5bfc\u81f4\u65f6\u5e8f\u9519\u4f4d\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0a\u56fe\u4e3a\u4f8b\uff0c\u8f93\u5165in_addends\u7684\u9ad816\u4f4d\uff08\u9ad8\u4f4d\u6570\uff09\u7ecf\u8fc7\u4e00\u7ea7\u5bc4\u5b58\u5668\u540e\u5230\u8fbe\u7b2c\u4e8c\u4e2a\u52a0\u6cd5\u5668\uff0c\u800c\u4f4e8\u4f4d\uff08\u4f4e\u4f4d\u6570\uff09\u76f4\u63a5\u5230\u8fbe\u7b2c\u4e8c\u4e2a\u52a0\u6cd5\u5668\uff0c\u4e8e\u662f\u8f93\u51fa\u53d8\u6210\u4e86<strong>\u8f93\u5165\u7684\u4f4e\u4f4d\u6570\u4e0e\u4e0a\u4e00\u5468\u671f\u7684\u9ad8\u4f4d\u6570<\/strong>\u7684\u548c\u3002<\/p>\n\n\n\n<p>\u6b63\u786e\u7684\u7535\u8def\u5e94\u5f53\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"308\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-24-1024x308.png\" alt=\"\" class=\"wp-image-3893\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-24-1024x308.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-24-300x90.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-24-768x231.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-24.png 1465w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u5728lenght\u7b49\u4e8e1\u65f6\uff0c\u540c\u6837\u9700\u8981\u5224\u65ad\u662f\u5426\u9700\u8981\u63d2\u5165\u5bc4\u5b58\u5668\u3002\u597d\u5728\u5224\u65ad\u7684\u903b\u8f91\u5e76\u4e0d\u590d\u6742\u3002\u8003\u8651\u5230\u5728\u9012\u5f52\u5f00\u59cb\u524d\u6211\u4eec\u5c31\u53ef\u4ee5\u786e\u5b9a\u6bcf\u6761\u8def\u5f84\u5e94\u5f53\u6709\u51e0\u7ea7\u5bc4\u5b58\u5668\uff0c\u5373log2\u200b( lenght)\uff0c\u53e6\u5916\uff0c\u5b50\u6a21\u5757\u7684\u5bc4\u5b58\u5668\u7ea7\u6570\u6bd4\u5b83\u7684\u4e0a\u4e00\u7ea7\u5c111\u3002\u6211\u4eec\u53ef\u4ee5\u589e\u52a0\u4e00\u4e2a\u53c2\u6570delay_stage\uff0c\u5728\u6700\u9ad8\u5c42\u5b83\u7684\u503c\u4e3a$clog2(lenght)\uff0c\u6bcf\u6b21\u4f8b\u5316\u5b50\u6a21\u5757\u65f6\u4f7f\u7528\u7684\u503c\u4e3a delay_stage -1\u3002\u8fd9\u6837\uff0c\u5728 lenght \u7b49\u4e8e1\u65f6\uff0c delay_stage \u7684\u6570\u503c\u5c31\u662f\u8be5\u6a21\u5757\u8fd8\u9700\u8981\u63d2\u5165\u7684\u5bc4\u5b58\u5668\u7ea7\u6570\u3002<br>\u63d2\u5165 delay_stage \u7ea7\u5bc4\u5b58\u5668\u53ef\u4ee5\u7528\u79fb\u4f4d\u5bc4\u5b58\u5668\u5b9e\u73b0\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if (LENGTH == 1) begin\n                \/\/ \u8be5\u5206\u652f\u662f \u65e0\u6cd5\u6574\u9664\u7684\u5206\u652f\n\t\tif (DELAY_STAGE &gt; 1) begin\n\t\t\treg &#091;DELAY_STAGE * DATA_WIDTH - 1 : 0]delay_fifo;\n\t\t\talways@(posedge clk) begin\n\t\t\t\tdelay_fifo &lt;= {delay_fifo&#091;(DELAY_STAGE-1)*DATA_WIDTH-1:0],in_addends};\n\t\t\tend\n\t\t\tassign\tout_sum = delay_fifo&#091;(DELAY_STAGE-1)*DATA_WIDTH-1:0];\n\t\tend\n\t\telse if (DELAY_STAGE == 1) begin\n\t\t\treg &#091;DATA_WIDTH - 1 : 0]delay_fifo;\n\t\t\talways@(posedge clk) begin\n\t\t\t\tdelay_fifo &lt;= in_addends;\n\t\t\tend\n\t\t\tassign\tout_sum = delay_fifo;\n\t\tend\n        else begin\n            assign\tout_sum = in_addends;\n\t\tend\n\tend <\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u989d\u5916\u52a0\u4e86\u4e2aDELAY_STAGE \u7b49\u4e8e1\u7684\u5206\u652f\uff0c\u662f\u56e0\u4e3aDELAY_STAGE \u7b49\u4e8e1\u65f6delay_fifo[(DELAY_STAGE-1)*DATA_WIDTH-1:0]\u53d8\u6210\u4e86delay_fifo[-1:0]\uff0c\u8fd9\u4e5f\u662f\u7f16\u8bd1\u5668\u4e0d\u5141\u8bb8\u7684\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>module AdderTreePipelined(in_addends, out_sum, clk);\n\nparameter DATA_WIDTH = 8;\nparameter LENGTH = 3;\nparameter DELAY_STAGE = $clog2(LENGTH);\n\nlocalparam OUT_WIDTH = DATA_WIDTH + $clog2(LENGTH);\nlocalparam LENGTH_A = LENGTH \/ 2;\nlocalparam LENGTH_B = LENGTH - LENGTH_A;\nlocalparam OUT_WIDTH_A = DATA_WIDTH + $clog2(LENGTH_A);\nlocalparam OUT_WIDTH_B = DATA_WIDTH + $clog2(LENGTH_B);\n\ninput       clk                        ;\ninput              &#091;DATA_WIDTH*LENGTH-1:0]\tin_addends                 ;\noutput      signed &#091;OUT_WIDTH-1:0]  \t\tout_sum                    ;\n\nreg signed&#091;OUT_WIDTH-1:0] out_sum_pip;\n\ngenerate\n    genvar i;\n\tif (LENGTH == 1) begin\n\t\tif (DELAY_STAGE &gt; 1) begin\n\t\t\treg &#091;DELAY_STAGE * DATA_WIDTH - 1 : 0]delay_fifo;\n\t\t\talways@(posedge clk) begin\n\t\t\t\tdelay_fifo &lt;= {delay_fifo&#091;(DELAY_STAGE-1)*DATA_WIDTH-1:0],in_addends};\n\t\t\tend\n\t\t\tassign\tout_sum = delay_fifo&#091;(DELAY_STAGE-1)*DATA_WIDTH-1:0];\n\t\tend\n\t\telse if (DELAY_STAGE == 1) begin\n\t\t\treg &#091;DATA_WIDTH - 1 : 0]delay_fifo;\n\t\t\talways@(posedge clk) begin\n\t\t\t\tdelay_fifo &lt;= in_addends;\n\t\t\tend\n\t\t\tassign\tout_sum = delay_fifo;\n\t\tend\n        else begin\n            assign\tout_sum = in_addends;\n\t\tend\n\tend \n    else begin\n\t\twire signed&#091;OUT_WIDTH_A-1:0] sum_a;\n\t\twire signed&#091;OUT_WIDTH_B-1:0] sum_b;\n\t\t\n\t\twire &#091;DATA_WIDTH * LENGTH_A - 1:0] addends_a;\n\t\twire &#091;DATA_WIDTH * LENGTH_B - 1:0] addends_b;\n\t\t\n\t\tassign addends_a = in_addends&#091;DATA_WIDTH * LENGTH_A - 1: 0];\n        assign addends_b = in_addends&#091;LENGTH * DATA_WIDTH - 1: DATA_WIDTH * LENGTH_A];\n\t\t\n\t\t\/\/divide set into two chunks, conquer\n\t\tAdderTreePipelined #(\n\t\t\t.DATA_WIDTH(DATA_WIDTH),\n\t\t\t.LENGTH(LENGTH_A),\n\t\t\t.DELAY_STAGE(DELAY_STAGE - 1)\n\t\t) subtree_a (\n\t\t\t.in_addends(addends_a),\n\t\t\t.out_sum(sum_a),\n            .clk(clk)\n\t\t);\n\t\t\n\t\tAdderTreePipelined #(\n\t\t\t.DATA_WIDTH(DATA_WIDTH),\n\t\t\t.LENGTH(LENGTH_B),\n\t\t\t.DELAY_STAGE(DELAY_STAGE - 1)\n\t\t) subtree_b (\n\t\t\t.in_addends(addends_b),\n\t\t\t.out_sum(sum_b),\n            .clk(clk)\n\t\t);\n        always@(posedge clk) begin\n            out_sum_pip &lt;= sum_a + sum_b;\n        end\n        assign\tout_sum = out_sum_pip;\n\tend\nendgenerate\n\nendmodule<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"280\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-27-1024x280.png\" alt=\"\" class=\"wp-image-3912\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-27-1024x280.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-27-300x82.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-27-768x210.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-27.png 1170w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption><br>in_addends = {-8&#8217;d1,-8&#8217;d2,-8&#8217;d3,-8&#8217;d4,-8&#8217;d5};<br><br>in_addends = {8&#8217;d1,8&#8217;d2,8&#8217;d3,8&#8217;d4,8&#8217;d5};<\/figcaption><\/figure>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>FPGA\u4e2dwire\u4e0ereg\u7c7b\u578b \u4e0e\u8f93\u5165\u8f93\u51fa &#8212;-\u7b14\u8bb0<\/h2>\n\n\n\n<p>\u6700\u8fd1\u5728\u5199FPGA\u6a21\u5757\u65f6\u5019\uff0c\u5bf9\u4e8e\u5355\u4e2a\u6a21\u5757\u7684\u903b\u8f91\u53ef\u4ee5 \u641e\u61c2\uff0c\u4f46\u5bf9\u4e8e\u591a\u4e2a\u6a21\u5757\u8fdb\u884c\u6570\u636e\u4ea4\u4e92\u7684\u65f6\u5019\uff0c\u603b\u4f1a\u51fa\u73b0\u83ab\u540d\u5176\u5999\u6570\u636e\u7c7b\u578b\u7684\u9519\u8bef\uff0c\u4e8e\u662f\u505a\u4e0b\u7b14\u8bb0\uff1a<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u5728\u8bbe\u8ba1\u4e2d\uff0c\u8f93\u5165\u4fe1\u53f7\u4e00\u822c\u6765\u8bf4\u4f60\u662f\u4e0d\u77e5\u9053\u4e0a\u4e00\u7ea7\u662f\u5bc4\u5b58\u5668\u8f93\u51fa\u8fd8\u662f\u7ec4\u5408\u903b\u8f91\u8f93\u51fa\uff0c\u90a3\u4e48\u5bf9\u4e8e\u672c\u7ea7\u6765\u8bf4\u5c31\u662f\u4e00\u6839\u5bfc\u7ebf\uff0c\u4e5f\u5c31\u662fwire\u578b\u3002\u800c\u8f93\u51fa\u4fe1\u53f7\u5219\u7531\u4f60\u81ea\u5df1\u6765\u51b3\u5b9a\u662f\u5bc4\u5b58\u5668\u8f93\u51fa\u8fd8\u662f\u7ec4\u5408\u903b\u8f91\u8f93\u51fa\uff0cwire\u578b\u3001reg\u578b\u90fd\u53ef\u4ee5\u3002\u4f46\u4e00\u822c\u7684\uff0c\u6574\u4e2a\u8bbe\u8ba1\u7684\u5916\u90e8\u8f93\u51fa\uff08\u5373\u6700\u9876\u5c42\u6a21\u5757\u7684\u8f93\u51fa\uff09\uff0c\u8981\u6c42\u662f\u5bc4\u5b58\u5668\u8f93\u51fa\uff0c\u8f83\u7a33\u5b9a\u3001\u6247\u51fa\u80fd\u529b\u4e5f\u8f83\u597d\u3002<\/p>\n\n\n\n<p class=\"has-bright-blue-background-color has-background\"><strong>\u8f93\u5165\u7aef\u53e3\u53ef\u4ee5\u7531wire\/reg\u9a71\u52a8\uff08\u8c03\u7528\u6a21\u5757\uff0c\u5411\u6a21\u5757\u4f20\u6570\u636e\u53ef\u4ee5\u4f20\u9012wire or reg\u7c7b\u578b\u6570\u636e\uff09\uff0c\u4f46\u8f93\u5165\u7aef\u53e3\u53ea\u80fd\u662fwire\uff08\u5373\u6a21\u5757\u4e2d\u5b9a\u4e49\u8f93\u5165 input wire x\uff09\uff1b\u8f93\u51fa\u7aef\u53e3\u53ef\u4ee5\u4f7fwire\/reg\u7c7b\u578b\uff0c\u8f93\u51fa\u7aef\u53e3\u53ea\u80fd\u9a71\u52a8wire\uff08\u8f93\u51fa\u7684\u6570\u636e\u53ea\u80fd\u8d4b\u7ed9wire\uff09\uff1b\u82e5\u8f93\u51fa\u7aef\u53e3\u5728\u8fc7\u7a0b\u5757\u4e2d\u8d4b\u503c\u5219\u4e3areg\u578b\uff0c\u82e5\u5728\u8fc7\u7a0b\u5757\u5916\u8d4b\u503c\u5219\u4e3anet\u578b\u3002\u7528\u5173\u952e\u8bcdinout\u58f0\u660e\u4e00\u4e2a\u53cc\u5411\u7aef\u53e3, inout\u7aef\u53e3\u4e0d\u80fd\u58f0\u660e\u4e3areg\u7c7b\u578b\uff0c\u53ea\u80fd\u662fwire\u7c7b\u578b\uff1b\u8f93\u5165\u548c\u53cc\u5411\u7aef\u53e3\u4e0d\u80fd\u58f0\u660e\u4e3a\u5bc4\u5b58\u5668\u7c7b\u578b\u3002<\/strong><\/p>\n\n\n\n<p>&nbsp;wire\u8868\u793a\u76f4\u901a\uff0c\u5373\u53ea\u8981\u8f93\u5165\u6709\u53d8\u5316\uff0c\u8f93\u51fa\u9a6c\u4e0a\u65e0\u6761\u4ef6\u5730\u53cd\u6620\uff1breg\u8868\u793a\u4e00\u5b9a\u8981\u6709\u89e6\u53d1\uff0c\u8f93\u51fa\u624d\u4f1a\u53cd\u6620\u8f93\u5165\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u4e0d\u6307\u5b9a\u5c31\u9ed8\u8ba4\u4e3a1\u4f4dwire\u7c7b\u578b\u3002\u4e13\u95e8\u6307\u5b9a\u51fawire\u7c7b\u578b\uff0c\u53ef\u80fd\u662f\u591a\u4f4d\u6216\u4e3a\u4f7f\u7a0b\u5e8f\u6613\u8bfb\u3002wire\u53ea\u80fd\u88abassign\u8fde\u7eed\u8d4b\u503c\uff0creg\u53ea\u80fd\u5728initial\u548calways\u4e2d\u8d4b\u503c\u3002wire\u4f7f\u7528\u5728\u8fde\u7eed\u8d4b\u503c\u8bed\u53e5\u4e2d\uff0c\u800creg\u4f7f\u7528\u5728\u8fc7\u7a0b\u8d4b\u503c\u8bed\u53e5\u4e2d\u3002<\/p>\n\n\n\n<p>1. \u4ece\u4eff\u771f\u7684\u89d2\u5ea6\u6765\u8bf4\uff0cHDL\u8bed\u8a00\u9762\u5bf9\u7684\u662f\u7f16\u8bd1\u5668\uff08\u5982Modelsim\u7b49\uff09\uff0c\u76f8\u5f53\u4e8e\u8f6f\u4ef6\u601d\u8def\u3002<br>\u8fd9\u65f6\uff1a<br>wire\u5bf9\u5e94\u4e8e\u8fde\u7eed\u8d4b\u503c\uff0c\u5982assign<br>reg\u5bf9\u5e94\u4e8e\u8fc7\u7a0b\u8d4b\u503c\uff0c\u5982always\uff0cinitial<\/p>\n\n\n\n<p>2. \u4ece\u7efc\u5408\u7684\u89d2\u5ea6\u6765\u8bf4\uff0cHDL\u8bed\u8a00\u9762\u5bf9\u7684\u662f\u7efc\u5408\u5668\uff08\u5982DC\u7b49\uff09\uff0c\u8981\u4ece\u7535\u8def\u7684\u89d2\u5ea6\u6765\u8003\u8651\u3002<br>\u8fd9\u65f6\uff1a<br>1\u3001wire\u578b\u7684\u53d8\u91cf\u7efc\u5408\u51fa\u6765\u4e00\u822c\u662f\u4e00\u6839\u5bfc\u7ebf\uff1b<br>2\u3001reg\u53d8\u91cf\u5728always\u5757\u4e2d\u6709\u4e24\u79cd\u60c5\u51b5\uff1a<br>(1)\u3001always\u540e\u7684\u654f\u611f\u8868\u4e2d\u662f\uff08a or b or c\uff09\u5f62\u5f0f\u7684\uff0c\u4e5f\u5c31\u662f\u4e0d\u5e26\u65f6\u949f\u8fb9\u6cbf\u7684\uff0c\u7efc\u5408\u51fa\u6765\u8fd8\u662f\u7ec4\u5408\u903b\u8f91<br>(2)\u3001always\u540e\u7684\u654f\u611f\u8868\u4e2d\u662f\uff08posedge clk\uff09\u5f62\u5f0f\u7684\uff0c\u4e5f\u5c31\u662f\u5e26\u8fb9\u6cbf\u7684\uff0c\u7efc\u5408\u51fa\u6765\u4e00\u822c\u662f\u65f6\u5e8f\u903b\u8f91\uff0c\u4f1a\u5305\u542b\u89e6\u53d1\u5668\uff08Flip\uff0dFlop\uff09<\/p>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>\u5b9a\u70b9\u6d6e\u70b9\u5de5\u5177<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np \nfrom scipy import signal\nimport subprocess\nimport os\nimport math\nimport skimage.measure\nfrom numpy.random import seed\n\n#Function to convert from the Fixed point precision that our hardware is using to the float values that python actually uses\ndef fp_to_float(s,integer_precision,fraction_precision):       #s = input binary string\n    number = 0.0\n    i = integer_precision - 1\n    j = 0\n    if(s&#091;0] == '1'):\n        s_complemented = twos_comp((s&#091;1:]),integer_precision,fraction_precision)\n    else:\n        s_complemented = s&#091;1:]\n    while(j != integer_precision + fraction_precision -1):\n        number += int(s_complemented&#091;j])*(2**i)\n        i -= 1\n        j += 1\n    if(s&#091;0] == '1'):\n        return (-1)*number\n    else:\n        return number\n\n#Function to convert between the actual float values and the fixed point values in the particular \n#precision that our hardware is using\ndef float_to_fp(num,integer_precision,fraction_precision):   \n    if(num&lt;0):\n        sign_bit = 1                            #sign bit is 1 for negative numbers in 2's complement                                                 #representation\n        num = -1*num\n    else:\n        sign_bit = 0\n    precision = '0'+ str(integer_precision) + 'b'\n    integral_part = format(int(num),precision)\n    fractional_part_f = num - int(num)\n    fractional_part = &#091;]\n    for i in range(fraction_precision):\n        d = fractional_part_f*2\n        fractional_part_f = d -int(d)        \n        fractional_part.append(int(d))\n    fraction_string = ''.join(str(e) for e in fractional_part)\n    if(sign_bit == 1):\n        binary = str(sign_bit) + twos_comp(integral_part + fraction_string,integer_precision,fraction_precision)\n    else:\n        binary = str(sign_bit) + integral_part+fraction_string\n    return str(binary)\n#Function to calculate 2's complement of a binary number\ndef twos_comp(val,integer_precision,fraction_precision):\n    flipped = ''.join(str(1-int(x))for x in val)\n    length = '0' + str(integer_precision+fraction_precision) + 'b'\n    bin_literal = format((int(flipped,2)+1),length)\n    return bin_literal<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"746\" height=\"266\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-28.png\" alt=\"\" class=\"wp-image-3938\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-28.png 746w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-28-300x107.png 300w\" sizes=\"(max-width: 746px) 100vw, 746px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"682\" height=\"274\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-29.png\" alt=\"\" class=\"wp-image-3939\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-29.png 682w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-29-300x121.png 300w\" sizes=\"(max-width: 682px) 100vw, 682px\" \/><\/figure>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>\u6a21\u5757\u4e32\u8054\u8bbe\u8ba1\uff1a<\/h2>\n\n\n\n<p><a href=\"https:\/\/thedatabus.io\/accelerator\">https:\/\/thedatabus.io\/accelerator<\/a><\/p>\n\n\n\n<h2>cov + relu + pool<\/h2>\n\n\n\n<p>\u8f6f\u4ef6\u6d4b\u8bd5\uff1a<\/p>\n\n\n\n<p>img\uff1a6*6<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"669\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-36-1024x669.png\" alt=\"\" class=\"wp-image-4267\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-36-1024x669.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-36-300x196.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-36-768x502.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-36.png 1155w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>\u8f6c\u6d6e\u70b9\u6570\uff1a16bit \uff1a1\u7b26\u53f7\u4f4d  7bit\u6574\u6570 8bit\u5c0f\u6570<\/strong><\/p>\n\n\n\n<p><strong>\u6743\u91cd\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"961\" height=\"329\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-37.png\" alt=\"\" class=\"wp-image-4270\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-37.png 961w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-37-300x103.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-37-768x263.png 768w\" sizes=\"(max-width: 961px) 100vw, 961px\" \/><\/figure>\n\n\n\n<p><strong>convolved output<\/strong>\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"861\" height=\"528\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-38.png\" alt=\"\" class=\"wp-image-4272\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-38.png 861w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-38-300x184.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-38-768x471.png 768w\" sizes=\"(max-width: 861px) 100vw, 861px\" \/><\/figure>\n\n\n\n<p>\u786c\u4ef6\u4eff\u771f\uff1a\uff081\uff0c7\uff0c8\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"202\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-40-1024x202.png\" alt=\"\" class=\"wp-image-4276\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-40-1024x202.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-40-300x59.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-40-768x151.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-40-1536x303.png 1536w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-40.png 1714w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u53ef\u4ee5\u53d1\u73b0\u8f6f\u4ef6\u548c vivado\u4e2derror\u8bef\u5dee\u5728 0.01\u91cf\u7ea7<\/p>\n\n\n\n<p>relu\u90e8\u5206\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"109\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-34-1024x109.png\" alt=\"\" class=\"wp-image-3959\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-34-1024x109.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-34-300x32.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-34-768x82.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/04\/image-34.png 1458w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>\u6c60\u5316\u90e8\u5206\uff1a \uff084*4\u77e9\u9635\uff09 2*2\u7684\u6c60\u5316<\/p>\n\n\n\n<p>bug\uff1a<\/p>\n\n\n\n<p>\u603b\u4f1a\u665a\u4e00\u4e2a\u65f6\u949f\u8ba1\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>+-----------+\n|00|01|02|03|\n+-----------+\n|04|05|06|07|\n+-----------+\n|08|09|10|11|\n+-----------+\n|12|13|14|15|\n+-----------+<\/code><\/pre>\n\n\n\n<p>\u987a\u5e8f\u8f93\u5165 0\uff0c1\uff0c2\uff0c3\uff0c4\uff0c5\uff0c6\uff0c&#8230;<\/p>\n\n\n\n<p>\u6b63\u786e\u7684\u5e94\u8be5\u662f\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1013\" height=\"233\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-42.png\" alt=\"\" class=\"wp-image-4284\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-42.png 1013w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-42-300x69.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-42-768x177.png 768w\" sizes=\"(max-width: 1013px) 100vw, 1013px\" \/><\/figure>\n\n\n\n<p>\u4f46\u5982\u679c\u5bf9\u9f50 ce\u548cclk\u4e0a\u5347\u6cbf\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1005\" height=\"230\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-41.png\" alt=\"\" class=\"wp-image-4283\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-41.png 1005w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-41-300x69.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-41-768x176.png 768w\" sizes=\"(max-width: 1005px) 100vw, 1005px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"237\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-43-1024x237.png\" alt=\"\" class=\"wp-image-4291\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-43-1024x237.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-43-300x69.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-43-768x177.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-43.png 1333w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"429\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-39-1024x429.png\" alt=\"\" class=\"wp-image-4273\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-39-1024x429.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-39-300x126.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-39-768x321.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-39-1536x643.png 1536w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-39.png 1541w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"182\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-63-1024x182.png\" alt=\"\" class=\"wp-image-4425\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-63-1024x182.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-63-300x53.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-63-768x136.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-63.png 1213w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"287\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-62-1024x287.png\" alt=\"\" class=\"wp-image-4424\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-62-1024x287.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-62-300x84.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-62-768x216.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-62.png 1475w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>\u6570\u636e\u52a0\u6cd5\u6ea2\u51fa\u5904\u7406<\/h2>\n\n\n\n<p>Verilog \u8865\u7801\u52a0\u6cd5\u6ea2\u51fa\u5224\u65ad\u53ca\u5904\u7406<\/p>\n\n\n\n<h3>\u4e00\u3001\u7b26\u53f7\u4f4d\u5224\u65ad<\/h3>\n\n\n\n<p>Xf\u3001Yf\u5206\u522b\u4e24\u4e2a\u6570\u7684\u7b26\u53f7\u4f4d,Zf\u4e3a\u8fd0\u7b97\u7ed3\u679c\u7b26\u53f7\u4f4d\u3002<\/p>\n\n\n\n<ul><li>\u5f53Xf =Yf =0\uff08\u4e24\u6570\u540c\u4e3a\u6b63\uff09,\u800cZf=1(\u7ed3\u679c\u4e3a\u8d1f)\u65f6,\u8d1f\u6ea2\u51fa\uff1b<\/li><li>\u5f53\u51fa\u73b0Xf =Yf =1\uff08\u4e24\u6570\u540c\u4e3a\u8d1f\uff09,\u800cZf=0\uff08\u7ed3\u679c\u4e3a\u6b63\uff09\uff0c\u6b63\u6ea2\u51fa\u3002<\/li><\/ul>\n\n\n\n<h3>\u4e8c\u3001\u8fdb\u4f4d\u5224\u65ad<\/h3>\n\n\n\n<p>Cs\u8868\u793a\u7b26\u53f7\u4f4d\u7684\u8fdb\u4f4d\uff0cCp\u8868\u793a\u6700\u9ad8\u6570\u503c\u4f4d\u8fdb\u4f4d\uff0c\u2295\u8868\u793a\u5f02\u6216\u3002<\/p>\n\n\n\n<ul><li>\u82e5 Cs\u2295Cp =0 \uff0c\u65e0\u6ea2\u51fa\uff1b<\/li><li>\u82e5 Cs\u2295Cp =1 \uff0c\u6709\u6ea2\u51fa\u3002<\/li><\/ul>\n\n\n\n<h3>\u4e09\u3001\u53d8\u5f62\u8865\u7801\u5224\u65ad<\/h3>\n\n\n\n<p>\u7528\u53d8\u5f62\u8865\u7801\u8fdb\u884c\u53cc\u7b26\u53f7\u4f4d\u8fd0\u7b97\uff08\u6b63\u6570\u7b26\u4e3a00,\u8d1f\u6570\u7b26\u53f7\u4ee511\uff09<\/p>\n\n\n\n<ul><li>\u82e5\u8fd0\u7b97\u7ed3\u679c\u7684\u7b26\u53f7\u4f4d\u4e3a&#8221;01&#8243;,\u5219\u6b63\u6ea2\u3002<\/li><li>\u82e5\u7ed3\u679c\u53cc\u7b26\u53f7\u4e3a10,\u5219\u8d1f\u6ea2\u51fa\u3002<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\u53d8\u5f62\u8865\u7801\u7684\u65b9\u6848\u4e3a\u4f8b\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a\n\nalways @ (* )\nbegin\n    case(dout&#091;DATA_WIDTH-1:DATA_WIDTH-2])\n    \t2'b01: dout &lt;= {1'b0,{(DATA_WIDTH-1){1'b1}}};       \/\/\u6b63\u6ea2\n    \t2'b10: dout &lt;= {1'b1,{(DATA_WIDTH-1){1'b0}}};     \/\/\u8d1f\u6ea2\n    \t2'b00,2'b11: dout &lt;= {dout&#091;DATA_WIDTH-1],dout&#091;DATA_WIDTH-3:0]};  \/\/\u65e0\u6ea2\u51fa\n    \tdefault: sum &lt;= {dout&#091;DATA_WIDTH-1],dout&#091;DATA_WIDTH-3:0]};\n    endcase\t      \nend<\/code><\/pre>\n\n\n\n<p><strong>\u5047\u8bbe\u60a8\u6709\u4e24\u4e2a 8 \u4f4d 2 \u7684\u8865\u7801\uff0ca[7:0] \u548c b[7:0]\u3002\u8fd9\u4e9b\u6570\u5b57\u76f8\u52a0\u4ea7\u751f s[7:0]\u3002\u8fd8\u8981\u8ba1\u7b97\u662f\u5426\u53d1\u751f\u4e86\uff08\u6709\u7b26\u53f7\u7684\uff09\u6ea2\u51fa\u3002<br>\u7ed9\u51fa\u8f93\u5165\u8f93\u51fa\u5982\u4e0b\uff1a(\u4e0d\u533a\u5206\u6b63\u8d1f\u6ea2\u51fa)<br>module top_module (<br>input [7:0] a,<br>input [7:0] b,<br>output [7:0] s,<br>output overflow<br>);<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Xf\u3001Yf\u5206\u522b\u4e24\u4e2a\u6570\u7684\u7b26\u53f7\u4f4d,Zf\u4e3a\u8fd0\u7b97\u7ed3\u679c\u7b26\u53f7\u4f4d\u3002\n\u5f53Xf =Yf =0\uff08\u4e24\u6570\u540c\u4e3a\u6b63\uff09,\u800cZf=1(\u7ed3\u679c\u4e3a\u8d1f)\u65f6,\u8d1f\u6ea2\u51fa\uff1b\n\u5f53\u51fa\u73b0Xf =Yf =1\uff08\u4e24\u6570\u540c\u4e3a\u8d1f\uff09,\u800cZf=0\uff08\u7ed3\u679c\u4e3a\u6b63\uff09\uff0c\u6b63\u6ea2\u51fa.\n\nmodule top_module (\n    input &#091;7:0] a,\n    input &#091;7:0] b,\n    output &#091;7:0] s,\n    output overflow\n); \n  \tassign s=a+b;\n    assign overflow=((~a&#091;7])&amp;(~b&#091;7])&amp;s&#091;7])|(a&#091;7]&amp;b&#091;7]&amp;(~s&#091;7]));\n            \nendmodule<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\uff3b\u65b9\u6cd5\u4e8c\uff3d\nCs\u8868\u793a\u7b26\u53f7\u4f4d\u7684\u8fdb\u4f4d\uff0cCp\u8868\u793a\u6700\u9ad8\u6570\u503c\u4f4d\u8fdb\u4f4d\uff0c\u2295\u8868\u793a\u5f02\u6216\u3002\n\u82e5 Cs\u2295Cp =0 \uff0c\u65e0\u6ea2\u51fa\uff1b\n\u82e5 Cs\u2295Cp =1 \uff0c\u6709\u6ea2\u51fa\u3002\n\nmodule top_module (\n    input &#091;7:0] a,\n    input &#091;7:0] b,\n    output &#091;7:0] s,\n    output overflow\n); \n    wire &#091;7:0] cout;\/\/\u6bcf\u4e00\u4f4d\u7684\u8fdb\u4f4d\n    integer i;\n    always @(*) begin\n        for(i=0;i&lt;8;i++) begin\n            if(i==0)\n            \t{cout&#091;i],s&#091;i]}=a&#091;i]+b&#091;i];\n            else\n            \t{cout&#091;i],s&#091;i]}=a&#091;i]+b&#091;i]+cout&#091;i-1];\/\/\u9700\u52a0\u4e0a\u524d\u4e00\u4f4d\u7684\u8fdb\u4f4d\n        end\n    end\n    assign overflow=(cout&#091;7]^cout&#091;6]==1)?1:0;\n            \nendmodule<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\uff3b\u65b9\u6cd5\u4e09\uff3d\n\u7528\u53d8\u5f62\u8865\u7801\u8fdb\u884c\u53cc\u7b26\u53f7\u4f4d\u8fd0\u7b97\uff08\u6b63\u6570\u7b26\u4e3a00,\u8d1f\u6570\u7b26\u53f7\u4ee511\uff09\n\u82e5\u8fd0\u7b97\u7ed3\u679c\u7684\u7b26\u53f7\u4f4d\u4e3a\"01\",\u5219\u6b63\u6ea2\uff1b\n\u82e5\u7ed3\u679c\u53cc\u7b26\u53f7\u4e3a10,\u5219\u8d1f\u6ea2\u51fa\uff1b\n\u82e5\u7ed3\u679c\u7684\u53cc\u7b26\u53f7\u4f4d\u4e3a00\u621611\uff0c\u65e0\u6ea2\u51fa\u3002\n\nmodule top_module (\n    input &#091;7:0] a,\n    input &#091;7:0] b,\n    output &#091;7:0] s,\n    output overflow\n); \n    wire &#091;8:0] a_2s;\n    wire &#091;8:0] b_2s;\n    wire &#091;8:0] s_2s;\n    assign a_2s={a&#091;7],a};\n    assign b_2s={b&#091;7],b};\n    assign s_2s=a_2s+b_2s;\n    assign s = s_2s&#091;7:0];\n    assign overflow = (s_2s&#091;8:7]==2'b01)?1:\n        (s_2s&#091;8:7]==2'b10)?1:0;\n\nendmodule<\/code><\/pre>\n\n\n\n<!--nextpage-->\n\n\n\n<h2 class=\"has-yellow-background-color has-background\">\u4f7f\u7528 python \u521b\u5efa\u8f6f\u4ef6\u4eff\u771f\u6d4b\u8bd5\u5e73\u53f0\uff1a<\/h2>\n\n\n\n<p>\u4e8c\u8fdb\u5236\u5728\u7ebf\u4e58\u6cd5\uff1a<strong><a href=\"https:\/\/www.osgeo.cn\/app\/s2841\">https:\/\/www.osgeo.cn\/app\/s2841<\/a><\/strong><\/p>\n\n\n\n<p>\u9a8c\u8bc1\u662f\u4e00\u4ef6\u75db\u82e6\u7684\u4e8b&#8230;&#8230;.<\/p>\n\n\n\n<p>\u6d4b\u8bd5\u8bbe\u8ba1\u7684 MAC\uff08\u4e58\u6cd5\u548c\u7d2f\u52a0\uff09\u5355\u5143\u3002<\/p>\n\n\n\n<p>       \u81ea\u52a8\u5316\u6d4b\u8bd5\u5e73\u53f0\u7684\u57fa\u672c\u601d\u60f3\u662f\u62e5\u6709\u4e00\u4e2a\u7ecf\u8fc7\u9a8c\u8bc1\u7684\u9ec4\u91d1\u6a21\u578b\uff0c\u5e76\u4e14\u59cb\u7ec8\u4e3a\u7ed9\u5b9a\u7684\u4e00\u7ec4\u8f93\u5165\u8f93\u51fa\u6b63\u786e\u7684\u503c\u3002\u867d\u7136\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u6784\u5efa\u9ec4\u91d1\u6a21\u578b\uff0c\u4f46\u6211\u6700\u559c\u6b22\u7684\u4e00\u76f4\u662f python\uff0c\u56e0\u4e3a\u5b83\u6613\u4e8e\u4f7f\u7528\uff0c\u5e76\u4e14\u4e3a\u6570\u5b66\u8ba1\u7b97\u9886\u57df\u7684\u4efb\u4f55\u4e8b\u7269\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u5e93\u96c6\u3002Python \u8ba9\u60a8\u7684\u751f\u6d3b\u66f4\u8f7b\u677e\uff0c\u5c24\u5176\u662f\u5f53\u60a8\u7684\u4efb\u52a1\u6d89\u53ca\u4e0e\u7b97\u6cd5\u76f8\u5173\u7684 DSP \u65f6\uff0c\u8fd9\u4e9b\u7b97\u6cd5\u5f88\u5bb9\u6613\u4f7f\u7528\u8f6f\u4ef6\u3002<\/p>\n\n\n\n<p>\u4e58\u6cd5\u548c\u7d2f\u52a0\u5355\u5143\u7684python\u6a21\u578b\uff1a<\/p>\n\n\n\n<p>\u4e0b\u9762\u4ee3\u7801\u5c06\u751f\u6210\u968f\u673a\u6d6e\u70b9\u6570\u636e\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u5176\u4f20\u9012\u7ed9\u6211\u4eec\u7684 Verilog \u6a21\u5757\uff0c\u5e76\u5c06\u5176\u7ed3\u679c\u4e0e\u6b64 python \u4ee3\u7801\u672c\u8eab\u7684\u7ed3\u679c\u8fdb\u884c\u6bd4\u8f83\u3002 truncate   \u5c06number\uff081.234545&#8230;\uff09\u622a\u53d6\u6307\u5b9a\u5c0f\u6570\u4f4dreturn 1.23 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np \nimport subprocess\nimport os\nimport math\n\n#Function to truncate (not round) any floating point number to two decimal places\ndef truncate(number, digits) -&gt; float:\n    stepper = 10.0 ** digits\n    return math.trunc(stepper * number) \/ stepper\n\nNoT = 10 # Number of tests to be run\n\nfor i in range(NoT):\n    #choosing the values of a,b,c randomly\n    a = np.random.uniform(-1,1,1)&#091;0]\n    b = np.random.uniform(-1,1,1)&#091;0]\n    c = np.random.uniform(-1,1,1)&#091;0]\n\t#performs the MAC (Multiply and Add) operation\n    p_golden = a*b + c\n    #truncating to two decimal places because the value generated by our hardware will never be the\n    #exact same owing to the precision loss due to fixed point representation. \n\tp_golden_trunc = truncate(p_golden,2)<\/code><\/pre>\n\n\n\n<p>\u5b9a\u70b9\u4e58\u6cd5\u5668\u548c\u5b9a\u70b9\u52a0\u6cd5\u5668\u7684\u6784\u5efa\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/file: qmult.v\n\/\/ (Q,N) = (12,16) =&gt; 1 sign-bit + 3 integer-bits + 12 fractional-bits = 16 total-bits\n\/\/                    |S|III|FFFFFFFFFFFF|\n\/\/ The same thing in A(I,F) format would be A(3,12)\nmodule qmult #(\n\t\/\/Parameterized values\n\tparameter N = 16,\n\tparameter Q = 12\n\t)\n\t(\n\t input                  clk,\n\t input                  rst,\n\t input\t\t\t&#091;N-1:0]\ta,\n\t input\t\t\t&#091;N-1:0]\tb,\n\t output         &#091;N-1:0] q_result,    \/\/output quantized to same number of bits as the input\n     output\t\t\toverflow             \/\/signal to indicate output greater than the range of our format\n\t );\n\t \n\t \/\/\tThe underlying assumption, here, is that both fixed-point values are of the same length (N,Q)\n\t \/\/\tBecause of this, the results will be of length N+N = 2N bits\n\t \/\/\tThis also simplifies the hand-back of results, as the binimal point \n\t \/\/\twill always be in the same location\n\t\n\twire &#091;2*N-1:0]\tf_result;\t\t\/\/\tMultiplication by 2 values of N bits requires a \n\t\t\t\t\t\t\t\t\t\/\/\tregister that is N+N = 2N deep\n\twire &#091;N-1:0]   multiplicand;\n\twire &#091;N-1:0]\tmultiplier;\n\twire &#091;N-1:0]    a_2cmp, b_2cmp;\n\twire &#091;N-2:0]    quantized_result,quantized_result_2cmp;\n\t\n\tassign a_2cmp = {~a&#091;N-1],~a&#091;N-2:0]+ 1'b1};  \/\/2's complement of a {(N-1){1'b1}} - \n\tassign b_2cmp = {~b&#091;N-1],~b&#091;N-2:0]+ 1'b1};  \/\/2's complement of b  {(N-1){1'b1}} - \n\t\n    assign multiplicand = (a&#091;N-1]) ? a_2cmp : a;              \n    assign multiplier   = (b&#091;N-1]) ? b_2cmp : b;\n    \/\/We remove the sign bit for multiplication\n    assign f_result = multiplicand&#091;N-2:0] * multiplier&#091;N-2:0];  \n    \/\/Sign bit of output would be XOR or input sign bits                                             \n    assign q_result&#091;N-1] = a&#091;N-1]^b&#091;N-1];             \n    \/\/Quantization of output to required number of bits                                               \n    assign quantized_result = f_result&#091;N-2+Q:Q];              \n    \/\/2's complement of quantized_result                                                             \n    assign quantized_result_2cmp = ~quantized_result&#091;N-2:0] + 1'b1;  \n     \/\/If the result is negative, we return a 2's complement representation of the output value\n    assign q_result&#091;N-2:0] = (a&#091;N-1]^b&#091;N-1]) ? quantized_result_2cmp : quantized_result; \n    \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \n    assign overflow = (f_result&#091;2*N-2:N-1+Q] &gt; 0) ? 1'b1 : 1'b0;\n\nendmodule<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/file: qadd.v\nmodule qadd #(\n\tparameter N = 16,\n\tparameter Q = 12\n\t)\n\t(\n    input &#091;N-1:0] a,\n    input &#091;N-1:0] b,\n    output &#091;N-1:0] c\n    );\n\n\/\/ (Q,N) = (12,16) =&gt; 1 sign-bit + 3 integer-bits + 12 fractional-bits = 16 total-bits\n\/\/                    |S|III|FFFFFFFFFFFF|\n\/\/ The same thing in A(I,F) format would be A(3,12)\n\n\/\/Since we supply every negative number in it's 2's complement form by default, all we \n\/\/need to do is add these two numbers together (note that to subtract a binary number \n\/\/is the same as to add its two's complement)\nassign c = a + b;\n\n\/\/If for whatever reason your system (the software\/testbench feeding this hadrware with \n\/\/inputs) does not supply negative numbers in their two's complement form,(some people \n\/\/prefer to keep the magnitude as it is and make the sign bit '1' to represent negatives)\n\/\/ then you should take a look at the fixed point arithmetic modules at opencores linked \n\/\/above this code.\n\nendmodule<\/code><\/pre>\n\n\n\n<p>\u4eff\u771f\u9519\u8bef\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a = 0000000111100001 = 0.11748478081607838\nb = 1111111111111110 = -0.0005302183628016488  \/\/\u5bf9\u4e8e\u63a5\u8fd1\u4e8e0\u7684\u6570\nc = 1111101101111001 = -0.283025178155329\np_golden = -0.28 \/\/\u8f6f\u4ef6\u4eff\u771f\np_practical = 7.71 \/\/\u786c\u4ef6\u5b9e\u73b0\nabs_diff = 7.43               <\/code><\/pre>\n\n\n\n<p>\u901a\u8fc7\u624b\u52a8\u4f20\u9012\u8fd9\u4e9b\u8f93\u5165\u6765\u5206\u6790\u6a21\u5757\u7684\u5185\u90e8\u4fe1\u53f7\u540e\uff0c\u6211\u80fd\u591f\u627e\u5230\u9519\u8bef\uff0c\u5b83\u662f\u7531<code>qmult<\/code>\u6a21\u5757\u4e2d\u7684\u4ee5\u4e0b\u884c\u5f15\u8d77\u7684\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>assign quantized_result = f_result&#091;N-2+Q:Q];<\/code><\/pre>\n\n\n\n<p>\u57fa\u672c\u4e0a\uff0c\u6211\u4eec\u5c06\u4e58\u6cd5\u5668\u7684\u8f93\u51fa\u622a\u65ad\u4e3a\u56fa\u5b9a\u4f4d\u6570\uff0c\u8fd9\u6837\u6bcf\u6b21\u4e58\u6cd5\u540e\u6570\u636e\u8def\u5f84\u5c31\u4e0d\u4f1a\u53d8\u5f97\u5f02\u5e38\u5927\u3002\u4f46\u662f\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u79cd\u622a\u65ad\u4f1a\u5bfc\u81f4\u975e\u5e38\u5c0f\u7684\u6570\u5b57\u7684\u4e22\u5931\uff0c\u5373\u5f53\u622a\u65ad\u8303\u56f4\u5185\u7684\u6240\u6709\u4f4d\u90fd\u4e3a\u96f6\u5e76\u4e14\u975e\u96f6\u4f4d\u4f4d\u4e8e\u8be5\u8303\u56f4\u4e4b\u540e\uff0c\u56e0\u6b64\u4e0d\u4f1a\u5728\u91cf\u5316\u7ed3\u679c\u4e2d\u6355\u83b7.<\/p>\n\n\n\n<ul><li>\u589e\u52a0\u7528\u4e8e\u8868\u793a\u6570\u5b57\u5c0f\u6570\u90e8\u5206\u7684\u4f4d\u6570\u3002\u4f46\u8fd9\u4f1a\u51cf\u5c11\u53ef\u7528\u4e8e\u8868\u793a\u6574\u6570\u90e8\u5206\u7684\u4f4d\u6570\uff0c\u4f7f\u6700\u5927\u6570\u5b57\u5c0f\u4e8e\u5f53\u524d\u503c 2\u3002<\/li><li>\u589e\u52a0\u7528\u4e8e\u8868\u793a\u5b9a\u70b9\u6570\u7684\u603b\u4f4d\u6570\uff08\u4f7f\u7528 32 \u800c\u4e0d\u662f 16\uff09\u3002\u4f8b\u5982\uff0c\u5f53\u6211\u5c06 N \u66f4\u6539\u4e3a 32 \u5e76\u5c06 Q \u66f4\u6539\u4e3a 26 \u65f6\uff0c\u4f1a\u89e3\u51b3\u8be5\u95ee\u9898<\/li><\/ul>\n\n\n\n<p class=\"has-light-pink-background-color has-background\"><strong>\u4e58\u6cd5\uff1a<\/strong><\/p>\n\n\n\n<p>N=16\uff0cQ=12(\u5c0f\u6570\u4f4d)\uff1a\u7cbe\u5ea60.01<\/p>\n\n\n\n<p>\u8f6f\u4ef6\u5b9e\u73b0\uff1a\u771f\u6b63\u7684\uff0816bit\uff09x*y =00000000001001100011111111110100<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"353\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-23-1024x353.png\" alt=\"\" class=\"wp-image-4180\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-23-1024x353.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-23-300x103.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-23-768x265.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-23.png 1221w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u786c\u4ef6\u5e94\u8be5\u7684\u7ed3\u679c\uff1a\u820d\u5f03\u4f4eQ=12\u4f4d\uff0c\u4fdd\u755916bit\uff0c\u4ece\u4f4e13\u4f4d\u5f00\u59cb\u3002&#8217;0000001001100011&#8242;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"121\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-24-1024x121.png\" alt=\"\" class=\"wp-image-4181\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-24-1024x121.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-24-300x35.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-24-768x91.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-24.png 1331w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p> N=16\uff0cQ=8(\u5c0f\u6570\u4f4d)\uff0c7bit\u6574\u6570   \u7edd\u5927\u90e8\u5206\u6570\u57280-8\u4e4b\u95f4\u3002<\/p>\n\n\n\n<p>\u7ed3\u679c14.92 vs 14.94 \u8bef\u5dee\u57280.01<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"353\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-25-1024x353.png\" alt=\"\" class=\"wp-image-4193\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-25-1024x353.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-25-300x103.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-25-768x265.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-25.png 1219w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"944\" height=\"174\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-26.png\" alt=\"\" class=\"wp-image-4195\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-26.png 944w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-26-300x55.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-26-768x142.png 768w\" sizes=\"(max-width: 944px) 100vw, 944px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"785\" height=\"151\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-27.png\" alt=\"\" class=\"wp-image-4196\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-27.png 785w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-27-300x58.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-27-768x148.png 768w\" sizes=\"(max-width: 785px) 100vw, 785px\" \/><\/figure>\n\n\n\n<p> <\/p>\n\n\n\n<p>N=16\uff0cQ=9(\u5c0f\u6570\u4f4d)\uff0c6bit\u6574\u6570   \u7edd\u5927\u90e8\u5206\u6570\u57280-8\u4e4b\u95f4\u3002 <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"638\" height=\"419\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-28.png\" alt=\"\" class=\"wp-image-4202\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-28.png 638w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-28-300x197.png 300w\" sizes=\"(max-width: 638px) 100vw, 638px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-29.png\" alt=\"\" class=\"wp-image-4203\" width=\"639\" height=\"489\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-29.png 720w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-29-300x230.png 300w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><\/figure>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u52a0\u6cd5\uff1ac = a+b<\/p>\n\n\n\n<p> N=16\uff0cQ=9(\u5c0f\u6570\u4f4d)\uff0c6bit\u6574\u6570   \u7edd\u5927\u90e8\u5206\u6570\u5728\u5377\u79ef\u8f93\u51fa\u503c\u57280-8\u4e4b\u95f4\uff0c\u4e5f\u5c31\u662f\u8bf4 \u4e5d\u4e2a\u6570\u76f8\u4e58\u6c42\u548c\u4e00\u822c\u4e0d\u4f1a\u8d85\u51fa8.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.99cankao.com\/digital-computation\/binaryarith.php\">https:\/\/www.99cankao.com\/digital-computation\/binaryarith.php<\/a><\/p>\n\n\n\n<p>\u8f6f\u4ef6\u4eff\u771f\u4e0elog\u8f93\u51fa\uff1a<\/p>\n\n\n\n<h2>python\u8f85\u52a9\u5de5\u5177\uff1a<\/h2>\n\n\n\n<p>\u76ee\u524d\u5b8c\u6210\uff1a<\/p>\n\n\n\n<p>1\u3001\u6821\u9a8cvivado\u4e2d\u8f93\u51fafile\u6587\u4ef6\u548c python\u6d4b\u8bd5\u7684\u7ed3\u679c\u662f\u5426\u6b63\u786e\u3001\u8bef\u5dee\u5927\u5c0f<\/p>\n\n\n\n<p>2\u3001\u5b8c\u6210\u5355\u4e2a\u5377\u79ef\u3001\u591a\u901a\u9053\u5377\u79ef\uff08\u88650\uff09\u7684\u8f93\u5165\u8f93\u51fapython\u6570\u636elog\u4fe1\u606f<\/p>\n\n\n\n<p>3\u3001\u5b8c\u6210\u6fc0\u6d3b\u3001\u6c60\u5316\u7684log<\/p>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>\u7b2cN\u5c42\u7684\u5b9e\u73b0\uff1a<\/h2>\n\n\n\n<p>\u8f93\u5165\u5c42\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" width=\"215\" height=\"204\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-31.png\" alt=\"\" class=\"wp-image-4222\"\/><\/figure><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"581\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-65-1024x581.png\" alt=\"\" class=\"wp-image-4435\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-65-1024x581.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-65-300x170.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-65-768x436.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-65-1536x871.png 1536w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-65.png 1564w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u7b2c\u4e8c\u5c42\u7684\u5b9e\u73b0\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" width=\"388\" height=\"221\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-44.png\" alt=\"\" class=\"wp-image-4295\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-44.png 388w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-44-300x171.png 300w\" sizes=\"(max-width: 388px) 100vw, 388px\" \/><\/figure><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"630\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-64-1024x630.png\" alt=\"\" class=\"wp-image-4434\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-64-1024x630.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-64-300x184.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-64-768x472.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-64-1536x944.png 1536w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-64.png 1584w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2>\u6570\u636e\u88650\u6a21\u5757\u5b9e\u73b0\uff1a<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"547\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-67-1024x547.png\" alt=\"\" class=\"wp-image-4439\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-67-1024x547.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-67-300x160.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-67-768x410.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-67.png 1500w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-68.png\" alt=\"\" class=\"wp-image-4448\" width=\"288\" height=\"296\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-68.png 480w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-68-292x300.png 292w\" sizes=\"(max-width: 288px) 100vw, 288px\" \/><\/figure><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"496\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-70-1024x496.png\" alt=\"\" class=\"wp-image-4451\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-70-1024x496.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-70-300x145.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-70-768x372.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-70.png 1499w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u8bbe\u7f6e \u8ba1\u6570\u5668 \uff1a  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>module pad_fifo(\nclk,ce,global_rst,pad_valid\n    );\nparameter pad = 1; \nparameter n = 9'h00a; \/\/\ninput clk,ce,global_rst;\noutput reg pad_valid;\nreg &#091;31:0] count;\n\nalways@(posedge clk)begin\n    if(global_rst)begin\n        pad_valid &lt;= 1'b0;\n        count&lt;=0;\n    end\n    else if(count &lt;= n+2*pad-1)begin\n        pad_valid &lt;= 1'b1;\n    end\n    else if((count+1)%(n+2*pad)==1 || (count+1)%(n+2*pad)==0)begin\n        pad_valid &lt;= 1'b1;\n    end\n    else if(count &gt;= (n+2*pad)*(n+2*pad)-1)begin\n        pad_valid &lt;= 1'b1;\n    end\n    else begin\n        pad_valid &lt;= 1'b0;\n    end\nend\nendmodule<\/code><\/pre>\n\n\n\n<p class=\"has-light-pink-background-color has-background\"> \u6570\u636e\u88650\uff1a\u5bf9\u4e8eyolo\u6765\u8bf4\uff0c\u8fd8\u6709\u4e00\u4e2a\u6c60\u5316\u5c42\uff0c\u9700\u8981\u5bf9\u6570\u636e\u8fdb\u884c\u53f3\u4e0b\u88650<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"861\" height=\"177\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-16.png\" alt=\"\" class=\"wp-image-4550\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-16.png 861w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-16-300x62.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-16-768x158.png 768w\" sizes=\"(max-width: 861px) 100vw, 861px\" \/><\/figure>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>yolo \u7684\u4e0a\u91c7\u6837\u5c42\u7684FPGA\u5b9e\u73b0<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/img-blog.csdnimg.cn\/20200415173027192.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2FsYW5nYWl4aWFveGlhbw==,size_16,color_FFFFFF,t_70\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"284\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-10-1024x284.png\" alt=\"\" class=\"wp-image-4517\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-10-1024x284.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-10-300x83.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-10-768x213.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-10.png 1080w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-light-pink-background-color has-background\"><strong>\u4e00\u79cd\u5b9e\u73b0\u601d\u8def\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"546\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-15-1024x546.png\" alt=\"\" class=\"wp-image-4540\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-15-1024x546.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-15-300x160.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-15-768x410.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-15-1536x819.png 1536w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-15-2048x1093.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>\u5377\u79ef\u7684\u5e76\u884c\u5ea6\u8003\u8651\uff1a<\/h2>\n\n\n\n<p>1\u3001\u4e0d\u540c\u8f93\u51fa\u901a\u9053\u4f7f\u7528\u4e32\u884c\u5b9e\u73b0<\/p>\n\n\n\n<p>2\u3001\u5728\u5355\u4e2a\u8f93\u51fa\u901a\u9053\u5b9e\u73b0\u65f6\u5185\u90e8\u4e5f\u6709\u53ef\u80fd\u9700\u8981\u4e32\u884c \u5b9e\u73b0 <\/p>\n\n\n\n<p>\u4ee5\u8f93\u516564\u901a\u9053\uff0c\u8f93\u51fa128\u901a\u9053\u4e3a\u4f8b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"874\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-12-1024x874.png\" alt=\"\" class=\"wp-image-4534\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-12-1024x874.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-12-300x256.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-12-768x656.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-12-1536x1312.png 1536w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-12.png 1671w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u53c2\u6570\u5316C=8\uff082\u7684\u500d\u6570\u5373\u53ef\uff09\uff0c\u6bcf\u6b21\u53ea\u80fdc\u4e2a\u5377\u79ef\u6838\u5e76\u884c\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"653\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-17-1024x653.png\" alt=\"\" class=\"wp-image-4560\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-17-1024x653.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-17-300x191.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-17-768x490.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-17.png 1517w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>yolo cat\u901a\u9053\u7ef4\u5ea6\u8fde\u63a5\uff1a<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"443\" height=\"227\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-11.png\" alt=\"\" class=\"wp-image-4523\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-11.png 443w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/image-11-300x154.png 300w\" sizes=\"(max-width: 443px) 100vw, 443px\" \/><\/figure>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u901a\u8fc7\u8bfb\u53d6\u4e0d\u540c\u7684fifo\u5b9e\u73b0 <\/p>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>yolo\u8f6f\u4ef6\u8bad\u7ec3\u6743\u91cdand\u9700\u4fee\u6539\u6a21\u578b\uff08\u8f6f\u4ef6\uff09<\/h2>\n\n\n\n<p>\u6211\u4eec\u786c\u4ef6\u4e2d\u5b9e\u73b0\u7684leakrelu\u662f0.125*x\uff0c\u9700\u8981\u5bf9\u8f6f\u4ef6\u6a21\u578b\u4e5f\u8fdb\u884c\u76f8\u5e94\u4fee\u6539\u3002<\/p>\n\n\n\n<p> yolo\u8f6f\u4ef6\u8bad\u7ec3\u6743\u91cd \u53c2\u8003\uff1a<a rel=\"noreferrer noopener\" href=\"http:\/\/139.9.1.231\/index.php\/2022\/03\/29\/yolov3-tiny\/\" target=\"_blank\">http:\/\/139.9.1.231\/index.php\/2022\/03\/29\/yolov3-tiny\/<\/a><\/p>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>\u95ee\u9898\uff1a<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"462\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/d61546f37c92f6d518b3edae274f975-1024x462.png\" alt=\"\" class=\"wp-image-4542\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/d61546f37c92f6d518b3edae274f975-1024x462.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/d61546f37c92f6d518b3edae274f975-300x135.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/d61546f37c92f6d518b3edae274f975-768x347.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/d61546f37c92f6d518b3edae274f975.png 1440w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>weight\u6743\u91cd \u7684\u83b7\u53d6\uff1a\u539f\u59cb\u662f\u4e00\u4e2a\u65f6\u949f\u5468\u671f\u90fd\u9001\u5165\u6240\u6709\u6743\u91cd\u3002\u5b9e\u9645\u5e94\u8be5\u4e5f\u53ef\u4ee5\u5206\u6279\u9001\u5165\uff1a<\/p>\n\n\n\n<p>\u4ee53*3\u5377\u79ef\u4e3a\u4f8b\uff0c\u53ef\u4ee5\u6bcf\u4e2a\u65f6\u949f\uff0c\u9001\u4e00\u4e2aactivate \u548c \u4e00\u4e2a\u6743\u91cd\uff0c\u5728\u4e5d\u4e2a\u65f6\u949f\u540e\uff0cwight\u5168\u90e8\u9001\u5165<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/thedatabus.io\/static\/convolver-c77524c06470fc0f38cc9cbeb59a6e5a.gif\" alt=\"\u5377\u79ef\u52a8\u753b\"\/><\/figure>\n\n\n\n<p>\u5f85\u505a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/e8c2062110397e2375e2614e9607634-1024x664.png\" alt=\"\" class=\"wp-image-4545\" width=\"690\" height=\"447\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/e8c2062110397e2375e2614e9607634-1024x664.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/e8c2062110397e2375e2614e9607634-300x195.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/e8c2062110397e2375e2614e9607634-768x498.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/e8c2062110397e2375e2614e9607634.png 1152w\" sizes=\"(max-width: 690px) 100vw, 690px\" \/><\/figure>\n\n\n\n<p>\u8fdb\u5ea6\uff08\u786c\u4ef6\uff09\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"523\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/2e4498ca593018546d35267cdc8ac68-1024x523.png\" alt=\"\" class=\"wp-image-4547\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/2e4498ca593018546d35267cdc8ac68-1024x523.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/2e4498ca593018546d35267cdc8ac68-300x153.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/2e4498ca593018546d35267cdc8ac68-768x392.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/06\/2e4498ca593018546d35267cdc8ac68.png 1395w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<!--nextpage-->\n\n\n\n<h2 class=\"has-text-align-center\">\u8f6f\u4ef6\u90e8\u5206&#8211;\u4ee5\u786c\u4ef6\u4e3a\u6307\u5bfc\u4e2d\u5fc3 <\/h2>\n\n\n\n<p>1\u3001\u8f6f\u4ef6\u6d4b\u8bd5\u7ed3\u679c\uff1a<\/p>\n\n\n\n<p>Nvidia 2070 Ti \u5355\u5f20\u56fe\u7247\u9884\u6d4b\u65f6\u95f4 \u57280.02-0.025 S \u4e4b\u95f4<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"658\" height=\"60\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-302.png\" alt=\"\" class=\"wp-image-6217\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-302.png 658w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-302-300x27.png 300w\" sizes=\"(max-width: 658px) 100vw, 658px\" \/><\/figure>\n\n\n\n<p>\u6d4b\u8bd5\u7ed3\u679c\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"500\" height=\"375\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/19.jpg\" alt=\"\" class=\"wp-image-6211\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/19.jpg 500w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/19-300x225.jpg 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"500\" height=\"375\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/64.jpg\" alt=\"\" class=\"wp-image-6212\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/64.jpg 500w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/64-300x225.jpg 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"500\" height=\"375\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/28.jpg\" alt=\"\" class=\"wp-image-6213\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/28.jpg 500w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/28-300x225.jpg 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"500\" height=\"375\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/81.jpg\" alt=\"\" class=\"wp-image-6214\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/81.jpg 500w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/81-300x225.jpg 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"500\" height=\"375\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/36.jpg\" alt=\"\" class=\"wp-image-6215\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/36.jpg 500w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/36-300x225.jpg 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"500\" height=\"375\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/52.jpg\" alt=\"\" class=\"wp-image-6216\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/52.jpg 500w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/52-300x225.jpg 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"500\" height=\"321\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/132.jpg\" alt=\"\" class=\"wp-image-6218\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/132.jpg 500w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/132-300x193.jpg 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"648\" height=\"915\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-303.png\" alt=\"\" class=\"wp-image-6219\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-303.png 648w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-303-212x300.png 212w\" sizes=\"(max-width: 648px) 100vw, 648px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"774\" height=\"620\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-304.png\" alt=\"\" class=\"wp-image-6220\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-304.png 774w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-304-300x240.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-304-768x615.png 768w\" sizes=\"(max-width: 774px) 100vw, 774px\" \/><\/figure>\n\n\n\n<p>BN_conv\u878d\u548c\uff1a<\/p>\n\n\n\n<p>YOLOv3_tiny_quantize_bnfuse(<br>(a_tracker_in): AveragedRangeTracker()<br>(conv1): Conv2d_fuse(<br>(convs): Sequential(<br>(0): Conv2d(3, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>(1): LeakyReLU(negative_slope=0.125, inplace=True)<br>)<br>)<br>(a_tracker1): AveragedRangeTracker()<br>(pool1): MaxPool2d(kernel_size=(2, 2), stride=2, padding=0, dilation=1, ceil_mode=False)<br>(conv2): Conv2d_fuse(<br>(convs): Sequential(<br>(0): Conv2d(16, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>(1): LeakyReLU(negative_slope=0.125, inplace=True)<br>)<br>)<br>(a_tracker2): AveragedRangeTracker()<br>(pool2): MaxPool2d(kernel_size=(2, 2), stride=2, padding=0, dilation=1, ceil_mode=False)<br>(conv3): Conv2d_fuse(<br>(convs): Sequential(<br>(0): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>(1): LeakyReLU(negative_slope=0.125, inplace=True)<br>)<br>)<br>(a_tracker3): AveragedRangeTracker()<br>(pool3): MaxPool2d(kernel_size=(2, 2), stride=2, padding=0, dilation=1, ceil_mode=False)<br>(conv4): Conv2d_fuse(<br>(convs): Sequential(<br>(0): Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>(1): LeakyReLU(negative_slope=0.125, inplace=True)<br>)<br>)<br>(a_tracker4): AveragedRangeTracker()<br>(pool4): MaxPool2d(kernel_size=(2, 2), stride=2, padding=0, dilation=1, ceil_mode=False)<br>(conv5): Conv2d_fuse(<br>(convs): Sequential(<br>(0): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>(1): LeakyReLU(negative_slope=0.125, inplace=True)<br>)<br>)<br>(a_tracker5): AveragedRangeTracker()<br>(pool5): MaxPool2d(kernel_size=(2, 2), stride=2, padding=0, dilation=1, ceil_mode=False)<br>(conv6): Conv2d_fuse(<br>(convs): Sequential(<br>(0): Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>(1): LeakyReLU(negative_slope=0.125, inplace=True)<br>)<br>)<br>(a_tracker6): AveragedRangeTracker()<br>(pool6): Sequential(<br>(0): ZeroPad2d(padding=(0, 1, 0, 1), value=0.0)<br>(1): MaxPool2d(kernel_size=(2, 2), stride=1, padding=0, dilation=1, ceil_mode=False)<br>)<br>(conv7): Conv2d_fuse(<br>(convs): Sequential(<br>(0): Conv2d(512, 1024, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>(1): LeakyReLU(negative_slope=0.125, inplace=True)<br>)<br>)<br>(a_tracker7): AveragedRangeTracker()<br>(conv_set_2): Conv2d_fuse(<br>(convs): Sequential(<br>(0): Conv2d(1024, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>(1): LeakyReLU(negative_slope=0.125, inplace=True)<br>)<br>)<br>(a_tracker8): AveragedRangeTracker()<br>(conv_1x1_2): Conv2d_fuse(<br>(convs): Sequential(<br>(0): Conv2d(256, 128, kernel_size=(1, 1), stride=(1, 1))<br>(1): LeakyReLU(negative_slope=0.125, inplace=True)<br>)<br>)<br>(a_tracker9): AveragedRangeTracker()<br>(extra_conv_2): Conv2d_fuse(<br>(convs): Sequential(<br>(0): Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>(1): LeakyReLU(negative_slope=0.125, inplace=True)<br>)<br>)<br>(a_tracker11): AveragedRangeTracker()<br>(pred_2): Conv2d(512, 75, kernel_size=(1, 1), stride=(1, 1))<br>(a_tracker12): AveragedRangeTracker()<br>(conv_set_1): Conv2d_fuse(<br>(convs): Sequential(<br>(0): Conv2d(384, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>(1): LeakyReLU(negative_slope=0.125, inplace=True)<br>)<br>)<br>(a_tracker10): AveragedRangeTracker()<br>(pred_1): Conv2d(256, 75, kernel_size=(1, 1), stride=(1, 1))<br>(a_tracker13): AveragedRangeTracker()<br>)<\/p>\n\n\n\n<p>\u8f93\u5165\u7684\u6570\u636e\u9884\u5904\u7406\uff1a<\/p>\n\n\n\n<p> \u5f52\u4e00\u5316\uff080-1\u4e4b\u95f4\uff09\u3001resize\u5230416*416<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"795\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-305-1024x795.png\" alt=\"\" class=\"wp-image-6223\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-305-1024x795.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-305-300x233.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-305-768x596.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-305.png 1245w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u6570\u636e\u5206\u5e03\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-306.png\" alt=\"\" class=\"wp-image-6227\" width=\"457\" height=\"292\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-306.png 698w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-306-300x193.png 300w\" sizes=\"(max-width: 457px) 100vw, 457px\" \/><\/figure><\/div>\n\n\n\n<p>\u539f\u59cb\u6743\u91cd\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"247\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-307-1024x247.png\" alt=\"\" class=\"wp-image-6230\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-307-1024x247.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-307-300x73.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-307-768x186.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-307.png 1142w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>BN\u878d\u5408+\u5fae\u8c03+\u91cf\u5316\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"225\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-308-1024x225.png\" alt=\"\" class=\"wp-image-6232\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-308-1024x225.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-308-300x66.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-308-768x169.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-308.png 1269w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u6743\u91cd\u5206\u5e03\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-309.png\" alt=\"\" class=\"wp-image-6234\" width=\"445\" height=\"318\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-309.png 668w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-309-300x215.png 300w\" sizes=\"(max-width: 445px) 100vw, 445px\" \/><figcaption>conv1<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-314.png\" alt=\"\" class=\"wp-image-6249\" width=\"408\" height=\"291\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-314.png 676w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-314-300x214.png 300w\" sizes=\"(max-width: 408px) 100vw, 408px\" \/><figcaption> conv1 <\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-315.png\" alt=\"\" class=\"wp-image-6251\" width=\"336\" height=\"233\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-315.png 688w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-315-300x208.png 300w\" sizes=\"(max-width: 336px) 100vw, 336px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-316.png\" alt=\"\" class=\"wp-image-6253\" width=\"381\" height=\"282\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-316.png 646w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-316-300x222.png 300w\" sizes=\"(max-width: 381px) 100vw, 381px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-317.png\" alt=\"\" class=\"wp-image-6254\" width=\"432\" height=\"299\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-317.png 687w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-317-300x207.png 300w\" sizes=\"(max-width: 432px) 100vw, 432px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-318.png\" alt=\"\" class=\"wp-image-6255\" width=\"405\" height=\"276\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-318.png 702w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-318-300x205.png 300w\" sizes=\"(max-width: 405px) 100vw, 405px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-319.png\" alt=\"\" class=\"wp-image-6256\" width=\"382\" height=\"260\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-319.png 697w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-319-300x204.png 300w\" sizes=\"(max-width: 382px) 100vw, 382px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-320.png\" alt=\"\" class=\"wp-image-6257\" width=\"349\" height=\"253\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-320.png 656w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-320-300x218.png 300w\" sizes=\"(max-width: 349px) 100vw, 349px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-321.png\" alt=\"\" class=\"wp-image-6258\" width=\"420\" height=\"285\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-321.png 707w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-321-300x204.png 300w\" sizes=\"(max-width: 420px) 100vw, 420px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-322.png\" alt=\"\" class=\"wp-image-6259\" width=\"466\" height=\"329\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-322.png 668w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-322-300x212.png 300w\" sizes=\"(max-width: 466px) 100vw, 466px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-323.png\" alt=\"\" class=\"wp-image-6260\" width=\"489\" height=\"321\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-323.png 714w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-323-300x197.png 300w\" sizes=\"(max-width: 489px) 100vw, 489px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-325.png\" alt=\"\" class=\"wp-image-6262\" width=\"453\" height=\"320\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-325.png 672w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-325-300x212.png 300w\" sizes=\"(max-width: 453px) 100vw, 453px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-326.png\" alt=\"\" class=\"wp-image-6263\" width=\"420\" height=\"300\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-326.png 671w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-326-300x214.png 300w\" sizes=\"(max-width: 420px) 100vw, 420px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-327.png\" alt=\"\" class=\"wp-image-6264\" width=\"409\" height=\"289\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-327.png 671w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-327-300x212.png 300w\" sizes=\"(max-width: 409px) 100vw, 409px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-328.png\" alt=\"\" class=\"wp-image-6265\" width=\"402\" height=\"275\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-328.png 699w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-328-300x206.png 300w\" sizes=\"(max-width: 402px) 100vw, 402px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-329.png\" alt=\"\" class=\"wp-image-6266\" width=\"440\" height=\"309\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-329.png 681w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-329-300x211.png 300w\" sizes=\"(max-width: 440px) 100vw, 440px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-330.png\" alt=\"\" class=\"wp-image-6268\" width=\"456\" height=\"304\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-330.png 710w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-330-300x201.png 300w\" sizes=\"(max-width: 456px) 100vw, 456px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-331.png\" alt=\"\" class=\"wp-image-6269\" width=\"416\" height=\"291\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-331.png 681w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-331-300x210.png 300w\" sizes=\"(max-width: 416px) 100vw, 416px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-334.png\" alt=\"\" class=\"wp-image-6273\" width=\"344\" height=\"222\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-334.png 741w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-334-300x193.png 300w\" sizes=\"(max-width: 344px) 100vw, 344px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-333.png\" alt=\"\" class=\"wp-image-6272\" width=\"413\" height=\"280\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-333.png 691w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-333-300x203.png 300w\" sizes=\"(max-width: 413px) 100vw, 413px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-335.png\" alt=\"\" class=\"wp-image-6274\" width=\"404\" height=\"280\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-335.png 698w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-335-300x208.png 300w\" sizes=\"(max-width: 404px) 100vw, 404px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-336.png\" alt=\"\" class=\"wp-image-6275\" width=\"354\" height=\"257\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-336.png 658w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-336-300x218.png 300w\" sizes=\"(max-width: 354px) 100vw, 354px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-337.png\" alt=\"\" class=\"wp-image-6276\" width=\"446\" height=\"303\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-337.png 703w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-337-300x204.png 300w\" sizes=\"(max-width: 446px) 100vw, 446px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-338.png\" alt=\"\" class=\"wp-image-6277\" width=\"382\" height=\"269\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-338.png 674w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-338-300x211.png 300w\" sizes=\"(max-width: 382px) 100vw, 382px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-339.png\" alt=\"\" class=\"wp-image-6278\" width=\"426\" height=\"273\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-339.png 729w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-339-300x193.png 300w\" sizes=\"(max-width: 426px) 100vw, 426px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-340.png\" alt=\"\" class=\"wp-image-6279\" width=\"359\" height=\"246\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-340.png 692w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-340-300x206.png 300w\" sizes=\"(max-width: 359px) 100vw, 359px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-341.png\" alt=\"\" class=\"wp-image-6280\" width=\"394\" height=\"287\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-341.png 651w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-341-300x219.png 300w\" sizes=\"(max-width: 394px) 100vw, 394px\" \/><\/figure><\/div>\n\n\n\n<p>\u8f93\u5165\u5404\u5c42\u7684\u5206\u5e03\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"823\" height=\"1024\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-310-823x1024.png\" alt=\"\" class=\"wp-image-6237\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-310-823x1024.png 823w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-310-241x300.png 241w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-310-768x956.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-310.png 908w\" sizes=\"(max-width: 823px) 100vw, 823px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"925\" height=\"688\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-311.png\" alt=\"\" class=\"wp-image-6238\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-311.png 925w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-311-300x223.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-311-768x571.png 768w\" sizes=\"(max-width: 925px) 100vw, 925px\" \/><\/figure>\n\n\n\n<p>\u6d4b\u8bd5\u4e86100\u5f20\u56fe\u7247\uff1a\u6700\u5927\u7684\u8f93\u51fa19\uff0c\u6700\u5c0f\u7684\u8f93\u51fa-16<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"708\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-312-1024x708.png\" alt=\"\" class=\"wp-image-6243\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-312-1024x708.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-312-300x208.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-312-768x531.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-312.png 1051w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u6839\u636e\u786c\u4ef6\u4e4b\u524d\u7684\u6d4b\u8bd5\u7ed3\u679c\u53cd\u5e94\uff1a<\/p>\n\n\n\n<p>\u4ee5\u524d\u7684\u6d4b\u8bd5\u8bf4\u660e\u5728\u8f93\u5165-1&#8211;+1\u7684\u6570\u636e\u8303\u56f4\u5185\uff0c\u6743\u91cd-1\u5230+1\u4e4b\u95f4\uff0c16bit\uff087+8\uff09\u60c5\u51b5\u4e0b\u7684error\u4e3a0.01\u91cf\u7ea7\uff0c\u56e0\u6b64\u6211\u4eec\u4f7f\u7528\u4ee5\u4e0b\u51fd\u6570\u6a21\u62df\u6bcf\u5c42\u7684\u6270\u52a8\uff1a<\/p>\n\n\n\n<p># \u751f\u6210 -+0.05\u4e4b\u95f4\u7684\u968f\u673a\u6570&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/p>\n\n\n\n<p> pred_2 = pred_2 + 5*torch.rand(pred_2.shape).to(self.device)\/100 <\/p>\n\n\n\n<p>\u6211\u4eec\u6bcf\u5c42\u7684\u8f93\u51fa\u5927\u6982\u5728-10+10\u8303\u56f4\u5185\uff0c\u6743\u91cd\u518d+1-1\u4e4b\u95f4\uff0c\u56e0\u6b64\u4e0a\u8ff0\u5047\u8bbe\u662f\u53ef\u884c\u7684\u3002&nbsp;&nbsp;<\/p>\n\n\n\n<p>\u6700\u7ec8\u751f\u6210\u7684\u7ed3\u679c\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"883\" height=\"657\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-342.png\" alt=\"\" class=\"wp-image-6290\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-342.png 883w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-342-300x223.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-342-768x571.png 768w\" sizes=\"(max-width: 883px) 100vw, 883px\" \/><figcaption><strong>\u6dfb\u52a0\u6270\u52a8<\/strong><\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"891\" height=\"677\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-343.png\" alt=\"\" class=\"wp-image-6292\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-343.png 891w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-343-300x228.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-343-768x584.png 768w\" sizes=\"(max-width: 891px) 100vw, 891px\" \/><figcaption>\u539f\u672c\u7ed3\u679c<\/figcaption><\/figure>\n\n\n\n<p>\u770b\u4e00\u4e0blog\u65e5\u5fd7\u8f93\u51fa\uff1a<\/p>\n\n\n\n<p>\u672a\u52a0\u6270\u52a8\u8f93\u51fa\uff1a\u6700\u7ec8\u7684\u7d2f\u8ba1\u6270\u52a8\u57280.1\u8303\u56f4\u5185<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"193\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-346-1024x193.png\" alt=\"\" class=\"wp-image-6299\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-346-1024x193.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-346-300x57.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-346-768x145.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-346.png 1096w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u6dfb\u52a0\u6270\u52a8\uff08\u6bcf\u4e00\u5c42\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"207\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-345-1024x207.png\" alt=\"\" class=\"wp-image-6297\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-345-1024x207.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-345-300x61.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-345-768x155.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-345.png 1099w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"896\" height=\"633\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-347.png\" alt=\"\" class=\"wp-image-6302\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-347.png 896w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-347-300x212.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-347-768x543.png 768w\" sizes=\"(max-width: 896px) 100vw, 896px\" \/><figcaption>\u539f\u59cb\u7ed3\u679c<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"883\" height=\"585\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-348.png\" alt=\"\" class=\"wp-image-6303\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-348.png 883w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-348-300x199.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-348-768x509.png 768w\" sizes=\"(max-width: 883px) 100vw, 883px\" \/><figcaption>\u6dfb\u52a0\u6270\u52a8<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"904\" height=\"543\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-349.png\" alt=\"\" class=\"wp-image-6305\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-349.png 904w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-349-300x180.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-349-768x461.png 768w\" sizes=\"(max-width: 904px) 100vw, 904px\" \/><figcaption>\u539f\u59cb<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"845\" height=\"540\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-350.png\" alt=\"\" class=\"wp-image-6306\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-350.png 845w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-350-300x192.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-350-768x491.png 768w\" sizes=\"(max-width: 845px) 100vw, 845px\" \/><figcaption>\u6270\u52a8<\/figcaption><\/figure>\n\n\n\n<p>\u518d\u56de\u5230\u4e0a\u6b21\u7ec4\u4f1a\u8bf4\u7684\uff0c\u4e3a\u4e86\u9a8c\u8bc1 FPGA\u7684\u5177\u4f53\u8ba1\u7b97\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u7684\u95ee\u9898\uff0c\u6211\u4eec\u9700\u8981\u5b8c\u5168\u6a21\u62df\u786c\u4ef6\u7684\u5377\u79ef\u7b97\u6cd5\uff1a\u5373<\/p>\n\n\n\n<p>1\u3001\u9700\u8981\u5c06\u6bcf\u5c42\u7684\u8f93\u5165\u8f93\u51fa\u6570\u636e\u8fdb\u884c16bit\u91cf\u5316<\/p>\n\n\n\n<p>2\u3001\u9700\u8981\u5bf9\u7f51\u7edc\u6743\u91cd\u91cd\u65b016bit\u91cf\u5316\uff0c\u5e76\u5199\u5165<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u8fdb\u884c\u4fee\u6539\uff1a<\/p>\n\n\n\n<p>1\u3001\u5bf9\u8f93\u5165\u6570\u636e\u8fdb\u884c\u4fee\u6539\uff1a<\/p>\n\n\n\n<p>step1\uff1a\u5bf9\u8f93\u5165\u56fe\u7247\u8fdb\u884cresize\u3001\u6807\u51c6\u5316\u3001\u8f6ctensor\u7b49\u5904\u7406<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"373\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-353-1024x373.png\" alt=\"\" class=\"wp-image-6325\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-353-1024x373.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-353-300x109.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-353-768x280.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-353.png 1236w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>step2\uff1a\u5bf9\u6570\u636e\u8fdb\u884c\u8f6c\u5316\u91cf\u5316<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"578\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-352-1024x578.png\" alt=\"\" class=\"wp-image-6324\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-352-1024x578.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-352-300x169.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-352-768x433.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-352-1536x866.png 1536w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-352.png 1562w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u8f6c\u5316 \u7ed3\u679c\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1019\" height=\"136\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-354.png\" alt=\"\" class=\"wp-image-6327\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-354.png 1019w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-354-300x40.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-354-768x103.png 768w\" sizes=\"(max-width: 1019px) 100vw, 1019px\" \/><figcaption>\u8f93\u5165<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"134\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-355-1024x134.png\" alt=\"\" class=\"wp-image-6328\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-355-1024x134.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-355-300x39.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-355-768x101.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-355.png 1077w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>\u91cf\u5316\u540e<\/figcaption><\/figure>\n\n\n\n<p>2\u3001\u5bf9\u6743\u91cd\u8fdb\u884c\u4fee\u6539<\/p>\n\n\n\n<p>\u6240\u6709\u7684\u6743\u91cd\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"649\" height=\"1024\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-351-649x1024.png\" alt=\"\" class=\"wp-image-6316\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-351-649x1024.png 649w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-351-190x300.png 190w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-351.png 672w\" sizes=\"(max-width: 649px) 100vw, 649px\" \/><\/figure>\n\n\n\n<p>\u8fd9\u91cc\u5bf9\u6743\u91cd\u8c03\u6574\uff0c\u5e76\u4e14\u8981\u91cd\u65b0\u4fdd\u5b58\u6a21\u578b\uff0c\u6ce8\u610f\u56e0\u4e3a\u4e4b\u524d\u7edf\u8ba1\u8fc7\u5404\u5c42\u7684\u6743\u91cd\u5206\u5e03\uff0c\u6240\u4ee5\u8f6c\u6362\u7684\u65f6\u5019\u4e0d\u4f1a\u51fa\u73b0\u6570\u636e\u7684\u6ea2\u51fa<\/p>\n\n\n\n<p>\u5177\u4f53\u6765\u8bf4\uff0c\u5c31\u662f\u5148\u63d0\u53d6 pth\u7684\u90a3\u4e2a\u6743\u91cd\u503c\uff0c\u7136\u540e \u4f7f\u7528\u51fd\u6570\u8f6c\u6362\u4e3a16bit\u6240\u8868\u793a\u7684\u6570\uff0c\u518d\u91cd\u65b0\u5199\u5165\uff08\u6ce8\u610f\u5199\u5165\u987a\u5e8f\uff09<\/p>\n\n\n\n<p>\u5c31\u662f\u5c06\u4e0b\u9762\u7684\u53c2\u6570data\uff0c\u901a\u8fc7quant_data\u8fdb\u884c\u6570\u636e\u91cf\u5316\uff0c\u6700\u540esave<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"787\" height=\"903\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-356.png\" alt=\"\" class=\"wp-image-6337\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-356.png 787w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-356-261x300.png 261w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-356-768x881.png 768w\" sizes=\"(max-width: 787px) 100vw, 787px\" \/><\/figure>\n\n\n\n<p>16bit\u91cf\u5316\u7ed3\u679c\uff1a\uff088bit\u5c0f\u6570\u60c5\u51b5\uff1a\u6700\u5927\u8bef\u5dee0.003\u91cf\u7ea7\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"298\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-360-1024x298.png\" alt=\"\" class=\"wp-image-6346\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-360-1024x298.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-360-300x87.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-360-768x223.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-360.png 1354w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"736\" height=\"130\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-357.png\" alt=\"\" class=\"wp-image-6338\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-357.png 736w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-357-300x53.png 300w\" sizes=\"(max-width: 736px) 100vw, 736px\" \/><figcaption>\u539f\u59cb<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"739\" height=\"118\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-359.png\" alt=\"\" class=\"wp-image-6341\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-359.png 739w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-359-300x48.png 300w\" sizes=\"(max-width: 739px) 100vw, 739px\" \/><figcaption>16bit\u91cf\u5316<\/figcaption><\/figure>\n\n\n\n<p>\u63a5\u4e0b\u6765\u4e3a\u4e86\u9a8c\u8bc1\u6211\u4eec\u91cf\u5316\u7684\u6b63\u786e\u6027\uff1a<\/p>\n\n\n\n<p>\u7edf\u8ba1\u6bcf\u4e00\u5c42\u7684error\u8bef\u5dee\u8303\u56f4<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"380\" height=\"1024\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-361-380x1024.png\" alt=\"\" class=\"wp-image-6353\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-361-380x1024.png 380w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-361-111x300.png 111w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-361.png 423w\" sizes=\"(max-width: 380px) 100vw, 380px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"564\" height=\"797\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-362.png\" alt=\"\" class=\"wp-image-6356\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-362.png 564w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-362-212x300.png 212w\" sizes=\"(max-width: 564px) 100vw, 564px\" \/><\/figure>\n\n\n\n<p>\u6700\u7ec8\uff0c\u5c06\u6570\u636e\u548c\u6743\u91cd\u91cf\u5316\u5b8c\u6210\u548c\u539f\u59cb\u8fdb\u884c\u7ed3\u679c\u6bd4\u8f83\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"918\" height=\"603\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-363.png\" alt=\"\" class=\"wp-image-6365\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-363.png 918w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-363-300x197.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-363-768x504.png 768w\" sizes=\"(max-width: 918px) 100vw, 918px\" \/><figcaption>\u539f\u59cb<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"897\" height=\"546\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-364.png\" alt=\"\" class=\"wp-image-6366\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-364.png 897w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-364-300x183.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-364-768x467.png 768w\" sizes=\"(max-width: 897px) 100vw, 897px\" \/><figcaption>\u91cf\u5316<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"885\" height=\"646\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-366.png\" alt=\"\" class=\"wp-image-6369\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-366.png 885w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-366-300x219.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-366-768x561.png 768w\" sizes=\"(max-width: 885px) 100vw, 885px\" \/><figcaption>\u539f\u59cb<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"892\" height=\"593\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-365.png\" alt=\"\" class=\"wp-image-6367\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-365.png 892w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-365-300x199.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-365-768x511.png 768w\" sizes=\"(max-width: 892px) 100vw, 892px\" \/><figcaption>\u91cf\u5316<\/figcaption><\/figure>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u63a5\u4e0b\u6765\u6765\u5230\u6700\u6838\u5fc3\u7684\uff1a\u6a21\u62dffpga\u4e2d\u7684\u4e58\u6cd5\uff0c\u4e4b\u524d\u6211\u4e48\u4eec\u65e0\u8bba\u662f\u81ea\u5df1\u5199\u7684python\u8f85\u52a9\u51fd\u6570 or torch\u63d0\u4f9b\u7684\u5377\u79ef\uff0c\u90fd\u662f\u4f7f\u7528\u73b0\u6709\u7684api\uff0c\u5c0f\u6570\u4e58\u6cd5\u3002\u56e0\u6b64\u9700\u8981\u91cd\u5199conv\u5377\u79ef\u51fd\u6570\uff0c\uff08\u5173\u952e\u662f\u5176\u4e2d\u7684\u4e58\u6cd5\u90e8\u5206\uff09<\/p>\n\n\n\n<p>1\u3001\u9996\u5148\u4fee\u6539\u4e58\u6cd5<\/p>\n\n\n\n<p>\u8f93\u5165 0011011101<\/p>\n\n\n\n<p>0011110111000011 * 0011110111000011 = 32bit<\/p>\n\n\n\n<p>\u5220\u53bb\u524d8bit +\u6700\u540e8bit<\/p>\n\n\n\n<p>\u5b9e\u73b0\u5f88\u9ebb\u70e6\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"728\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-367-1024x728.png\" alt=\"\" class=\"wp-image-6380\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-367-1024x728.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-367-300x213.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-367-768x546.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-367.png 1283w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u9a8c\u8bc1\uff1a1.1234*1.1234<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"292\" height=\"85\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-368.png\" alt=\"\" class=\"wp-image-6383\"\/><\/figure>\n\n\n\n<p>\u8f6f\u4ef6\u6a21\u62dffpga\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"628\" height=\"194\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-370.png\" alt=\"\" class=\"wp-image-6388\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-370.png 628w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-370-300x93.png 300w\" sizes=\"(max-width: 628px) 100vw, 628px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"283\" height=\"74\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-372.png\" alt=\"\" class=\"wp-image-6391\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"539\" height=\"150\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-373.png\" alt=\"\" class=\"wp-image-6393\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-373.png 539w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-373-300x83.png 300w\" sizes=\"(max-width: 539px) 100vw, 539px\" \/><\/figure>\n\n\n\n<p>\u57fa\u7840\u7684\u4e58\u6cd5\u5668\u5df2\u7ecf\u5b8c\u6210\u4e86\uff0c\u4e0b\u4e00\u6b65\u5c31\u662f\u8981\u66ff\u6362\u6389\u5377\u79ef\u4e2d\u7684\u4e58\u6cd5\u8fd0\u7b97\uff0c\u56e0\u4e3a\u4e4b\u524d\u4f7f\u7528\u7684conv\u51fd\u6570\u662f\u5e93\u81ea\u5e26\u7684api\uff0c\u65e0\u6cd5\u5bf9\u5176\u8fdb\u884c\u4fee\u6539\uff0c\u56e0\u6b64\u9700\u8981\u624b\u5199\u4e00\u4e2aconv2d\u7684\u5377\u79ef\u51fd\u6570\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"759\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-374-1024x759.png\" alt=\"\" class=\"wp-image-6396\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-374-1024x759.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-374-300x222.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-374-768x570.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-374.png 1312w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"533\" height=\"284\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-375.png\" alt=\"\" class=\"wp-image-6397\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-375.png 533w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-375-300x160.png 300w\" sizes=\"(max-width: 533px) 100vw, 533px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-376.png\" alt=\"\" class=\"wp-image-6398\" width=\"526\" height=\"287\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-376.png 556w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/08\/image-376-300x163.png 300w\" sizes=\"(max-width: 526px) 100vw, 526px\" \/><\/figure>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>\u6570\u636e\u5904\u7406\uff1a\u4e3aDDR\u5199\u5165\u63d0\u4f9b\u6570\u636e<\/h2>\n\n\n\n<p>\u76ee\u524d\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5c06\u4e8c\u8fdb\u523610101bit\u5199\u5165txt\u3001\u4ee5\u53cabin\u6587\u4ef6\u4e2d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5b9e\u73b0\u529f\u80fd\uff1a\u5c06\u8f93\u5165 s = &#091;\"0111101\",\"0111011\"] \u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6570\u7ec4\u5199\u5165filepath\uff08bin\u6587\u4ef6\uff09\uff0c\u5e76\u4ecebin\u6587\u4ef6\u8bfb\u53d6\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\n    r_w\uff1a\u8bfb\u5199\u6a21\u5f0f r\u8bfb\uff0cw\u5199\n    s\uff1a\u8f93\u5165\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6570\u7ec4 \n    bite=2:\u5f53r_w=\"r\"\u662f\uff0c\u6bcf\u6b21\u4ecebin\u6587\u4ef6\u4e2d\u8bfb\u53d62\u4e2aBite\uff0816bbit\uff09\u4f5c\u4e3a\u4e2a\u6570\u636e\n    filepath\uff1abin\u6587\u4ef6<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>def stringbit_bin(filepath,s=None,r_w=\"r\",bite=2 ):\n    \"\"\"\n    \u51fd\u6570\u8bf4\u660e\uff1a\n    \u5b9e\u73b0\u529f\u80fd\uff1a\u5c06\u8f93\u5165 s = &#091;\"0111101\",\"0111011\"] \u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6570\u7ec4\u5199\u5165filepath\uff08bin\u6587\u4ef6\uff09\uff0c\u5e76\u4ecebin\u6587\u4ef6\u8bfb\u53d6\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\n    r_w\uff1a\u8bfb\u5199\u6a21\u5f0f r\u8bfb\uff0cw\u5199\n    s\uff1a\u8f93\u5165\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6570\u7ec4 \n    bite=2:\u5f53r_w=\"r\"\u662f\uff0c\u6bcf\u6b21\u4ecebin\u6587\u4ef6\u4e2d\u8bfb\u53d62\u4e2aBite\uff0816bbit\uff09\u4f5c\u4e3a\u4e2a\u6570\u636e\n    filepath\uff1abin\u6587\u4ef6\n    \"\"\"\n    if r_w ==\"r\":\n        # \u4e3a\u4e86\u80fd\u591f\u4ece\u6587\u4ef6\u4e2d\u5f97\u5230\u5b8c\u5168\u4e00\u81f4\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0c\u9700\u4fdd\u7559\u539f\u59cb\u957f\u5ea6l\n        # \u4ece\u6587\u4ef6\u4e2d\u8fd8\u539f\n        size = os.path.getsize(filepath) #\u83b7\u5f97\u6587\u4ef6\u5927\u5c0f\n        with open(filepath, \"rb\") as f:\n            for i in range(size):\n                data = f.read(2) #\u6bcf\u6b21\u8f93\u51fa2\u4e2a\u5b57\u8282\n                binstr = \"\".join(&#091;\"{:08b}\".format(c) for c in data])\n                binstr = binstr&#091;:l] # \u6b64\u65f6\u7684binstr\u4e3a\u539f\u6765\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\n                print(binstr)\n    elif r_w == \"w\":\n        # \u9700\u4fdd\u5b58\u7684\u5b57\u7b26\u4e32 s\n        assert s != None\n        ls = len(s)\n        for s_item in s:\n        # \u9996\u5148\u9700\u8981\u4fdd\u5b58\u539f\u5b57\u7b26\u4e32\u957f\u5ea6\n            l = len(s_item)\n        # \u9996\u5148\u5c06s\u53d8\u6210\u76848\u7684\u6574\u6570\u500d\u957f\u7684\u5b57\u7b26\u4e32 \u53ef\u4ee5\u76f4\u63a5\u5728\u540e\u9762\u586b0\n            if 0 != l % 8:\n                r = l % 8\n                s_item += \"0\"*(8-r)\n            # \u5c06s\u8f6c\u6210bytes\n            b = bytes(&#091;int(s_item&#091;i:i+8], 2) for i in range(0, len(s_item), 8)])\n                # bytes \u53ef\u4ee5\u76f4\u63a5\u5199\u5165\u4ee5\u4e8c\u8fdb\u5236\u6a21\u5f0f\u6253\u5f00\u7684\u6587\u4ef6\n            # \u4f8b\u5982\n            with open(filepath, \"ab+\") as f:\n                f.write(b)\n    else:\n        pass<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" width=\"209\" height=\"51\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/09\/image-10.png\" alt=\"\" class=\"wp-image-7063\"\/><\/figure><\/div>\n\n\n\n<!--nextpage-->\n\n\n\n<h2>\u66f4\u65b0 :\u6a21\u578b\u7684\u88c1\u526a\u91cf\u5316\uff08\u65b0\u9700\u6c42\uff09<\/h2>\n\n\n\n<p><strong>why\uff1f\u6700\u8fd1\u53d1\u73b0\u5c3d\u7ba1yolov3-tiny\u7f51\u7edc\u5df2\u7ecf\u8db3\u591f\u5c0f\u4e86\uff0c\u4f46\u5b9e\u9645\u4e0a\u5bf9\u4e8e\u6211\u4eec\u65b0niao\u6765\u8bf4\u628a\u8fd9\u4e2a\u7f51\u7edc\u653e\u5230vu3p\u7684\u677f\u5b50\u4e0a\u5b9e\u73b0\u7684\u96be\u5ea6\u8fd8\u662f\u6709\u70b9\u5927\u3002<\/strong><\/p>\n\n\n\n<p>1\u3001\u7f51\u7edc\u5927\u4e3b\u8981\u5305\u62ec\u4e24\u4e2a\u65b9\u9762\uff1ainput\u56fe\u7247\u5927\u5c0f\uff08416*416*3\uff09\u548c\u7f51\u7edc\u7684weight\u53c2\u6570\u6570\u91cf\uff088.7M\u4e2a\uff09<\/p>\n\n\n\n<p>2\u3001\u5728\u4e00\u4e2a\u6211\u4eec\u5728\u786c\u4ef6\u4f7f\u752816bit\u7684\u4e8c\u8fdb\u5236\u6570\u8868\u793a\u4e00\u4e2a\u6570\u636e\uff0c\u8fd9\u65e0\u7591\u4f1a\u589e\u5927\u6570\u636e\u7684\u4f53\u91cf<\/p>\n\n\n\n<p>\u600e\u4e48\u88c1\u526a\uff1f\uff08\u5c3d\u91cf\u4e0d\u4f1a\u5bfc\u81f4\u786c\u4ef6\u540c\u5b66\u5927\u6539\u52a8\u5df2\u505a\u597d\u7684\u6a21\u5757\uff08\u5c31\u662f\u8bf4\u8fd8\u662f\u4f7f\u7528\u4f20\u7edf\u5377\u79ef\u6c60\u5316\u6fc0\u6d3b\uff09\uff09<\/p>\n\n\n\n<p>\u53c2\u8003\uff1ahttps:\/\/github.com\/coldlarry\/YOLOv3-complete-pruning<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"866\" height=\"281\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image.png\" alt=\"\" class=\"wp-image-9881\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image.png 866w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-300x97.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-768x249.png 768w\" sizes=\"(max-width: 866px) 100vw, 866px\" \/><\/figure>\n\n\n\n<p>\u9274\u4e8e\u76ee\u524d\u786c\u4ef6\u5927\u90e8\u5206\u5df2\u7ecf\u8bbe\u8ba1\u6709\u4e86\u96cf\u5f62\uff0c\u5927\u7684\u66f4\u6539\u4e0d\u592a\u73b0\u5b9e\uff0c\u6bd4\u5982\u7a00\u758f\u5316\u526a\u679d \u3002<\/p>\n\n\n\n<p>\u5c1d\u8bd5\uff1a\u5c06512 -1024\u7684\u5377\u79ef\u4ee5\u53ca\u65c1\u8fb9\u7684\u5377\u79ef\u5c42\u901a\u9053\u6570\u76f4\u63a5\u51cf\u534a\uff1a<\/p>\n\n\n\n<p class=\"has-bright-blue-background-color has-background\"><strong>\u6700\u540e\u4e00\u5c42\u7684\u8f93\u51fa\u901a\u9053\u657075\u901a\u9053<\/strong><\/p>\n\n\n\n<p>\u7ed3\u679c\uff1a<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">AP\u7565\u964d\u3001\u53c2\u6570\u91cf\uff1a\u51cf\u5c113.5M\u4e2a(\u6548\u679c\u8fd8\u51d1\u5408)<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-1.png\" alt=\"\" class=\"wp-image-9886\" width=\"492\" height=\"306\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-1.png 645w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-1-300x187.png 300w\" sizes=\"(max-width: 492px) 100vw, 492px\" \/><\/figure><\/div>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u63a5\u4e0b\u6765\u5c1d\u8bd5\uff1a<\/p>\n\n\n\n<p>1\u3001\u628a\u5377\u79ef\u5c42  &#8212;&gt; 1*1conv + 3*3 dconv<\/p>\n\n\n\n<p>resize: \u5bf9<strong>\u8f93\u5165\u5927\u5c0f 416  &#8211;&gt;  320(\u6548\u679c\u4e0b\u964d\u5f88\u5389\u5bb3)<\/strong> <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" width=\"614\" height=\"529\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-18.png\" alt=\"\" class=\"wp-image-9956\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-18.png 614w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-18-300x258.png 300w\" sizes=\"(max-width: 614px) 100vw, 614px\" \/><figcaption>resize:320*320<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"has-bright-blue-background-color has-background\">2<strong>\u3001\u5728 \u5c1d\u8bd5\uff1a\u5c06512 -1024\u7684\u5377\u79ef\u4ee5\u53ca\u65c1\u8fb9\u7684\u5377\u79ef\u5c42\u901a\u9053\u6570\u76f4\u63a5\u51cf\u534a<\/strong>,\u4e4b\u540e\u5bf9<strong>\u8f93\u5165\u5927\u5c0f 416  &#8211;&gt;  384<\/strong>\uff08<strong>\u6b63\u5728\u505a\uff0c\u8bbe\u7f6e\u4e3a384\u7684\u8bdd\u6700\u540e\u6700\u5c0f\u7684\u7279\u5f81\u56fe\u662f12*12\u8fd9\u6837\u65b9\u4fbf\u786c\u4ef6\u5b9e\u73b0<\/strong>\uff09 <strong>AP\uff1a0.47&#8212;&gt;0.43<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" width=\"612\" height=\"126\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-97.png\" alt=\"\" class=\"wp-image-10445\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-97.png 612w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-97-300x62.png 300w\" sizes=\"(max-width: 612px) 100vw, 612px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-20.png\" alt=\"\" class=\"wp-image-9967\" width=\"281\" height=\"427\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-20.png 330w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-20-197x300.png 197w\" sizes=\"(max-width: 281px) 100vw, 281px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-21.png\" alt=\"\" class=\"wp-image-9969\" width=\"-27\" height=\"-30\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-21.png 459w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-21-271x300.png 271w\" sizes=\"(max-width: 459px) 100vw, 459px\" \/><figcaption>bn+conv\u878d\u5408\u540e<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\uff1a\u76f4\u63a5\u4fee\u6539\u4f1a\u5bfc\u81f4\u6548\u679c \u4e0b\u964d\u5f88\u5389\u5bb3\uff1a\u901a\u8fc7\u4e0d\u65ad\u5730\u8c03\u53c2\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-98.png\" alt=\"\" class=\"wp-image-10462\" width=\"278\" height=\"514\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-98.png 512w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-98-162x300.png 162w\" sizes=\"(max-width: 278px) 100vw, 278px\" \/><figcaption>yolotiny_small<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-99.png\" alt=\"\" class=\"wp-image-10468\" width=\"367\" height=\"245\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-99.png 583w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-99-300x200.png 300w\" sizes=\"(max-width: 367px) 100vw, 367px\" \/><figcaption>conf_thresh:0.0001,nms_thresh=0.50<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" width=\"426\" height=\"505\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-100.png\" alt=\"\" class=\"wp-image-10470\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-100.png 426w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-100-253x300.png 253w\" sizes=\"(max-width: 426px) 100vw, 426px\" \/><figcaption>bn\u878d\u5408\u540e<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u4e0b\u4e00\u6b65\uff1a\u5fae\u8c03\uff08\u5fae\u8c03\u5b8c \u5b9e\u9645\u4e0a\u5c31\u53ef\u4ee5\u6570\u636e\u5206\u6790\u3001\u63d0\u53d6\u53c2\u6570\u3001\u91cf\u5316\u52307bit+8bit\u3001\u5199\u5165bin\u6587\u4ef6\uff0c\u7136\u540e\u63d0\u4f9b\u7ed9\u786c\u4ef6\u540c\u5b66\u4e86\uff09<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-68.png\" alt=\"\" class=\"wp-image-10209\" width=\"385\" height=\"355\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-68.png 880w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-68-300x277.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-68-768x710.png 768w\" sizes=\"(max-width: 385px) 100vw, 385px\" \/><figcaption>\u539f\u6765<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u8fd9\u91cc\u56e0\u4e3abn\u878d\u5408\u540e\u7684ap\u57fa\u672c\u6ca1\u6709\u6539\u53d8\uff0c\u6240\u4ee5\u7528\u5728\u8fdb\u884c\u91cf\u5316\u4e86\u3002<\/p>\n\n\n\n<p>\u5fae\u8c03\u5b8c\uff1a\u8fdb\u884c\u91cf\u5316\uff08\u4e0d\u518d\u4f7f\u7528\u6700\u5f00\u59cb\u7684\u91cf\u5316\u65b9\u6cd5\uff0c\u635f\u5931\u6709\u70b9\u5927\uff09<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-69-1024x667.png\" alt=\"\" class=\"wp-image-10228\" width=\"559\" height=\"364\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-69-1024x667.png 1024w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-69-300x195.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-69-768x500.png 768w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-69.png 1193w\" sizes=\"(max-width: 559px) 100vw, 559px\" \/><figcaption>\u539f\u59cb<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" width=\"613\" height=\"107\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-101.png\" alt=\"\" class=\"wp-image-10480\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-101.png 613w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-101-300x52.png 300w\" sizes=\"(max-width: 613px) 100vw, 613px\" \/><figcaption>\u6700\u65b0\u91cf\u5316\u540e\u7684ap<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" width=\"463\" height=\"753\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-102.png\" alt=\"\" class=\"wp-image-10489\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-102.png 463w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-102-184x300.png 184w\" sizes=\"(max-width: 463px) 100vw, 463px\" \/><\/figure><\/div>\n\n\n\n<p>\u91cf\u5316\u62a5\u7684\u8b66\u544a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u6700\u65b0\u7248\u672c\ndef quantize_tensor(activation,integer_precision=7, fraction_precision=8,channel_level=False):\n    _max = activation.abs().max()\n    if _max &gt; 2**integer_precision:\n        print(\"data is too big, overflows!!!\")\n        one = torch.ones_like(activation)*(2**integer_precision- 1\/(2**fraction_precision))\n        _activation = torch.where(activation &gt; 2**integer_precision ,one, activation)\n        _activation = torch.where(_activation &lt; -2**integer_precision ,one*-1, _activation)     \n    else:\n        _activation = activation\n    # 0.00390625 \u8868\u793a\u7684\u6700\u5927\u7cbe\u5ea6\n    _int = _activation.trunc()  #\u6574\u6570\u90e8\u5206\n    _frac = _activation.frac()  #\u5c0f\u6570\u90e8\u5206\n    new_tensor =_int +  (_frac\/\/2**(-fraction_precision))*(2**(-fraction_precision))\n    return new_tensor, 1<\/code><\/pre>\n\n\n\n<p>use torch.div(a, b, rounding_mode=&#8217;trunc&#8217;), or for actual floor division, use torch.div(a, b, rounding_mode=&#8217;floor&#8217;)<\/p>\n\n\n\n<p>\u628a\u6743\u91cd\u5199\u5165bin\/text\u6587\u4ef6\u4e2d<\/p>\n\n\n\n<p class=\"has-bright-blue-background-color has-background\"><strong>2\u3001FPGA\u786c\u4ef6\u540c\u5b66\u6700\u7ec8\u5e0c\u671b\u7684\u76ee\u6807 \u662f\u628a\u6743\u91cd\u53c2\u6570\u964d\u52303M\u4e00\u4e0b\uff0c\u8fd9\u6837\u53ef\u4ee5\u76f4\u63a5\u628a\u6743\u91cd\u653e\u5728uram \/bram,\u8fd9\u6837\u4e0d\u9700\u8981\u4eceddr\u8bfb\u53d6\u6743\u91cd\u6570\u636e\uff08\u4f1a\u5f88\u5927\u7a0b\u5ea6\u51cf\u8f7b\u786c\u4ef6\u540c\u5b66\u7684\u5de5\u4f5c\u91cf\uff09<\/strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<strong>\u6240\u4ee5\u9700\u8981\u8f6f\u4ef6\u540c\u5b66\u5c3d\u6700\u5927\u53ef\u80fd\u7684\u538b\u7f29\uff01\uff01\uff01\uff01<\/strong><\/p>\n\n\n\n<p class=\"has-dark-gray-color has-light-pink-background-color has-text-color has-background\"><strong>\u5f85\u505a\uff1a1\u3001\u642d\u5efa\u6bcf\u4e00\u5c42\u7684python\u4eff\u771f\u7a0b\u5e8f\uff0c\u4f9b\u786c\u4ef6\u505a\u53c2\u8003                                                            2\u3001\u539f\u6765\u7684torch\u8bad\u7ec3\uff0c\u9700\u8981 \u5c06\u6700\u65b0\u7684\u6a21\u578b\u548c\u8f93\u5165\u8fdb\u884c\u4e00\u7cfb\u5217\u7684\u5fae\u8c03\u3001\u91cf\u5316\u3001\u4ee5\u53ca\u6700\u540e\u63d0\u53d6\u5404\u5c42\u53c2\u6570\uff0c\u5199\u5165bin\u6587\u4ef6                                                                                                       3\u3001torch\u8bad\u7ec3\u8fc7\u7a0b\u7684\u91cf\u5316\u8fc7\u7a0b\uff1a\u8fdb\u884c\u4f18\u5316\uff0816bit\uff09<\/strong>                                                         <strong>4\u3001\u5c1d\u8bd5\u4f7f\u7528repconv\uff08yolov6\u6765\u66ff\u4ee3 yolov3\u4e2d\u7684\u5377\u79ef\u5c42\uff09  <\/strong><\/p>\n\n\n\n<p> <strong>3\u3001torch\u8bad\u7ec3\u8fc7\u7a0b\u7684\u91cf\u5316\u8fc7\u7a0b\uff1a\u8fdb\u884c\u4f18\u5316\uff0816bit\uff09<\/strong>   \uff1a<\/p>\n\n\n\n<p>\u4fee\u6539 \u539f\u59cb\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class AveragedRangeTracker_v1(nn.Module):\n    def __init__(self, momentum=0.1):\n        super().__init__()\n        self.momentum = momentum\n        self.register_buffer('scale', torch.zeros(1))\n        self.register_buffer('first_a', torch.zeros(1))\n    def quantize_activation(self, activation, integer_precision=7, fraction_precision=8, rescale=True, \n                            quantization=False, freeze = False):\n        if(quantization == False):\n            return activation\n        # \u5b9e\u9645\u4e0a\u8fd9\u90e8\u5206\u7684\u5185\u5bb9\u5c31\u662f\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u628a\u8f93\u5165---\u300b\u7ea6\u675f\u5230bitwidth=8\u6240\u80fd\u8868\u793a\u7684\u8303\u56f4\uff0c\u5e76\u66ff\u6362\u6389\n        # \u5b9e\u9645\u7684\u8f93\u5165\u3002\n        with torch.no_grad():\n            _max = activation.abs().max()\n            if _max &gt; 2**integer_precision:\n                print(\"data is too big, overflows!!!\")\n                one = torch.ones_like(activation)*(2**integer_precision- 1\/(2**fraction_precision))\n                _activation = torch.where(activation &gt; 2**integer_precision ,one, activation)\n                _activation = torch.where(_activation &lt; -2**integer_precision ,one*-1, _activation)     \n            else:\n                _activation = activation\n            quantized_a = (_activation\/\/2**(-fraction_precision))*(2**(-fraction_precision))\n            quantized_a.requires_grad = True\n        return quantized_a<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>def quantize_tensor_v1(activation,integer_precision=7, fraction_precision=8,channel_level=False):\n    _max = activation.abs().max()\n    if _max &gt; 2**integer_precision:\n        print(\"data is too big, overflows!!!\")\n        one = torch.ones_like(activation)*(2**integer_precision- 1\/(2**fraction_precision))\n        _activation = torch.where(activation &gt; 2**integer_precision ,one, activation)\n        _activation = torch.where(_activation &lt; -2**integer_precision ,one*-1, _activation)     \n    else:\n        _activation = activation\n    new_tensor = (_activation\/\/2**(-fraction_precision))*(2**(-fraction_precision))\n    return new_tensor, 1<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>def quantize_tensor_b_v1(activation,integer_precision=7, fraction_precision=8,channel_level=False):\n    _max = activation.abs().max()\n    if _max &gt; 2**integer_precision:\n        print(\"data is too big, overflows!!!\")\n        one = torch.ones_like(activation)*(2**integer_precision- 1\/(2**fraction_precision))\n        _activation = torch.where(activation &gt; 2**integer_precision ,one, activation)\n        _activation = torch.where(_activation &lt; -2**integer_precision ,one*-1, _activation)     \n    else:\n        _activation = activation\n    new_tensor = (_activation\/\/2**(-fraction_precision))*(2**(-fraction_precision))\n    return new_tensor, 1<\/code><\/pre>\n\n\n\n<p class=\"has-dark-gray-color has-light-pink-background-color has-text-color has-background\">repvggcode\uff1ahttps:\/\/github.com\/DingXiaoH\/RepVGG\/blob\/main\/repvgg.py<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\n<strong>repconv\uff08yolov6\u6765\u66ff\u4ee3 yolov3\u4e2d\u7684\u5377\u79ef\u5c42\uff09 \uff1a  <\/strong>   \n\n#   This func derives the equivalent kernel and bias in a DIFFERENTIABLE way.\n#   You can get the equivalent kernel and bias at any time and do whatever you want,\n    #   for example, apply some penalties or constraints during training, just like you do to the other models.\n#   May be useful for quantization or pruning.\n    def get_equivalent_kernel_bias(self):\n        kernel3x3, bias3x3 = self._fuse_bn_tensor(self.rbr_dense)\n        kernel1x1, bias1x1 = self._fuse_bn_tensor(self.rbr_1x1)\n        kernelid, biasid = self._fuse_bn_tensor(self.rbr_identity)\n        return kernel3x3 + self._pad_1x1_to_3x3_tensor(kernel1x1) + kernelid, bias3x3 + bias1x1 + biasid\n\n    def _pad_1x1_to_3x3_tensor(self, kernel1x1):\n        if kernel1x1 is None:\n            return 0\n        else:\n            return torch.nn.functional.pad(kernel1x1, &#091;1,1,1,1])\n\n    def _fuse_bn_tensor(self, branch):\n        if branch is None:\n            return 0, 0\n        if isinstance(branch, nn.Sequential):\n            kernel = branch.conv.weight\n            running_mean = branch.bn.running_mean\n            running_var = branch.bn.running_var\n            gamma = branch.bn.weight\n            beta = branch.bn.bias\n            eps = branch.bn.eps\n        else:\n            assert isinstance(branch, nn.BatchNorm2d)\n            if not hasattr(self, 'id_tensor'):\n                input_dim = self.in_channels \/\/ self.groups\n                kernel_value = np.zeros((self.in_channels, input_dim, 3, 3), dtype=np.float32)\n                for i in range(self.in_channels):\n                    kernel_value&#091;i, i % input_dim, 1, 1] = 1\n                self.id_tensor = torch.from_numpy(kernel_value).to(branch.weight.device)\n            kernel = self.id_tensor\n            running_mean = branch.running_mean\n            running_var = branch.running_var\n            gamma = branch.weight\n            beta = branch.bias\n            eps = branch.eps\n        std = (running_var + eps).sqrt()\n        t = (gamma \/ std).reshape(-1, 1, 1, 1)\n        return kernel * t, beta - running_mean * gamma \/ std<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-70.png\" alt=\"\" class=\"wp-image-10261\" width=\"690\" height=\"113\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-70.png 969w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-70-300x50.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-70-768x127.png 768w\" sizes=\"(max-width: 690px) 100vw, 690px\" \/><figcaption>\u4e00\u5f00\u59cbrepvgg\u7684\u4f7f\u7528<\/figcaption><\/figure>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-103.png\" alt=\"\" class=\"wp-image-10491\" width=\"406\" height=\"721\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-103.png 429w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-103-169x300.png 169w\" sizes=\"(max-width: 406px) 100vw, 406px\" \/><figcaption>\u8c03\u53c2\u4e4b\u540e<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" width=\"454\" height=\"414\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-104.png\" alt=\"\" class=\"wp-image-10497\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-104.png 454w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-104-300x274.png 300w\" sizes=\"(max-width: 454px) 100vw, 454px\" \/><figcaption>bn\u878d\u5408<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u91cf\u5316\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" width=\"364\" height=\"513\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-105.png\" alt=\"\" class=\"wp-image-10504\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-105.png 364w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-105-213x300.png 213w\" sizes=\"(max-width: 364px) 100vw, 364px\" \/><\/figure><\/div>\n\n\n\n<p>rep_small_v1:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-106.png\" alt=\"\" class=\"wp-image-10507\" width=\"303\" height=\"524\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-106.png 424w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/11\/image-106-174x300.png 174w\" sizes=\"(max-width: 303px) 100vw, 303px\" \/><figcaption>train<\/figcaption><\/figure><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>class Conv2d_v1(nn.Module):\n    \"\"\"\n    \u6a21\u5757\u8bf4\u660e\uff1aconv2d+bn+\u6fc0\u6d3b\u51fd\u6570\uff0c\n    \u5728\u8bad\u7ec3\u5b8c\u4ee5\u540e\uff0c\u8fdb\u884cdeploy_model = repvgg_model_convert(train_model, save_path='RepVGG-A0-deploy.pth')\u4e4b\u524d\uff0c\u8bbe\u7f6etrain_model.eval()\uff0c\u7136\u540e\u5728\u8f6c\u6362\u5c31\u53ef\u4ee5\u4e86\n    \u5b9e\u73b0bn+conv\u878d\u5408\n    if deploy == true: \u8fd4\u56de\u878d\u5408\u540e\u7684\u6a21\u578b\n    \"\"\"\n    def __init__(self, in_channels, out_channels, kernel_size=3, padding=1, stride=1, dilation=1, leakyReLU=True,groups=1,deploy=False,padding_mode=\"zeros\"):\n        super(Conv2d_v1, self).__init__()\n        self.nonlinearity = nn.LeakyReLU(0.125, inplace=True) if leakyReLU else nn.ReLU(inplace=True)\n        self.deploy = deploy\n        if self.deploy:\n            self.rbr_reparam = nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=kernel_size, stride=stride,\n                                      padding=padding, dilation=dilation, groups=groups, bias=True, padding_mode=padding_mode)\n        else:\n            self.rbr_dense = conv_bn(in_channels=in_channels, out_channels=out_channels, kernel_size=kernel_size, stride=stride, padding=padding, groups=groups)\n\n    def forward(self, inputs):\n        if hasattr(self, 'rbr_reparam'):\n            # print(\"rbr_reparam:\")\n            return self.nonlinearity(self.rbr_reparam(inputs))\n        return self.nonlinearity(self.rbr_dense(inputs))\n\n    def _fuse_bn_tensor(self, branch):\n        if branch is None:\n            return 0, 0\n        if isinstance(branch, nn.Sequential):\n            kernel = branch.conv.weight\n            running_mean = branch.bn.running_mean\n            running_var = branch.bn.running_var\n            gamma = branch.bn.weight\n            beta = branch.bn.bias\n            eps = branch.bn.eps\n        else:\n            assert isinstance(branch, nn.BatchNorm2d)\n            if not hasattr(self, 'id_tensor'):\n                input_dim = self.in_channels \/\/ self.groups\n                kernel_value = np.zeros((self.in_channels, input_dim, 3, 3), dtype=np.float32)\n                for i in range(self.in_channels):\n                    kernel_value&#091;i, i % input_dim, 1, 1] = 1\n                self.id_tensor = torch.from_numpy(kernel_value).to(branch.weight.device)\n            kernel = self.id_tensor\n            running_mean = branch.running_mean\n            running_var = branch.running_var\n            gamma = branch.weight\n            beta = branch.bias\n            eps = branch.eps\n        std = (running_var + eps).sqrt()\n        t = (gamma \/ std).reshape(-1, 1, 1, 1)\n        return kernel * t, beta - running_mean * gamma \/ std\n    \n    def switch_to_deploy(self):\n        if hasattr(self, 'rbr_reparam'):\n            return\n        kernel, bias = self._fuse_bn_tensor(self.rbr_dense)\n        self.rbr_reparam = nn.Conv2d(in_channels=self.rbr_dense.conv.in_channels, out_channels=self.rbr_dense.conv.out_channels,\n                                     kernel_size=self.rbr_dense.conv.kernel_size, stride=self.rbr_dense.conv.stride,\n                                     padding=self.rbr_dense.conv.padding, dilation=self.rbr_dense.conv.dilation, groups=self.rbr_dense.conv.groups, bias=True)\n        self.rbr_reparam.weight.data = kernel\n        self.rbr_reparam.bias.data = bias\n        self.__delattr__('rbr_dense')\n        if hasattr(self, 'rbr_identity'):\n            self.__delattr__('rbr_identity')\n        if hasattr(self, 'id_tensor'):\n            self.__delattr__('id_tensor')\n        self.deploy = True<\/code><\/pre>\n\n\n\n<p class=\"has-bright-blue-background-color has-background\">\u6700\u65b0\uff1a\u4f7f\u7528\u6700\u8fd1\u90bb\u63d2\u503c\u66ff\u4ee3\u53cc\u7ebf\u6027\u63d2\u503c\u7b97\u6cd5<\/p>\n\n\n\n<p>C_5_up = F.interpolate(C_5_1, scale_factor=2.0, mode=&#8217;nearest&#8217;)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img alt=\"\"\/><\/figure>\n\n\n\n<p>\u5982\u4f55bn\u548cconv\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"531\" height=\"719\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2023\/03\/image-16.png\" alt=\"\" class=\"wp-image-14836\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2023\/03\/image-16.png 531w, http:\/\/139.9.1.231\/wp-content\/uploads\/2023\/03\/image-16-222x300.png 222w\" sizes=\"(max-width: 531px) 100vw, 531px\" \/><\/figure>\n\n\n\n<p class=\"has-dark-gray-color has-light-pink-background-color has-text-color has-background\">\u5f85\u505a\uff1a1 \u770b\u770brepvgg\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff08\u8bba\u6587+\u4ee3\u7801 \uff09  2\u3001yolov6\u7684\u4ee3\u7801\uff0c\u662f\u600e\u4e48\u90e8\u7f72\u5230\u5de5\u4e1a\u5316\u7684 2\u3001\u76ee\u524d\u6548\u679c\u63d0\u5347\u4e0d\u660e\u663e\uff0c\u5c1d\u8bd5\u77e5\u8bc6\u84b8\u998f or \u6570\u636e\u589e\u5f3a\uff08\u53c2\u8003yolov5\/v6\uff09<\/p>\n\n\n\n<p class=\"has-bright-blue-background-color has-background\"><strong>1\u3001\u6570\u636e\u589e\u5f3a\uff1a\u53c2\u8003yolovx\uff08\u5f85\u505a\uff09<\/strong><\/p>\n\n\n\n<p>\u53c2\u8003\u535a\u5ba2\uff1a<a href=\"https:\/\/blog.csdn.net\/qq_39237205\/article\/details\/125730988\">https:\/\/blog.csdn.net\/qq_39237205\/article\/details\/125730988<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.codeleading.com\/article\/80135054649\/\">https:\/\/www.codeleading.com\/article\/80135054649\/<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/my.oschina.net\/u\/4580321\/blog\/4358486\">https:\/\/my.oschina.net\/u\/4580321\/blog\/4358486<\/a><\/p>\n\n\n\n<p>YOLOV5\u4f1a\u8fdb\u884c\u4e09\u79cd\u6570\u636e\u589e\u5f3a\uff1a\u7f29\u653e\uff0c\u8272\u5f69\u7a7a\u95f4\u8c03\u6574\u548c\u9a6c\u8d5b\u514b\u589e\u5f3a\u3002\u5176\u4e2d\u9a6c\u8d5b\u514b\u589e\u5f3a\u662f\u901a\u8fc7\u5c06\u56db\u5f20\u56fe\u50cf\u8fdb\u884c\u968f\u673a\u7f29\u653e\u3001\u968f\u673a\u88c1\u526a\u3001\u968f\u673a\u5206\u5e03\u65b9\u5f0f\u8fdb\u884c\u62fc\u63a5\uff0c\u5c0f\u76ee\u6807\u7684\u68c0\u6d4b\u6548\u679c\u5f97\u5230\u63d0\u5347\u3002<\/p>\n\n\n\n<p>\u5728\u7f51\u7edc\u7684\u8f93\u5165\u7aef\uff0cYolox\u4e3b\u8981\u91c7\u7528\u4e86Mosaic\u3001Mixup\u4e24\u79cd\u6570\u636e\u589e\u5f3a\u65b9\u6cd5\u3002\u901a\u8fc7\u968f\u673a\u7f29\u653e\u3001\u968f\u673a\u88c1\u526a\u3001\u968f\u673a\u6392\u5e03\u7684\u65b9\u5f0f\u8fdb\u884c\u62fc\u63a5\uff0c\u5bf9\u4e8e\u5c0f\u76ee\u6807\u7684\u68c0\u6d4b\u6548\u679c\u63d0\u5347\uff0c\u8fd8\u662f\u5f88\u4e0d\u9519\u7684\u3002\u800c\u4e14\u5728Yolov4\u3001Yolov5\u7b97\u6cd5\u4e2d\uff0c\u4e5f\u5f97\u5230\u4e86\u5e7f\u6cdb\u7684\u5e94\u7528\u3002\u662f\u4e00\u79cd\u975e\u5e38\u6709\u6548\u7684\u589e\u5f3a\u65b9\u5f0f\u3002MixUp\u662f\u5728Mosaic\u57fa\u7840\u4e0a\uff0c\u589e\u52a0\u7684\u4e00\u79cd\u989d\u5916\u7684\u589e\u5f3a\u7b56\u7565\u3002<\/p>\n\n\n\n<p class=\"has-bright-blue-background-color has-background\"><strong>2\u3001\u77e5\u8bc6\u84b8\u998f \uff08\u5f85\u505a\uff09 <\/strong><\/p>\n\n\n\n<p>\u53c2\u8003\u6587\u732e <a href=\"https:\/\/blog.csdn.net\/qq_39523365\/article\/details\/118525815\">https:\/\/blog.csdn.net\/qq_39523365\/article\/details\/118525815<\/a><\/p>\n\n\n\n<p>\u77e5\u8bc6\u84b8\u998f\uff08Knowledge Distilling\uff09\u662f\u6a21\u578b\u538b\u7f29\u7684\u4e00\u79cd\u65b9\u6cd5\uff0c\u662f\u6307\u5229\u7528\u5df2\u7ecf\u8bad\u7ec3\u7684\u4e00\u4e2a\u8f83\u590d\u6742\u7684Teacher\u6a21\u578b\uff0c\u6307\u5bfc\u4e00\u4e2a\u8f83\u8f7b\u91cf\u7684Student\u6a21\u578b\u8bad\u7ec3\uff0c\u4ece\u800c\u5728\u51cf\u5c0f\u6a21\u578b\u5927\u5c0f\u548c\u8ba1\u7b97\u8d44\u6e90\u7684\u540c\u65f6\uff0c\u5c3d\u91cf\u4fdd\u6301\u539fTeacher\u6a21\u578b\u7684\u51c6\u786e\u7387\u7684\u65b9\u6cd5\u3002\u5373\u7528\u4e00\u4e2a\u590d\u6742\u7f51\u7edc\uff08teacher network\uff09\u5b66\u5230\u7684\u4e1c\u897f\u53bb\u8f85\u52a9\u8bad\u7ec3\u4e00\u4e2a\u7b80\u5355\u7f51\u7edc\uff08student network\uff09\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>device = &#8220;xcvu3p-ffvc1517-2-e&#8221; \u53c2\u8003\uff1a https:\/\/ &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/03\/27\/fpgayolo\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">FPGA\u2014YOLO<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13],"tags":[],"_links":{"self":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/3024"}],"collection":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/comments?post=3024"}],"version-history":[{"count":610,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/3024\/revisions"}],"predecessor-version":[{"id":14888,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/3024\/revisions\/14888"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=3024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=3024"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=3024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}