Defining different parameter value for simulation and synthesis

蓝咒 提交于 2021-01-27 17:12:31

问题


I'm using systemVerilog and I have a package that holds some of my modules parameter values (for example parameter SPI_RATE = 2_000_000;). Is there any way I can set one value for simulation and a different one for synthesis? (I'm using ModelSim). For example I would like something like:

if(IN_SIM) begin
parameter SPI_RATE = 2_000_000;
end
else begin
parameter SPI_RATE = 1_000_000;
end

Thanks!


回答1:


Yes, that's possible. SystemVerilog supports conditional compiler directives such as `ifdef, `ifndef, `else, `elsif, and `endif. Note that those directives are using a grave accent (ASCII 0x60) and not a normal apostrophe (ASCII 0x27).

Furthermore, most synthesis tools support the macro identifier SYNTHESIS. So, you could do the following:

`ifdef SYNTHESIS
  parameter SPI_RATE = 1_000_000;
`else
  parameter SPI_RATE = 2_000_000;    
`endif 



回答2:


Yes. You can set a macro from the command line in any simulation using the +define plusarg, eg:

+define+SPI_RATE=2_000_000

Then somewhere in your code, you can say

parameter SPI_RATE = `SPI_RATE;

And in your synthesiser there will be a mechanism for setting the value of a macro: read the instructions for your synthesiser.




回答3:


With Synplify Pro, you can use the /*synthesis translate_off */ /*synthesis translate_off */ to accomplish this, a similar construct is usable in VHDL with appropriate syntax/comment changes. Xilinx Vivado uses // synthesis translate_off and // synthesis translate_on

const logic IN_SIM = 1'b0
/*synthesis translate_off */
    || 1'b1
/*synthesis translate_on */
    ;

The advantage of this construct is that it doesn't require any external scripting changes.



来源:https://stackoverflow.com/questions/60946670/defining-different-parameter-value-for-simulation-and-synthesis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!