1 |
266 |
lampret |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// MP3 demo Traffic Cop ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This file is part of the MP3 demo application ////
|
6 |
|
|
//// http://www.opencores.org/cores/or1k/mp3/ ////
|
7 |
|
|
//// ////
|
8 |
|
|
//// Description ////
|
9 |
|
|
//// This block connectes the RISC, audio i/f and memory ////
|
10 |
|
|
//// controller together. ////
|
11 |
|
|
//// ////
|
12 |
|
|
//// To Do: ////
|
13 |
|
|
//// - nothing really ////
|
14 |
|
|
//// ////
|
15 |
|
|
//// Author(s): ////
|
16 |
|
|
//// - Lior Shtram, lior.shtram@flextronicssemi.com ////
|
17 |
|
|
//// ////
|
18 |
|
|
//////////////////////////////////////////////////////////////////////
|
19 |
|
|
//// ////
|
20 |
|
|
//// Copyright (C) 2001 Authors ////
|
21 |
|
|
//// ////
|
22 |
|
|
//// This source file may be used and distributed without ////
|
23 |
|
|
//// restriction provided that this copyright statement is not ////
|
24 |
|
|
//// removed from the file and that any derivative work contains ////
|
25 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
26 |
|
|
//// ////
|
27 |
|
|
//// This source file is free software; you can redistribute it ////
|
28 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
29 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
30 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
31 |
|
|
//// later version. ////
|
32 |
|
|
//// ////
|
33 |
|
|
//// This source is distributed in the hope that it will be ////
|
34 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
35 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
36 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
37 |
|
|
//// details. ////
|
38 |
|
|
//// ////
|
39 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
40 |
|
|
//// Public License along with this source; if not, download it ////
|
41 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
42 |
|
|
//// ////
|
43 |
|
|
//////////////////////////////////////////////////////////////////////
|
44 |
|
|
//
|
45 |
|
|
// CVS Revision History
|
46 |
|
|
//
|
47 |
|
|
// $Log: not supported by cvs2svn $
|
48 |
|
|
//
|
49 |
|
|
// synopsys translate_off
|
50 |
|
|
`include "timescale.v"
|
51 |
|
|
// synopsys translate_on
|
52 |
|
|
|
53 |
|
|
// sr_input_sel
|
54 |
|
|
`define SR_RD 3'b001
|
55 |
|
|
`define SR_RI 3'b010
|
56 |
|
|
`define SR_VM 3'b011
|
57 |
|
|
`define SR_DM 3'b100
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
module tcop_top (
|
61 |
|
|
rstn,
|
62 |
|
|
clk,
|
63 |
|
|
|
64 |
|
|
wb_vs_adr_i,
|
65 |
|
|
wb_vs_dat_i,
|
66 |
|
|
wb_vs_dat_o,
|
67 |
|
|
wb_vs_sel_i,
|
68 |
|
|
wb_vs_we_i,
|
69 |
|
|
wb_vs_stb_i,
|
70 |
|
|
wb_vs_cyc_i,
|
71 |
|
|
wb_vs_ack_o,
|
72 |
|
|
wb_vs_err_o,
|
73 |
|
|
|
74 |
|
|
wb_vm_adr_o,
|
75 |
|
|
wb_vm_dat_i,
|
76 |
|
|
wb_vm_sel_o,
|
77 |
|
|
wb_vm_we_o,
|
78 |
|
|
wb_vm_stb_o,
|
79 |
|
|
wb_vm_cyc_o,
|
80 |
|
|
wb_vm_cab_o,
|
81 |
|
|
wb_vm_ack_i,
|
82 |
|
|
wb_vm_err_i,
|
83 |
|
|
|
84 |
|
|
wb_dm_adr_o,
|
85 |
|
|
wb_dm_dat_i,
|
86 |
|
|
wb_dm_dat_o,
|
87 |
|
|
wb_dm_sel_o,
|
88 |
|
|
wb_dm_we_o,
|
89 |
|
|
wb_dm_stb_o,
|
90 |
|
|
wb_dm_cyc_o,
|
91 |
|
|
wb_dm_cab_o,
|
92 |
|
|
wb_dm_ack_i,
|
93 |
|
|
wb_dm_err_i,
|
94 |
|
|
|
95 |
|
|
wb_ri_cyc_o,
|
96 |
|
|
wb_ri_adr_o,
|
97 |
|
|
wb_ri_dat_i,
|
98 |
|
|
wb_ri_dat_o,
|
99 |
|
|
wb_ri_sel_o,
|
100 |
|
|
wb_ri_ack_i,
|
101 |
|
|
wb_ri_err_i,
|
102 |
|
|
wb_ri_rty_i,
|
103 |
|
|
wb_ri_we_o,
|
104 |
|
|
wb_ri_stb_o,
|
105 |
|
|
|
106 |
|
|
wb_rd_cyc_o,
|
107 |
|
|
wb_rd_adr_o,
|
108 |
|
|
wb_rd_dat_i,
|
109 |
|
|
wb_rd_dat_o,
|
110 |
|
|
wb_rd_sel_o,
|
111 |
|
|
wb_rd_ack_i,
|
112 |
|
|
wb_rd_err_i,
|
113 |
|
|
wb_rd_rty_i,
|
114 |
|
|
wb_rd_we_o,
|
115 |
|
|
wb_rd_stb_o,
|
116 |
|
|
|
117 |
|
|
wb_sr_dat_i,
|
118 |
|
|
wb_sr_dat_o,
|
119 |
|
|
wb_sr_adr_i,
|
120 |
|
|
wb_sr_sel_i,
|
121 |
|
|
wb_sr_we_i,
|
122 |
|
|
wb_sr_cyc_i,
|
123 |
|
|
wb_sr_stb_i,
|
124 |
|
|
wb_sr_ack_o,
|
125 |
|
|
wb_sr_err_o,
|
126 |
|
|
|
127 |
|
|
wb_fl_dat_i,
|
128 |
|
|
wb_fl_dat_o,
|
129 |
|
|
wb_fl_adr_i,
|
130 |
|
|
wb_fl_sel_i,
|
131 |
|
|
wb_fl_we_i,
|
132 |
|
|
wb_fl_cyc_i,
|
133 |
|
|
wb_fl_stb_i,
|
134 |
|
|
wb_fl_ack_o,
|
135 |
|
|
wb_fl_err_o,
|
136 |
|
|
|
137 |
|
|
wb_au_dat_i,
|
138 |
|
|
wb_au_dat_o,
|
139 |
|
|
wb_au_adr_i,
|
140 |
|
|
wb_au_sel_i,
|
141 |
|
|
wb_au_we_i,
|
142 |
|
|
wb_au_cyc_i,
|
143 |
|
|
wb_au_stb_i,
|
144 |
|
|
wb_au_ack_o,
|
145 |
|
|
wb_au_err_o
|
146 |
|
|
|
147 |
|
|
);
|
148 |
|
|
|
149 |
|
|
parameter data_width = 32;
|
150 |
|
|
parameter addr_width = 32;
|
151 |
|
|
|
152 |
|
|
parameter n_mast_i = (data_width + 2) ;
|
153 |
|
|
parameter n_mast_o = data_width + addr_width + 6 ;
|
154 |
|
|
|
155 |
|
|
input clk;
|
156 |
|
|
input rstn;
|
157 |
|
|
|
158 |
|
|
output [addr_width-1:0] wb_vs_adr_i;
|
159 |
|
|
output [data_width-1:0] wb_vs_dat_i;
|
160 |
|
|
input [data_width-1:0] wb_vs_dat_o;
|
161 |
|
|
output [3:0] wb_vs_sel_i;
|
162 |
|
|
output wb_vs_we_i;
|
163 |
|
|
output wb_vs_stb_i;
|
164 |
|
|
output wb_vs_cyc_i;
|
165 |
|
|
input wb_vs_ack_o;
|
166 |
|
|
input wb_vs_err_o;
|
167 |
|
|
|
168 |
|
|
input [addr_width-1:0] wb_vm_adr_o;
|
169 |
|
|
output [data_width-1:0] wb_vm_dat_i;
|
170 |
|
|
input [3:0] wb_vm_sel_o;
|
171 |
|
|
input wb_vm_stb_o;
|
172 |
|
|
input wb_vm_we_o;
|
173 |
|
|
input wb_vm_cyc_o;
|
174 |
|
|
input wb_vm_cab_o;
|
175 |
|
|
output wb_vm_ack_i;
|
176 |
|
|
output wb_vm_err_i;
|
177 |
|
|
|
178 |
|
|
input [addr_width-1:0] wb_dm_adr_o;
|
179 |
|
|
output [data_width-1:0] wb_dm_dat_i;
|
180 |
|
|
input [data_width-1:0] wb_dm_dat_o;
|
181 |
|
|
input [3:0] wb_dm_sel_o;
|
182 |
|
|
input wb_dm_stb_o;
|
183 |
|
|
input wb_dm_we_o;
|
184 |
|
|
input wb_dm_cyc_o;
|
185 |
|
|
input wb_dm_cab_o;
|
186 |
|
|
output wb_dm_ack_i;
|
187 |
|
|
output wb_dm_err_i;
|
188 |
|
|
|
189 |
|
|
input [addr_width-1:0] wb_ri_adr_o;
|
190 |
|
|
input wb_ri_cyc_o;
|
191 |
|
|
output [data_width-1:0] wb_ri_dat_i;
|
192 |
|
|
input [data_width-1:0] wb_ri_dat_o;
|
193 |
|
|
input [3:0] wb_ri_sel_o;
|
194 |
|
|
output wb_ri_ack_i;
|
195 |
|
|
output wb_ri_err_i;
|
196 |
|
|
output wb_ri_rty_i;
|
197 |
|
|
input wb_ri_we_o;
|
198 |
|
|
input wb_ri_stb_o;
|
199 |
|
|
|
200 |
|
|
input [addr_width-1:0] wb_rd_adr_o;
|
201 |
|
|
input wb_rd_cyc_o;
|
202 |
|
|
output [data_width-1:0] wb_rd_dat_i;
|
203 |
|
|
input [data_width-1:0] wb_rd_dat_o;
|
204 |
|
|
input [3:0] wb_rd_sel_o;
|
205 |
|
|
output wb_rd_ack_i;
|
206 |
|
|
output wb_rd_err_i;
|
207 |
|
|
output wb_rd_rty_i;
|
208 |
|
|
input wb_rd_we_o;
|
209 |
|
|
input wb_rd_stb_o;
|
210 |
|
|
|
211 |
|
|
output [data_width-1:0] wb_sr_dat_i;
|
212 |
|
|
input [data_width-1:0] wb_sr_dat_o;
|
213 |
|
|
output [addr_width-1:0] wb_sr_adr_i;
|
214 |
|
|
output [3:0] wb_sr_sel_i;
|
215 |
|
|
output wb_sr_we_i;
|
216 |
|
|
output wb_sr_cyc_i;
|
217 |
|
|
output wb_sr_stb_i;
|
218 |
|
|
input wb_sr_ack_o;
|
219 |
|
|
input wb_sr_err_o;
|
220 |
|
|
|
221 |
|
|
output [data_width-1:0] wb_fl_dat_i;
|
222 |
|
|
input [data_width-1:0] wb_fl_dat_o;
|
223 |
|
|
output [addr_width-1:0] wb_fl_adr_i;
|
224 |
|
|
output [3:0] wb_fl_sel_i;
|
225 |
|
|
output wb_fl_we_i;
|
226 |
|
|
output wb_fl_cyc_i;
|
227 |
|
|
output wb_fl_stb_i;
|
228 |
|
|
input wb_fl_ack_o;
|
229 |
|
|
input wb_fl_err_o;
|
230 |
|
|
|
231 |
|
|
output [data_width-1:0] wb_au_dat_i;
|
232 |
|
|
input [data_width-1:0] wb_au_dat_o;
|
233 |
|
|
output [addr_width-1:0] wb_au_adr_i;
|
234 |
|
|
output [3:0] wb_au_sel_i;
|
235 |
|
|
output wb_au_we_i;
|
236 |
|
|
output wb_au_cyc_i;
|
237 |
|
|
output wb_au_stb_i;
|
238 |
|
|
input wb_au_ack_o;
|
239 |
|
|
input wb_au_err_o;
|
240 |
|
|
|
241 |
|
|
|
242 |
|
|
wire [data_width-1:0] data_width_zeros;
|
243 |
|
|
assign data_width_zeros = 0;
|
244 |
|
|
wire [n_mast_i-1:0] n_mast_i_zeros;
|
245 |
|
|
assign n_mast_i_zeros = 0;
|
246 |
|
|
wire [n_mast_o-1:0] n_mast_o_zeros;
|
247 |
|
|
wire [n_mast_i-1:0] ri_inputs;
|
248 |
|
|
wire [n_mast_o-1:0] ri_outputs;
|
249 |
|
|
wire [n_mast_i-1:0] rd_inputs;
|
250 |
|
|
wire [n_mast_o-1:0] rd_outputs;
|
251 |
|
|
wire [n_mast_i-1:0] vm_inputs;
|
252 |
|
|
wire [n_mast_o-1:0] vm_outputs;
|
253 |
|
|
wire [n_mast_i-1:0] dm_inputs;
|
254 |
|
|
wire [n_mast_o-1:0] dm_outputs;
|
255 |
|
|
wire [n_mast_o-1:0] vs_inputs;
|
256 |
|
|
wire [n_mast_i-1:0] vs_outputs;
|
257 |
|
|
reg [n_mast_o-1:0] sr_inputs;
|
258 |
|
|
wire [n_mast_i-1:0] sr_outputs;
|
259 |
|
|
wire [n_mast_o-1:0] fl_inputs;
|
260 |
|
|
wire [n_mast_i-1:0] fl_outputs;
|
261 |
|
|
wire [n_mast_o-1:0] au_inputs;
|
262 |
|
|
wire [n_mast_i-1:0] au_outputs;
|
263 |
|
|
wire [n_mast_i-1:0] sr_to_dm;
|
264 |
|
|
wire [n_mast_i-1:0] fl_to_dm;
|
265 |
|
|
wire [n_mast_i-1:0] au_to_rd;
|
266 |
|
|
wire [n_mast_i-1:0] vs_to_rd;
|
267 |
|
|
wire [n_mast_i-1:0] sr_to_rd;
|
268 |
|
|
wire [n_mast_i-1:0] fl_to_rd;
|
269 |
|
|
wire [n_mast_i-1:0] sr_to_ri;
|
270 |
|
|
wire [n_mast_i-1:0] fl_to_ri;
|
271 |
|
|
wire fl_input_sel;
|
272 |
|
|
reg [2:0] sr_input_sel;
|
273 |
|
|
reg [3:0] dm_cs;
|
274 |
|
|
reg [3:0] rd_cs;
|
275 |
|
|
wire dm_fl_cs;
|
276 |
|
|
wire dm_sr_cs;
|
277 |
|
|
wire dm_au_cs;
|
278 |
|
|
wire dm_vs_cs;
|
279 |
|
|
wire rd_fl_cs;
|
280 |
|
|
wire rd_sr_cs;
|
281 |
|
|
wire rd_au_cs;
|
282 |
|
|
wire rd_vs_cs;
|
283 |
|
|
wire ri_fl_cs;
|
284 |
|
|
wire ri_sr_cs;
|
285 |
|
|
//reg rd_sr_con;
|
286 |
|
|
reg dm_fl_con;
|
287 |
|
|
reg rd_fl_con;
|
288 |
|
|
reg ri_fl_con;
|
289 |
|
|
|
290 |
|
|
// We don't support retries
|
291 |
|
|
assign wb_ri_rty_i = 1'b0;
|
292 |
|
|
assign wb_rd_rty_i = 1'b0;
|
293 |
|
|
|
294 |
|
|
//////////////////////////////////
|
295 |
|
|
// Gathering all inputs and outputs together
|
296 |
|
|
|
297 |
|
|
assign { wb_ri_dat_i, wb_ri_ack_i, wb_ri_err_i } = ri_inputs ;
|
298 |
|
|
assign ri_outputs = { wb_ri_dat_o, wb_ri_adr_o, wb_ri_sel_o, wb_ri_we_o, wb_ri_stb_o };
|
299 |
|
|
|
300 |
|
|
assign { wb_rd_dat_i, wb_rd_ack_i, wb_rd_err_i } = rd_inputs ;
|
301 |
|
|
assign rd_outputs = { wb_rd_dat_o, wb_rd_adr_o, wb_rd_sel_o, wb_rd_we_o, wb_rd_stb_o };
|
302 |
|
|
|
303 |
|
|
assign { wb_vm_dat_i, wb_vm_ack_i, wb_vm_err_i } = vm_inputs ;
|
304 |
|
|
// This is a problem !!!!!!!!!!!!!!!
|
305 |
|
|
assign vm_outputs = { data_width_zeros, wb_vm_adr_o, wb_vm_sel_o, wb_vm_we_o, wb_vm_stb_o };
|
306 |
|
|
|
307 |
|
|
assign { wb_dm_dat_i, wb_dm_ack_i, wb_dm_err_i } = dm_inputs ;
|
308 |
|
|
assign dm_outputs = { wb_dm_dat_o, wb_dm_adr_o, wb_dm_sel_o, wb_dm_we_o, wb_dm_stb_o };
|
309 |
|
|
|
310 |
|
|
assign { wb_vs_dat_i, wb_vs_adr_i, wb_vs_sel_i, wb_vs_we_i, wb_vs_stb_i } = vs_inputs;
|
311 |
|
|
assign vs_outputs = { wb_vs_dat_o, wb_vs_ack_o, wb_vs_err_o };
|
312 |
|
|
|
313 |
|
|
assign { wb_fl_dat_i, wb_fl_adr_i, wb_fl_sel_i, wb_fl_we_i, wb_fl_stb_i } = fl_inputs;
|
314 |
|
|
assign fl_outputs = { wb_fl_dat_o, wb_fl_ack_o, wb_fl_err_o };
|
315 |
|
|
|
316 |
|
|
assign { wb_sr_dat_i, wb_sr_adr_i, wb_sr_sel_i, wb_sr_we_i, wb_sr_stb_i } = sr_inputs;
|
317 |
|
|
assign sr_outputs = { wb_sr_dat_o, wb_sr_ack_o, wb_sr_err_o };
|
318 |
|
|
|
319 |
|
|
assign { wb_au_dat_i, wb_au_adr_i, wb_au_sel_i, wb_au_we_i, wb_au_stb_i } = au_inputs;
|
320 |
|
|
assign au_outputs = { wb_au_dat_o, wb_au_ack_o, wb_au_err_o };
|
321 |
|
|
|
322 |
|
|
//////////////////////////////////////////////////////////////////////////
|
323 |
|
|
// Connectivity
|
324 |
|
|
|
325 |
|
|
// VGA slave is only accessable by RISC Data
|
326 |
|
|
assign vs_inputs = rd_outputs;
|
327 |
|
|
// Audio is only accessable by RISC Data
|
328 |
|
|
assign au_inputs = rd_outputs;
|
329 |
|
|
|
330 |
|
|
// SRAM is accessable by either RISC Data or VGA Master
|
331 |
|
|
always @(sr_input_sel or rd_outputs or vm_outputs or ri_outputs or dm_outputs or n_mast_i_zeros)
|
332 |
|
|
begin
|
333 |
|
|
case (sr_input_sel)
|
334 |
|
|
`SR_RD: sr_inputs <= rd_outputs;
|
335 |
|
|
`SR_RI: sr_inputs <= ri_outputs;
|
336 |
|
|
`SR_VM: sr_inputs <= vm_outputs;
|
337 |
|
|
`SR_DM: sr_inputs <= dm_outputs;
|
338 |
|
|
default: sr_inputs <= n_mast_i_zeros;
|
339 |
|
|
endcase
|
340 |
|
|
end
|
341 |
|
|
|
342 |
|
|
// FLASH is accessable by either RISC Instruction, RISC Data or Development I/F
|
343 |
|
|
assign fl_inputs = ( ri_fl_con ? ri_outputs : rd_fl_con ? rd_outputs : dm_outputs );
|
344 |
|
|
|
345 |
|
|
// RISC Instruction access
|
346 |
|
|
assign sr_to_ri = ( sr_input_sel == `SR_RI ? sr_outputs : n_mast_i_zeros );
|
347 |
|
|
assign fl_to_ri = ( ri_fl_con ? fl_outputs : n_mast_i_zeros );
|
348 |
|
|
assign ri_inputs = sr_to_ri | fl_to_ri;
|
349 |
|
|
|
350 |
|
|
// Development I/F access
|
351 |
|
|
assign sr_to_dm = ( sr_input_sel == `SR_DM ? sr_outputs : n_mast_i_zeros );
|
352 |
|
|
assign fl_to_dm = ( dm_fl_con ? fl_outputs : n_mast_i_zeros );
|
353 |
|
|
assign dm_inputs = sr_to_dm | fl_to_dm;
|
354 |
|
|
|
355 |
|
|
// VGA Master can only access SRAM
|
356 |
|
|
assign vm_inputs = ( sr_input_sel == 2'b11 ? sr_outputs : n_mast_i_zeros );
|
357 |
|
|
|
358 |
|
|
// RISC Data can access all 4 slaves
|
359 |
|
|
// SRAM can go to two masters
|
360 |
|
|
assign sr_to_rd = ( sr_input_sel == `SR_RD ? sr_outputs : n_mast_i_zeros );
|
361 |
|
|
// FLASH can go to two masters
|
362 |
|
|
assign fl_to_rd = ( ( ri_fl_con | !rd_fl_cs ) ? n_mast_i_zeros : fl_outputs );
|
363 |
|
|
// Audio can go to RISC Data
|
364 |
|
|
assign au_to_rd = ( ( !rd_au_cs ) ? n_mast_i_zeros : au_outputs );
|
365 |
|
|
// Video slave can go to RISC Data
|
366 |
|
|
assign vs_to_rd = ( ( !rd_vs_cs ) ? n_mast_i_zeros : vs_outputs );
|
367 |
|
|
// Now we just OR all slave outputs
|
368 |
|
|
assign rd_inputs = sr_to_rd | fl_to_rd | au_to_rd | vs_to_rd;
|
369 |
|
|
|
370 |
|
|
|
371 |
|
|
///////////////////////////////////////////////////////////////////////////
|
372 |
|
|
// Decoding
|
373 |
|
|
|
374 |
|
|
// decoding address of RISC data
|
375 |
|
|
always @( wb_rd_adr_o[addr_width-1:addr_width-2] )
|
376 |
|
|
begin
|
377 |
|
|
case ( wb_rd_adr_o[addr_width-1:addr_width-2] )
|
378 |
|
|
2'b00: rd_cs = 4'b0001;
|
379 |
|
|
2'b01: rd_cs = 4'b0010;
|
380 |
|
|
2'b10: rd_cs = 4'b0100;
|
381 |
|
|
2'b11: rd_cs = 4'b1000;
|
382 |
|
|
default: rd_cs = 4'bx;
|
383 |
|
|
endcase
|
384 |
|
|
end
|
385 |
|
|
|
386 |
|
|
assign rd_sr_cs = rd_cs[2];
|
387 |
|
|
assign rd_fl_cs = rd_cs[0];
|
388 |
|
|
assign rd_au_cs = rd_cs[1];
|
389 |
|
|
assign rd_vs_cs = rd_cs[3];
|
390 |
|
|
|
391 |
|
|
// decoding address of Development I/F
|
392 |
|
|
always @( wb_dm_adr_o[addr_width-1:addr_width-2] )
|
393 |
|
|
begin
|
394 |
|
|
case ( wb_dm_adr_o[addr_width-1:addr_width-2] )
|
395 |
|
|
2'b00: dm_cs = 4'b0001;
|
396 |
|
|
2'b01: dm_cs = 4'b0010;
|
397 |
|
|
2'b10: dm_cs = 4'b0100;
|
398 |
|
|
2'b11: dm_cs = 4'b1000;
|
399 |
|
|
default: dm_cs = 4'bx;
|
400 |
|
|
endcase
|
401 |
|
|
end
|
402 |
|
|
|
403 |
|
|
assign dm_sr_cs = dm_cs[2];
|
404 |
|
|
assign dm_fl_cs = dm_cs[0];
|
405 |
|
|
assign dm_au_cs = dm_cs[1];
|
406 |
|
|
assign dm_vs_cs = dm_cs[3];
|
407 |
|
|
|
408 |
|
|
// decoding of address of RISC instruction
|
409 |
|
|
assign ri_sr_cs = wb_ri_adr_o[addr_width-1];
|
410 |
|
|
assign ri_fl_cs = ~wb_ri_adr_o[addr_width-1];
|
411 |
|
|
|
412 |
|
|
// Priority mechanism for Flash slave between RISC Data, RISC Insn, and Development I/F masters
|
413 |
|
|
always @( posedge clk or negedge rstn )
|
414 |
|
|
if (!rstn) begin
|
415 |
|
|
dm_fl_con <= 1'b0;
|
416 |
|
|
rd_fl_con <= 1'b0;
|
417 |
|
|
ri_fl_con <= 1'b0;
|
418 |
|
|
end
|
419 |
|
|
else
|
420 |
|
|
case ( { dm_fl_con, rd_fl_con, ri_fl_con } )
|
421 |
|
|
3'b000: if ( wb_dm_cyc_o & wb_dm_stb_o & dm_fl_cs ) dm_fl_con <= #1 1'b1;
|
422 |
|
|
else if ( wb_rd_cyc_o & wb_rd_stb_o & rd_fl_cs ) rd_fl_con <= #1 1'b1;
|
423 |
|
|
else if ( wb_ri_cyc_o & wb_ri_stb_o & ri_fl_cs ) ri_fl_con <= #1 1'b1;
|
424 |
|
|
3'b001: if ( (wb_ri_cyc_o & wb_ri_stb_o & ri_fl_cs)
|
425 |
|
|
& !(wb_rd_cyc_o & wb_rd_stb_o & rd_fl_cs & wb_fl_ack_o)
|
426 |
|
|
& !(wb_dm_cyc_o & wb_dm_stb_o & dm_fl_cs & wb_fl_ack_o) ) ri_fl_con <= #1 1'b1;
|
427 |
|
|
else ri_fl_con <= #1 1'b0;
|
428 |
|
|
3'b010: if ( wb_rd_cyc_o & wb_rd_stb_o & rd_fl_cs ) rd_fl_con <= #1 1'b1;
|
429 |
|
|
else rd_fl_con <= #1 1'b0;
|
430 |
|
|
3'b100: if ( wb_dm_cyc_o & wb_dm_stb_o & dm_fl_cs ) dm_fl_con <= #1 1'b1;
|
431 |
|
|
else dm_fl_con <= #1 1'b0;
|
432 |
|
|
default: $display("Error, two or more masters currently accessing FLASH");
|
433 |
|
|
endcase
|
434 |
|
|
|
435 |
|
|
// Priority mechanism between RISC Data, VGA Master and Development I/F Master
|
436 |
|
|
always @( posedge clk or negedge rstn )
|
437 |
|
|
if (!rstn)
|
438 |
|
|
sr_input_sel <= 3'b000;
|
439 |
|
|
else
|
440 |
|
|
case ( sr_input_sel )
|
441 |
|
|
3'b000: if ( wb_vm_cyc_o & wb_vm_stb_o ) sr_input_sel <= #1 `SR_VM;
|
442 |
|
|
else
|
443 |
|
|
if ( wb_dm_cyc_o & wb_dm_stb_o & dm_sr_cs ) sr_input_sel <= #1 `SR_DM;
|
444 |
|
|
else if ( wb_rd_cyc_o & wb_rd_stb_o & rd_sr_cs ) sr_input_sel <= #1 `SR_RD;
|
445 |
|
|
else if ( wb_ri_cyc_o & wb_ri_stb_o & ri_sr_cs ) sr_input_sel <= #1 `SR_RI;
|
446 |
|
|
`SR_VM: if ( wb_vm_cyc_o & wb_vm_stb_o ) sr_input_sel <= #1 `SR_VM;
|
447 |
|
|
else sr_input_sel <= #1 3'b000;
|
448 |
|
|
`SR_RI: if ( ( wb_ri_cyc_o & wb_ri_stb_o & ri_sr_cs ) & !(wb_rd_cyc_o & rd_sr_cs & wb_sr_ack_o)) sr_input_sel <= #1 `SR_RI;
|
449 |
|
|
else sr_input_sel <= #1 3'b000;
|
450 |
|
|
`SR_RD: if ( wb_rd_cyc_o & wb_rd_stb_o & rd_sr_cs & ~wb_rd_ack_i) sr_input_sel <= #1 `SR_RD;
|
451 |
|
|
else sr_input_sel <= #1 3'b000;
|
452 |
|
|
`SR_DM: if ( wb_dm_cyc_o & wb_dm_stb_o & dm_sr_cs & ~wb_dm_ack_i) sr_input_sel <= #1 `SR_DM;
|
453 |
|
|
else sr_input_sel <= #1 3'b000;
|
454 |
|
|
default: $display("Error, two or more masters currently accessing SRAM");
|
455 |
|
|
endcase
|
456 |
|
|
|
457 |
|
|
// Connecting the cyc signals
|
458 |
|
|
assign wb_fl_cyc_i = dm_fl_con ? wb_dm_cyc_o : rd_fl_con ? wb_rd_cyc_o : ri_fl_con ? wb_ri_cyc_o : 1'b0;
|
459 |
|
|
assign wb_sr_cyc_i = sr_input_sel == `SR_VM ? wb_vm_cyc_o : sr_input_sel == `SR_RD ? wb_rd_cyc_o : sr_input_sel == `SR_RI ? wb_ri_cyc_o : sr_input_sel == `SR_DM ? wb_dm_cyc_o : 1'b0;
|
460 |
|
|
assign wb_au_cyc_i = rd_au_cs ? wb_rd_cyc_o : 1'b0 ;
|
461 |
|
|
assign wb_vs_cyc_i = rd_vs_cs ? wb_rd_cyc_o : 1'b0 ;
|
462 |
|
|
|
463 |
|
|
endmodule
|