{"id":2358,"date":"2011-04-08T23:38:00","date_gmt":"2011-04-08T14:38:00","guid":{"rendered":"https:\/\/hdmr.org\/d\/?e=1087"},"modified":"2011-04-08T23:38:00","modified_gmt":"2011-04-08T14:38:00","slug":"blogn-1087","status":"publish","type":"post","link":"https:\/\/hdmr.org\/d\/?e=1087","title":{"rendered":"generate\u3067\u81ea\u52d5\u7684\u306b\u56de\u8def\u3092\u751f\u6210\u3059\u308b"},"content":{"rendered":"<p>\u4eca\u65e5\u306f\u4e45\u3057\u3076\u308a\u306bVerilog\u66f8\u3044\u3066\u305f\u3002<\/p>\n<p>\u4f55\u3092\u3057\u3066\u3044\u305f\u306e\u304b\u3068\u3044\u3046\u3068\u6570\u72ec\u3092\u89e3\u304f\u56de\u8def\u3092\u4f5c\u308b\u305f\u3081\u3067\u3059\u306d\u3002<\/p>\n<p>\u4ee5\u524d\u304b\u3089\u3084\u308d\u3046\u3068\u601d\u3063\u3066\u305f\u306e\u3060\u3051\u3069\u3001\u3061\u3087\u3046\u3069\u6687\u306a\u306e\u3067\u3061\u3087\u3046\u3069\u3044\u3044\u3002<\/p>\n<hr \/>\n<p> \u6570\u72ec\u3092\u89e3\u304f\u65b9\u6cd5\u3060\u304c\u3001\u7e26\u30fb\u6a2a\u30fb3\u00d73\u306e\u30d6\u30ed\u30c3\u30af\u305d\u308c\u305e\u308c\u306b\u542b\u307e\u308c\u308b\u6570\u5b57\u3092\u5217\u6319\u3057\u3066\u3001\u3053\u308c\u3089\u3044\u305a\u308c\u306e\u67a0\u306b\u3082\u542b\u307e\u308c\u306a\u3044\u6570\u5b57\u304c\u5019\u88dc\u306b\u306a\u308b\u3002  <\/p>\n<p>\u4eca\u65e5\u306f\u7e26\u30fb\u6a2a\u30fb3\u00d73\u306e\u30d6\u30ed\u30c3\u30af\u305d\u308c\u305e\u308c\u306b\u542b\u307e\u308c\u308b\u6570\u5b57\u3092\u5217\u6319\u3059\u308b\u3053\u3068\u3092\u3084\u3063\u3066\u3044\u305f\u3002<\/p>\n<p>\u5404\u30de\u30b9\u306e\u6570\u5b57\u30923\u306a\u30899&#8217;b001000000\u306e\u3088\u3046\u306b\u4f55\u756a\u76ee\u304b\u306e\u30d3\u30c3\u30c8\u30921\u306b\u3059\u308b\u3053\u3068\u3067\u793a\u3059\u3053\u3068\u306b\u3059\u308b\u3002<\/p>\n<p>\u3053\u308c\u3092\u7e26\u30fb\u6a2a\u30fb3\u00d73\u306e\u30d6\u30ed\u30c3\u30af\u306e\u5168\u3066\u306e\u30de\u30b9\u306e\u5024\u306b\u3064\u3044\u3066OR\u3092\u53d6\u308c\u3070\u3001\u542b\u307e\u308c\u308b\u6570\u5b57\u5168\u3066\u304c\u9078\u3070\u308c\u305f\u72b6\u614b\u306b\u306a\u308b\u3002<\/p>\n<p>\u554f\u984c\u306f\u3053\u308c\u3092\u3069\u3046\u3084\u3063\u3066OR\u3092\u53d6\u308b\u304b\u3060\u3002\u5168\u90e8\u624b\u3067\u66f8\u304f\u306e\u304c\u624b\u3063\u53d6\u308a\u65e9\u3044\u6c17\u3082\u3059\u308b\u304c\u3061\u3087\u3063\u3068\u305d\u308c\u306f\u304b\u3063\u3053\u308f\u308b\u3044\u3002<\/p>\n<p>\u305d\u3053\u3067Verilog\u306egenerate\u3092\u4f7f\u3063\u3066\u3084\u3063\u3066\u307f\u305f\u3002<\/p>\n<hr \/>\n<p> \u307e\u305agenerate\u306e\u4f7f\u3044\u65b9\u306e\u4f8b\u3060\u304c\u3053\u3093\u306a\u98a8\u306b\u3059\u308b\u3002  <\/p>\n<pre>wire [7:0] a,b,c,e;\ngenerate\n  genvar i;\n  for(i=0;i&lt;8;i=i+1) begin :gen\n    assign b=~a;\n    always @(posedge clk)  c&lt;=b;\n    Module1 m(a,e);\n  end\nendgenerate<\/pre>\n<p>generate\u306e\u30d6\u30ed\u30c3\u30af\u3092\u4f5c\u3063\u3066\u3001\u305d\u306e\u4e2d\u3067\u751f\u6210\u306b\u4f7f\u3046\u5909\u6570\u306egenvar\u3092\u5ba3\u8a00\u3057\u3066for\u30eb\u30fc\u30d7\u3092\u56de\u3059\u3002<\/p>\n<p>for\u306e\u5f8c1\u6587\u3067\u7d42\u308f\u3089\u306a\u3044\u304b\u3089begin\uff5eend\u3067\u304f\u304f\u308b\u304c\u3001\u3053\u3053\u3067:gen\u306a\u3069\u3057\u3066\u304a\u304f\u3068\u3001gen\u3068\u3044\u3046\u540d\u524d\u304c\u3064\u3044\u305f\u30d6\u30ed\u30c3\u30af\u306b\u3067\u304d\u308b\u3002<\/p>\n<p>\u540d\u524d\u3092\u3064\u3051\u305f\u3089\u305d\u306e\u540d\u524d\u304c\u968e\u5c64\u306b\u3064\u304f\u305d\u3046\u3067\u3059\u304c\u304f\u308f\u3057\u304f\u306f\u77e5\u3089\u306a\u3044\u3002<\/p>\n<p>\u3053\u306e\u4e0b\u306b\u306falways\u30fbassign\u3068\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5b9f\u4f53\u5316\u304c\u3067\u304d\u308b\u3088\u3046\u3060\u3002<\/p>\n<hr \/>\n<p>\u3057\u304b\u3057\u554f\u984c\u306f\u3069\u3046\u3084\u3063\u30669\u3064\u306e\u5909\u6570\u306eOR\u3092generate\u3092\u4f7f\u3063\u3066\u751f\u6210\u3059\u308b\u304b\u3067\u3042\u308b\u3002<\/p>\n<pre>assign y=x[0]|x[1]|x[2]|x[3]|x[4]|x[5]|x[6]|x[7]|x[8];<\/pre>\n<p>\u3088\u3046\u306f\u3053\u3046\u3044\u3046\u3053\u3068\u3092\u624b\u3067\u66f8\u304b\u305a\u306bgenerate\u3067\u66f8\u304f\u65b9\u6cd5\u304c\u3042\u308b\u304b\u3068\u3044\u3046\u3053\u3068\u3060\u3002<\/p>\n<p>assign\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u3084\u3063\u3066\u307f\u305f\u3002<\/p>\n<p>OR\u3068\u3063\u305f\u3084\u3064\u3092wire\u306b\u4e00\u65e6assign\u3057\u3066\u3001\u305d\u308c\u3068\u6b21\u306e\u3084\u3064\u3092OR\u53d6\u3063\u3066assign\u3057\u3066\u3068\u3044\u3046\u98a8\u306b\u3084\u3063\u305f\u3002<\/p>\n<p>\u7d50\u679c\u3053\u3093\u306a\u98a8\u306a\u8a18\u8ff0\u306b\u306a\u3063\u305f\u3002<\/p>\n<pre>wire [7:0] t[0:7]\ngenerate\n  genvar i;\n  for(i=0;i&lt;9;i=i+1) begin :ors\n    if     (i==0)  t[i]=x[i];\n    else if(i==8)  y   =t[i-1]|x[i];\n    else           t[i]=t[i-1]|x[i];\n  end\nend<\/pre>\n<p>\u3053\u3046\u3059\u308c\u3070\u6700\u7d42\u7684\u306b\u306f\u6700\u521d\u306b\u66f8\u3044\u305f\u3088\u3046\u306b9\u3064\u306eOR\u3092\u53d6\u3063\u305f\u5024\u304cy\u306bassign\u3055\u308c\u308b\u3002<\/p>\n<hr \/>\n<p>\u305f\u3060\u3067\u3055\u3048\u307e\u3069\u308d\u3063\u3053\u3044\u3057\u3044\u8a18\u8ff0\u3060\u304c\u3001\u5b9f\u969b\u306b\u306f\u7e26\u30fb\u6a2a\u30fb3\u00d73\u306e\u30d6\u30ed\u30c3\u30af\u306b\u3064\u3044\u3066\u8a08\u7b97\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u306e\u3067\u304b\u306a\u308a\u8907\u96d1\u306b\u306a\u3063\u3066\u3057\u307e\u3063\u305f\u3002<\/p>\n<p>\u305f\u3060\u57fa\u672c\u3068\u306a\u3063\u3066\u3044\u308b\u3068\u3053\u308d\u306f\u3053\u306e\u901a\u308a\u3067\u3001\u3042\u3068\u306fgenerate\u306efor\u3092\u5165\u308c\u5b50\u306b\u3057\u305f\u308a\u3068\u304b\u305d\u306e\u7a0b\u5ea6\u306e\u3053\u3068\u3002<\/p>\n<p>\u3082\u3063\u3068\u3082\u8907\u96d1\u306a\u306e\u306f\u8a18\u8ff0\u3060\u3051\u3067\u3001\u5b9f\u969b\u306b\u306f\u5408\u6210\u3055\u308c\u308c\u3070\u4e00\u65e6assign\u3057\u305f\u3060\u3051\u306ewire\u306a\u3069\u306f\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3046\u3002<\/p>\n<p>\u3060\u304b\u3089\u3067\u304d\u308b\u56de\u8def\u3082\u304a\u305d\u3089\u304f\u6700\u521d\u306b\u66f8\u3044\u305f\u3088\u3046\u306a\u8a18\u8ff0\u306b\u3088\u308a\u3067\u304d\u308b\u56de\u8def\u3068\u5dee\u306f\u306a\u3044\u306f\u305a\u3060\u3002<\/p>\n<p>\u3060\u304b\u3089generate\u3092\u3064\u304b\u3046\u3053\u3068\u306b\u3088\u308b\u5bb3\u306f\u307b\u307c\u306a\u3044\u306f\u305a\u306a\u306e\u3067\u3069\u3046\u305e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u65e5\u306f\u4e45\u3057\u3076\u308a\u306bVerilog\u66f8\u3044\u3066\u305f\u3002 \u4f55\u3092\u3057\u3066\u3044\u305f\u306e\u304b\u3068\u3044\u3046\u3068\u6570\u72ec\u3092\u89e3\u304f\u56de\u8def\u3092\u4f5c\u308b\u305f\u3081\u3067\u3059\u306d\u3002 \u4ee5\u524d\u304b\u3089\u3084\u308d\u3046\u3068\u601d\u3063\u3066\u305f\u306e\u3060\u3051\u3069\u3001\u3061\u3087\u3046\u3069\u6687\u306a\u306e\u3067\u3061\u3087\u3046\u3069\u3044\u3044\u3002 \u6570\u72ec\u3092\u89e3\u304f\u65b9\u6cd5\u3060\u304c\u3001\u7e26\u30fb\u6a2a\u30fb3\u00d73\u306e\u30d6\u30ed\u30c3\u30af\u305d\u308c\u305e\u308c\u306b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-2358","post","type-post","status-publish","format-standard","hentry","category-research"],"_links":{"self":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts\/2358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2358"}],"version-history":[{"count":0,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts\/2358\/revisions"}],"wp:attachment":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}