1 |
75 |
dgisselq |
////////////////////////////////////////////////////////////////////////////////
|
2 |
4 |
dgisselq |
//
|
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 |
75 |
dgisselq |
// code set implementing all of the functionality of the XESS XuLA2
|
10 |
|
|
// development board. If done well, the programs talking to this one
|
11 |
|
|
// should be able to talk to the board and apply the same tests to the
|
12 |
|
|
// board itself.
|
13 |
4 |
dgisselq |
//
|
14 |
75 |
dgisselq |
// Creator: Dan Gisselquist, Ph.D.
|
15 |
|
|
// Gisselquist Technology, LLC
|
16 |
4 |
dgisselq |
//
|
17 |
75 |
dgisselq |
////////////////////////////////////////////////////////////////////////////////
|
18 |
4 |
dgisselq |
//
|
19 |
75 |
dgisselq |
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
|
20 |
4 |
dgisselq |
//
|
21 |
75 |
dgisselq |
// This program is free software (firmware): you can redistribute it and/or
|
22 |
|
|
// modify it under the terms of the GNU General Public License as published
|
23 |
|
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
24 |
|
|
// your option) any later version.
|
25 |
|
|
//
|
26 |
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
27 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
28 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
29 |
|
|
// for more details.
|
30 |
|
|
//
|
31 |
|
|
// You should have received a copy of the GNU General Public License along
|
32 |
|
|
// with this program. (It's in the $(ROOT)/doc directory, run make with no
|
33 |
|
|
// target there if the PDF file isn't present.) If not, see
|
34 |
|
|
// <http://www.gnu.org/licenses/> for a copy.
|
35 |
|
|
//
|
36 |
|
|
// License: GPL, v3, as defined and found on www.gnu.org,
|
37 |
|
|
// http://www.gnu.org/licenses/gpl.html
|
38 |
|
|
//
|
39 |
|
|
//
|
40 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
41 |
|
|
//
|
42 |
|
|
//
|
43 |
4 |
dgisselq |
#include <signal.h>
|
44 |
|
|
#include <time.h>
|
45 |
|
|
|
46 |
|
|
#include "verilated.h"
|
47 |
|
|
#include "Vbusmaster.h"
|
48 |
|
|
|
49 |
|
|
#include "testb.h"
|
50 |
|
|
// #include "twoc.h"
|
51 |
|
|
#include "pipecmdr.h"
|
52 |
|
|
#include "qspiflashsim.h"
|
53 |
|
|
#include "sdramsim.h"
|
54 |
75 |
dgisselq |
#include "sdspisim.h"
|
55 |
4 |
dgisselq |
|
56 |
|
|
#include "port.h"
|
57 |
|
|
|
58 |
|
|
// Add a reset line, since Vbusmaster doesn't have one
|
59 |
|
|
class Vbusmasterr : public Vbusmaster {
|
60 |
|
|
public:
|
61 |
|
|
int i_rst;
|
62 |
|
|
virtual ~Vbusmasterr() {}
|
63 |
|
|
};
|
64 |
|
|
|
65 |
|
|
// No particular "parameters" need definition or redefinition here.
|
66 |
|
|
class BUSMASTER_TB : public PIPECMDR<Vbusmasterr> {
|
67 |
|
|
public:
|
68 |
|
|
unsigned long m_tx_busy_count;
|
69 |
|
|
QSPIFLASHSIM m_flash;
|
70 |
75 |
dgisselq |
SDSPISIM m_sdcard;
|
71 |
4 |
dgisselq |
SDRAMSIM m_sdram;
|
72 |
|
|
unsigned m_last_led;
|
73 |
|
|
time_t m_start_time;
|
74 |
75 |
dgisselq |
bool m_last_writeout;
|
75 |
4 |
dgisselq |
|
76 |
|
|
BUSMASTER_TB(void) : PIPECMDR(FPGAPORT) {
|
77 |
|
|
m_start_time = time(NULL);
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
void reset(void) {
|
81 |
|
|
m_core->i_clk = 1;
|
82 |
|
|
m_core->eval();
|
83 |
|
|
}
|
84 |
|
|
|
85 |
75 |
dgisselq |
void setsdcard(const char *fn) {
|
86 |
|
|
m_sdcard.load(fn);
|
87 |
96 |
dgisselq |
|
88 |
|
|
printf("LOADING SDCARD FROM: \'%s\'\n", fn);
|
89 |
75 |
dgisselq |
}
|
90 |
|
|
|
91 |
4 |
dgisselq |
void tick(void) {
|
92 |
75 |
dgisselq |
int flash_miso, sdcard_miso;
|
93 |
|
|
|
94 |
4 |
dgisselq |
if ((m_tickcount & ((1<<28)-1))==0) {
|
95 |
|
|
double ticks_per_second = m_tickcount;
|
96 |
47 |
dgisselq |
time_t seconds_passed = time(NULL)-m_start_time;
|
97 |
|
|
if (seconds_passed != 0) {
|
98 |
4 |
dgisselq |
ticks_per_second /= (double)(time(NULL) - m_start_time);
|
99 |
|
|
printf(" ******** %.6f TICKS PER SECOND\n",
|
100 |
|
|
ticks_per_second);
|
101 |
47 |
dgisselq |
}
|
102 |
4 |
dgisselq |
}
|
103 |
|
|
|
104 |
|
|
// Set up the bus before any clock tick
|
105 |
|
|
m_core->i_clk = 1;
|
106 |
75 |
dgisselq |
flash_miso = (m_flash(m_core->o_sf_cs_n,
|
107 |
|
|
m_core->o_spi_sck,
|
108 |
|
|
m_core->o_spi_mosi)&0x02)?1:0;
|
109 |
|
|
sdcard_miso = m_sdcard(m_core->o_sd_cs_n, m_core->o_spi_sck,
|
110 |
|
|
m_core->o_spi_mosi);
|
111 |
|
|
|
112 |
|
|
if ((m_core->o_sf_cs_n)&&(m_core->o_sd_cs_n))
|
113 |
|
|
m_core->i_spi_miso = 1;
|
114 |
|
|
else if ((!m_core->o_sf_cs_n)&&(m_core->o_sd_cs_n))
|
115 |
|
|
m_core->i_spi_miso = flash_miso;
|
116 |
|
|
else if ((m_core->o_sf_cs_n)&&(!m_core->o_sd_cs_n))
|
117 |
|
|
m_core->i_spi_miso = sdcard_miso;
|
118 |
|
|
else
|
119 |
|
|
assert((m_core->o_sf_cs_n)||(m_core->o_sd_cs_n));
|
120 |
|
|
|
121 |
4 |
dgisselq |
m_core->i_ram_data = m_sdram(1,
|
122 |
|
|
m_core->o_ram_cke, m_core->o_ram_cs_n,
|
123 |
|
|
m_core->o_ram_ras_n, m_core->o_ram_cas_n,
|
124 |
|
|
m_core->o_ram_we_n, m_core->o_ram_bs,
|
125 |
|
|
m_core->o_ram_addr, m_core->o_ram_drive_data,
|
126 |
|
|
m_core->o_ram_data);
|
127 |
|
|
PIPECMDR::tick();
|
128 |
|
|
|
129 |
|
|
bool writeout = false;
|
130 |
|
|
/*
|
131 |
37 |
dgisselq |
if (m_core->v__DOT__sdram__DOT__r_pending)
|
132 |
4 |
dgisselq |
writeout = true;
|
133 |
37 |
dgisselq |
else if (m_core->v__DOT__sdram__DOT__bank_active[0])
|
134 |
4 |
dgisselq |
writeout = true;
|
135 |
37 |
dgisselq |
else if (m_core->v__DOT__sdram__DOT__bank_active[1])
|
136 |
4 |
dgisselq |
writeout = true;
|
137 |
37 |
dgisselq |
else if (m_core->v__DOT__sdram__DOT__bank_active[2])
|
138 |
4 |
dgisselq |
writeout = true;
|
139 |
37 |
dgisselq |
else if (m_core->v__DOT__sdram__DOT__bank_active[3])
|
140 |
4 |
dgisselq |
writeout = true;
|
141 |
|
|
*/
|
142 |
75 |
dgisselq |
|
143 |
|
|
/*
|
144 |
|
|
if ((m_core->v__DOT__wbu_cyc)&&(!m_core->v__DOT__wbu_we))
|
145 |
|
|
writeout = true;
|
146 |
|
|
if (m_core->v__DOT__genbus__DOT__exec_stb)
|
147 |
|
|
writeout = true;
|
148 |
|
|
*/
|
149 |
|
|
|
150 |
|
|
if (!m_core->v__DOT__zippy__DOT__cmd_halt)
|
151 |
|
|
writeout = true;
|
152 |
|
|
|
153 |
|
|
if (!m_core->o_sd_cs_n)
|
154 |
|
|
writeout = true;
|
155 |
|
|
else if (!m_core->v__DOT__sdcard_cs_n)
|
156 |
|
|
writeout = true;
|
157 |
|
|
else if ((((m_core->v__DOT__wb_addr ^ 0x0120)&(~0x03))==0)
|
158 |
|
|
&&(m_core->v__DOT__wb_cyc))
|
159 |
|
|
writeout = true;
|
160 |
|
|
|
161 |
96 |
dgisselq |
/*
|
162 |
75 |
dgisselq |
writeout = (writeout)||(m_core->i_rx_stb)
|
163 |
|
|
||((m_core->o_tx_stb)&&(!m_core->i_tx_busy));
|
164 |
|
|
writeout = (writeout)||(m_core->v__DOT____Vcellinp__genbus____pinNumber9);
|
165 |
|
|
writeout = (writeout)||(m_core->v__DOT__wb_stb);
|
166 |
|
|
writeout = (writeout)||(m_core->v__DOT__wb_err);
|
167 |
96 |
dgisselq |
*/
|
168 |
75 |
dgisselq |
|
169 |
|
|
if ((writeout)||(m_last_writeout)) {
|
170 |
4 |
dgisselq |
printf("%08lx:", m_tickcount);
|
171 |
|
|
|
172 |
75 |
dgisselq |
/*
|
173 |
|
|
printf("%d/%02x %d/%02x%s ",
|
174 |
|
|
m_core->i_rx_stb, m_core->i_rx_data,
|
175 |
|
|
m_core->o_tx_stb, m_core->o_tx_data,
|
176 |
|
|
m_core->i_tx_busy?"/BSY":" ");
|
177 |
|
|
*/
|
178 |
|
|
|
179 |
|
|
printf("(%d,%d->%d),(%c:%d,%d->%d)|%c[%08x/%08x]@%08x %c%c%c",
|
180 |
4 |
dgisselq |
m_core->v__DOT__wbu_cyc,
|
181 |
|
|
m_core->v__DOT__dwb_cyc, // was zip_cyc
|
182 |
|
|
m_core->v__DOT__wb_cyc,
|
183 |
|
|
//
|
184 |
75 |
dgisselq |
m_core->v__DOT__wbu_zip_arbiter__DOT__r_a_owner?'Z':'j',
|
185 |
4 |
dgisselq |
m_core->v__DOT__wbu_stb,
|
186 |
|
|
// 0, // m_core->v__DOT__dwb_stb, // was zip_stb
|
187 |
|
|
m_core->v__DOT__zippy__DOT__thecpu__DOT__mem_stb_gbl,
|
188 |
|
|
m_core->v__DOT__wb_stb,
|
189 |
|
|
//
|
190 |
|
|
(m_core->v__DOT__wb_we)?'W':'R',
|
191 |
|
|
m_core->v__DOT__wb_data,
|
192 |
|
|
m_core->v__DOT__dwb_idata,
|
193 |
|
|
m_core->v__DOT__wb_addr,
|
194 |
75 |
dgisselq |
(m_core->v__DOT__dwb_ack)?'A':
|
195 |
|
|
(m_core->v__DOT____Vcellinp__genbus____pinNumber9)?'a':' ',
|
196 |
|
|
(m_core->v__DOT__dwb_stall)?'S':
|
197 |
|
|
(m_core->v__DOT____Vcellinp__genbus____pinNumber10)?'s':' ',
|
198 |
4 |
dgisselq |
(m_core->v__DOT__wb_err)?'E':'.');
|
199 |
|
|
|
200 |
75 |
dgisselq |
printf(" RUNWB %d@0x%08x %3x %3x %d %d/%d %d:%09lx",
|
201 |
|
|
m_core->v__DOT__genbus__DOT__runwb__DOT__wb_state,
|
202 |
|
|
m_core->v__DOT__wbu_addr,
|
203 |
|
|
m_core->v__DOT__genbus__DOT__runwb__DOT__r_len,
|
204 |
|
|
m_core->v__DOT__genbus__DOT__runwb__DOT__r_acks_needed,
|
205 |
|
|
m_core->v__DOT__genbus__DOT__runwb__DOT__w_eow,
|
206 |
|
|
m_core->v__DOT__genbus__DOT__runwb__DOT__last_ack,
|
207 |
|
|
m_core->v__DOT__genbus__DOT__runwb__DOT__zero_acks,
|
208 |
|
|
m_core->v__DOT__genbus__DOT__exec_stb,
|
209 |
|
|
m_core->v__DOT__genbus__DOT__exec_word);
|
210 |
|
|
|
211 |
|
|
/*
|
212 |
4 |
dgisselq |
printf("%c[%d%d%d%d,%d:%04x%c]@%06x(%d) ->%06x%c",
|
213 |
|
|
(m_core->v__DOT__sdram_sel)?'!':' ',
|
214 |
|
|
m_core->o_ram_cs_n, m_core->o_ram_ras_n,
|
215 |
|
|
m_core->o_ram_cas_n, m_core->o_ram_we_n,
|
216 |
|
|
m_core->o_ram_bs, m_core->o_ram_data,
|
217 |
|
|
(m_core->o_ram_drive_data)?'D':'-',
|
218 |
|
|
m_core->o_ram_addr,
|
219 |
|
|
(m_core->o_ram_addr>>10)&1,
|
220 |
|
|
m_core->i_ram_data,
|
221 |
|
|
(m_core->o_ram_drive_data)?'-':'V');
|
222 |
|
|
|
223 |
|
|
printf(" SD[%d,%d-%3x%d]",
|
224 |
|
|
m_core->v__DOT__sdram__DOT__r_state,
|
225 |
|
|
m_sdram.pwrup(),
|
226 |
|
|
m_core->v__DOT__sdram__DOT__refresh_clk,
|
227 |
|
|
m_core->v__DOT__sdram__DOT__need_refresh);
|
228 |
|
|
|
229 |
|
|
printf(" BNK[%d:%6x,%d:%6x,%d:%6x,%d:%6x],%x%d",
|
230 |
|
|
m_core->v__DOT__sdram__DOT__bank_active[0],
|
231 |
|
|
m_core->v__DOT__sdram__DOT__bank_row[0],
|
232 |
|
|
m_core->v__DOT__sdram__DOT__bank_active[1],
|
233 |
|
|
m_core->v__DOT__sdram__DOT__bank_row[1],
|
234 |
|
|
m_core->v__DOT__sdram__DOT__bank_active[2],
|
235 |
|
|
m_core->v__DOT__sdram__DOT__bank_row[2],
|
236 |
|
|
m_core->v__DOT__sdram__DOT__bank_active[3],
|
237 |
|
|
m_core->v__DOT__sdram__DOT__bank_row[3],
|
238 |
|
|
m_core->v__DOT__sdram__DOT__clocks_til_idle,
|
239 |
|
|
m_core->v__DOT__sdram__DOT__r_barrell_ack);
|
240 |
|
|
|
241 |
|
|
printf(" %s%s%c[%08x@%06x]",
|
242 |
|
|
(m_core->v__DOT__sdram__DOT__bus_cyc)?"C":" ",
|
243 |
|
|
(m_core->v__DOT__sdram__DOT__r_pending)?"PND":" ",
|
244 |
|
|
(m_core->v__DOT__sdram__DOT__r_we)?'W':'R',
|
245 |
37 |
dgisselq |
(m_core->v__DOT__sdram__DOT__r_we)
|
246 |
|
|
?(m_core->v__DOT__sdram__DOT__r_data)
|
247 |
|
|
:(m_core->v__DOT__sdram_data),
|
248 |
4 |
dgisselq |
(m_core->v__DOT__sdram__DOT__r_addr));
|
249 |
75 |
dgisselq |
*/
|
250 |
4 |
dgisselq |
|
251 |
75 |
dgisselq |
/*
|
252 |
96 |
dgisselq |
printf("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%2x %s%s %2d %2d",
|
253 |
37 |
dgisselq |
// (m_core->v__DOT__zippy__DOT__dbg_ack)?"A":"-",
|
254 |
|
|
// (m_core->v__DOT__zippy__DOT__dbg_stall)?"S":"-",
|
255 |
|
|
// (m_core->v__DOT__zippy__DOT__sys_dbg_cyc)?"D":"-",
|
256 |
4 |
dgisselq |
(m_core->v__DOT__zippy__DOT__cpu_lcl_cyc)?"L":"-",
|
257 |
75 |
dgisselq |
(m_core->v__DOT__zippy__DOT__thecpu__DOT__r_halted)?"Z":"-",
|
258 |
4 |
dgisselq |
(m_core->v__DOT__zippy__DOT__cmd_halt)?"H":"-",
|
259 |
|
|
(m_core->v__DOT__zippy__DOT__thecpu__DOT__pf_cyc)?"P":"-",
|
260 |
75 |
dgisselq |
(m_core->v__DOT__zippy__DOT__thecpu__DOT__pf_valid)?"V":"-",
|
261 |
4 |
dgisselq |
(m_core->v__DOT__zippy__DOT__thecpu__DOT__mem_cyc_gbl)?"G":"-",
|
262 |
|
|
(m_core->v__DOT__zippy__DOT__thecpu__DOT__mem_cyc_lcl)?"L":"-",
|
263 |
75 |
dgisselq |
(m_core->v__DOT__zippy__DOT__thecpu__DOT__r_dcdvalid)?"D":"-",
|
264 |
|
|
(m_core->v__DOT__zippy__DOT__thecpu__DOT__dcd_ce)?"d":"-",
|
265 |
4 |
dgisselq |
(m_core->v__DOT__zippy__DOT__thecpu__DOT__opvalid)?"O":"-",
|
266 |
|
|
(m_core->v__DOT__zippy__DOT__thecpu__DOT__op_ce)?"k":"-",
|
267 |
96 |
dgisselq |
(m_core->v__DOT__zippy__DOT__thecpu__DOT__opvalid_alu)?"A":"-",
|
268 |
|
|
(m_core->v__DOT__zippy__DOT__thecpu__DOT__alu_ce)?"a":"-",
|
269 |
75 |
dgisselq |
(m_core->v__DOT__zippy__DOT__thecpu__DOT__opvalid_mem)?"M":"-",
|
270 |
|
|
(m_core->v__DOT__zippy__DOT__thecpu__DOT__mem_ce)?"m":"-",
|
271 |
4 |
dgisselq |
(m_core->v__DOT__zippy__DOT__thecpu__DOT__new_pc)?"N":"-",
|
272 |
|
|
(m_core->v__DOT__zippy__DOT__thecpu__DOT__clear_pipeline)?"C":"-",
|
273 |
75 |
dgisselq |
(m_core->v__DOT__zippy__DOT__cmd_addr),
|
274 |
|
|
(m_core->v__DOT__zippy__DOT__thecpu__DOT__ibus_err_flag)?"IB":" ",
|
275 |
|
|
(m_core->v__DOT__zippy__DOT__thecpu__DOT__ubus_err_flag)?"UB":" ",
|
276 |
|
|
m_core->v__DOT__zippy__DOT__thecpu__DOT__domem__DOT__rdaddr,
|
277 |
|
|
m_core->v__DOT__zippy__DOT__thecpu__DOT__domem__DOT__wraddr);
|
278 |
4 |
dgisselq |
|
279 |
75 |
dgisselq |
printf(" PC0x%08x/%08x/%08x-%08x %s0x%08x",
|
280 |
|
|
m_core->v__DOT__zippy__DOT__thecpu__DOT__pf_pc,
|
281 |
|
|
m_core->v__DOT__zippy__DOT__thecpu__DOT__ipc,
|
282 |
|
|
m_core->v__DOT__zippy__DOT__thecpu__DOT__upc,
|
283 |
|
|
m_core->v__DOT__zippy__DOT__thecpu__DOT__instruction,
|
284 |
|
|
(m_core->v__DOT__zippy__DOT__thecpu__DOT__instruction_decoder__DOT__genblk3__DOT__r_early_branch)?"EB":" ",
|
285 |
|
|
m_core->v__DOT__zippy__DOT__thecpu__DOT__instruction_decoder__DOT__genblk3__DOT__r_branch_pc
|
286 |
|
|
);
|
287 |
96 |
dgisselq |
|
288 |
|
|
printf(" %s[%02x]=%08x(%08x)",
|
289 |
|
|
m_core->v__DOT__zippy__DOT__thecpu__DOT__wr_reg_ce?"WR":"--",
|
290 |
|
|
m_core->v__DOT__zippy__DOT__thecpu__DOT__wr_reg_id,
|
291 |
|
|
m_core->v__DOT__zippy__DOT__thecpu__DOT__wr_gpreg_vl,
|
292 |
|
|
m_core->v__DOT__zippy__DOT__thecpu__DOT__wr_spreg_vl);
|
293 |
75 |
dgisselq |
*/
|
294 |
96 |
dgisselq |
|
295 |
4 |
dgisselq |
|
296 |
96 |
dgisselq |
/*
|
297 |
|
|
printf(" SDSPI[%d,%d(%d),(%d)]",
|
298 |
75 |
dgisselq |
m_core->v__DOT__sdcard_controller__DOT__r_cmd_busy,
|
299 |
|
|
m_core->v__DOT__sdcard_controller__DOT__r_sdspi_clk,
|
300 |
|
|
m_core->v__DOT__sdcard_controller__DOT__r_cmd_state,
|
301 |
|
|
m_core->v__DOT__sdcard_controller__DOT__r_rsp_state);
|
302 |
96 |
dgisselq |
printf(" LL[%d,%2x->CK=%d/%2x,%s,ST=%2d,TX=%2x,RX=%2x->%d,%2x] ",
|
303 |
75 |
dgisselq |
m_core->v__DOT__sdcard_controller__DOT__ll_cmd_stb,
|
304 |
|
|
m_core->v__DOT__sdcard_controller__DOT__ll_cmd_dat,
|
305 |
|
|
m_core->v__DOT__sdcard_controller__DOT__lowlevel__DOT__r_z_counter,
|
306 |
|
|
// (m_core->v__DOT__sdcard_controller__DOT__lowlevel__DOT__r_clk_counter==0)?1:0,
|
307 |
|
|
m_core->v__DOT__sdcard_controller__DOT__lowlevel__DOT__r_clk_counter,
|
308 |
|
|
(m_core->v__DOT__sdcard_controller__DOT__lowlevel__DOT__r_idle)?"IDLE":" ",
|
309 |
|
|
m_core->v__DOT__sdcard_controller__DOT__lowlevel__DOT__r_state,
|
310 |
|
|
m_core->v__DOT__sdcard_controller__DOT__lowlevel__DOT__r_byte,
|
311 |
|
|
m_core->v__DOT__sdcard_controller__DOT__lowlevel__DOT__r_ireg,
|
312 |
|
|
m_core->v__DOT__sdcard_controller__DOT__ll_out_stb,
|
313 |
|
|
m_core->v__DOT__sdcard_controller__DOT__ll_out_dat
|
314 |
|
|
);
|
315 |
96 |
dgisselq |
printf(" CRC=%02x/%2d",
|
316 |
75 |
dgisselq |
m_core->v__DOT__sdcard_controller__DOT__r_cmd_crc,
|
317 |
|
|
m_core->v__DOT__sdcard_controller__DOT__r_cmd_crc_cnt);
|
318 |
|
|
printf(" SPI(%d,%d,%d/%d,%d)->?",
|
319 |
|
|
m_core->o_sf_cs_n,
|
320 |
|
|
m_core->o_sd_cs_n,
|
321 |
|
|
m_core->o_spi_sck, m_core->v__DOT__sdcard_sck,
|
322 |
|
|
m_core->o_spi_mosi);
|
323 |
|
|
|
324 |
|
|
printf(" CK=%d,LN=%d",
|
325 |
|
|
m_core->v__DOT__sdcard_controller__DOT__r_sdspi_clk,
|
326 |
|
|
m_core->v__DOT__sdcard_controller__DOT__r_lgblklen);
|
327 |
|
|
|
328 |
96 |
dgisselq |
|
329 |
75 |
dgisselq |
if (m_core->v__DOT__sdcard_controller__DOT__r_use_fifo){
|
330 |
|
|
printf(" FIFO");
|
331 |
|
|
if (m_core->v__DOT__sdcard_controller__DOT__r_fifo_wr)
|
332 |
96 |
dgisselq |
printf("-WR(%04x,%d,%d,%d)",
|
333 |
|
|
m_core->v__DOT__sdcard_controller__DOT__fifo_rd_crc_reg,
|
334 |
|
|
m_core->v__DOT__sdcard_controller__DOT__fifo_rd_crc_stb,
|
335 |
|
|
m_core->v__DOT__sdcard_controller__DOT__ll_fifo_pkt_state,
|
336 |
|
|
m_core->v__DOT__sdcard_controller__DOT__r_have_data_response_token);
|
337 |
75 |
dgisselq |
else
|
338 |
96 |
dgisselq |
printf("-RD(%04x,%d,%d,%d)",
|
339 |
|
|
m_core->v__DOT__sdcard_controller__DOT__fifo_wr_crc_reg,
|
340 |
|
|
m_core->v__DOT__sdcard_controller__DOT__fifo_wr_crc_stb,
|
341 |
|
|
m_core->v__DOT__sdcard_controller__DOT__ll_fifo_wr_state,
|
342 |
|
|
m_core->v__DOT__sdcard_controller__DOT__ll_fifo_wr_complete
|
343 |
|
|
);
|
344 |
75 |
dgisselq |
}
|
345 |
|
|
|
346 |
|
|
if (m_core->v__DOT__sdcard_controller__DOT__ll_fifo_rd)
|
347 |
|
|
printf(" LL-RD");
|
348 |
|
|
if (m_core->v__DOT__sdcard_controller__DOT__ll_fifo_wr)
|
349 |
|
|
printf(" LL-WR");
|
350 |
|
|
if (m_core->v__DOT__sdcard_controller__DOT__r_have_start_token)
|
351 |
|
|
printf(" START-TOK");
|
352 |
96 |
dgisselq |
printf(" %3d/%02x",
|
353 |
|
|
m_core->v__DOT__sdcard_controller__DOT__ll_fifo_addr,
|
354 |
|
|
m_core->v__DOT__sdcard_controller__DOT__fifo_byte&0x0ff);
|
355 |
|
|
*/
|
356 |
75 |
dgisselq |
|
357 |
96 |
dgisselq |
|
358 |
75 |
dgisselq |
/*
|
359 |
|
|
printf(" DMAC[%d]: %08x/%08x/%08x(%03x) -- (%d,%d,%c)%c%c:@%08x-[%4d,%4d/%4d,%4d-#%4d]%08x",
|
360 |
|
|
m_core->v__DOT__zippy__DOT__dma_controller__DOT__dma_state,
|
361 |
|
|
m_core->v__DOT__zippy__DOT__dma_controller__DOT__cfg_waddr,
|
362 |
|
|
m_core->v__DOT__zippy__DOT__dma_controller__DOT__cfg_raddr,
|
363 |
|
|
m_core->v__DOT__zippy__DOT__dma_controller__DOT__cfg_len,
|
364 |
|
|
m_core->v__DOT__zippy__DOT__dma_controller__DOT__cfg_blocklen_sub_one,
|
365 |
|
|
m_core->v__DOT__zippy__DOT__dc_cyc,
|
366 |
|
|
// m_core->v__DOT__zippy__DOT__dc_stb,
|
367 |
|
|
(m_core->v__DOT__zippy__DOT__dma_controller__DOT__dma_state == 2)?1:0,
|
368 |
|
|
|
369 |
|
|
((m_core->v__DOT__zippy__DOT__dma_controller__DOT__dma_state == 4)
|
370 |
|
|
||(m_core->v__DOT__zippy__DOT__dma_controller__DOT__dma_state == 5)
|
371 |
|
|
||(m_core->v__DOT__zippy__DOT__dma_controller__DOT__dma_state == 6))?'W':'R',
|
372 |
|
|
//(m_core->v__DOT__zippy__DOT__dc_we)?'W':'R',
|
373 |
|
|
(m_core->v__DOT__zippy__DOT__dc_ack)?'A':' ',
|
374 |
|
|
(m_core->v__DOT__zippy__DOT__dc_stall)?'S':' ',
|
375 |
|
|
m_core->v__DOT__zippy__DOT__dc_addr,
|
376 |
|
|
m_core->v__DOT__zippy__DOT__dma_controller__DOT__rdaddr,
|
377 |
|
|
m_core->v__DOT__zippy__DOT__dma_controller__DOT__nread,
|
378 |
|
|
m_core->v__DOT__zippy__DOT__dma_controller__DOT__nracks,
|
379 |
|
|
m_core->v__DOT__zippy__DOT__dma_controller__DOT__nwacks,
|
380 |
|
|
m_core->v__DOT__zippy__DOT__dma_controller__DOT__nwritten,
|
381 |
|
|
m_core->v__DOT__zippy__DOT__dc_data);
|
382 |
|
|
|
383 |
|
|
printf(" %08x-PIC%08x",
|
384 |
|
|
m_core->v__DOT__zippy__DOT__main_int_vector,
|
385 |
|
|
m_core->v__DOT__zippy__DOT__pic_data);
|
386 |
|
|
*/
|
387 |
|
|
|
388 |
|
|
printf("\n"); fflush(stdout);
|
389 |
|
|
} m_last_writeout = writeout;
|
390 |
|
|
|
391 |
4 |
dgisselq |
}
|
392 |
|
|
|
393 |
|
|
};
|
394 |
|
|
|
395 |
|
|
BUSMASTER_TB *tb;
|
396 |
|
|
|
397 |
|
|
void busmaster_kill(int v) {
|
398 |
|
|
tb->kill();
|
399 |
75 |
dgisselq |
fprintf(stderr, "KILLED!!\n");
|
400 |
4 |
dgisselq |
exit(0);
|
401 |
|
|
}
|
402 |
|
|
|
403 |
|
|
int main(int argc, char **argv) {
|
404 |
|
|
Verilated::commandArgs(argc, argv);
|
405 |
|
|
tb = new BUSMASTER_TB;
|
406 |
|
|
|
407 |
|
|
// signal(SIGINT, busmaster_kill);
|
408 |
|
|
|
409 |
|
|
tb->reset();
|
410 |
96 |
dgisselq |
if (argc > 1)
|
411 |
|
|
tb->setsdcard(argv[1]);
|
412 |
|
|
else
|
413 |
|
|
tb->setsdcard("/dev/zero");
|
414 |
4 |
dgisselq |
|
415 |
|
|
while(1)
|
416 |
|
|
tb->tick();
|
417 |
|
|
|
418 |
|
|
exit(0);
|
419 |
|
|
}
|
420 |
|
|
|