{"id":203868,"date":"2020-11-05T10:15:32","date_gmt":"2020-11-05T02:15:32","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=203868"},"modified":"2020-10-26T19:16:41","modified_gmt":"2020-10-26T11:16:41","slug":"verilog-continuous-assignment","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/verilog-continuous-assignment.html","title":{"rendered":"\u6559\u4f60\u8ba4\u8bc6Verilog \u8fde\u7eed\u8d4b\u503c"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u8fde\u7eed\u8d4b\u503c\u8bed\u53e5\u662f Verilog \u6570\u636e\u6d41\u5efa\u6a21\u7684\u57fa\u672c\u8bed\u53e5\uff0c\u7528\u4e8e\u5bf9 wire \u578b\u53d8\u91cf\u8fdb\u884c\u8d4b\u503c\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u5173\u952e\u8bcd\uff1aassign\uff0c \u5168\u52a0\u5668<\/strong><\/div>\n

\u8fde\u7eed\u8d4b\u503c\u8bed\u53e5\u662f Verilog \u6570\u636e\u6d41\u5efa\u6a21\u7684\u57fa\u672c\u8bed\u53e5\uff0c\u7528\u4e8e\u5bf9 wire \u578b\u53d8\u91cf\u8fdb\u884c\u8d4b\u503c\u3002\uff1a<\/p>\n

\u683c\u5f0f\u5982\u4e0b<\/p>\n

assign     LHS_target = RHS_expression  \uff1b<\/pre>\n

LHS\uff08left hand side\uff09 \u6307\u8d4b\u503c\u64cd\u4f5c\u7684\u5de6\u4fa7\uff0cRHS\uff08right hand side\uff09\u6307\u8d4b\u503c\u64cd\u4f5c\u7684\u53f3\u4fa7\u3002<\/p>\n

assign \u4e3a\u5173\u952e\u8bcd\uff0c\u4efb\u4f55\u5df2\u7ecf\u58f0\u660e wire \u53d8\u91cf\u7684\u8fde\u7eed\u8d4b\u503c\u8bed\u53e5\u90fd\u662f\u4ee5 assign \u5f00\u5934\uff0c\u4f8b\u5982\uff1a<\/p>\n

wire      Cout, A, B ;\r\nassign    Cout  = A & B ;     \/\/\u5b9e\u73b0\u8ba1\u7b97A\u4e0eB\u7684\u529f\u80fd<\/pre>\n

\u9700\u8981\u8bf4\u660e\u7684\u662f\uff1a<\/p>\n

    \n
  1. LHS_target \u5fc5\u987b\u662f\u4e00\u4e2a\u6807\u91cf\u6216\u8005\u7ebf\u578b\u5411\u91cf\uff0c\u800c\u4e0d\u80fd\u662f\u5bc4\u5b58\u5668\u7c7b\u578b\u3002<\/li>\n
  2. RHS_expression \u7684\u7c7b\u578b\u6ca1\u6709\u8981\u6c42\uff0c\u53ef\u4ee5\u662f\u6807\u91cf\u6216\u7ebf\u578b\u6216\u5b58\u5668\u5411\u91cf\uff0c\u4e5f\u53ef\u4ee5\u662f\u51fd\u6570\u8c03\u7528\u3002<\/li>\n
  3. \u53ea\u8981 RHS_expression \u8868\u8fbe\u5f0f\u7684\u64cd\u4f5c\u6570\u6709\u4e8b\u4ef6\u53d1\u751f\uff08\u503c\u7684\u53d8\u5316\uff09\u65f6\uff0cRHS_expression \u5c31\u4f1a\u7acb\u523b\u91cd\u65b0\u8ba1\u7b97\uff0c\u540c\u65f6\u8d4b\u503c\u7ed9 LHS_target\u3002<\/li>\n<\/ol>\n

    Verilog \u8fd8\u63d0\u4f9b\u4e86\u53e6\u4e00\u79cd\u5bf9 wire \u578b\u8d4b\u503c\u7684\u7b80\u5355\u65b9\u6cd5\uff0c\u5373\u5728 wire \u578b\u53d8\u91cf\u58f0\u660e\u7684\u65f6\u5019\u540c\u65f6\u5bf9\u5176\u8d4b\u503c\u3002wire \u578b\u53d8\u91cf\u53ea\u80fd\u88ab\u8d4b\u503c\u4e00\u6b21\uff0c\u56e0\u6b64\u8be5\u79cd\u8fde\u7eed\u8d4b\u503c\u65b9\u5f0f\u4e5f\u53ea\u80fd\u6709\u4e00\u6b21\u3002\u4f8b\u5982\u4e0b\u9762\u8d4b\u503c\u65b9\u5f0f\u548c\u4e0a\u9762\u7684\u8d4b\u503c\u4f8b\u5b50\u7684\u8d4b\u503c\u65b9\u5f0f\uff0c\u6548\u679c\u90fd\u662f\u4e00\u81f4\u7684\u3002<\/p>\n

    wire      A, B ;\r\nwire      Cout = A & B ;<\/pre>\n
    \u5168\u52a0\u5668<\/strong><\/div>\n

    \u4e0b\u9762\u91c7\u7528\u6570\u636e\u6d41\u63cf\u8ff0\u65b9\u5f0f\uff0c\u6765\u8bbe\u8ba1\u4e00\u4e2a 1bit \u5168\u52a0\u5668\u3002<\/p>\n

    \u8bbe Ai\uff0cBi\uff0cCi \u5206\u522b\u4e3a\u88ab\u52a0\u6570\u3001\u52a0\u6570\u548c\u76f8\u90bb\u4f4e\u4f4d\u7684\u8fdb\u4f4d\u6570\uff0cSo, Co \u5206\u522b\u4e3a\u672c\u4f4d\u548c\u4e0e\u5411\u76f8\u90bb\u9ad8\u4f4d\u7684\u8fdb\u4f4d\u6570\u3002<\/p>\n

    \u771f\u503c\u8868\u5982\u4e0b\uff1a<\/p>\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    Input<\/span><\/th>\n <\/th>\n <\/th>\nOutput<\/span><\/th>\n <\/th>\n<\/tr>\n<\/thead>\n
    Ci<\/span><\/td>\nAi<\/span><\/td>\nBi<\/span><\/td>\nSo<\/span><\/td>\nCo<\/span><\/td>\n<\/tr>\n
    0<\/span><\/td>\n0<\/span><\/td>\n0<\/span><\/td>\n0<\/span><\/td>\n0<\/span><\/td>\n<\/tr>\n
    0<\/span><\/td>\n0<\/span><\/td>\n1<\/span><\/td>\n1<\/span><\/td>\n0<\/span><\/td>\n<\/tr>\n
    0<\/span><\/td>\n1<\/span><\/td>\n0<\/span><\/td>\n1<\/span><\/td>\n0<\/span><\/td>\n<\/tr>\n
    0<\/span><\/td>\n1<\/span><\/td>\n1<\/span><\/td>\n0<\/span><\/td>\n1<\/span><\/td>\n<\/tr>\n
    1<\/span><\/td>\n0<\/span><\/td>\n0<\/span><\/td>\n1<\/span><\/td>\n0<\/span><\/td>\n<\/tr>\n
    1<\/span><\/td>\n0<\/span><\/td>\n1<\/span><\/td>\n0<\/span><\/td>\n1<\/span><\/td>\n<\/tr>\n
    1<\/span><\/td>\n1<\/span><\/td>\n0<\/span><\/td>\n0<\/span><\/td>\n1<\/span><\/td>\n<\/tr>\n
    1<\/span><\/td>\n1<\/span><\/td>\n1<\/span><\/td>\n1<\/span><\/td>\n1<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

    \u5168\u52a0\u5668\u7684\u8868\u8fbe\u5f0f\u4e3a\uff1a<\/p>\n

    So = Ai \u2295 Bi \u2295 Ci ;\r\nCo = AiBi + Ci(Ai+Bi)<\/pre>\n

    rtl \u4ee3\u7801\uff08full_adder1.v\uff09\u5982\u4e0b\uff1a<\/p>\n

    \u5b9e\u4f8b<\/strong><\/p>\n

    module full_adder1(\r\n    input    Ai, Bi, Ci,\r\n    output   So, Co);\r\n \r\n    assign So = Ai ^ Bi ^ Ci ;\r\n    assign Co = (Ai & Bi) | (Ci & (Ai | Bi));\r\nendmodule<\/pre>\n

    \u5f53\u7136\uff0c\u66f4\u4e3a\u8d34\u8fd1\u52a0\u6cd5\u5668\u7684\u4ee3\u7801\u63cf\u8ff0\u53ef\u4ee5\u4e3a\uff1a<\/p>\n

    \u5b9e\u4f8b<\/strong><\/p>\n

    module full_adder1(\r\n    input    Ai, Bi, Ci\r\n    output   So, Co);\r\n \r\n    assign {Co, So} = Ai + Bi + Ci ;\r\nendmodule<\/pre>\n

    testbench\uff08test.sv\uff09\u53c2\u8003\u5982\u4e0b\uff1a<\/p>\n

    \u5b9e\u4f8b<\/strong><\/p>\n

    `timescale 1ns\/1ns\r\n \r\nmodule test ;\r\n    reg Ai, Bi, Ci ;\r\n    wire So, Co ;\r\n \r\n    initial begin\r\n        {Ai, Bi, Ci}      = 3'b0;\r\n        forever begin\r\n            #10 ;\r\n            {Ai, Bi, Ci}      = {Ai, Bi, Ci} + 1'b1;\r\n        end\r\n    end\r\n \r\n    full_adder1  u_adder(\r\n        .Ai      (Ai),\r\n        .Bi      (Bi),\r\n        .Ci      (Ci),\r\n        .So      (So),\r\n        .Co      (Co));\r\n \r\n    initial begin\r\n        forever begin\r\n            #100;\r\n            \/\/$display(\"---gyc---%d\", $time);\r\n            if ($time >= 1000) begin\r\n            $finish ;\r\n            end\r\n        end\r\n    end\r\n \r\n endmodule<\/pre>\n

    \u4eff\u771f\u7ed3\u679c\u5982\u4e0b\uff1a
    \n\"\"<\/p>\n","protected":false},"excerpt":{"rendered":"

    \u8fde\u7eed\u8d4b\u503c\u8bed\u53e5\u662f Verilog \u6570\u636e\u6d41\u5efa\u6a21\u7684\u57fa\u672c\u8bed\u53e5\uff0c\u7528\u4e8e\u5bf9 wire \u578b\u53d8\u91cf\u8fdb\u884c\u8d4b\u503c\u3002\uff1a \u683c\u5f0f\u5982\u4e0b assi […]<\/p>\n","protected":false},"author":321,"featured_media":203870,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-203868","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/203868","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/321"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=203868"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/203868\/revisions"}],"predecessor-version":[{"id":203872,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/203868\/revisions\/203872"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/203870"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=203868"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=203868"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=203868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}