summaryrefslogtreecommitdiff
path: root/cpu8/cpu_and/cpu_and.cpp
blob: 17e5f0f7db693bea51ea30a7fec71b6257df9bbd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include <iomanip>

#include "systemc.h"

#include "cpu_and.hpp"

SC_MODULE(test_cpu_and)
{
	sc_signal<bool> a,b,c;
	sc_clock TestClk;

	cpu_and circ_and;

	void apply_test()
	{
		a = 0; b = 0;
		wait();
		a = 1; b = 0;
		wait();
		a = 0; b = 1;
		wait();
		a = 1; b = 1;
		wait();
		sc_stop();
	}

	void monitor_signals()
	{
		cout << "Time" << endl;
		while (true)
		{
			cout << std::setw(5) << sc_time_stamp() << " ";
			cout << std::setw(2) << a.read() << " ";
			cout << std::setw(2) << b.read() << " ";
			cout << std::setw(2) << c.read() << " ";
			cout << endl;
			wait();
		}
	}

	SC_CTOR(test_cpu_and):
	TestClk("TestClk", 10, SC_NS),
	circ_and("cpu_AND") 
	{
		circ_and.in_a(a);
		circ_and.in_b(b);
		circ_and.out_c(c);
		SC_THREAD(monitor_signals);
		sensitive << TestClk;
		SC_THREAD(apply_test);
		sensitive << TestClk;
		
	}
};

int sc_main(int argc, char **argv) {
	test_cpu_and test_and("cpu_and_test");

	sc_start();

	return(0);
}