-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMemory.cpp
More file actions
47 lines (36 loc) · 791 Bytes
/
Copy pathMemory.cpp
File metadata and controls
47 lines (36 loc) · 791 Bytes
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
/*
* @ASCK
*/
#include <systemc.h>
SC_MODULE (Memory) {
sc_in <bool> r_nw;
sc_in <sc_uint<13>> addr;
sc_in <sc_int<8>> data;
sc_out <sc_int<8>> out;
/*
** module global variables
*/
sc_int<8> mem[8192] = {0}; // 2^13 rows
bool done = false;
SC_CTOR (Memory){
SC_METHOD (process);
sensitive << r_nw << addr << data;
}
void process () {
if(done){
return;
}
if(addr.read() < 8192){
if(r_nw.read()){
out.write(mem[addr.read()]);
}
else{
mem[addr.read()] = data.read();
out.write(mem[addr.read()]);
}
}
else{
out.write(0);
}
}
};