-
Notifications
You must be signed in to change notification settings - Fork 0
/
memoryTB.cpp
68 lines (66 loc) · 1.77 KB
/
memoryTB.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef MEMORYTB_CPP
#define MEMORYTB_CPP
#include "Memory.h"
SC_MODULE(MEMORYTB)
{
sc_signal<sc_logic> clk, read_request, write_request, input_valid, ready;
sc_signal<sc_lv<32>> data_in, address_in, data_out;
Memory<32, 32> *UUT;
SC_CTOR(MEMORYTB)
{
UUT = new Memory<32, 32>("memory_instance");
(*UUT)(clk, data_in, address_in, read_request, write_request, input_valid, ready, data_out);
SC_THREAD(clocking);
SC_THREAD(scenario);
}
void clocking();
void scenario();
};
void MEMORYTB::clocking()
{
while (true)
{
clk = SC_LOGIC_0;
wait(10, SC_NS);
clk = SC_LOGIC_1;
wait(10, SC_NS);
}
}
void MEMORYTB::scenario()
{
while (true)
{
wait(10, SC_NS);
read_request = sc_logic_1;
data_in = 200;
address_in = 2;
wait(30, SC_NS);
read_request = sc_logic_0;
input_valid = SC_LOGIC_1;
write_request = sc_logic_1;
address_in = 5;
data_in = 255;
wait(20, SC_NS);
write_request = SC_LOGIC_0;
read_request = SC_LOGIC_1;
address_in = 5;
wait(30, SC_NS);
}
}
/*int sc_main(int argc, char *argv[])
{
MEMORYTB *TOP = new MEMORYTB("TB_INSTANCE");
sc_trace_file *VCDFile;
VCDFile = sc_create_vcd_trace_file("MEMORYTB");
sc_trace(VCDFile, TOP->clk, "clk");
sc_trace(VCDFile, TOP->read_request, "read_request");
sc_trace(VCDFile, TOP->write_request, "write_request");
sc_trace(VCDFile, TOP->input_valid, "input_valid");
sc_trace(VCDFile, TOP->ready, "ready");
sc_trace(VCDFile, TOP->data_in, "data_in");
sc_trace(VCDFile, TOP->data_out, "data_out");
sc_trace(VCDFile, TOP->address_in, "address_in");
sc_start(150, SC_NS);
return 0;
}*/
#endif