#include "systemc.h"
#include "main.cpp"
#include "conio.h"
int sc_main(int argc, char* argv[]) {
sc_signal<bool> clock;
sc_signal<bool> reset;
sc_signal<bool> enable;
sc_signal<bool> load;
sc_signal<bool> up_down;
sc_signal<sc_uint<8> > counter_out;
sc_signal<sc_uint<8> > data;
int i = 0;
data = 0;
first_counter counter("COUNTER");
counter.clock(clock);
counter.reset(reset);
counter.enable(enable);
counter.data(data);
counter.up_down(up_down);
counter.load(load);
counter.counter_out(counter_out);
sc_start(1, SC_NS);
sc_trace_file *wf = sc_create_vcd_trace_file("counter");
sc_trace(wf, clock, "clock");
sc_trace(wf, data, "data");
sc_trace(wf, load, "load");
sc_trace(wf, reset, "reset");
sc_trace(wf, enable, "enable");
sc_trace(wf, up_down, "up_down");
sc_trace(wf, counter_out, "count");
reset = 0;
enable = 0;
load = 0;
up_down = 1;
for (i = 0; i < 5; i++) {
clock = 0;
sc_start(1, SC_NS);
clock = 1;
sc_start(1, SC_NS);
}
enable = 1;
reset = 0;
load = 0;
enable = 0;
cout << "@" << sc_time_stamp() << " De-Asserting reset\n" << endl;
for (i = 0; i < 5; i++) {
clock = 0;
sc_start(1, SC_NS);
clock = 1;
sc_start(1, SC_NS);
}
cout << "@" << sc_time_stamp() << " Asserting Enable\n" << endl;
enable = 1;
for (i = 0; i < 255; i++) {
clock = 0;
sc_start(1, SC_NS);
clock = 1;
sc_start(1, SC_NS);
}
enable = 1;
up_down = 0;
for (i = 0; i < 255; i++) {
clock = 0;
sc_start(1, SC_NS);
clock = 1;
sc_start(1, SC_NS);
}
cout << "@" << sc_time_stamp() << " De-Asserting Enable\n" << endl;
enable = 0;
cout << "@" << sc_time_stamp() << " Terminating simulation\n" << endl;
sc_close_vcd_trace_file(wf);
_getch();
return 0;
}