verilog条件编译

前言

在设计流程中,可能有的模块是不使用的,但某时候可能需要使用。

不同代码段的选择就可以使用条件编译。

 

流程

使用`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

以上。

原文地址:https://www.cnblogs.com/kingstacker/p/12195638.html