/
main.cpp
54 lines (47 loc) · 1.26 KB
/
main.cpp
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
/*
* main.cpp
*
* Created on: Nov 4, 2015
* Author: rkouere
*/
#include "systemc.h"
//#include "ram.h"
//#include "ram2.h"
#include "ram.h"
int sc_main(int argc, char * argv[]) {
try {
//Instantiate Modules
Memory mem("main_memory");
CPU cpu("cpu");
//Signals
sc_buffer<Memory::Function> sigMemFunc;
sc_buffer<Memory::RetCode> sigMemDone;
sc_signal<int> sigMemAddr;
sc_signal_rv<32> sigMemData;
// The clock that will drive the CPU and Memory
sc_clock clk;
// Connecting module ports with signals
mem.Port_Func(sigMemFunc);
mem.Port_Addr(sigMemAddr);
mem.Port_Data(sigMemData);
mem.Port_Done(sigMemDone);
cpu.Port_MemFunc(sigMemFunc);
cpu.Port_MemAddr(sigMemAddr);
cpu.Port_MemData(sigMemData);
cpu.Port_MemDone(sigMemDone);
mem.Port_CLK(clk);
cpu.Port_CLK(clk);
cout << "Installing trace signals. Output in ram_trace.vcd " << endl;
sc_trace_file *wf = sc_create_vcd_trace_file("ram_trace");
sc_trace(wf, clk, "clock");
sc_trace(wf, sigMemFunc, "function");
sc_trace(wf, sigMemAddr, "sigMemAddr");
sc_trace(wf, sigMemData, "sigMemData");
cout << " Running (press CTRL + C to exit)... " << endl;
// Start Simulation
sc_start();
} catch (const std::exception & e) {
cerr << e.what() << endl;
}
return 0;
}