-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandomNumberGenerator_tb.cpp
47 lines (37 loc) · 1.11 KB
/
RandomNumberGenerator_tb.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
/* Created by Hamna Mohiuddin @hamnamohi as a part of the Google Summer of Code 2024 Project. */
#include <iostream>
#include <verilated.h>
#include <verilated_vcd_c.h>
#include "VRandomNumberGenerator.h"
vluint64_t sim_time = 0;
int main(int argc, char** argv) {
Verilated::commandArgs(argc, argv);
VRandomNumberGenerator* dut = new VRandomNumberGenerator;
Verilated::traceEverOn(true);
VerilatedVcdC* m_trace = new VerilatedVcdC;
dut->trace(m_trace, 99);
m_trace->open("rng.vcd");
dut->clk = 0;
dut->rst_n = 0;
dut->enable = 0;
dut->eval();
m_trace->dump(sim_time++);
dut->rst_n = 1;
dut->eval();
m_trace->dump(sim_time++);
dut->enable = 1;
for (int i = 0; i < 2; ++i) {
dut->clk = !dut->clk;
dut->eval();
m_trace->dump(sim_time++);
if (dut->clk) {
std::cout << "Time: " << sim_time << std::endl;
int signed_number = dut->random_number;
std::cout << "Random Number: " << signed_number << std::endl;
}
}
dut->final();
m_trace->close();
delete dut;
return 0;
}