1 |
21 |
dgisselq |
///////////////////////////////////////////////////////////////////////////
|
2 |
|
|
//
|
3 |
|
|
// Filename: zipsystem.v
|
4 |
|
|
//
|
5 |
|
|
// Project: Zip CPU -- a small, lightweight, RISC CPU soft core
|
6 |
|
|
//
|
7 |
|
|
// Purpose: This portion of the ZIP CPU implements a number of soft
|
8 |
|
|
// peripherals to the CPU nearby its CORE. The functionality
|
9 |
|
|
// sits on the data bus, and does not include any true
|
10 |
|
|
// external hardware peripherals. The peripherals included here
|
11 |
|
|
// include:
|
12 |
|
|
//
|
13 |
|
|
//
|
14 |
|
|
// Local interrupt controller--for any/all of the interrupts generated
|
15 |
|
|
// here. This would include a pin for interrupts generated
|
16 |
|
|
// elsewhere, so this interrupt controller could be a master
|
17 |
|
|
// handling all interrupts. My interrupt controller would work
|
18 |
|
|
// for this purpose.
|
19 |
|
|
//
|
20 |
|
|
// The ZIP-CPU supports only one interrupt because, as I understand
|
21 |
|
|
// modern systems (Linux), they tend to send all interrupts to the
|
22 |
|
|
// same interrupt vector anyway. Hence, that's what we do here.
|
23 |
|
|
//
|
24 |
|
|
// Bus Error interrupts -- generates an interrupt any time the wishbone
|
25 |
|
|
// bus produces an error on a given access, for whatever purpose
|
26 |
|
|
// also records the address on the bus at the time of the error.
|
27 |
|
|
//
|
28 |
|
|
// Trap instructions
|
29 |
|
|
// Writing to this "register" will always create an interrupt.
|
30 |
|
|
// After the interrupt, this register may be read to see what
|
31 |
|
|
// value had been written to it.
|
32 |
|
|
//
|
33 |
|
|
// Bit reverse register ... ?
|
34 |
|
|
//
|
35 |
|
|
// (Potentially an eventual floating point co-processor ...)
|
36 |
|
|
//
|
37 |
|
|
// Real-time clock
|
38 |
|
|
//
|
39 |
|
|
// Interval timer(s) (Count down from fixed value, and either stop on
|
40 |
|
|
// zero, or issue an interrupt and restart automatically on zero)
|
41 |
|
|
// These can be implemented as watchdog timers if desired--the
|
42 |
|
|
// only difference is that a watchdog timer's interrupt feeds the
|
43 |
|
|
// reset line instead of the processor interrupt line.
|
44 |
|
|
//
|
45 |
|
|
// Watch-dog timer: this is the same as an interval timer, only it's
|
46 |
|
|
// interrupt/time-out line is wired to the reset line instead of
|
47 |
|
|
// the interrupt line of the CPU.
|
48 |
|
|
//
|
49 |
|
|
// ROM Memory map
|
50 |
|
|
// Set a register to control this map, and a DMA will begin to
|
51 |
|
|
// fill this memory from a slower FLASH. Once filled, accesses
|
52 |
|
|
// will be from this memory instead of
|
53 |
|
|
//
|
54 |
|
|
//
|
55 |
|
|
// Doing some market comparison, let's look at what peripherals a TI
|
56 |
|
|
// MSP430 might offer: MSP's may have I2C ports, SPI, UART, DMA, ADC,
|
57 |
|
|
// Comparators, 16,32-bit timers, 16x16 or 32x32 timers, AES, BSL,
|
58 |
|
|
// brown-out-reset(s), real-time-clocks, temperature sensors, USB ports,
|
59 |
|
|
// Spi-Bi-Wire, UART Boot-strap Loader (BSL), programmable digital I/O,
|
60 |
|
|
// watchdog-timers,
|
61 |
|
|
//
|
62 |
|
|
// Creator: Dan Gisselquist, Ph.D.
|
63 |
|
|
// Gisselquist Technology, LLC
|
64 |
|
|
//
|
65 |
|
|
///////////////////////////////////////////////////////////////////////////
|
66 |
|
|
//
|
67 |
|
|
// Copyright (C) 2015, Gisselquist Technology, LLC
|
68 |
|
|
//
|
69 |
|
|
// This program is free software (firmware): you can redistribute it and/or
|
70 |
|
|
// modify it under the terms of the GNU General Public License as published
|
71 |
|
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
72 |
|
|
// your option) any later version.
|
73 |
|
|
//
|
74 |
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
75 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
76 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
77 |
|
|
// for more details.
|
78 |
|
|
//
|
79 |
|
|
// License: GPL, v3, as defined and found on www.gnu.org,
|
80 |
|
|
// http://www.gnu.org/licenses/gpl.html
|
81 |
|
|
//
|
82 |
|
|
//
|
83 |
|
|
///////////////////////////////////////////////////////////////////////////
|
84 |
|
|
//
|
85 |
|
|
`include "cpudefs.v"
|
86 |
|
|
//
|
87 |
|
|
// While I hate adding delays to any bus access, this next delay is required
|
88 |
|
|
// to make timing close in my Basys-3 design.
|
89 |
|
|
`define DELAY_DBG_BUS
|
90 |
|
|
// On my previous version, I needed to add a delay to access the external
|
91 |
|
|
// bus. Activate the define below and that delay will be put back into place.
|
92 |
|
|
// This particular version no longer needs the delay in order to run at
|
93 |
|
|
// 100 MHz. Timing indicates I may even run this at 250 MHz without the
|
94 |
|
|
// delay too, so we're doing better. To get rid of this, I placed the logic
|
95 |
|
|
// determining whether or not I was accessing the local system bus one clock
|
96 |
|
|
// earlier, or into the memops.v file. This also required my wishbone bus
|
97 |
|
|
// arbiter to maintain the bus selection as well, so that got updated ...
|
98 |
|
|
// you get the picture. But, the bottom line is that I no longer need this
|
99 |
|
|
// delay.
|
100 |
|
|
//
|
101 |
|
|
// `define DELAY_EXT_BUS // Required no longer!
|
102 |
|
|
//
|
103 |
|
|
//
|
104 |
|
|
// If space is tight, you might not wish to have your performance and
|
105 |
|
|
// accounting counters, so let's make those optional here
|
106 |
|
|
// Without this flag, Slice LUT count is 3315 (ZipSystem),2432 (ZipCPU)
|
107 |
|
|
// When including counters,
|
108 |
|
|
// Slice LUTs ZipSystem ZipCPU
|
109 |
|
|
// With Counters 3315 2432
|
110 |
|
|
// Without Counters 2796 2046
|
111 |
|
|
|
112 |
|
|
//
|
113 |
|
|
// Now, where am I placing all of my peripherals?
|
114 |
|
|
`define PERIPHBASE 32'hc0000000
|
115 |
|
|
`define INTCTRL 5'h0 //
|
116 |
|
|
`define WATCHDOG 5'h1 // Interrupt generates reset signal
|
117 |
|
|
`define BUSWATCHDOG 5'h2 // Sets IVEC[0]
|
118 |
|
|
`define CTRINT 5'h3 // Sets IVEC[5]
|
119 |
|
|
`define TIMER_A 5'h4 // Sets IVEC[4]
|
120 |
|
|
`define TIMER_B 5'h5 // Sets IVEC[3]
|
121 |
|
|
`define TIMER_C 5'h6 // Sets IVEC[2]
|
122 |
|
|
`define JIFFIES 5'h7 // Sets IVEC[1]
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
`ifdef INCLUDE_ACCOUNTING_COUNTERS
|
126 |
|
|
`define MSTR_TASK_CTR 5'h08
|
127 |
|
|
`define MSTR_MSTL_CTR 5'h09
|
128 |
|
|
`define MSTR_PSTL_CTR 5'h0a
|
129 |
|
|
`define MSTR_INST_CTR 5'h0b
|
130 |
|
|
`define USER_TASK_CTR 5'h0c
|
131 |
|
|
`define USER_MSTL_CTR 5'h0d
|
132 |
|
|
`define USER_PSTL_CTR 5'h0e
|
133 |
|
|
`define USER_INST_CTR 5'h0f
|
134 |
|
|
`endif
|
135 |
|
|
|
136 |
|
|
// Although I have a hole at 5'h2, the DMA controller requires four wishbone
|
137 |
|
|
// addresses, therefore we place it by itself and expand our address bus
|
138 |
|
|
// width here by another bit.
|
139 |
|
|
`define DMAC 5'h10
|
140 |
|
|
|
141 |
|
|
// `define RTC_CLOCK 32'hc0000008 // A global something
|
142 |
|
|
// `define BITREV 32'hc0000003
|
143 |
|
|
//
|
144 |
|
|
// DBGCTRL
|
145 |
|
|
// 10 HALT
|
146 |
|
|
// 9 HALT(ED)
|
147 |
|
|
// 8 STEP (W=1 steps, and returns to halted)
|
148 |
|
|
// 7 INTERRUPT-FLAG
|
149 |
|
|
// 6 RESET_FLAG
|
150 |
|
|
// ADDRESS:
|
151 |
|
|
// 5 PERIPHERAL-BIT
|
152 |
|
|
// [4:0] REGISTER-ADDR
|
153 |
|
|
// DBGDATA
|
154 |
|
|
// read/writes internal registers
|
155 |
|
|
//
|
156 |
|
|
//
|
157 |
|
|
//
|
158 |
|
|
module zipsystem(i_clk, i_rst,
|
159 |
|
|
// Wishbone master interface from the CPU
|
160 |
|
|
o_wb_cyc, o_wb_stb, o_wb_we, o_wb_addr, o_wb_data,
|
161 |
|
|
i_wb_ack, i_wb_stall, i_wb_data, i_wb_err,
|
162 |
|
|
// Incoming interrupts
|
163 |
|
|
i_ext_int,
|
164 |
|
|
// Our one outgoing interrupt
|
165 |
|
|
o_ext_int,
|
166 |
|
|
// Wishbone slave interface for debugging purposes
|
167 |
|
|
i_dbg_cyc, i_dbg_stb, i_dbg_we, i_dbg_addr, i_dbg_data,
|
168 |
|
|
o_dbg_ack, o_dbg_stall, o_dbg_data
|
169 |
|
|
`ifdef DEBUG_SCOPE
|
170 |
|
|
, o_cpu_debug
|
171 |
|
|
`endif
|
172 |
|
|
);
|
173 |
|
|
parameter RESET_ADDRESS=24'h0100000, ADDRESS_WIDTH=24,
|
174 |
|
|
LGICACHE=10, START_HALTED=1, EXTERNAL_INTERRUPTS=1,
|
175 |
|
|
`ifdef OPT_MULTIPLY
|
176 |
|
|
IMPLEMENT_MPY = 1,
|
177 |
|
|
`else
|
178 |
|
|
IMPLEMENT_MPY = 0,
|
179 |
|
|
`endif
|
180 |
|
|
`ifdef OPT_DIVIDE
|
181 |
|
|
IMPLEMENT_DIVIDE=1,
|
182 |
|
|
`else
|
183 |
|
|
IMPLEMENT_DIVIDE=0,
|
184 |
|
|
`endif
|
185 |
|
|
`ifdef OPT_IMPLEMENT_FPU
|
186 |
|
|
IMPLEMENT_FPU=1,
|
187 |
|
|
`else
|
188 |
|
|
IMPLEMENT_FPU=0,
|
189 |
|
|
`endif
|
190 |
|
|
IMPLEMENT_LOCK=1,
|
191 |
|
|
// Derived parameters
|
192 |
|
|
AW=ADDRESS_WIDTH;
|
193 |
|
|
input i_clk, i_rst;
|
194 |
|
|
// Wishbone master
|
195 |
|
|
output wire o_wb_cyc, o_wb_stb, o_wb_we;
|
196 |
|
|
output wire [(AW-1):0] o_wb_addr;
|
197 |
|
|
output wire [31:0] o_wb_data;
|
198 |
|
|
input i_wb_ack, i_wb_stall;
|
199 |
|
|
input [31:0] i_wb_data;
|
200 |
|
|
input i_wb_err;
|
201 |
|
|
// Incoming interrupts
|
202 |
|
|
input [(EXTERNAL_INTERRUPTS-1):0] i_ext_int;
|
203 |
|
|
// Outgoing interrupt
|
204 |
|
|
output wire o_ext_int;
|
205 |
|
|
// Wishbone slave
|
206 |
|
|
input i_dbg_cyc, i_dbg_stb, i_dbg_we, i_dbg_addr;
|
207 |
|
|
input [31:0] i_dbg_data;
|
208 |
|
|
output wire o_dbg_ack;
|
209 |
|
|
output wire o_dbg_stall;
|
210 |
|
|
output wire [31:0] o_dbg_data;
|
211 |
|
|
//
|
212 |
|
|
`ifdef DEBUG_SCOPE
|
213 |
|
|
output wire [31:0] o_cpu_debug;
|
214 |
|
|
`endif
|
215 |
|
|
|
216 |
|
|
wire [31:0] ext_idata;
|
217 |
|
|
|
218 |
|
|
// Handle our interrupt vector generation/coordination
|
219 |
|
|
wire [14:0] main_int_vector, alt_int_vector;
|
220 |
|
|
wire ctri_int, tma_int, tmb_int, tmc_int, jif_int, dmac_int;
|
221 |
|
|
wire mtc_int, moc_int, mpc_int, mic_int,
|
222 |
|
|
utc_int, uoc_int, upc_int, uic_int;
|
223 |
|
|
generate
|
224 |
|
|
if (EXTERNAL_INTERRUPTS < 9)
|
225 |
|
|
assign main_int_vector = { {(9-EXTERNAL_INTERRUPTS){1'b0}},
|
226 |
|
|
i_ext_int, ctri_int,
|
227 |
|
|
tma_int, tmb_int, tmc_int,
|
228 |
|
|
jif_int, dmac_int };
|
229 |
|
|
else
|
230 |
|
|
assign main_int_vector = { i_ext_int[8:0], ctri_int,
|
231 |
|
|
tma_int, tmb_int, tmc_int,
|
232 |
|
|
jif_int, dmac_int };
|
233 |
|
|
endgenerate
|
234 |
|
|
generate
|
235 |
|
|
if (EXTERNAL_INTERRUPTS <= 9)
|
236 |
|
|
`ifdef INCLUDE_ACCOUNTING_COUNTERS
|
237 |
|
|
assign alt_int_vector = { 7'h00,
|
238 |
|
|
mtc_int, moc_int, mpc_int, mic_int,
|
239 |
|
|
utc_int, uoc_int, upc_int, uic_int };
|
240 |
|
|
`else
|
241 |
|
|
assign alt_int_vector = { 15'h00 };
|
242 |
|
|
`endif
|
243 |
|
|
else
|
244 |
|
|
`ifdef INCLUDE_ACCOUNTING_COUNTERS
|
245 |
|
|
assign alt_int_vector = { {(7-(EXTERNAL_INTERRUPTS-9)){1'b0}},
|
246 |
|
|
i_ext_int[(EXTERNAL_INTERRUPTS-1):9],
|
247 |
|
|
mtc_int, moc_int, mpc_int, mic_int,
|
248 |
|
|
utc_int, uoc_int, upc_int, uic_int };
|
249 |
|
|
`else
|
250 |
|
|
assign alt_int_vector = { {(15-(EXTERNAL_INTERRUPTS-9)){1'b0}},
|
251 |
|
|
i_ext_int[(EXTERNAL_INTERRUPTS-1):9] };
|
252 |
|
|
`endif
|
253 |
|
|
endgenerate
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
// Delay the debug port by one clock, to meet timing requirements
|
257 |
|
|
wire dbg_cyc, dbg_stb, dbg_we, dbg_addr, dbg_stall;
|
258 |
|
|
wire [31:0] dbg_idata, dbg_odata;
|
259 |
|
|
reg dbg_ack;
|
260 |
|
|
`ifdef DELAY_DBG_BUS
|
261 |
|
|
wire dbg_err, no_dbg_err;
|
262 |
|
|
assign dbg_err = 1'b0;
|
263 |
|
|
busdelay #(1,32) wbdelay(i_clk,
|
264 |
|
|
i_dbg_cyc, i_dbg_stb, i_dbg_we, i_dbg_addr, i_dbg_data,
|
265 |
|
|
o_dbg_ack, o_dbg_stall, o_dbg_data, no_dbg_err,
|
266 |
|
|
dbg_cyc, dbg_stb, dbg_we, dbg_addr, dbg_idata,
|
267 |
|
|
dbg_ack, dbg_stall, dbg_odata, dbg_err);
|
268 |
|
|
`else
|
269 |
|
|
assign dbg_cyc = i_dbg_cyc;
|
270 |
|
|
assign dbg_stb = i_dbg_stb;
|
271 |
|
|
assign dbg_we = i_dbg_we;
|
272 |
|
|
assign dbg_addr = i_dbg_addr;
|
273 |
|
|
assign dbg_idata = i_dbg_data;
|
274 |
|
|
assign o_dbg_ack = dbg_ack;
|
275 |
|
|
assign o_dbg_stall = dbg_stall;
|
276 |
|
|
assign o_dbg_data = dbg_odata;
|
277 |
|
|
`endif
|
278 |
|
|
|
279 |
|
|
//
|
280 |
|
|
//
|
281 |
|
|
//
|
282 |
|
|
wire sys_cyc, sys_stb, sys_we;
|
283 |
|
|
wire [4:0] sys_addr;
|
284 |
|
|
wire [(AW-1):0] cpu_addr;
|
285 |
|
|
wire [31:0] sys_data;
|
286 |
|
|
wire sys_ack, sys_stall;
|
287 |
|
|
|
288 |
|
|
//
|
289 |
|
|
// The external debug interface
|
290 |
|
|
//
|
291 |
|
|
// We offer only a limited interface here, requiring a pre-register
|
292 |
|
|
// write to set the local address. This interface allows access to
|
293 |
|
|
// the Zip System on a debug basis only, and not to the rest of the
|
294 |
|
|
// wishbone bus. Further, to access these registers, the control
|
295 |
|
|
// register must first be accessed to both stop the CPU and to
|
296 |
|
|
// set the following address in question. Hence all accesses require
|
297 |
|
|
// two accesses: write the address to the control register (and halt
|
298 |
|
|
// the CPU if not halted), then read/write the data from the data
|
299 |
|
|
// register.
|
300 |
|
|
//
|
301 |
|
|
wire cpu_break, dbg_cmd_write;
|
302 |
|
|
reg cmd_reset, cmd_halt, cmd_step, cmd_clear_pf_cache;
|
303 |
|
|
reg [5:0] cmd_addr;
|
304 |
|
|
wire [3:0] cpu_dbg_cc;
|
305 |
|
|
assign dbg_cmd_write = (dbg_cyc)&&(dbg_stb)&&(dbg_we)&&(~dbg_addr);
|
306 |
|
|
//
|
307 |
|
|
initial cmd_reset = 1'b1;
|
308 |
|
|
always @(posedge i_clk)
|
309 |
|
|
cmd_reset <= ((dbg_cmd_write)&&(dbg_idata[6]));
|
310 |
|
|
//
|
311 |
|
|
initial cmd_halt = 1'b1;
|
312 |
|
|
always @(posedge i_clk)
|
313 |
|
|
if (i_rst)
|
314 |
|
|
cmd_halt <= (START_HALTED == 1)? 1'b1 : 1'b0;
|
315 |
|
|
else if (dbg_cmd_write)
|
316 |
|
|
cmd_halt <= ((dbg_idata[10])||(dbg_idata[8]));
|
317 |
|
|
else if ((cmd_step)||(cpu_break))
|
318 |
|
|
cmd_halt <= 1'b1;
|
319 |
|
|
|
320 |
|
|
always @(posedge i_clk)
|
321 |
|
|
cmd_clear_pf_cache = (~i_rst)&&(dbg_cmd_write)
|
322 |
|
|
&&((dbg_idata[11])||(dbg_idata[6]));
|
323 |
|
|
//
|
324 |
|
|
initial cmd_step = 1'b0;
|
325 |
|
|
always @(posedge i_clk)
|
326 |
|
|
cmd_step <= (dbg_cmd_write)&&(dbg_idata[8]);
|
327 |
|
|
//
|
328 |
|
|
always @(posedge i_clk)
|
329 |
|
|
if (dbg_cmd_write)
|
330 |
|
|
cmd_addr <= dbg_idata[5:0];
|
331 |
|
|
|
332 |
|
|
wire cpu_reset;
|
333 |
|
|
assign cpu_reset = (cmd_reset)||(wdt_reset)||(i_rst);
|
334 |
|
|
|
335 |
|
|
wire cpu_halt, cpu_dbg_stall;
|
336 |
|
|
assign cpu_halt = (i_rst)||((cmd_halt)&&(~cmd_step));
|
337 |
|
|
wire [31:0] pic_data;
|
338 |
|
|
wire [31:0] cmd_data;
|
339 |
|
|
// Values:
|
340 |
|
|
// 0x0003f -> cmd_addr mask
|
341 |
|
|
// 0x00040 -> reset
|
342 |
|
|
// 0x00080 -> PIC interrrupt pending
|
343 |
|
|
// 0x00100 -> cmd_step
|
344 |
|
|
// 0x00200 -> cmd_stall
|
345 |
|
|
// 0x00400 -> cmd_halt
|
346 |
|
|
// 0x00800 -> cmd_clear_pf_cache
|
347 |
|
|
// 0x01000 -> cc.sleep
|
348 |
|
|
// 0x02000 -> cc.gie
|
349 |
|
|
// 0x04000 -> External (PIC) interrupt line is high
|
350 |
|
|
// Other external interrupts follow
|
351 |
|
|
generate
|
352 |
|
|
if (EXTERNAL_INTERRUPTS < 16)
|
353 |
|
|
assign cmd_data = { {(16-EXTERNAL_INTERRUPTS){1'b0}},
|
354 |
|
|
i_ext_int,
|
355 |
|
|
cpu_dbg_cc, // 4 bits
|
356 |
|
|
1'b0, cmd_halt, (~cpu_dbg_stall), 1'b0,
|
357 |
|
|
pic_data[15], cpu_reset, cmd_addr };
|
358 |
|
|
else
|
359 |
|
|
assign cmd_data = { i_ext_int[15:0], cpu_dbg_cc,
|
360 |
|
|
1'b0, cmd_halt, (~cpu_dbg_stall), 1'b0,
|
361 |
|
|
pic_data[15], cpu_reset, cmd_addr };
|
362 |
|
|
endgenerate
|
363 |
|
|
|
364 |
|
|
wire cpu_gie;
|
365 |
|
|
assign cpu_gie = cpu_dbg_cc[1];
|
366 |
|
|
|
367 |
|
|
`ifdef USE_TRAP
|
368 |
|
|
//
|
369 |
|
|
// The TRAP peripheral
|
370 |
|
|
//
|
371 |
|
|
wire trap_ack, trap_stall, trap_int;
|
372 |
|
|
wire [31:0] trap_data;
|
373 |
|
|
ziptrap trapp(i_clk,
|
374 |
|
|
sys_cyc, (sys_stb)&&(sys_addr == `TRAP_ADDR), sys_we,
|
375 |
|
|
sys_data,
|
376 |
|
|
trap_ack, trap_stall, trap_data, trap_int);
|
377 |
|
|
`endif
|
378 |
|
|
|
379 |
|
|
//
|
380 |
|
|
// The WATCHDOG Timer
|
381 |
|
|
//
|
382 |
|
|
wire wdt_ack, wdt_stall, wdt_reset;
|
383 |
|
|
wire [31:0] wdt_data;
|
384 |
|
|
ziptimer watchdog(i_clk, cpu_reset, ~cmd_halt,
|
385 |
|
|
sys_cyc, ((sys_stb)&&(sys_addr == `WATCHDOG)), sys_we,
|
386 |
|
|
sys_data,
|
387 |
|
|
wdt_ack, wdt_stall, wdt_data, wdt_reset);
|
388 |
|
|
|
389 |
|
|
//
|
390 |
|
|
// Position two, a second watchdog timer--this time for the wishbone
|
391 |
|
|
// bus, in order to tell/find wishbone bus lockups. In its current
|
392 |
|
|
// configuration, it cannot be configured and all bus accesses must
|
393 |
|
|
// take less than the number written to this register.
|
394 |
|
|
//
|
395 |
|
|
reg wdbus_ack;
|
396 |
|
|
reg [(AW-1):0] r_wdbus_data;
|
397 |
|
|
wire [31:0] wdbus_data;
|
398 |
|
|
wire [14:0] wdbus_ignored_data;
|
399 |
|
|
wire reset_wdbus_timer, wdbus_int;
|
400 |
|
|
assign reset_wdbus_timer = ((o_wb_cyc)&&((o_wb_stb)||(i_wb_ack)));
|
401 |
|
|
wbwatchdog #(14) watchbus(i_clk,(cpu_reset)||(reset_wdbus_timer),
|
402 |
|
|
o_wb_cyc, 14'h2000, wdbus_int);
|
403 |
|
|
initial r_wdbus_data = 0;
|
404 |
|
|
always @(posedge i_clk)
|
405 |
|
|
if ((wdbus_int)||(cpu_ext_err))
|
406 |
|
|
r_wdbus_data = o_wb_addr;
|
407 |
|
|
assign wdbus_data = { {(32-AW){1'b0}}, r_wdbus_data };
|
408 |
|
|
initial wdbus_ack = 1'b0;
|
409 |
|
|
always @(posedge i_clk)
|
410 |
|
|
wdbus_ack <= ((sys_cyc)&&(sys_stb)&&(sys_addr == 5'h02));
|
411 |
|
|
|
412 |
|
|
// Counters -- for performance measurement and accounting
|
413 |
|
|
//
|
414 |
|
|
// Here's the stuff we'll be counting ....
|
415 |
|
|
//
|
416 |
|
|
wire cpu_op_stall, cpu_pf_stall, cpu_i_count;
|
417 |
|
|
|
418 |
|
|
`ifdef INCLUDE_ACCOUNTING_COUNTERS
|
419 |
|
|
//
|
420 |
|
|
// The master counters will, in general, not be reset. They'll be used
|
421 |
|
|
// for an overall counter.
|
422 |
|
|
//
|
423 |
|
|
// Master task counter
|
424 |
|
|
wire mtc_ack, mtc_stall;
|
425 |
|
|
wire [31:0] mtc_data;
|
426 |
|
|
zipcounter mtask_ctr(i_clk, (~cpu_halt), sys_cyc,
|
427 |
|
|
(sys_stb)&&(sys_addr == `MSTR_TASK_CTR),
|
428 |
|
|
sys_we, sys_data,
|
429 |
|
|
mtc_ack, mtc_stall, mtc_data, mtc_int);
|
430 |
|
|
|
431 |
|
|
// Master Operand Stall counter
|
432 |
|
|
wire moc_ack, moc_stall;
|
433 |
|
|
wire [31:0] moc_data;
|
434 |
|
|
zipcounter mmstall_ctr(i_clk,(cpu_op_stall), sys_cyc,
|
435 |
|
|
(sys_stb)&&(sys_addr == `MSTR_MSTL_CTR),
|
436 |
|
|
sys_we, sys_data,
|
437 |
|
|
moc_ack, moc_stall, moc_data, moc_int);
|
438 |
|
|
|
439 |
|
|
// Master PreFetch-Stall counter
|
440 |
|
|
wire mpc_ack, mpc_stall;
|
441 |
|
|
wire [31:0] mpc_data;
|
442 |
|
|
zipcounter mpstall_ctr(i_clk,(cpu_pf_stall), sys_cyc,
|
443 |
|
|
(sys_stb)&&(sys_addr == `MSTR_PSTL_CTR),
|
444 |
|
|
sys_we, sys_data,
|
445 |
|
|
mpc_ack, mpc_stall, mpc_data, mpc_int);
|
446 |
|
|
|
447 |
|
|
// Master Instruction counter
|
448 |
|
|
wire mic_ack, mic_stall;
|
449 |
|
|
wire [31:0] mic_data;
|
450 |
|
|
zipcounter mins_ctr(i_clk,(cpu_i_count), sys_cyc,
|
451 |
|
|
(sys_stb)&&(sys_addr == `MSTR_INST_CTR),
|
452 |
|
|
sys_we, sys_data,
|
453 |
|
|
mic_ack, mic_stall, mic_data, mic_int);
|
454 |
|
|
|
455 |
|
|
//
|
456 |
|
|
// The user counters are different from those of the master. They will
|
457 |
|
|
// be reset any time a task is given control of the CPU.
|
458 |
|
|
//
|
459 |
|
|
// User task counter
|
460 |
|
|
wire utc_ack, utc_stall;
|
461 |
|
|
wire [31:0] utc_data;
|
462 |
|
|
zipcounter utask_ctr(i_clk,(~cpu_halt)&&(cpu_gie), sys_cyc,
|
463 |
|
|
(sys_stb)&&(sys_addr == `USER_TASK_CTR),
|
464 |
|
|
sys_we, sys_data,
|
465 |
|
|
utc_ack, utc_stall, utc_data, utc_int);
|
466 |
|
|
|
467 |
|
|
// User Op-Stall counter
|
468 |
|
|
wire uoc_ack, uoc_stall;
|
469 |
|
|
wire [31:0] uoc_data;
|
470 |
|
|
zipcounter umstall_ctr(i_clk,(cpu_op_stall)&&(cpu_gie), sys_cyc,
|
471 |
|
|
(sys_stb)&&(sys_addr == `USER_MSTL_CTR),
|
472 |
|
|
sys_we, sys_data,
|
473 |
|
|
uoc_ack, uoc_stall, uoc_data, uoc_int);
|
474 |
|
|
|
475 |
|
|
// User PreFetch-Stall counter
|
476 |
|
|
wire upc_ack, upc_stall;
|
477 |
|
|
wire [31:0] upc_data;
|
478 |
|
|
zipcounter upstall_ctr(i_clk,(cpu_pf_stall)&&(cpu_gie), sys_cyc,
|
479 |
|
|
(sys_stb)&&(sys_addr == `USER_PSTL_CTR),
|
480 |
|
|
sys_we, sys_data,
|
481 |
|
|
upc_ack, upc_stall, upc_data, upc_int);
|
482 |
|
|
|
483 |
|
|
// User instruction counter
|
484 |
|
|
wire uic_ack, uic_stall;
|
485 |
|
|
wire [31:0] uic_data;
|
486 |
|
|
zipcounter uins_ctr(i_clk,(cpu_i_count)&&(cpu_gie), sys_cyc,
|
487 |
|
|
(sys_stb)&&(sys_addr == `USER_INST_CTR),
|
488 |
|
|
sys_we, sys_data,
|
489 |
|
|
uic_ack, uic_stall, uic_data, uic_int);
|
490 |
|
|
|
491 |
|
|
// A little bit of pre-cleanup (actr = accounting counters)
|
492 |
|
|
wire actr_ack, actr_stall;
|
493 |
|
|
wire [31:0] actr_data;
|
494 |
|
|
assign actr_ack = ((mtc_ack | moc_ack | mpc_ack | mic_ack)
|
495 |
|
|
|(utc_ack | uoc_ack | upc_ack | uic_ack));
|
496 |
|
|
assign actr_stall = ((mtc_stall | moc_stall | mpc_stall | mic_stall)
|
497 |
|
|
|(utc_stall | uoc_stall | upc_stall|uic_stall));
|
498 |
|
|
assign actr_data = ((mtc_ack) ? mtc_data
|
499 |
|
|
: ((moc_ack) ? moc_data
|
500 |
|
|
: ((mpc_ack) ? mpc_data
|
501 |
|
|
: ((mic_ack) ? mic_data
|
502 |
|
|
: ((utc_ack) ? utc_data
|
503 |
|
|
: ((uoc_ack) ? uoc_data
|
504 |
|
|
: ((upc_ack) ? upc_data
|
505 |
|
|
: uic_data)))))));
|
506 |
|
|
`else // INCLUDE_ACCOUNTING_COUNTERS
|
507 |
|
|
reg actr_ack;
|
508 |
|
|
wire actr_stall;
|
509 |
|
|
wire [31:0] actr_data;
|
510 |
|
|
assign actr_stall = 1'b0;
|
511 |
|
|
assign actr_data = 32'h0000;
|
512 |
|
|
|
513 |
|
|
assign mtc_int = 1'b0;
|
514 |
|
|
assign moc_int = 1'b0;
|
515 |
|
|
assign mpc_int = 1'b0;
|
516 |
|
|
assign mic_int = 1'b0;
|
517 |
|
|
assign utc_int = 1'b0;
|
518 |
|
|
assign uoc_int = 1'b0;
|
519 |
|
|
assign upc_int = 1'b0;
|
520 |
|
|
assign uic_int = 1'b0;
|
521 |
|
|
|
522 |
|
|
always @(posedge i_clk)
|
523 |
|
|
actr_ack <= (sys_stb)&&(sys_addr[4:3] == 2'b01);
|
524 |
|
|
`endif // INCLUDE_ACCOUNTING_COUNTERS
|
525 |
|
|
|
526 |
|
|
//
|
527 |
|
|
// The DMA Controller
|
528 |
|
|
//
|
529 |
|
|
wire dmac_stb, dc_err;
|
530 |
|
|
wire [31:0] dmac_data;
|
531 |
|
|
wire dmac_ack, dmac_stall;
|
532 |
|
|
wire dc_cyc, dc_stb, dc_we, dc_ack, dc_stall;
|
533 |
|
|
wire [31:0] dc_data;
|
534 |
|
|
wire [(AW-1):0] dc_addr;
|
535 |
|
|
wire cpu_gbl_cyc;
|
536 |
|
|
assign dmac_stb = (sys_stb)&&(sys_addr[4]);
|
537 |
|
|
`ifdef INCLUDE_DMA_CONTROLLER
|
538 |
|
|
wbdmac #(AW) dma_controller(i_clk,
|
539 |
|
|
sys_cyc, dmac_stb, sys_we,
|
540 |
|
|
sys_addr[1:0], sys_data,
|
541 |
|
|
dmac_ack, dmac_stall, dmac_data,
|
542 |
|
|
// Need the outgoing DMAC wishbone bus
|
543 |
|
|
dc_cyc, dc_stb, dc_we, dc_addr, dc_data,
|
544 |
|
|
dc_ack, dc_stall, ext_idata, dc_err,
|
545 |
|
|
// External device interrupts
|
546 |
|
|
{ 1'b0, alt_int_vector, 1'b0,
|
547 |
|
|
main_int_vector[14:1], 1'b0 },
|
548 |
|
|
// DMAC interrupt, for upon completion
|
549 |
|
|
dmac_int);
|
550 |
|
|
// Whether or not the CPU wants the bus, and
|
551 |
|
|
// thus we must kick the DMAC off.
|
552 |
|
|
// However, the logic required for this
|
553 |
|
|
// override never worked well, so here
|
554 |
|
|
// we just don't use it.
|
555 |
|
|
// cpu_gbl_cyc);
|
556 |
|
|
`else
|
557 |
|
|
reg r_dmac_ack;
|
558 |
|
|
always @(posedge i_clk)
|
559 |
|
|
r_dmac_ack <= (sys_cyc)&&(dmac_stb);
|
560 |
|
|
assign dmac_ack = r_dmac_ack;
|
561 |
|
|
assign dmac_data = 32'h000;
|
562 |
|
|
assign dmac_stall = 1'b0;
|
563 |
|
|
|
564 |
|
|
assign dc_cyc = 1'b0;
|
565 |
|
|
assign dc_stb = 1'b0;
|
566 |
|
|
assign dc_we = 1'b0;
|
567 |
|
|
assign dc_addr = { (AW) {1'b0} };
|
568 |
|
|
assign dc_data = 32'h00;
|
569 |
|
|
|
570 |
|
|
assign dmac_int = 1'b0;
|
571 |
|
|
`endif
|
572 |
|
|
|
573 |
|
|
wire ctri_sel, ctri_stall;
|
574 |
|
|
reg ctri_ack;
|
575 |
|
|
wire [31:0] ctri_data;
|
576 |
|
|
assign ctri_sel = (sys_cyc)&&(sys_stb)&&(sys_addr == `CTRINT);
|
577 |
|
|
always @(posedge i_clk)
|
578 |
|
|
ctri_ack <= ctri_sel;
|
579 |
|
|
assign ctri_stall = 1'b0;
|
580 |
|
|
`ifdef INCLUDE_ACCOUNTING_COUNTERS
|
581 |
|
|
//
|
582 |
|
|
// Counter Interrupt controller
|
583 |
|
|
//
|
584 |
|
|
generate
|
585 |
|
|
if (EXTERNAL_INTERRUPTS <= 9)
|
586 |
|
|
begin
|
587 |
|
|
icontrol #(8) ctri(i_clk, cpu_reset, (ctri_sel),
|
588 |
|
|
sys_data, ctri_data, alt_int_vector[7:0],
|
589 |
|
|
ctri_int);
|
590 |
|
|
end else begin
|
591 |
|
|
icontrol #(8+(EXTERNAL_INTERRUPTS-9))
|
592 |
|
|
ctri(i_clk, cpu_reset, (ctri_sel),
|
593 |
|
|
sys_data, ctri_data,
|
594 |
|
|
alt_int_vector[(EXTERNAL_INTERRUPTS-1):0],
|
595 |
|
|
ctri_int);
|
596 |
|
|
end endgenerate
|
597 |
|
|
|
598 |
|
|
`else // INCLUDE_ACCOUNTING_COUNTERS
|
599 |
|
|
|
600 |
|
|
generate
|
601 |
|
|
if (EXTERNAL_INTERRUPTS <= 9)
|
602 |
|
|
begin
|
603 |
|
|
assign ctri_stall = 1'b0;
|
604 |
|
|
assign ctri_data = 32'h0000;
|
605 |
|
|
assign ctri_int = 1'b0;
|
606 |
|
|
end else begin
|
607 |
|
|
icontrol #(EXTERNAL_INTERRUPTS-9)
|
608 |
|
|
ctri(i_clk, cpu_reset, (ctri_sel),
|
609 |
|
|
sys_data, ctri_data,
|
610 |
|
|
alt_int_vector[(EXTERNAL_INTERRUPTS-10):0],
|
611 |
|
|
ctri_int);
|
612 |
|
|
end endgenerate
|
613 |
|
|
`endif // INCLUDE_ACCOUNTING_COUNTERS
|
614 |
|
|
|
615 |
|
|
|
616 |
|
|
//
|
617 |
|
|
// Timer A
|
618 |
|
|
//
|
619 |
|
|
wire tma_ack, tma_stall;
|
620 |
|
|
wire [31:0] tma_data;
|
621 |
|
|
ziptimer timer_a(i_clk, cpu_reset, ~cmd_halt,
|
622 |
|
|
sys_cyc, (sys_stb)&&(sys_addr == `TIMER_A), sys_we,
|
623 |
|
|
sys_data,
|
624 |
|
|
tma_ack, tma_stall, tma_data, tma_int);
|
625 |
|
|
|
626 |
|
|
//
|
627 |
|
|
// Timer B
|
628 |
|
|
//
|
629 |
|
|
wire tmb_ack, tmb_stall;
|
630 |
|
|
wire [31:0] tmb_data;
|
631 |
|
|
ziptimer timer_b(i_clk, cpu_reset, ~cmd_halt,
|
632 |
|
|
sys_cyc, (sys_stb)&&(sys_addr == `TIMER_B), sys_we,
|
633 |
|
|
sys_data,
|
634 |
|
|
tmb_ack, tmb_stall, tmb_data, tmb_int);
|
635 |
|
|
|
636 |
|
|
//
|
637 |
|
|
// Timer C
|
638 |
|
|
//
|
639 |
|
|
wire tmc_ack, tmc_stall;
|
640 |
|
|
wire [31:0] tmc_data;
|
641 |
|
|
ziptimer timer_c(i_clk, cpu_reset, ~cmd_halt,
|
642 |
|
|
sys_cyc, (sys_stb)&&(sys_addr == `TIMER_C), sys_we,
|
643 |
|
|
sys_data,
|
644 |
|
|
tmc_ack, tmc_stall, tmc_data, tmc_int);
|
645 |
|
|
|
646 |
|
|
//
|
647 |
|
|
// JIFFIES
|
648 |
|
|
//
|
649 |
|
|
wire jif_ack, jif_stall;
|
650 |
|
|
wire [31:0] jif_data;
|
651 |
|
|
zipjiffies jiffies(i_clk, ~cmd_halt,
|
652 |
|
|
sys_cyc, (sys_stb)&&(sys_addr == `JIFFIES), sys_we,
|
653 |
|
|
sys_data,
|
654 |
|
|
jif_ack, jif_stall, jif_data, jif_int);
|
655 |
|
|
|
656 |
|
|
//
|
657 |
|
|
// The programmable interrupt controller peripheral
|
658 |
|
|
//
|
659 |
|
|
wire pic_interrupt;
|
660 |
|
|
generate
|
661 |
|
|
if (EXTERNAL_INTERRUPTS < 9)
|
662 |
|
|
begin
|
663 |
|
|
icontrol #(6+EXTERNAL_INTERRUPTS) pic(i_clk, cpu_reset,
|
664 |
|
|
(sys_cyc)&&(sys_stb)&&(sys_we)
|
665 |
|
|
&&(sys_addr==`INTCTRL),
|
666 |
|
|
sys_data, pic_data,
|
667 |
|
|
main_int_vector[(6+EXTERNAL_INTERRUPTS-1):0], pic_interrupt);
|
668 |
|
|
end else begin
|
669 |
|
|
icontrol #(15) pic(i_clk, cpu_reset,
|
670 |
|
|
(sys_cyc)&&(sys_stb)&&(sys_we)
|
671 |
|
|
&&(sys_addr==`INTCTRL),
|
672 |
|
|
sys_data, pic_data,
|
673 |
|
|
main_int_vector[14:0], pic_interrupt);
|
674 |
|
|
end endgenerate
|
675 |
|
|
|
676 |
|
|
wire pic_stall;
|
677 |
|
|
assign pic_stall = 1'b0;
|
678 |
|
|
reg pic_ack;
|
679 |
|
|
always @(posedge i_clk)
|
680 |
|
|
pic_ack <= (sys_cyc)&&(sys_stb)&&(sys_addr == `INTCTRL);
|
681 |
|
|
|
682 |
|
|
//
|
683 |
|
|
// The CPU itself
|
684 |
|
|
//
|
685 |
|
|
wire cpu_gbl_stb, cpu_lcl_cyc, cpu_lcl_stb,
|
686 |
|
|
cpu_we, cpu_dbg_we;
|
687 |
|
|
wire [31:0] cpu_data, wb_data;
|
688 |
|
|
wire cpu_ack, cpu_stall, cpu_err;
|
689 |
|
|
wire [31:0] cpu_dbg_data;
|
690 |
|
|
assign cpu_dbg_we = ((dbg_cyc)&&(dbg_stb)&&(~cmd_addr[5])
|
691 |
|
|
&&(dbg_we)&&(dbg_addr));
|
692 |
|
|
zipcpu #(RESET_ADDRESS,ADDRESS_WIDTH,LGICACHE, IMPLEMENT_MPY,
|
693 |
|
|
IMPLEMENT_DIVIDE, IMPLEMENT_FPU, IMPLEMENT_LOCK)
|
694 |
|
|
thecpu(i_clk, cpu_reset, pic_interrupt,
|
695 |
|
|
cpu_halt, cmd_clear_pf_cache, cmd_addr[4:0], cpu_dbg_we,
|
696 |
|
|
dbg_idata, cpu_dbg_stall, cpu_dbg_data,
|
697 |
|
|
cpu_dbg_cc, cpu_break,
|
698 |
|
|
cpu_gbl_cyc, cpu_gbl_stb,
|
699 |
|
|
cpu_lcl_cyc, cpu_lcl_stb,
|
700 |
|
|
cpu_we, cpu_addr, cpu_data,
|
701 |
|
|
cpu_ack, cpu_stall, wb_data,
|
702 |
|
|
cpu_err,
|
703 |
|
|
cpu_op_stall, cpu_pf_stall, cpu_i_count
|
704 |
|
|
`ifdef DEBUG_SCOPE
|
705 |
|
|
, o_cpu_debug
|
706 |
|
|
`endif
|
707 |
|
|
);
|
708 |
|
|
|
709 |
|
|
// Now, arbitrate the bus ... first for the local peripherals
|
710 |
|
|
// For the debugger to have access to the local system bus, the
|
711 |
|
|
// following must be true:
|
712 |
|
|
// (dbg_cyc) The debugger must request the bus
|
713 |
|
|
// (~cpu_lcl_cyc) The CPU cannot be using it (CPU gets priority)
|
714 |
|
|
// (dbg_addr) The debugger must be requesting its data
|
715 |
|
|
// register, not just the control register
|
716 |
|
|
// and one of two other things. Either
|
717 |
|
|
// ((cpu_halt)&&(~cpu_dbg_stall)) the CPU is completely halted,
|
718 |
|
|
// or
|
719 |
|
|
// (~cmd_addr[5]) we are trying to read a CPU register
|
720 |
|
|
// while in motion. Let the user beware that,
|
721 |
|
|
// by not waiting for the CPU to fully halt,
|
722 |
|
|
// his results may not be what he expects.
|
723 |
|
|
//
|
724 |
|
|
wire sys_dbg_cyc = ((dbg_cyc)&&(~cpu_lcl_cyc)&&(dbg_addr))
|
725 |
|
|
&&(((cpu_halt)&&(~cpu_dbg_stall))
|
726 |
|
|
||(~cmd_addr[5]));
|
727 |
|
|
assign sys_cyc = (cpu_lcl_cyc)||(sys_dbg_cyc);
|
728 |
|
|
assign sys_stb = (cpu_lcl_cyc)
|
729 |
|
|
? (cpu_lcl_stb)
|
730 |
|
|
: ((dbg_stb)&&(dbg_addr)&&(cmd_addr[5]));
|
731 |
|
|
|
732 |
|
|
assign sys_we = (cpu_lcl_cyc) ? cpu_we : dbg_we;
|
733 |
|
|
assign sys_addr= (cpu_lcl_cyc) ? cpu_addr[4:0] : cmd_addr[4:0];
|
734 |
|
|
assign sys_data= (cpu_lcl_cyc) ? cpu_data : dbg_idata;
|
735 |
|
|
|
736 |
|
|
// Return debug response values
|
737 |
|
|
assign dbg_odata = (~dbg_addr)?cmd_data
|
738 |
|
|
:((~cmd_addr[5])?cpu_dbg_data : wb_data);
|
739 |
|
|
initial dbg_ack = 1'b0;
|
740 |
|
|
always @(posedge i_clk)
|
741 |
|
|
dbg_ack <= (dbg_cyc)&&(~dbg_stall);
|
742 |
|
|
assign dbg_stall=(dbg_cyc)&&((~sys_dbg_cyc)||(sys_stall))&&(dbg_addr);
|
743 |
|
|
|
744 |
|
|
// Now for the external wishbone bus
|
745 |
|
|
// Need to arbitrate between the flash cache and the CPU
|
746 |
|
|
// The way this works, though, the CPU will stall once the flash
|
747 |
|
|
// cache gets access to the bus--the CPU will be stuck until the
|
748 |
|
|
// flash cache is finished with the bus.
|
749 |
|
|
wire ext_cyc, ext_stb, ext_we, ext_err;
|
750 |
|
|
wire cpu_ext_ack, cpu_ext_stall, ext_ack, ext_stall,
|
751 |
|
|
cpu_ext_err;
|
752 |
|
|
wire [(AW-1):0] ext_addr;
|
753 |
|
|
wire [31:0] ext_odata;
|
754 |
|
|
wbpriarbiter #(32,AW) dmacvcpu(i_clk,
|
755 |
|
|
cpu_gbl_cyc, cpu_gbl_stb, cpu_we, cpu_addr, cpu_data,
|
756 |
|
|
cpu_ext_ack, cpu_ext_stall, cpu_ext_err,
|
757 |
|
|
dc_cyc, dc_stb, dc_we, dc_addr, dc_data,
|
758 |
|
|
dc_ack, dc_stall, dc_err,
|
759 |
|
|
ext_cyc, ext_stb, ext_we, ext_addr, ext_odata,
|
760 |
|
|
ext_ack, ext_stall, ext_err);
|
761 |
|
|
|
762 |
|
|
`ifdef DELAY_EXT_BUS
|
763 |
|
|
busdelay #(AW,32) extbus(i_clk,
|
764 |
|
|
ext_cyc, ext_stb, ext_we, ext_addr, ext_odata,
|
765 |
|
|
ext_ack, ext_stall, ext_idata, ext_err,
|
766 |
|
|
o_wb_cyc, o_wb_stb, o_wb_we, o_wb_addr, o_wb_data,
|
767 |
|
|
i_wb_ack, i_wb_stall, i_wb_data, (i_wb_err)||(wdbus_int));
|
768 |
|
|
`else
|
769 |
|
|
assign o_wb_cyc = ext_cyc;
|
770 |
|
|
assign o_wb_stb = ext_stb;
|
771 |
|
|
assign o_wb_we = ext_we;
|
772 |
|
|
assign o_wb_addr = ext_addr;
|
773 |
|
|
assign o_wb_data = ext_odata;
|
774 |
|
|
assign ext_ack = i_wb_ack;
|
775 |
|
|
assign ext_stall = i_wb_stall;
|
776 |
|
|
assign ext_idata = i_wb_data;
|
777 |
|
|
assign ext_err = (i_wb_err)||(wdbus_int);
|
778 |
|
|
`endif
|
779 |
|
|
|
780 |
|
|
wire tmr_ack;
|
781 |
|
|
assign tmr_ack = (tma_ack|tmb_ack|tmc_ack|jif_ack);
|
782 |
|
|
wire [31:0] tmr_data;
|
783 |
|
|
assign tmr_data = (tma_ack)?tma_data
|
784 |
|
|
:(tmb_ack ? tmb_data
|
785 |
|
|
:(tmc_ack ? tmc_data
|
786 |
|
|
:jif_data));
|
787 |
|
|
assign wb_data = (tmr_ack|wdt_ack)?((tmr_ack)?tmr_data:wdt_data)
|
788 |
|
|
:((actr_ack|dmac_ack)?((actr_ack)?actr_data:dmac_data)
|
789 |
|
|
:((pic_ack|ctri_ack)?((pic_ack)?pic_data:ctri_data)
|
790 |
|
|
:((wdbus_ack)?wdbus_data:(ext_idata))));
|
791 |
|
|
|
792 |
|
|
assign sys_stall = (tma_stall | tmb_stall | tmc_stall | jif_stall
|
793 |
|
|
| wdt_stall | ctri_stall | actr_stall
|
794 |
|
|
| pic_stall | dmac_stall);
|
795 |
|
|
assign cpu_stall = (sys_stall)|(cpu_ext_stall);
|
796 |
|
|
assign sys_ack = (tmr_ack|wdt_ack|ctri_ack|actr_ack|pic_ack|dmac_ack|wdbus_ack);
|
797 |
|
|
assign cpu_ack = (sys_ack)||(cpu_ext_ack);
|
798 |
|
|
assign cpu_err = (cpu_ext_err)&&(cpu_gbl_cyc);
|
799 |
|
|
|
800 |
|
|
assign o_ext_int = (cmd_halt) && (~cpu_stall);
|
801 |
|
|
|
802 |
|
|
endmodule
|