iMackshun

OneBitFullAdderTB.v

Feb 12th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.46 KB | None | 0 0
  1. // ***********************************************************
  2. // One-Bit Adder Testbench:
  3. // This testbench tests the functionality of a one-bit full adder
  4. // ***********************************************************
  5. //Marks the beginning of the module.
  6. module OneBitFullAdderTB();
  7. //Create three registers, which will be used to store data as inputs to the Adder.
  8. reg Ain;
  9. reg Bin;
  10. reg CarryIn;
  11. //Creates two wires, which will be used to store the output of the Adder.
  12. wire SumOut;
  13. wire CarryOut;
  14. //Creates an instance of a Full Bit Adder, with the previously declared variables being passed into it.
  15. OneBitFullAdder FA0(Ain, Bin, CarryIn, SumOut, CarryOut);
  16. //Marks the beginning of the procedural block, which is to execute once at time 0.
  17. initial
  18. begin
  19. //Assigns values to the inputs.
  20. Ain = 1'b0;
  21. Bin = 1'b0;
  22. CarryIn = 1'b0;
  23. //Delay.
  24. #10;
  25. //Assigns values to the inputs.
  26. Ain = 1'b0;
  27. Bin = 1'b1;
  28. CarryIn = 1'b0;
  29. //Delay.
  30. #10;
  31. //Assigns values to the inputs.
  32. Ain = 1'b1;
  33. Bin = 1'b1;
  34. CarryIn = 1'b0;
  35. //Delay.
  36. #10;
  37. //Assigns values to the inputs.
  38. Ain = 1'b1;
  39. Bin = 1'b1;
  40. CarryIn = 1'b1;
  41. //Delay.
  42. #10;
  43. //Marks the end of the simulation(?)
  44. $finish;
  45. //Marks the end of the procedural block.
  46. end
  47. //Marks the beginning of the procedural block.
  48. initial
  49. begin
  50. //Outputs to the console.
  51. $monitor("Ain=%1b, Bin=%1b, Carryin=%b, SumOut=%b, CarryOut=%b, time=%t\n", Ain, Bin, CarryIn,
  52. SumOut, CarryOut, $time);
  53. //Marks the end of the block.
  54. end
  55. endmodule
Advertisement
Add Comment
Please, Sign In to add comment