Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
212 lines (187 sloc) 5.73 KB
////////////////////////////////////////////////////////////////////////////////
//
// Filename: ./testb.h
//
// Project: VideoZip, a ZipCPU SoC supporting video functionality
//
// DO NOT EDIT THIS FILE!
// Computer Generated: This file is computer generated by AUTOFPGA. DO NOT EDIT.
// DO NOT EDIT THIS FILE!
//
// CmdLine: ../../../autofpga/trunk/sw/autofpga ../../../autofpga/trunk/sw/autofpga -o . global.txt bkram.txt buserr.txt clkcounter.txt dlyarbiter.txt flash.txt gpio.txt icape.txt mdio.txt pic.txt pwrcount.txt rtcdate.txt rtcgps.txt spio.txt version.txt wbmouse.txt wboledbw.txt wbpmic.txt wbuconsole.txt zipmaster.txt gps.txt sdspi.txt hdmi.txt xdc.txt xpander.txt sdvidram.txt genclk.txt vidarbiter.txt
//
// Creator: Dan Gisselquist, Ph.D.
// Gisselquist Technology, LLC
//
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017, Gisselquist Technology, LLC
//
// This program is free software (firmware): you can redistribute it and/or
// modify it under the terms of the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program. (It's in the $(ROOT)/doc directory. Run make with no
// target there if the PDF file isn't present.) If not, see
// <http://www.gnu.org/licenses/> for a copy.
//
// License: GPL, v3, as defined and found on www.gnu.org,
// http://www.gnu.org/licenses/gpl.html
//
//
////////////////////////////////////////////////////////////////////////////////
//
//
#ifndef TESTB_H
#define TESTB_H
#include <stdio.h>
#include <stdint.h>
#include <verilated_vcd_c.h>
#include "tbclock.h"
#include <tbclock.h>
template <class VA> class TESTB {
public:
VA *m_core;
bool m_changed;
VerilatedVcdC* m_trace;
bool m_done;
unsigned long m_time_ps;
TBCLOCK m_clk;
TBCLOCK m_hdmi_out_clk;
TBCLOCK m_hdmi_in_clk;
TBCLOCK m_hdmi_in_hsclk;
TBCLOCK m_clk_200mhz;
TESTB(void) {
m_core = new VA;
m_time_ps = 0ul;
m_trace = NULL;
m_done = false;
Verilated::traceEverOn(true);
m_clk.init(10000); // 100.00 MHz
m_hdmi_out_clk.init(6734); // 148.50 MHz
m_hdmi_in_clk.init(6734); // 148.50 MHz
m_hdmi_in_hsclk.init(673); // 1485.88 MHz
m_clk_200mhz.init(5000); // 200.00 MHz
}
virtual ~TESTB(void) {
if (m_trace) m_trace->close();
delete m_core;
m_core = NULL;
}
virtual void opentrace(const char *vcdname) {
if (!m_trace) {
m_trace = new VerilatedVcdC;
m_core->trace(m_trace, 99);
m_trace->open(vcdname);
}
}
void trace(const char *vcdname) {
opentrace(vcdname);
}
virtual void closetrace(void) {
if (m_trace) {
m_trace->close();
delete m_trace;
m_trace = NULL;
}
}
virtual void eval(void) {
m_core->eval();
}
virtual void tick(void) {
unsigned mintime = m_clk.time_to_tick();
if (m_hdmi_out_clk.time_to_tick() < mintime)
mintime = m_hdmi_out_clk.time_to_tick();
if (m_hdmi_in_clk.time_to_tick() < mintime)
mintime = m_hdmi_in_clk.time_to_tick();
if (m_hdmi_in_hsclk.time_to_tick() < mintime)
mintime = m_hdmi_in_hsclk.time_to_tick();
if (m_clk_200mhz.time_to_tick() < mintime)
mintime = m_clk_200mhz.time_to_tick();
assert(mintime > 1);
eval();
if (m_trace) m_trace->dump(m_time_ps+1);
m_core->i_clk = m_clk.advance(mintime);
m_core->i_hdmi_out_clk = m_hdmi_out_clk.advance(mintime);
m_core->i_hdmi_in_clk = m_hdmi_in_clk.advance(mintime);
m_core->i_hdmi_in_hsclk = m_hdmi_in_hsclk.advance(mintime);
m_core->i_clk_200mhz = m_clk_200mhz.advance(mintime);
m_time_ps += mintime;
eval();
if (m_trace) {
m_trace->dump(m_time_ps+1);
m_trace->flush();
}
if (m_clk.falling_edge()) {
m_changed = true;
sim_clk_tick();
}
if (m_hdmi_out_clk.falling_edge()) {
m_changed = true;
sim_hdmi_out_clk_tick();
}
if (m_hdmi_in_clk.falling_edge()) {
m_changed = true;
sim_hdmi_in_clk_tick();
}
if (m_hdmi_in_hsclk.falling_edge()) {
m_changed = true;
sim_hdmi_in_hsclk_tick();
}
if (m_clk_200mhz.falling_edge()) {
m_changed = true;
sim_clk_200mhz_tick();
}
}
virtual void sim_clk_tick(void) {
// Your test fixture should over-ride this method.
// If you change any of the inputs to the design
// (i.e. w/in main.v), then set m_changed to true.
m_changed = false;
}
virtual void sim_hdmi_out_clk_tick(void) {
// Your test fixture should over-ride this method.
// If you change any of the inputs to the design
// (i.e. w/in main.v), then set m_changed to true.
m_changed = false;
}
virtual void sim_hdmi_in_clk_tick(void) {
// Your test fixture should over-ride this method.
// If you change any of the inputs to the design
// (i.e. w/in main.v), then set m_changed to true.
m_changed = false;
}
virtual void sim_hdmi_in_hsclk_tick(void) {
// Your test fixture should over-ride this method.
// If you change any of the inputs to the design
// (i.e. w/in main.v), then set m_changed to true.
m_changed = false;
}
virtual void sim_clk_200mhz_tick(void) {
// Your test fixture should over-ride this method.
// If you change any of the inputs to the design
// (i.e. w/in main.v), then set m_changed to true.
m_changed = false;
}
virtual bool done(void) {
if (m_done)
return true;
if (Verilated::gotFinish())
m_done = true;
return m_done;
}
virtual void reset(void) {
m_core->i_reset = 1;
tick();
m_core->i_reset = 0;
// printf("RESET\n");
}
};
#endif // TESTB