bram: more refactor
This commit is contained in:
parent
285b6d9501
commit
c7dadc5681
|
@ -1,10 +1,5 @@
|
||||||
#include <memory>
|
|
||||||
#include <cassert>
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <cstdint>
|
|
||||||
#include <cstring>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <verilated.h>
|
#include <verilated.h>
|
||||||
|
@ -118,9 +113,8 @@ static void refresh_data() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
Verilated::commandArgs(argc, argv);
|
|
||||||
Verilated::traceEverOn(true);
|
Verilated::traceEverOn(true);
|
||||||
tb = new TB<Vbram_interface>();
|
tb = new TB<Vbram_interface>(argc, argv);
|
||||||
|
|
||||||
printf("test basic read/write\n");
|
printf("test basic read/write\n");
|
||||||
refresh_data();
|
refresh_data();
|
||||||
|
|
|
@ -1,13 +1,19 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <verilated.h>
|
||||||
|
|
||||||
/* https://zipcpu.com/blog/2017/06/21/looking-at-verilator.html */
|
/* https://zipcpu.com/blog/2017/06/21/looking-at-verilator.html */
|
||||||
template <class TOP> class TB {
|
template <class TOP> class TB {
|
||||||
int tick_count;
|
int tick_count;
|
||||||
int bailout;
|
int bailout;
|
||||||
|
|
||||||
public: TOP mod;
|
public:
|
||||||
TB(int _bailout = 0) : mod(), bailout(_bailout) {
|
TOP mod;
|
||||||
|
VerilatedContext vc;
|
||||||
|
|
||||||
|
TB(int argc, char *argv[], int _bailout = 0) : mod(), bailout(_bailout), vc() {
|
||||||
|
vc.commandArgs(argc, argv);
|
||||||
|
vc.traceEverOn(true);
|
||||||
mod.clk = 0;
|
mod.clk = 0;
|
||||||
tick_count = 0;
|
tick_count = 0;
|
||||||
}
|
}
|
||||||
|
@ -19,10 +25,10 @@ template <class TOP> class TB {
|
||||||
virtual void run_clock() {
|
virtual void run_clock() {
|
||||||
mod.clk = !mod.clk;
|
mod.clk = !mod.clk;
|
||||||
mod.eval();
|
mod.eval();
|
||||||
Verilated::timeInc(1);
|
vc.timeInc(1);
|
||||||
mod.clk = !mod.clk;
|
mod.clk = !mod.clk;
|
||||||
mod.eval();
|
mod.eval();
|
||||||
Verilated::timeInc(1);
|
vc.timeInc(1);
|
||||||
tick_count++;
|
tick_count++;
|
||||||
|
|
||||||
if (bailout > 0 && tick_count >= bailout)
|
if (bailout > 0 && tick_count >= bailout)
|
||||||
|
|
Loading…
Reference in New Issue