#include "systemc.h" SC_MODULE (testbench) { //Note that we put our input ports from our model //as output ports and output ports as input ports. //This is because we want to write to the inputs //of the model to test different cases and read //the outputs of the model to verify correctness sc_out > A_p,B_p; sc_out CIN_p; sc_in > SUM_p; sc_in COUT_p; //Declare a thread called "process" in the constructor //block of the testbench. A SC_THREAD has the ability to //suspend itself using wait statements. SC_CTOR (testbench) { SC_THREAD (process); } //Define the functionality of the "process" thread. void process() { //Case 1 //Note to Assign a value to a port of type logic //you must use SC_LOGIC_1 or SC_LOGIC_0 A_p = "0000"; B_p = "0000"; CIN_p = SC_LOGIC_0; wait (5, SC_NS); //Allow signals to set assert ( SUM_p.read() == "0000" ); //The assert signal assert ( COUT_p.read() == SC_LOGIC_0 ); //checks the output wait (10, SC_NS); print(); //Case 2 A_p = "0000"; B_p = "0000"; CIN_p = SC_LOGIC_1; wait (5, SC_NS); assert ( SUM_p.read() == "0001" ); assert ( COUT_p.read() == SC_LOGIC_0 ); wait (10, SC_NS); print(); //Add 4 More Test Cases sc_stop(); //End Simulation } //Utility Function That Prints the Designs Inputs and Outputs void print() { //Insert Code Here to Print Inputs and Outputs to Monitor } };