`timescale 1ns /1ps
module block_unblock(
input Clk,
input Reset_n,
input a,
input b,
input c,
output reg [1:0]out
);
reg [1:0] d;
always@(posedge Clk or negedge Reset_n)if(Reset_n ==0)begin
out <=0;
d <=0;
end
else begin
out = d + c;
d = a + b;// out <= d + c;// d <= a + b;
end
endmodule
仿真文件程序
`timescale 1ns /1ns
module block_unblock_tb();
reg Clk;
reg Reset_n;
reg a;
reg b;
reg c;
wire [1:0]out;
block_unblock block_test(.Clk(Clk),.Reset_n(Reset_n),.a(a),.b(b),.c(c),.out(out));
initial Clk <=1;
always #10 Clk <=!Clk;
initial begin
Reset_n <=0;
a =0; b =0; c =0;
#200;
Reset_n =1;
#200;
a =0; b =0; c =0;
#200;
a =0; b =0; c =1;
#200;
a =0; b =1; c =0;
#200;
a =0; b =1; c =1;
#200;
a =1; b =0; c =0;
#200;
a =1; b =0; c =1;
#200;
a =1; b =1; c =0;
#200;
a =1; b =1; c =1;
#200;
$stop;
end
endmodule