如何根据条件给parameter赋值?
时间:10-02
整理:3721RD
点击:
ex:
test.v
module test(
a,b
);
parameter AA = 1;
input a;
output b;
assign b = AA==1'b1 ? a : 0;
endmodule
tb.v
module tb();
parameter PAR_A = 0;
//int width;
//scanf(width);
//if(width == 10)PAR_A=0;
//else if(width == 20)PAR_A=1;
test #(.AA(PAR_A)) (
.a(1'b1),
.b()
);
endmodule
根据width的值,我希望有时PAR_A = 1, 有时PAR_A=0。
该如何做?
环境支持systemverilog,但是tb.v不能改为tb.sv
test.v
module test(
a,b
);
parameter AA = 1;
input a;
output b;
assign b = AA==1'b1 ? a : 0;
endmodule
tb.v
module tb();
parameter PAR_A = 0;
//int width;
//scanf(width);
//if(width == 10)PAR_A=0;
//else if(width == 20)PAR_A=1;
test #(.AA(PAR_A)) (
.a(1'b1),
.b()
);
endmodule
根据width的值,我希望有时PAR_A = 1, 有时PAR_A=0。
该如何做?
环境支持systemverilog,但是tb.v不能改为tb.sv
