Created
March 18, 2019 08:39
-
-
Save taichi-ishitani/7c60a3726b360bee7188b0e9044487eb 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 i_clk, | |
input logic i_rst_n, | |
input logic [1:0] i_foo, | |
output logic [1:0] o_bar, | |
output logic [1:0] o_baz | |
); | |
if (1) begin : g_bar | |
function automatic logic [1:0] f(logic [1:0] v); | |
return ~v; | |
endfunction | |
end | |
if (1) begin : g_baz | |
function automatic logic [1:0] f(logic [1:0] v); | |
return {v[0], v[1]}; | |
endfunction | |
end | |
always_ff @(posedge i_clk, negedge i_rst_n) begin | |
if (!i_rst_n) begin | |
o_bar <= 0; | |
o_baz <= 0; | |
end | |
else begin | |
o_bar <= g_bar.f(i_foo); | |
o_baz <= g_baz.f(i_foo); | |
end | |
end | |
endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
generate ブロック中で定義した関数は、定義した generate ブロック外でも使うことができる。
以下のツールで使用できることを確認済み。