summaryrefslogtreecommitdiff
path: root/verilog/tbdatapath.cpp
blob: ff7d3b827b9c06c79e22ce22dac648668df120d8 (plain) (blame)
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
69
70
71
72
73
#include<memory>

#include<iostream>
#include<iomanip>
#include<bitset>

#include <verilated.h>

#include "svdpi.h"

#include "Vdatapath.h"
#include "Vdatapath__Dpi.h"

#include "tbdatapath.h"

int main(int argc, char** argv, char** env) {

	if (false && argc && argv && env) {}

	Verilated::mkdir("log_datapath");

	const std::unique_ptr<VerilatedContext> contextp {new VerilatedContext};
	contextp->commandArgs(argc, argv);
	contextp->debug(0);
	contextp->traceEverOn(true);
	contextp->randReset(2);
	contextp->randReset(2);

	const std::unique_ptr<Vdatapath> top{new Vdatapath{contextp.get(), "TOP"}};

	contextp->timeInc(1);
	top->clk = 0;
	top->rst = 1;

	top->eval();

	contextp->timeInc(1);
	top->clk = 1;
	top->rst = 1;

	top->eval();

	contextp->timeInc(1);
	top->clk = 0;
	top->rst = 0;

	top->eval();

	for (int i = 0; i < 75; i++) {
		contextp->timeInc(1);
		top->clk = !top->clk;
		top->eval();
	}

	const svScope scope = svGetScopeFromName("TOP.datapath.reg0");
	assert(scope);
	svSetScope(scope);

	uint32_t reg_addr;
	uint32_t reg_val;
	for (int i = 1; i < 6; i++) {
		reg_addr = i;
		reg_val = 0;
		top->get_reg_value(&reg_addr, &reg_val);
		std::cout << "Register: " << i << " Value: " << std::hex << reg_val << std::endl;
	}

	top->final();

	return 0;

	
}