//----------------------------------------------------- // This is my second Systemc Example // Design Name : first_counter // File Name : first_counter.cpp // Function : This is a 4 bit up-counter with // Synchronous active high reset and // with active high enable signal //----------------------------------------------------- #include "systemc.h" SC_MODULE (first_counter) { sc_in_clk clock ; // Clock input of the design sc_in reset ; // active high, synchronous Reset input sc_in enable; // Active high enable signal for counter sc_out > counter_out; // 4 bit vector output of the counter //------------Local Variables Here--------------------- sc_uint<4> count; //------------Code Starts Here------------------------- // Below function implements actual counter logic void incr_count () { // For threads, we need to have while true loop while (true) { // Wait for the event in sensitivity list to occure // In this example - positive edge of clock wait(); if (reset.read() == 1) { count = 0; counter_out.write(count); // If enable is active, then we increment the counter } else if (enable.read() == 1) { count = count + 1; counter_out.write(count); } } } // End of function incr_count // Below functions prints value of count when ever it changes void print_count () { while (true) { wait(); cout<<"@" << sc_time_stamp() << " :: Counter Value "<