diff options
author | Yann Herklotz <git@yannherklotz.com> | 2021-11-11 12:25:30 +0000 |
---|---|---|
committer | Yann Herklotz <git@yannherklotz.com> | 2021-11-11 12:25:30 +0000 |
commit | 2db488419e0ccca350dcc6e2442cb7bbc07f68ab (patch) | |
tree | 35c94691f2d63d589b9fa7ac07ac372b4a43cb13 /driver | |
parent | 1595abe367aa4291386029dab5ac0d2d2de0ff81 (diff) | |
download | vericert-2db488419e0ccca350dcc6e2442cb7bbc07f68ab.tar.gz vericert-2db488419e0ccca350dcc6e2442cb7bbc07f68ab.zip |
Add a Verilator driver
Diffstat (limited to 'driver')
-rw-r--r-- | driver/verilator_main.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/driver/verilator_main.cpp b/driver/verilator_main.cpp new file mode 100644 index 0000000..4561158 --- /dev/null +++ b/driver/verilator_main.cpp @@ -0,0 +1,35 @@ +#include <stdlib.h> +#include <stdio.h> +#include "Vmain.h" +#include "verilated.h" + +int main(int argc, char **argv) { + // Initialize Verilators variables + Verilated::commandArgs(argc, argv); + + // Create an instance of our module under test + Vmain *tb = new Vmain; + + tb->clk = 0; + tb->start = 0; + tb->reset = 0; + tb->eval(); tb->clk = 1; tb->eval(); tb->clk = 0; tb->eval(); + tb->reset = 1; + tb->eval(); tb->clk = 1; tb->eval(); tb->clk = 0; tb->eval(); + tb->reset = 0; + tb->eval(); tb->clk = 1; tb->eval(); tb->clk = 0; tb->eval(); + + int cycles = 1; + + // Tick the clock until we are done + while(!tb->finish) { + tb->clk = 1; + tb->eval(); + tb->clk = 0; + tb->eval(); + cycles++; + } + + printf("cycles: %d\nfinished: %d\n", cycles, (unsigned)tb->return_val); + exit(EXIT_SUCCESS); +} |