カウンターの定数のサイズを設定したい:
localparam MAX_COUNT = ((debounce_per_ms * clk_freq)) + 1;
parameter MAX_COUNT_UPPER = $rtoi($floor($log10(MAX_COUNT)/$log10(2)));
これは XST (ise) とベリレーターでうまく動作しますが、Icarus では次のエラーが発生します。
src/button_deb.v:20: error: $rtoi() is not a constant system function.
「整数」タイプを使用してこれを解決できます:
parameter integer MAX_COUNT_UPPER = $floor($log10(MAX_COUNT)/$log10(2));
しかし、それはベリレーターで警告を出します:
$ verilator -cc src/button_deb.v
%Warning-REALCVT: src/button_deb.v:20: Implicit conversion of real to integer
%Warning-REALCVT: Use "/* verilator lint_off REALCVT */" and lint_on around source to disable this message.
%Error: Exiting due to 1 warning(s)
%Error: Command Failed /usr/local/bin/verilator_bin -cc src/button_deb.v
これを行う良い方法があり、Icarus、veilator、および Xst と互換性があると思いますか?