-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtop.cpp
More file actions
49 lines (47 loc) · 1.24 KB
/
top.cpp
File metadata and controls
49 lines (47 loc) · 1.24 KB
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
#include "top.h"
void top::transciever(void)
{
cout << "Waiting for positive edge" << endl;
wait(clk.posedge_event());
ren_lc.write(sc_bit('0'));
index = "00001000";
cout << index << endl;
for(int i=0;i<8;i++)
{
sc_logic ibit = (sc_logic) index[7-i];
cout << "Sending bit " << i+1 << " as " << ibit << " at time " << sc_time_stamp() << endl;
index_lc.write(index);
}
wait(clk.posedge_event());
ren_lc.write(sc_bit('1'));
index_lc.write(high_impedance);
wait(valid_lc.posedge_event());
begin_RRAM_read.notify();
wait(done_RRAM_read);
cout << sc_time_stamp() << endl;
wait(clk.posedge_event());
wait(5,SC_NS);
cout << sc_time_stamp() << endl;
ren_lc.write(sc_bit('1'));
wen_lc.write(sc_bit('0'));
wait(1,SC_MS);
wait(clk.posedge_event());
wait(5,SC_NS);
wen_lc.write(sc_bit('1'));
}
void top::top_RRAM_read(void)
{
for(;;)
{
data = data_lc.read();
cout << "Byte number " << 1 << " read as " << data.to_string(SC_BIN) << endl;
for (int i=0;i<RRAM_bytes_read-1;i++)
{
wait(clk.negedge_event() & valid_lc.posedge_event());
data = data_lc.read();
cout << "Byte number " << i+2 << " read as " << data.to_string(SC_BIN) << endl;
}
done_RRAM_read.notify();
wait();
}
}