1)wire类型的变量不可以直接用 = 赋值啊,前面必须加上assign
2)module的例化,注意不是class,不能用new。
3)module的实例不能放在initial begin中。必须放在外面。
4)在sv中规定变量的定义,必须放在最前面,可以在initial begin中的最前面,也可以是initial begin外面,module中的最前面。可以即在module的最前面有一部分定义,在initial begin的最前面有一部分定义,只要module和initial begin中间没有其他内容即可。
// Code your testbench here
// or browse Examples
module test(mode1, mode2,out);
input [1:0] mode1;
input [1:0] mode2;
output reg[10:0] out;//注意时reg类型的,如果是wire类型的 14行和17行会赋值失败的。
always@(*)begin
if(mode1==0 && mode2==2)begin
out = 100; //line 14
end
else begin
out = 33; //line 17 wire类型只能使用assign赋值
end
end
endmodule
module dut;
reg [10:0] ans ;
reg [1:0] a;
reg [1:0] b;
test t1(.mode1(a),.mode2(b),.out(ans)) ; //注意module的例化和class的例化不一样哦,不是new
/不能放在initial begin中,放在initial begin中会报错。
//initial begin时不可综合的,用来做测试的,所以里面不能定义module的例化。而且initial begin时在0时刻就开始执行的,只执行一次的。
initial begin
#1;
a=0;
b=0;
#2;
a=0;
b=2;
#1
$display("the out of t1",ans);
end
endmodule;