-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreceiver.cpp
45 lines (38 loc) · 1.06 KB
/
receiver.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
#include <stdlib.h>
#include <iostream>
#include <cstdlib>
#include <verilated.h>
#include <verilated_vcd_c.h>
#include "Vreceiver.h"
#define MAX_SIM_TIME 200000
int sim_time = 0;
int posedge_cnt = 0;
int main(int argc, char** argv, char** env) {
srand (time(NULL));
Verilated::commandArgs(argc, argv);
Vreceiver *circuit = new Vreceiver;
Verilated::traceEverOn(true);
VerilatedVcdC *m_trace = new VerilatedVcdC;
circuit->trace(m_trace, 5);
m_trace->open("receiver-trace.vcd");
std::vector<int> data = {1, 0, 0, 0, 0, 1, 1, 0, 1, 0};
int count = 0;
while (sim_time < MAX_SIM_TIME) {
circuit->i_rx = 1;
if ((sim_time >= MAX_SIM_TIME/8 ) && (data.size() != 0)) {
circuit->i_rx = data.back();
count++;
if (count == 5000) {
data.pop_back();
count = 0;
}
};
circuit->i_clk ^= 1;
circuit->eval();
m_trace->dump(sim_time);
sim_time++;
}
m_trace->close();
delete circuit;
exit(EXIT_SUCCESS);
}