条件编译是根据不同的条件选择执行,则:
module compile(A,B,out);
input A,B;
output out;
`ifdef add
assign out = A+B;
`else
assign out = A-B;
`endif
endmodule
add是表示宏名的,可以使用`define进行定义,即:
`define add
各个模块之间也可以使用条件编译,即:
`define add
`ifdef add
module compile();
`else
module ADD();
`endif
可以根据实际情况进行选择性的编译。