{"id":1054,"date":"2019-09-18T15:20:18","date_gmt":"2019-09-18T14:20:18","guid":{"rendered":"http:\/\/www.fabienm.eu\/flf\/?p=1054"},"modified":"2020-05-30T04:41:19","modified_gmt":"2020-05-30T03:41:19","slug":"la-taille-en-bits","status":"publish","type":"post","link":"http:\/\/www.fabienm.eu\/flf\/la-taille-en-bits\/","title":{"rendered":"Register size in bits"},"content":{"rendered":"\n<p>How to calculate register size in bits N<\/p>\n\n\n\n<p><strong><a href=\"https:\/\/www.chisel-lang.org\/api\/3.0.1\/chisel3\/util\/log2Ceil$.html\">Chisel3  : log2Ceil()<\/a><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import chisel3.util.log2Ceil\n\nval Nsize = log2Ceil(N)<\/code><\/pre>\n\n\n\n<p><strong><a href=\"https:\/\/rahulhiyertechnical.blogspot.com\/2016\/10\/clog2-in-verilog.html\">Verilog : $clog2()<\/a><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> parameter NSIZE = $clog2(N);<\/code><\/pre>\n\n\n\n<p><a href=\"http:\/\/result := integer(ceil(log2(real(a))));\"><strong>VHDL : ceil(log2()<\/strong><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>use IEEE.math_real.\"ceil\";\nuse IEEE.math_real.\"log2\";\n\nNsize := integer(ceil(log2(real(N))));<\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/www.tutorialspoint.com\/python\/number_ceil.htm\"><strong>Python: math.ceil(math.log(N+1, 2))<\/strong><\/a><\/p>\n\n\n\n<p><code>import math<br>Nsize = math.ceil(math.log(N, 2))<\/code><\/p>\n\n\n\n<p><a href=\"https:\/\/clash-lang.org\"><strong>C\u03bbaSH<\/strong><\/a><strong>: ?<\/strong><\/p>\n\n\n\n<p><strong>SystemC\/C++: <\/strong> ceil(log2())<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;math.h>       \/* ceil and log *\/\nNsize = ceil(log2(N));<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to calculate register size in bits N Chisel3 : log2Ceil() Verilog : $clog2() VHDL : ceil(log2() Python: math.ceil(math.log(N+1, 2)) import mathNsize = math.ceil(math.log(N, 2)) C\u03bbaSH: ? SystemC\/C++: ceil(log2())<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[4,3,1,99,20,11],"tags":[57,88,56,30,60],"class_list":["post-1054","post","type-post","status-publish","format-standard","hentry","category-chisel-langages","category-langages","category-non-classe","category-tipoftheweek","category-verilog","category-vhdl","tag-chisel","tag-chisel3","tag-python","tag-verilog","tag-vhdl"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"post-thumbnail":false},"uagb_author_info":{"display_name":"Fabien Marteau","author_link":"http:\/\/www.fabienm.eu\/flf\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":"How to calculate register size in bits N Chisel3 : log2Ceil() Verilog : $clog2() VHDL : ceil(log2() Python: math.ceil(math.log(N+1, 2)) import mathNsize = math.ceil(math.log(N, 2)) C\u03bbaSH: ? SystemC\/C++: ceil(log2())","_links":{"self":[{"href":"http:\/\/www.fabienm.eu\/flf\/wp-json\/wp\/v2\/posts\/1054","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.fabienm.eu\/flf\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.fabienm.eu\/flf\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.fabienm.eu\/flf\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.fabienm.eu\/flf\/wp-json\/wp\/v2\/comments?post=1054"}],"version-history":[{"count":12,"href":"http:\/\/www.fabienm.eu\/flf\/wp-json\/wp\/v2\/posts\/1054\/revisions"}],"predecessor-version":[{"id":1549,"href":"http:\/\/www.fabienm.eu\/flf\/wp-json\/wp\/v2\/posts\/1054\/revisions\/1549"}],"wp:attachment":[{"href":"http:\/\/www.fabienm.eu\/flf\/wp-json\/wp\/v2\/media?parent=1054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.fabienm.eu\/flf\/wp-json\/wp\/v2\/categories?post=1054"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.fabienm.eu\/flf\/wp-json\/wp\/v2\/tags?post=1054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}