本帖最后由 fpgaw 于 2010-7-6 05:31 编辑
module multi(a,b,multiout);
input [2:0] a,b;
output [5:0] multiout;
reg [5:0] multiout,result;
integer i;
always @ (a or b)
begin
result=0;
for (i=0;i<=2;i=i+1)
if (b)
result=result+(a<<i);
multiout=result;
end
endmodule
module multi_top;
reg [2:0] a,b;
wire [5:0] multiout;
parameter delay=50;
multi UUT(a,b,multiout);
initial
begin
a=0;
b=0;
end
always #50 a[0]=~a[0];
initial
begin
a[1]=1;
a[2]=0;
b[0]=1;
b[1]=0;
b[2]=1;
end
always @ (multiout)
begin
$display ("multiout=%b",multiout);
end
endmodule |