Created
October 20, 2019 14:34
-
-
Save taichi-ishitani/cec6acc29ec3c1801590d49c1cd91753 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module top ( | |
input logic [1:0] i_a, | |
input logic [1:0] i_b, | |
output logic [1:0] o_c | |
); | |
function automatic logic [1:0] add(); | |
return i_a + i_b; | |
endfunction | |
always_comb begin | |
o_c = add(); | |
end | |
endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
普通の
always
の場合、always
文中で直接参照されている信号の変化のタイミングでしか、always
文が評価されない。上記の場合、直接参照している信号がないので、上記の
always
文は一切評価されない。よって、合成とシミュレーションで不一致が出てしまう。
しかし、
always_comb
の場合、function
で使用している信号の変化のタイミングでも評価される。上記の場合だと、
i_a
/i_b
が変化すれば、o_d = add()
が実行される。なので、合成とシミュレーションで不一致が起きない。