tdc state machine
This commit is contained in:
@@ -5,43 +5,66 @@
|
||||
#include "Vtop.h"
|
||||
|
||||
void tick(int tickcount, Vtop *tb, VerilatedVcdC* tfp) {
|
||||
tb->eval();
|
||||
if (tfp)
|
||||
tfp->dump(tickcount * 10 - 2);
|
||||
tb->i_clk = 1;
|
||||
tb->eval();
|
||||
if (tfp)
|
||||
tfp->dump(tickcount * 10);
|
||||
tb->i_clk = 0;
|
||||
tb->eval();
|
||||
if (tfp) {
|
||||
tfp->dump(tickcount * 10 + 5);
|
||||
tfp->flush();
|
||||
}
|
||||
tb->eval();
|
||||
if (tfp)
|
||||
tfp->dump(tickcount * 10 - 2);
|
||||
tb->i_clk = 1;
|
||||
tb->eval();
|
||||
if (tfp)
|
||||
tfp->dump(tickcount * 10);
|
||||
tb->i_clk = 0;
|
||||
tb->eval();
|
||||
if (tfp) {
|
||||
tfp->dump(tickcount * 10 + 5);
|
||||
tfp->flush();
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
// Call commandArgs first!
|
||||
Verilated::commandArgs(argc, argv);
|
||||
// Call commandArgs first!
|
||||
Verilated::commandArgs(argc, argv);
|
||||
|
||||
// Instantiate our design
|
||||
Vtop *tb = new Vtop;
|
||||
Verilated::traceEverOn(true);
|
||||
VerilatedVcdC* tfp = new VerilatedVcdC;
|
||||
// Instantiate our design
|
||||
Vtop *tb = new Vtop;
|
||||
Verilated::traceEverOn(true);
|
||||
VerilatedVcdC* tfp = new VerilatedVcdC;
|
||||
|
||||
tb->trace(tfp, 00);
|
||||
tfp->open("build/waveform.vcd");
|
||||
tb->trace(tfp, 00);
|
||||
tfp->open("build/waveform.vcd");
|
||||
|
||||
unsigned tickcount = 0;
|
||||
int last_led = tb->o_led;
|
||||
tb->i_resetN = 1;
|
||||
tb->i_start = 0;
|
||||
tb->i_stop = 0;
|
||||
unsigned tickcount = 0;
|
||||
int last_led = tb->o_led;
|
||||
for (int k = 0; k < 2; k++)
|
||||
tick(++tickcount, tb, tfp);
|
||||
|
||||
for(int k=0; k<(1 << 12); k++) {
|
||||
tick(++tickcount, tb, tfp);
|
||||
tb->i_resetN = 0;
|
||||
tick(++tickcount, tb, tfp);
|
||||
tb->i_resetN = 1;
|
||||
|
||||
if (last_led != tb->o_led) {
|
||||
printf("k = %7d, led = %d\n", k, tb->o_led);
|
||||
}
|
||||
for (int k = 0; k < 3; k++)
|
||||
tick(++tickcount, tb, tfp);
|
||||
|
||||
last_led = tb->o_led;
|
||||
}
|
||||
tb->i_start = 1;
|
||||
tick(++tickcount, tb, tfp);
|
||||
tb->i_start = 0;
|
||||
|
||||
for (int k = 0; k < 15; k++)
|
||||
tick(++tickcount, tb, tfp);
|
||||
|
||||
tb->i_stop = 1;
|
||||
tick(++tickcount, tb, tfp);
|
||||
tb->i_stop = 0;
|
||||
|
||||
for (int k = 0; k < 3; k++)
|
||||
tick(++tickcount, tb, tfp);
|
||||
|
||||
tb->i_resetN = 0;
|
||||
tick(++tickcount, tb, tfp);
|
||||
tb->i_resetN = 1;
|
||||
|
||||
for (int k = 0; k < 3; k++)
|
||||
tick(++tickcount, tb, tfp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user