OpenCores
URL https://opencores.org/ocsvn/zipcpu/zipcpu/trunk

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sim/] [verilator/] [testb.h] - Diff between revs 208 and 209

Show entire file | Details | Blame | View Log

Rev 208 Rev 209
Line 1... Line 1...
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Filename:    testb.h
// Filename:    testb.h
//
//
// Project:     Zip CPU -- a small, lightweight, RISC CPU core
// Project:     Zip CPU -- a small, lightweight, RISC CPU soft core
//
//
// Purpose:     A wrapper for a common interface to a clocked FPGA core
// Purpose:     A wrapper for a common interface to a clocked FPGA core
//              begin exercised in Verilator.
//              begin exercised in Verilator.
//
//
// Creator:     Dan Gisselquist, Ph.D.
// Creator:     Dan Gisselquist, Ph.D.
Line 32... Line 32...
// License:     GPL, v3, as defined and found on www.gnu.org,
// License:     GPL, v3, as defined and found on www.gnu.org,
//              http://www.gnu.org/licenses/gpl.html
//              http://www.gnu.org/licenses/gpl.html
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
 
//
 
//
#ifndef TESTB_H
#ifndef TESTB_H
#define TESTB_H
#define TESTB_H
 
 
#include <stdio.h>
#include <stdio.h>
#include <stdint.h>
#include <stdint.h>
#include <verilated_vcd_c.h>
#include <verilated_vcd_c.h>
 
 
 
#define TBASSERT(TB,A) do { if (!(A)) { (TB).closetrace(); } assert(A); } while(0);
 
 
template <class VA>     class TESTB {
template <class VA>     class TESTB {
public:
public:
        VA      *m_core;
        VA      *m_core;
        VerilatedVcdC*  m_trace;
        VerilatedVcdC*  m_trace;
        unsigned long   m_tickcount;
        uint64_t        m_tickcount;
 
 
        TESTB(void) : m_trace(NULL), m_tickcount(0l) {
        TESTB(void) : m_trace(NULL), m_tickcount(0l) {
                m_core = new VA;
                m_core = new VA;
                Verilated::traceEverOn(true);
                Verilated::traceEverOn(true);
                m_core->i_clk = 0;
                m_core->i_clk = 0;
                eval(); // Get our initial values set properly.
                eval(); // Get our initial values set properly.
        }
        }
        virtual ~TESTB(void) {
        virtual ~TESTB(void) {
                if (m_trace) m_trace->close();
                closetrace();
                delete m_core;
                delete m_core;
                m_core = NULL;
                m_core = NULL;
        }
        }
 
 
        virtual void    opentrace(const char *vcdname) {
        virtual void    opentrace(const char *vcdname) {
Line 68... Line 72...
        }
        }
 
 
        virtual void    closetrace(void) {
        virtual void    closetrace(void) {
                if (m_trace) {
                if (m_trace) {
                        m_trace->close();
                        m_trace->close();
 
                        delete m_trace;
                        m_trace = NULL;
                        m_trace = NULL;
                }
                }
        }
        }
 
 
        virtual void    eval(void) {
        virtual void    eval(void) {
Line 85... Line 90...
                // of the clock.  This is necessary since some of the 
                // of the clock.  This is necessary since some of the 
                // connection modules may have made changes, for which some
                // connection modules may have made changes, for which some
                // logic depends.  This forces that logic to be recalculated
                // logic depends.  This forces that logic to be recalculated
                // before the top of the clock.
                // before the top of the clock.
                eval();
                eval();
                if (m_trace) m_trace->dump(10*m_tickcount-2);
                if (m_trace) m_trace->dump((vluint64_t)(10*m_tickcount-2));
                m_core->i_clk = 1;
                m_core->i_clk = 1;
                eval();
                eval();
                if (m_trace) m_trace->dump(10*m_tickcount);
                if (m_trace) m_trace->dump((vluint64_t)(10*m_tickcount));
                m_core->i_clk = 0;
                m_core->i_clk = 0;
                eval();
                eval();
                if (m_trace) m_trace->dump(10*m_tickcount+5);
                if (m_trace) {
 
                        m_trace->dump((vluint64_t)(10*m_tickcount+5));
 
                        m_trace->flush();
 
                }
        }
        }
 
 
        virtual void    reset(void) {
        virtual void    reset(void) {
                m_core->i_rst = 1;
                m_core->i_reset = 1;
                tick();
                tick();
                m_core->i_rst = 0;
                m_core->i_reset = 0;
                // printf("RESET\n");
                // printf("RESET\n");
        }
        }
 
 
 
        unsigned long   tickcount(void) {
 
                return m_tickcount;
 
        }
};
};
 
 
#endif
#endif
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2021 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.