Escolar Documentos
Profissional Documentos
Cultura Documentos
----------------------------------------------------------------------
input s;
input r;
input clk;
output q;
output qb;
reg q;
reg qb;
always@(posedge clk)
begin
if(s==0 & r==0)
q=q;
else if(s==0 & r==1)
q=1'b0;
else if(s==1 & r==0)
q=1'b1;
else
q=1'b0;
qb=~q;
end
endmodule
end
endmodule
-------------------------------------------------------------------
output q;
reg q;
always @(posedge clk)
begin
if (en==0)
q=1'b0;
else
q=d;
end
endmodule
end
endmodule
q=4'b0000;
else
q<=q+1;
endmodule
rst = 0;
#50;
rst=1;
end
endmodule
-----------------------------------------------------------------
reg load;
wire [8:0] sum;
seriadd uut (
.a(a),
.b(b),
.clk(clk),
.load(load),
.sum(sum)
);
initial clk=1'b0;
always #10 clk=~clk;
initial begin
a =8'd100;
b =8'd25;
load = 0;
#10;
load=1;
#10;
load=0;
#80;
$display("a=%d",a,"b=%d",b,"sum=%d",sum);
end
endmodule
------------------------------------------------------------------------------------------
initial begin
a = 8'd25;
b = 8'd25;
#100;
a=8'd23;
b=8'd20;
#100;
end
endmodule
----------------------------------------------------------------------------------------