-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsim_main.cpp
More file actions
55 lines (46 loc) · 1.43 KB
/
Copy pathsim_main.cpp
File metadata and controls
55 lines (46 loc) · 1.43 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
50
51
52
53
54
55
#include "Vagriguard_top.h"
#include "verilated.h"
#include "renode_bus.h"
#include <cstdio>
#include <cstdlib>
// Global Verilator top instance
Vagriguard_top* top = nullptr;
// The Init function required by the Renode library
RenodeAgent* Init() {
return new RenodeAgent();
}
int main(int argc, char** argv) {
Verilated::commandArgs(argc, argv);
top = new Vagriguard_top;
RenodeAgent* agent = Init();
if (argc >= 3) {
printf("Connecting to Renode on ports %s / %s...\n", argv[1], argv[2]);
agent->connect(atoi(argv[1]), atoi(argv[2]), "127.0.0.1");
agent->simulate();
} else {
printf("Standalone mode - AgriGuard simulation\n");
printf("For Renode: %s <receiver_port> <sender_port>\n", argv[0]);
top->clk_16mhz = 0;
top->rst_n = 0;
top->pdm_data = 0;
top->spi_sck = 0;
top->spi_mosi = 0;
top->spi_csn = 1;
for (int i = 0; i < 10; i++) {
top->clk_16mhz = !top->clk_16mhz;
top->eval();
}
top->rst_n = 1;
for (int i = 0; i < 100; i++) {
top->clk_16mhz = !top->clk_16mhz;
top->eval();
if (top->clk_16mhz) {
printf("Cycle %d: pdm_clk_out=%d, fpga_irq=%d\n",
i/2, top->pdm_clk_out, top->fpga_irq);
}
}
}
top->final();
delete top;
return 0;
}