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

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [bench/] [cpp/] [testb.h] - Blame information for rev 49

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    testb.h
4
//
5
// Project:     Zip CPU -- a small, lightweight, RISC CPU core
6
//
7
// Purpose:     A wrapper for a common interface to a clocked FPGA core
8
//              begin exercised in Verilator.
9
//
10
// Creator:     Dan Gisselquist, Ph.D.
11
//              Gisselquist Technology, LLC
12
//
13
////////////////////////////////////////////////////////////////////////////////
14
//
15 49 dgisselq
// Copyright (C) 2015,2017, Gisselquist Technology, LLC
16 2 dgisselq
//
17
// This program is free software (firmware): you can redistribute it and/or
18
// modify it under the terms of  the GNU General Public License as published
19
// by the Free Software Foundation, either version 3 of the License, or (at
20
// your option) any later version.
21
//
22
// This program is distributed in the hope that it will be useful, but WITHOUT
23
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
24
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25
// for more details.
26
//
27
// You should have received a copy of the GNU General Public License along
28
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
29
// target there if the PDF file isn't present.)  If not, see
30
// <http://www.gnu.org/licenses/> for a copy.
31
//
32
// License:     GPL, v3, as defined and found on www.gnu.org,
33
//              http://www.gnu.org/licenses/gpl.html
34
//
35
//
36
////////////////////////////////////////////////////////////////////////////////
37
#ifndef TESTB_H
38
#define TESTB_H
39
 
40 49 dgisselq
#include <stdio.h>
41
#include <stdint.h>
42
#include <verilated_vcd_c.h>
43
 
44 2 dgisselq
template <class VA>     class TESTB {
45
public:
46
        VA      *m_core;
47 49 dgisselq
        VerilatedVcdC*  m_trace;
48 2 dgisselq
        unsigned long   m_tickcount;
49
 
50 49 dgisselq
        TESTB(void) : m_trace(NULL), m_tickcount(0l) {
51
                m_core = new VA;
52
                Verilated::traceEverOn(true);
53
        }
54
        virtual ~TESTB(void) {
55
                if (m_trace) m_trace->close();
56
                delete m_core;
57
                m_core = NULL;
58
        }
59 2 dgisselq
 
60 49 dgisselq
        virtual void    opentrace(const char *vcdname) {
61
                m_trace = new VerilatedVcdC;
62
                m_core->trace(m_trace, 99);
63
                m_trace->open(vcdname);
64
        }
65
 
66
        virtual void    closetrace(void) {
67
                if (m_trace) {
68
                        m_trace->close();
69
                        m_trace = NULL;
70
                }
71
        }
72
 
73 2 dgisselq
        virtual void    eval(void) {
74
                m_core->eval();
75
        }
76
 
77
        virtual void    tick(void) {
78 49 dgisselq
                m_tickcount++;
79
 
80
                //if((m_trace)&&(m_tickcount)) m_trace->dump(10*m_tickcount-4);
81
                eval();
82
                if ((m_trace)&&(m_tickcount)) m_trace->dump(10*m_tickcount-2);
83 2 dgisselq
                m_core->i_clk = 1;
84
                eval();
85 49 dgisselq
                if (m_trace) m_trace->dump(10*m_tickcount);
86 2 dgisselq
                m_core->i_clk = 0;
87
                eval();
88 49 dgisselq
                if (m_trace) m_trace->dump(10*m_tickcount+5);
89 2 dgisselq
 
90
        }
91
 
92
        virtual void    reset(void) {
93
                m_core->i_rst = 1;
94
                tick();
95
                m_core->i_rst = 0;
96
                // printf("RESET\n");
97
        }
98
};
99
 
100
#endif

powered by: WebSVN 2.1.0

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