前言
在設計流程中,可能有的模塊是不使用的,但某時候可能需要使用。
不同代碼段的選擇就可以使用條件編譯。
流程
使用`define和`ifdef `else `endif語句實現此功能。
`timescale 1ns/1ps `define SIM_USE //定義SIM_USE,如果取消定義,注釋此句即可 module xxx ( input i_clk , input i_rst_n , output xxx ); `ifdef SIM_USE xxxxxxxx //如果定義了SIM_USE,則會編譯這段代碼 `else xxxxxxxx //如果沒有定義SIM_USE,則編譯這段代碼 `endif endmodule // end the xxx model
以上。