Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ***********************************************************
- // One-Bit Adder Testbench:
- // This testbench tests the functionality of a one-bit full adder
- // ***********************************************************
- //Marks the beginning of the module.
- module OneBitFullAdderTB();
- //Create three registers, which will be used to store data as inputs to the Adder.
- reg Ain;
- reg Bin;
- reg CarryIn;
- //Creates two wires, which will be used to store the output of the Adder.
- wire SumOut;
- wire CarryOut;
- //Creates an instance of a Full Bit Adder, with the previously declared variables being passed into it.
- OneBitFullAdder FA0(Ain, Bin, CarryIn, SumOut, CarryOut);
- //Marks the beginning of the procedural block, which is to execute once at time 0.
- initial
- begin
- //Assigns values to the inputs.
- Ain = 1'b0;
- Bin = 1'b0;
- CarryIn = 1'b0;
- //Delay.
- #10;
- //Assigns values to the inputs.
- Ain = 1'b0;
- Bin = 1'b1;
- CarryIn = 1'b0;
- //Delay.
- #10;
- //Assigns values to the inputs.
- Ain = 1'b1;
- Bin = 1'b1;
- CarryIn = 1'b0;
- //Delay.
- #10;
- //Assigns values to the inputs.
- Ain = 1'b1;
- Bin = 1'b1;
- CarryIn = 1'b1;
- //Delay.
- #10;
- //Marks the end of the simulation(?)
- $finish;
- //Marks the end of the procedural block.
- end
- //Marks the beginning of the procedural block.
- initial
- begin
- //Outputs to the console.
- $monitor("Ain=%1b, Bin=%1b, Carryin=%b, SumOut=%b, CarryOut=%b, time=%t\n", Ain, Bin, CarryIn,
- SumOut, CarryOut, $time);
- //Marks the end of the block.
- end
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment