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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [bench/] [cpp/] [busmaster_tb.cpp] - Blame information for rev 54

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 dgisselq
//
2
//
3
// Filename:    busmaster_tb.cpp
4
//
5
// Project:     FPGA library development (XuLA2 development board)
6
//
7
// Purpose:     This is piped version of the testbench for the busmaster
8
//              verilog code.  The busmaster code is designed to be a complete
9
//              code set implementing all of the functionality of the XESS
10
//              XuLA2 development board.  If done well, the programs talking to
11
//              this one should be able to talk to the board and apply the
12
//              same tests to the board itself.
13
//
14
// Creator:     Dan Gisselquist
15
//              Gisselquist Tecnology, LLC
16
//
17
// Copyright:   2015
18
//
19
//
20
#include <signal.h>
21
#include <time.h>
22
 
23
#include "verilated.h"
24
#include "Vbusmaster.h"
25
 
26
#include "testb.h"
27
// #include "twoc.h"
28
#include "pipecmdr.h"
29
#include "qspiflashsim.h"
30
#include "sdramsim.h"
31
 
32
#include "port.h"
33
 
34
// Add a reset line, since Vbusmaster doesn't have one
35
class   Vbusmasterr : public Vbusmaster {
36
public:
37
        int     i_rst;
38
        virtual ~Vbusmasterr() {}
39
};
40
 
41
// No particular "parameters" need definition or redefinition here.
42
class   BUSMASTER_TB : public PIPECMDR<Vbusmasterr> {
43
public:
44
        unsigned long   m_tx_busy_count;
45
        QSPIFLASHSIM    m_flash;
46
        SDRAMSIM        m_sdram;
47
        unsigned        m_last_led;
48
        time_t          m_start_time;
49
 
50
        BUSMASTER_TB(void) : PIPECMDR(FPGAPORT) {
51
                m_start_time = time(NULL);
52
        }
53
 
54
        void    reset(void) {
55
                m_core->i_clk = 1;
56
                m_core->eval();
57
        }
58
 
59
        void    tick(void) {
60
                if ((m_tickcount & ((1<<28)-1))==0) {
61
                        double  ticks_per_second = m_tickcount;
62 47 dgisselq
                        time_t  seconds_passed = time(NULL)-m_start_time;
63
                        if (seconds_passed != 0) {
64 4 dgisselq
                        ticks_per_second /= (double)(time(NULL) - m_start_time);
65
                        printf(" ********   %.6f TICKS PER SECOND\n",
66
                                ticks_per_second);
67 47 dgisselq
                        }
68 4 dgisselq
                }
69
 
70
                // Set up the bus before any clock tick
71
                m_core->i_clk = 1;
72
                m_core->i_spi_miso = m_flash(m_core->o_sf_cs_n,
73
                                                m_core->o_spi_sck,
74
                                                m_core->o_spi_mosi)&0x02;
75
                m_core->i_ram_data = m_sdram(1,
76
                                m_core->o_ram_cke, m_core->o_ram_cs_n,
77
                                m_core->o_ram_ras_n, m_core->o_ram_cas_n,
78
                                m_core->o_ram_we_n, m_core->o_ram_bs,
79
                                m_core->o_ram_addr, m_core->o_ram_drive_data,
80
                                m_core->o_ram_data);
81
                PIPECMDR::tick();
82
 
83
                bool    writeout = false;
84
                /*
85 37 dgisselq
                if (m_core->v__DOT__sdram__DOT__r_pending)
86 4 dgisselq
                        writeout = true;
87 37 dgisselq
                else if (m_core->v__DOT__sdram__DOT__bank_active[0])
88 4 dgisselq
                        writeout = true;
89 37 dgisselq
                else if (m_core->v__DOT__sdram__DOT__bank_active[1])
90 4 dgisselq
                        writeout = true;
91 37 dgisselq
                else if (m_core->v__DOT__sdram__DOT__bank_active[2])
92 4 dgisselq
                        writeout = true;
93 37 dgisselq
                else if (m_core->v__DOT__sdram__DOT__bank_active[3])
94 4 dgisselq
                        writeout = true;
95
                */
96
                if (writeout) {
97
                        printf("%08lx:", m_tickcount);
98
 
99
                        printf("(%d,%d->%d),(%d,%d->%d)|%c[%08x/%08x]@%08x %d%d%c",
100
                                m_core->v__DOT__wbu_cyc,
101
                                m_core->v__DOT__dwb_cyc, // was zip_cyc
102
                                m_core->v__DOT__wb_cyc,
103
                                //
104
                                m_core->v__DOT__wbu_stb,
105
                                // 0, // m_core->v__DOT__dwb_stb, // was zip_stb
106
                                m_core->v__DOT__zippy__DOT__thecpu__DOT__mem_stb_gbl,
107
                                m_core->v__DOT__wb_stb,
108
                                //
109
                                (m_core->v__DOT__wb_we)?'W':'R',
110
                                m_core->v__DOT__wb_data,
111
                                        m_core->v__DOT__dwb_idata,
112
                                m_core->v__DOT__wb_addr,
113
                                m_core->v__DOT__dwb_ack,
114
                                m_core->v__DOT__dwb_stall,
115
                                (m_core->v__DOT__wb_err)?'E':'.');
116
 
117
                        printf("%c[%d%d%d%d,%d:%04x%c]@%06x(%d) ->%06x%c",
118
                                (m_core->v__DOT__sdram_sel)?'!':' ',
119
                                m_core->o_ram_cs_n, m_core->o_ram_ras_n,
120
                                m_core->o_ram_cas_n, m_core->o_ram_we_n,
121
                                m_core->o_ram_bs, m_core->o_ram_data,
122
                                (m_core->o_ram_drive_data)?'D':'-',
123
                                m_core->o_ram_addr,
124
                                        (m_core->o_ram_addr>>10)&1,
125
                                m_core->i_ram_data,
126
                                (m_core->o_ram_drive_data)?'-':'V');
127
 
128
                        printf(" SD[%d,%d-%3x%d]",
129
                                m_core->v__DOT__sdram__DOT__r_state,
130
                                m_sdram.pwrup(),
131
                                m_core->v__DOT__sdram__DOT__refresh_clk,
132
                                m_core->v__DOT__sdram__DOT__need_refresh);
133
 
134
                        printf(" BNK[%d:%6x,%d:%6x,%d:%6x,%d:%6x],%x%d",
135
                                m_core->v__DOT__sdram__DOT__bank_active[0],
136
                                m_core->v__DOT__sdram__DOT__bank_row[0],
137
                                m_core->v__DOT__sdram__DOT__bank_active[1],
138
                                m_core->v__DOT__sdram__DOT__bank_row[1],
139
                                m_core->v__DOT__sdram__DOT__bank_active[2],
140
                                m_core->v__DOT__sdram__DOT__bank_row[2],
141
                                m_core->v__DOT__sdram__DOT__bank_active[3],
142
                                m_core->v__DOT__sdram__DOT__bank_row[3],
143
                                m_core->v__DOT__sdram__DOT__clocks_til_idle,
144
                                m_core->v__DOT__sdram__DOT__r_barrell_ack);
145
 
146
                        printf(" %s%s%c[%08x@%06x]",
147
                                (m_core->v__DOT__sdram__DOT__bus_cyc)?"C":" ",
148
                                (m_core->v__DOT__sdram__DOT__r_pending)?"PND":"   ",
149
                                (m_core->v__DOT__sdram__DOT__r_we)?'W':'R',
150 37 dgisselq
                                (m_core->v__DOT__sdram__DOT__r_we)
151
                                ?(m_core->v__DOT__sdram__DOT__r_data)
152
                                :(m_core->v__DOT__sdram_data),
153 4 dgisselq
                                (m_core->v__DOT__sdram__DOT__r_addr));
154
 
155 37 dgisselq
                        printf("%s%s%s%s%s%s%s%s%s%s%s%2x",
156
                                // (m_core->v__DOT__zippy__DOT__dbg_ack)?"A":"-",
157
                                // (m_core->v__DOT__zippy__DOT__dbg_stall)?"S":"-",
158
                                // (m_core->v__DOT__zippy__DOT__sys_dbg_cyc)?"D":"-",
159 4 dgisselq
                                (m_core->v__DOT__zippy__DOT__cpu_lcl_cyc)?"L":"-",
160
                                (m_core->v__DOT__zippy__DOT__cpu_dbg_stall)?"Z":"-",
161
                                (m_core->v__DOT__zippy__DOT__cmd_halt)?"H":"-",
162
                                (m_core->v__DOT__zippy__DOT__thecpu__DOT__pf_cyc)?"P":"-",
163
                                (m_core->v__DOT__zippy__DOT__thecpu__DOT__mem_cyc_gbl)?"G":"-",
164
                                (m_core->v__DOT__zippy__DOT__thecpu__DOT__mem_cyc_lcl)?"L":"-",
165
                                (m_core->v__DOT__zippy__DOT__thecpu__DOT__dcd_ce)?"k":"-",
166
                                (m_core->v__DOT__zippy__DOT__thecpu__DOT__opvalid)?"O":"-",
167
                                (m_core->v__DOT__zippy__DOT__thecpu__DOT__op_ce)?"k":"-",
168
                                (m_core->v__DOT__zippy__DOT__thecpu__DOT__new_pc)?"N":"-",
169
                                (m_core->v__DOT__zippy__DOT__thecpu__DOT__clear_pipeline)?"C":"-",
170
                                (m_core->v__DOT__zippy__DOT__cmd_addr));
171
 
172
                        printf("\n");
173
                }
174
 
175
        }
176
 
177
};
178
 
179
BUSMASTER_TB    *tb;
180
 
181
void    busmaster_kill(int v) {
182
        tb->kill();
183
        exit(0);
184
}
185
 
186
int     main(int argc, char **argv) {
187
        Verilated::commandArgs(argc, argv);
188
        tb = new BUSMASTER_TB;
189
 
190
        // signal(SIGINT,  busmaster_kill);
191
 
192
        tb->reset();
193
 
194
        while(1)
195
                tb->tick();
196
 
197
        exit(0);
198
}
199
 

powered by: WebSVN 2.1.0

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