57 lines
1.1 KiB
C++
57 lines
1.1 KiB
C++
#include "Vtop.h"
|
|
#include "verilated.h"
|
|
|
|
#include <stdint.h>
|
|
#include <iostream>
|
|
#include <random>
|
|
|
|
#include "verilated_vcd_c.h"
|
|
|
|
struct state {
|
|
VerilatedContext *ctx;
|
|
Vtop *vtop;
|
|
VerilatedVcdC *trace;
|
|
};
|
|
|
|
void posedge(state &state) {
|
|
state.ctx->timeInc(1);
|
|
state.vtop->clk_12m = 1;
|
|
state.vtop->eval();
|
|
state.trace->dump(state.ctx->time());
|
|
|
|
state.ctx->timeInc(1);
|
|
state.vtop->clk_12m = 0;
|
|
state.vtop->eval();
|
|
state.trace->dump(state.ctx->time());
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
VerilatedContext *vctx = new VerilatedContext;
|
|
Verilated::traceEverOn(true);
|
|
Vtop *vtop = new Vtop(vctx);
|
|
|
|
if (argc != 2) {
|
|
std::cout << "Run with argument for destination!" << std::endl;
|
|
return 1;
|
|
}
|
|
|
|
VerilatedVcdC *trace = new VerilatedVcdC;
|
|
vtop->trace(trace, 99);
|
|
trace->open(argv[1]);
|
|
std::cout << "(writing trace to " << argv[1] << ")" << std::endl;
|
|
|
|
state state = {
|
|
.ctx = vctx,
|
|
.vtop = vtop,
|
|
.trace = trace,
|
|
};
|
|
|
|
|
|
for (int i = 0; i < 2<<24; i++) {
|
|
posedge(state);
|
|
}
|
|
|
|
state.trace->close();
|
|
}
|
|
|