其他分享
首页 > 其他分享> > [SV]SystemVerilog中define的用法

[SV]SystemVerilog中define的用法

作者:互联网

SystemVerilog中define的一种用法,見下面的例子:

module top ;
 
  `define A_SRAM_RW(dst_cc_num,src_cc_num)\
     if(strm_sel[``dst_cc_num``] == 1'b1)begin\
       force top.my_dut.strm_in``dst_cc_num``_en = top.my_dut.strm_in``src_cc_num``_en;\
     end
 
  initial begin
    `A_SRAM_RW(1,0)
    `A_SRAM_RW(2,0)
  end
 
endmodule

result:

module top;
  initial begin
     if(strm_sel[1] == 1'b1)begin
       force top.my_dut.strm_in1_en = top.my_dut.strm_in0_en;
     end
     if(strm_sel[2] == 1'b1)begin
       force top.my_dut.strm_in2_en = top.my_dut.strm_in0_en;
     end
  end
endmodule

 

       上面的例子中,dst_cc_num和src_cc_num是要传进来的参数,引用传进来的参数时要在参数前和后加``,不接收传进来的变量,比如

generate 
  for(genvar jj=1;jj<`CC_NUM;jj++)begin
    `A_SRAM

标签:en,cc,top,SV,num,strm,dut,SystemVerilog,define
来源: https://blog.csdn.net/gsjthxy/article/details/97030730