URL
https://opencores.org/ocsvn/eco32/eco32/trunk
[/] [eco32/] [trunk/] [fpga/] [mc-vl/] [main.cpp] - Diff between revs 309 and 310
Go to most recent revision |
Show entire file |
Details |
Blame |
View Log
Rev 309 |
Rev 310 |
Line 1... |
Line 1... |
/*
|
/*
|
* main.cpp -- simulation control
|
* main.cpp -- simulation control
|
*/
|
*/
|
|
|
|
|
|
#if VM_TRACE
|
|
#define VCD_NAME "dump.vcd"
|
|
#endif
|
|
|
|
#define DURATION_NAME "duration.dat" /* simulation duration file name */
|
|
#define RST_IN_OFF 145 /* trailing edge of rst_in, in ns */
|
|
#define HALF_PERIOD 10 /* half of clock period, in ns */
|
|
|
|
|
|
#include <iostream>
|
|
#include <fstream>
|
|
using namespace std;
|
|
|
#include "Veco32test.h"
|
#include "Veco32test.h"
|
#include "verilated.h"
|
#include "verilated.h"
|
|
|
|
#if VM_TRACE
|
|
#include "verilated_vcd_c.h"
|
|
#endif
|
|
|
|
|
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
Verilated::commandArgs(argc, argv);
|
Verilated::commandArgs(argc, argv);
|
Veco32test *top = new Veco32test;
|
Veco32test *top = new Veco32test;
|
vluint64_t numHalfCycles = 0;
|
#if VM_TRACE
|
top->clk_in = 0;
|
Verilated::traceEverOn(true);
|
|
VerilatedVcdC *tfp = new VerilatedVcdC;
|
|
top->trace(tfp, 99);
|
|
tfp->open(VCD_NAME);
|
|
#endif
|
|
ifstream durationFile(DURATION_NAME);
|
|
if (!durationFile.is_open()) {
|
|
cout << "Error: cannot open input file '"
|
|
<< DURATION_NAME
|
|
<< "'\n";
|
|
abort();
|
|
}
|
|
vluint64_t maxTime;
|
|
durationFile >> maxTime;
|
|
maxTime += RST_IN_OFF;
|
|
durationFile.close();
|
|
vluint64_t curTime = 0;
|
|
top->clk_in = 1;
|
top->rst_in_n = 0;
|
top->rst_in_n = 0;
|
while (numHalfCycles < 2 * 30000000) {
|
while (curTime <= maxTime) {
|
if (numHalfCycles == 2 * 145) {
|
if (top->rst_in_n == 0 && curTime >= RST_IN_OFF) {
|
top->rst_in_n = 1;
|
top->rst_in_n = 1;
|
}
|
}
|
top->eval();
|
top->eval();
|
|
#if VM_TRACE
|
|
tfp->dump(curTime);
|
|
#endif
|
top->clk_in = !top->clk_in;
|
top->clk_in = !top->clk_in;
|
numHalfCycles++;
|
curTime += HALF_PERIOD;
|
}
|
}
|
top->final();
|
top->final();
|
|
#if VM_TRACE
|
|
tfp->close();
|
|
delete tfp;
|
|
#endif
|
delete top;
|
delete top;
|
return 0;
|
return 0;
|
}
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.