#include #include #include "systemc.h" #include "systemc" #include #include #include "cpu_gatedlatch.hpp" SC_MODULE(test_cpu_gatedlatch) { sc_out d,e; sc_in clk; void test_cpu_gatedlatch_stim() { wait(); d.write(0); e.write(0); wait(); d.write(1); e.write(0); wait(); d.write(0); e.write(1); wait(); d.write(1); e.write(1); wait(); d.write(0); e.write(0); wait(); d.write(1); e.write(0); wait(); d.write(0); e.write(1); wait(); d.write(0); e.write(0); wait(); sc_stop(); } SC_CTOR(test_cpu_gatedlatch) { SC_THREAD(test_cpu_gatedlatch_stim); sensitive << clk.pos(); } }; int sc_main(int argc, char **argv) { int i; sc_signal sig_in_d,sig_in_e, sig_out_q, sig_out_nq; sc_clock TestClk("TestClk", 10, SC_NS, 0.5, 1, SC_NS); test_cpu_gatedlatch Stim1("Stimulus"); Stim1.e(sig_in_e); Stim1.d(sig_in_d); Stim1.clk(TestClk); cpu_gatedlatch DUT("cpu_gatedlatch"); DUT.in_d(sig_in_d); DUT.in_e(sig_in_e); DUT.out_q(sig_out_q); DUT.out_nq(sig_out_nq); sc_trace_file *Tf; Tf = sc_create_vcd_trace_file("trace_cpu_gatedlatch.dat"); sc_trace(Tf, sig_in_d, "D"); sc_trace(Tf, sig_in_e, "E"); sc_trace(Tf, sig_out_q, "Q"); sc_trace(Tf, sig_out_nq, "NQ"); sc_start(); sc_close_vcd_trace_file(Tf); return(0); }