//================================
// ex6-3 Half Adder circuit
module EX10_11( A,B,Cin ,Cout ,Sum);
input A,B,Cin; // 1位元輸入
output reg Cout , Sum ; // Output 1位元輸出
always@ ( A,B) begin
{Cout,Sum}= A+B+Cin;
end
endmodule
//================================
// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps
module Test_bench;
// Inputs
reg A,B,Cin;
// Outputs
wire Cout , Sum ;
// Instantiate the Unit Under Test (UUT)
// ex6-3 Half Adder circuit
EX10_11 UUT (
.A(A),
.B(B),
.Cin(Cin),
.Cout(Cout),
.Sum(Sum)
);
initial begin
$monitor( A,B,Cin,Cout ,Sum);
//Apply inputs
A=1'b0; B=1'b0;Cin=1'b0;
#100;
{A,B,Cin}=3'b001;
#100;
{A,B,Cin}=3'b010;
#100;
{A,B,Cin}=3'b011;
#100;
{A,B,Cin}=3'b100;
#100;
{A,B,Cin}=3'b101;
#100;
{A,B,Cin}=3'b110;
#100;
{A,B,Cin}=3'b111;
#100;
end
initial begin
#800 $stop;
end
沒有留言:
張貼留言