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

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [bench/] [cpp/] [testb.h] - Diff between revs 2 and 49

Show entire file | Details | Blame | View Log

Rev 2 Rev 49
Line 10... Line 10...
// Creator:     Dan Gisselquist, Ph.D.
// Creator:     Dan Gisselquist, Ph.D.
//              Gisselquist Technology, LLC
//              Gisselquist Technology, LLC
//
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Copyright (C) 2015, Gisselquist Technology, LLC
// Copyright (C) 2015,2017, Gisselquist Technology, LLC
//
//
// This program is free software (firmware): you can redistribute it and/or
// 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
// 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
// by the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
// your option) any later version.
Line 35... Line 35...
//
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
#ifndef TESTB_H
#ifndef TESTB_H
#define TESTB_H
#define TESTB_H
 
 
 
#include <stdio.h>
 
#include <stdint.h>
 
#include <verilated_vcd_c.h>
 
 
template <class VA>     class TESTB {
template <class VA>     class TESTB {
public:
public:
        VA      *m_core;
        VA      *m_core;
 
        VerilatedVcdC*  m_trace;
        unsigned long   m_tickcount;
        unsigned long   m_tickcount;
 
 
        TESTB(void) { m_core = new VA; }
        TESTB(void) : m_trace(NULL), m_tickcount(0l) {
        virtual ~TESTB(void) { delete m_core; m_core = NULL; }
                m_core = new VA;
 
                Verilated::traceEverOn(true);
 
        }
 
        virtual ~TESTB(void) {
 
                if (m_trace) m_trace->close();
 
                delete m_core;
 
                m_core = NULL;
 
        }
 
 
 
        virtual void    opentrace(const char *vcdname) {
 
                m_trace = new VerilatedVcdC;
 
                m_core->trace(m_trace, 99);
 
                m_trace->open(vcdname);
 
        }
 
 
 
        virtual void    closetrace(void) {
 
                if (m_trace) {
 
                        m_trace->close();
 
                        m_trace = NULL;
 
                }
 
        }
 
 
        virtual void    eval(void) {
        virtual void    eval(void) {
                m_core->eval();
                m_core->eval();
        }
        }
 
 
        virtual void    tick(void) {
        virtual void    tick(void) {
 
                m_tickcount++;
 
 
 
                //if((m_trace)&&(m_tickcount)) m_trace->dump(10*m_tickcount-4);
 
                eval();
 
                if ((m_trace)&&(m_tickcount)) m_trace->dump(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);
                m_core->i_clk = 0;
                m_core->i_clk = 0;
                eval();
                eval();
 
                if (m_trace) m_trace->dump(10*m_tickcount+5);
 
 
                m_tickcount++;
 
        }
        }
 
 
        virtual void    reset(void) {
        virtual void    reset(void) {
                m_core->i_rst = 1;
                m_core->i_rst = 1;
                tick();
                tick();
                m_core->i_rst = 0;
                m_core->i_rst = 0;
                m_tickcount = 0l;
 
                // printf("RESET\n");
                // printf("RESET\n");
        }
        }
};
};
 
 
#endif
#endif

powered by: WebSVN 2.1.0

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