blinky_with_pll, works on hardware but verilator does not know how to handle the SB40_PLL_CORE yet
This commit is contained in:
47
blinky_with_pll/blinky.cpp
Normal file
47
blinky_with_pll/blinky.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "verilated.h"
|
||||
#include "verilated_vcd_c.h"
|
||||
#include "Vblinky.h"
|
||||
|
||||
void tick(int tickcount, Vblinky *tb, VerilatedVcdC* tfp) {
|
||||
tb->eval();
|
||||
if (tfp)
|
||||
tfp->dump(tickcount * 10 - 2);
|
||||
tb->sysclk = 1;
|
||||
tb->eval();
|
||||
if (tfp)
|
||||
tfp->dump(tickcount * 10);
|
||||
tb->sysclk = 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);
|
||||
|
||||
// Instantiate our design
|
||||
Vblinky *tb = new Vblinky;
|
||||
Verilated::traceEverOn(true);
|
||||
VerilatedVcdC* tfp = new VerilatedVcdC;
|
||||
|
||||
tb->trace(tfp, 00);
|
||||
tfp->open("build/waveform.vcd");
|
||||
|
||||
unsigned tickcount = 0;
|
||||
int last_led = tb->o_led;
|
||||
|
||||
for(int k=0; k<(1 << 12); k++) {
|
||||
tick(++tickcount, tb, tfp);
|
||||
|
||||
if (last_led != tb->o_led) {
|
||||
printf("k = %7d, led = %d\n", k, tb->o_led);
|
||||
}
|
||||
|
||||
last_led = tb->o_led;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user