Skip to content

Instantly share code, notes, and snippets.

@taichi-ishitani
Created March 18, 2019 08:39
Show Gist options
  • Save taichi-ishitani/7c60a3726b360bee7188b0e9044487eb to your computer and use it in GitHub Desktop.
Save taichi-ishitani/7c60a3726b360bee7188b0e9044487eb to your computer and use it in GitHub Desktop.
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
@taichi-ishitani
Copy link
Author

generate ブロック中で定義した関数は、定義した generate ブロック外でも使うことができる。
以下のツールで使用できることを確認済み。

  • VCS
  • Xcelium
  • Design Compiler
  • Vivado

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment