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

Subversion Repositories versatile_library

[/] [versatile_library/] [trunk/] [rtl/] [verilog/] [wb.v] - Blame information for rev 78

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

Line No. Rev Author Line
1 12 unneback
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Versatile library, wishbone stuff                           ////
4
////                                                              ////
5
////  Description                                                 ////
6
////  Wishbone compliant modules                                  ////
7
////                                                              ////
8
////                                                              ////
9
////  To Do:                                                      ////
10
////   -                                                          ////
11
////                                                              ////
12
////  Author(s):                                                  ////
13
////      - Michael Unneback, unneback@opencores.org              ////
14
////        ORSoC AB                                              ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2010 Authors and OPENCORES.ORG                 ////
19
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
 
43 75 unneback
`ifdef WB_ADR_INC
44
// async wb3 - wb3 bridge
45
`timescale 1ns/1ns
46
`define MODULE wb_adr_inc
47
module `BASE`MODULE (
48
`undef MODULE
49
 
50
    always @ (posedge clk or posedge rst)
51
        if (rst)
52
           col_reg <= {col_reg_width{1'b0}};
53
        else
54
            case (state)
55
            `FSM_IDLE:
56
               col_reg <= col[col_reg_width-1:0];
57
            `FSM_RW:
58
               if (~stall)
59
                  case (bte_i)
60
`ifdef SDR_BEAT4
61
                        beat4:  col_reg[2:0] <= col_reg[2:0] + 3'd1;
62
`endif
63
`ifdef SDR_BEAT8
64
                        beat8:  col_reg[3:0] <= col_reg[3:0] + 4'd1;
65
`endif
66
`ifdef SDR_BEAT16
67
                        beat16: col_reg[4:0] <= col_reg[4:0] + 5'd1;
68
`endif
69
                  endcase
70
            endcase
71
`endif
72
 
73 40 unneback
`ifdef WB3WB3_BRIDGE
74 12 unneback
// async wb3 - wb3 bridge
75
`timescale 1ns/1ns
76 40 unneback
`define MODULE wb3wb3_bridge
77
module `BASE`MODULE (
78
`undef MODULE
79 12 unneback
        // wishbone slave side
80
        wbs_dat_i, wbs_adr_i, wbs_sel_i, wbs_bte_i, wbs_cti_i, wbs_we_i, wbs_cyc_i, wbs_stb_i, wbs_dat_o, wbs_ack_o, wbs_clk, wbs_rst,
81
        // wishbone master side
82
        wbm_dat_o, wbm_adr_o, wbm_sel_o, wbm_bte_o, wbm_cti_o, wbm_we_o, wbm_cyc_o, wbm_stb_o, wbm_dat_i, wbm_ack_i, wbm_clk, wbm_rst);
83
 
84
input [31:0] wbs_dat_i;
85
input [31:2] wbs_adr_i;
86
input [3:0]  wbs_sel_i;
87
input [1:0]  wbs_bte_i;
88
input [2:0]  wbs_cti_i;
89
input wbs_we_i, wbs_cyc_i, wbs_stb_i;
90
output [31:0] wbs_dat_o;
91 14 unneback
output wbs_ack_o;
92 12 unneback
input wbs_clk, wbs_rst;
93
 
94
output [31:0] wbm_dat_o;
95
output reg [31:2] wbm_adr_o;
96
output [3:0]  wbm_sel_o;
97
output reg [1:0]  wbm_bte_o;
98
output reg [2:0]  wbm_cti_o;
99 14 unneback
output reg wbm_we_o;
100
output wbm_cyc_o;
101 12 unneback
output wbm_stb_o;
102
input [31:0]  wbm_dat_i;
103
input wbm_ack_i;
104
input wbm_clk, wbm_rst;
105
 
106
parameter addr_width = 4;
107
 
108
// bte
109
parameter linear       = 2'b00;
110
parameter wrap4        = 2'b01;
111
parameter wrap8        = 2'b10;
112
parameter wrap16       = 2'b11;
113
// cti
114
parameter classic      = 3'b000;
115
parameter incburst     = 3'b010;
116
parameter endofburst   = 3'b111;
117
 
118
parameter wbs_adr  = 1'b0;
119
parameter wbs_data = 1'b1;
120
 
121 33 unneback
parameter wbm_adr0      = 2'b00;
122
parameter wbm_adr1      = 2'b01;
123
parameter wbm_data      = 2'b10;
124
parameter wbm_data_wait = 2'b11;
125 12 unneback
 
126
reg [1:0] wbs_bte_reg;
127
reg wbs;
128
wire wbs_eoc_alert, wbm_eoc_alert;
129
reg wbs_eoc, wbm_eoc;
130
reg [1:0] wbm;
131
 
132 14 unneback
wire [1:16] wbs_count, wbm_count;
133 12 unneback
 
134
wire [35:0] a_d, a_q, b_d, b_q;
135
wire a_wr, a_rd, a_fifo_full, a_fifo_empty, b_wr, b_rd, b_fifo_full, b_fifo_empty;
136
reg a_rd_reg;
137
wire b_rd_adr, b_rd_data;
138 14 unneback
wire b_rd_data_reg;
139
wire [35:0] temp;
140 12 unneback
 
141
`define WE 5
142
`define BTE 4:3
143
`define CTI 2:0
144
 
145
assign wbs_eoc_alert = (wbs_bte_reg==wrap4 & wbs_count[3]) | (wbs_bte_reg==wrap8 & wbs_count[7]) | (wbs_bte_reg==wrap16 & wbs_count[15]);
146
always @ (posedge wbs_clk or posedge wbs_rst)
147
if (wbs_rst)
148
        wbs_eoc <= 1'b0;
149
else
150
        if (wbs==wbs_adr & wbs_stb_i & !a_fifo_full)
151 78 unneback
                wbs_eoc <= (wbs_bte_i==linear) | (wbs_cti_i==3'b111);
152 12 unneback
        else if (wbs_eoc_alert & (a_rd | a_wr))
153
                wbs_eoc <= 1'b1;
154
 
155 40 unneback
`define MODULE cnt_shreg_ce_clear
156
`BASE`MODULE # ( .length(16))
157
`undef MODULE
158 12 unneback
    cnt0 (
159
        .cke(wbs_ack_o),
160
        .clear(wbs_eoc),
161
        .q(wbs_count),
162
        .rst(wbs_rst),
163
        .clk(wbs_clk));
164
 
165
always @ (posedge wbs_clk or posedge wbs_rst)
166
if (wbs_rst)
167
        wbs <= wbs_adr;
168
else
169 75 unneback
        if ((wbs==wbs_adr) & wbs_cyc_i & wbs_stb_i & a_fifo_empty)
170 12 unneback
                wbs <= wbs_data;
171
        else if (wbs_eoc & wbs_ack_o)
172
                wbs <= wbs_adr;
173
 
174
// wbs FIFO
175 75 unneback
assign a_d = (wbs==wbs_adr) ? {wbs_adr_i[31:2],wbs_we_i,((wbs_cti_i==3'b111) ? {2'b00,3'b000} : {wbs_bte_i,wbs_cti_i})} : {wbs_dat_i,wbs_sel_i};
176
assign a_wr = (wbs==wbs_adr)  ? wbs_cyc_i & wbs_stb_i & a_fifo_empty :
177 12 unneback
              (wbs==wbs_data) ? wbs_we_i  & wbs_stb_i & !a_fifo_full :
178
              1'b0;
179
assign a_rd = !a_fifo_empty;
180
always @ (posedge wbs_clk or posedge wbs_rst)
181
if (wbs_rst)
182
        a_rd_reg <= 1'b0;
183
else
184
        a_rd_reg <= a_rd;
185
assign wbs_ack_o = a_rd_reg | (a_wr & wbs==wbs_data);
186
 
187
assign wbs_dat_o = a_q[35:4];
188
 
189
always @ (posedge wbs_clk or posedge wbs_rst)
190
if (wbs_rst)
191 13 unneback
        wbs_bte_reg <= 2'b00;
192 12 unneback
else
193 13 unneback
        wbs_bte_reg <= wbs_bte_i;
194 12 unneback
 
195
// wbm FIFO
196
assign wbm_eoc_alert = (wbm_bte_o==wrap4 & wbm_count[3]) | (wbm_bte_o==wrap8 & wbm_count[7]) | (wbm_bte_o==wrap16 & wbm_count[15]);
197
always @ (posedge wbm_clk or posedge wbm_rst)
198
if (wbm_rst)
199
        wbm_eoc <= 1'b0;
200
else
201
        if (wbm==wbm_adr0 & !b_fifo_empty)
202
                wbm_eoc <= b_q[`BTE] == linear;
203
        else if (wbm_eoc_alert & wbm_ack_i)
204
                wbm_eoc <= 1'b1;
205
 
206
always @ (posedge wbm_clk or posedge wbm_rst)
207
if (wbm_rst)
208
        wbm <= wbm_adr0;
209
else
210 33 unneback
/*
211 12 unneback
    if ((wbm==wbm_adr0 & !b_fifo_empty) |
212
        (wbm==wbm_adr1 & !b_fifo_empty & wbm_we_o) |
213
        (wbm==wbm_adr1 & !wbm_we_o) |
214
        (wbm==wbm_data & wbm_ack_i & wbm_eoc))
215
        wbm <= {wbm[0],!(wbm[1] ^ wbm[0])};  // count sequence 00,01,10
216 33 unneback
*/
217
    case (wbm)
218
    wbm_adr0:
219
        if (!b_fifo_empty)
220
            wbm <= wbm_adr1;
221
    wbm_adr1:
222
        if (!wbm_we_o | (!b_fifo_empty & wbm_we_o))
223
            wbm <= wbm_data;
224
    wbm_data:
225
        if (wbm_ack_i & wbm_eoc)
226
            wbm <= wbm_adr0;
227
        else if (b_fifo_empty & wbm_we_o & wbm_ack_i)
228
            wbm <= wbm_data_wait;
229
    wbm_data_wait:
230
        if (!b_fifo_empty)
231
            wbm <= wbm_data;
232
    endcase
233 12 unneback
 
234
assign b_d = {wbm_dat_i,4'b1111};
235
assign b_wr = !wbm_we_o & wbm_ack_i;
236
assign b_rd_adr  = (wbm==wbm_adr0 & !b_fifo_empty);
237
assign b_rd_data = (wbm==wbm_adr1 & !b_fifo_empty & wbm_we_o) ? 1'b1 : // b_q[`WE]
238
                   (wbm==wbm_data & !b_fifo_empty & wbm_we_o & wbm_ack_i & !wbm_eoc) ? 1'b1 :
239 33 unneback
                   (wbm==wbm_data_wait & !b_fifo_empty) ? 1'b1 :
240 12 unneback
                   1'b0;
241
assign b_rd = b_rd_adr | b_rd_data;
242
 
243 40 unneback
`define MODULE dff
244
`BASE`MODULE dff1 ( .d(b_rd_data), .q(b_rd_data_reg), .clk(wbm_clk), .rst(wbm_rst));
245
`undef MODULE
246
`define MODULE dff_ce
247
`BASE`MODULE # ( .width(36)) dff2 ( .d(b_q), .ce(b_rd_data_reg), .q(temp), .clk(wbm_clk), .rst(wbm_rst));
248
`undef MODULE
249 12 unneback
 
250
assign {wbm_dat_o,wbm_sel_o} = (b_rd_data_reg) ? b_q : temp;
251
 
252 40 unneback
`define MODULE cnt_shreg_ce_clear
253 42 unneback
`BASE`MODULE # ( .length(16))
254 40 unneback
`undef MODULE
255 12 unneback
    cnt1 (
256
        .cke(wbm_ack_i),
257
        .clear(wbm_eoc),
258
        .q(wbm_count),
259
        .rst(wbm_rst),
260
        .clk(wbm_clk));
261
 
262 33 unneback
assign wbm_cyc_o = (wbm==wbm_data | wbm==wbm_data_wait);
263
assign wbm_stb_o = (wbm==wbm_data);
264 12 unneback
 
265
always @ (posedge wbm_clk or posedge wbm_rst)
266
if (wbm_rst)
267
        {wbm_adr_o,wbm_we_o,wbm_bte_o,wbm_cti_o} <= {30'h0,1'b0,linear,classic};
268
else begin
269
        if (wbm==wbm_adr0 & !b_fifo_empty)
270
                {wbm_adr_o,wbm_we_o,wbm_bte_o,wbm_cti_o} <= b_q;
271
        else if (wbm_eoc_alert & wbm_ack_i)
272
                wbm_cti_o <= endofburst;
273
end
274
 
275
//async_fifo_dw_simplex_top
276 40 unneback
`define MODULE fifo_2r2w_async_simplex
277
`BASE`MODULE
278
`undef MODULE
279 12 unneback
# ( .data_width(36), .addr_width(addr_width))
280
fifo (
281
    // a side
282
    .a_d(a_d),
283
    .a_wr(a_wr),
284
    .a_fifo_full(a_fifo_full),
285
    .a_q(a_q),
286
    .a_rd(a_rd),
287
    .a_fifo_empty(a_fifo_empty),
288
    .a_clk(wbs_clk),
289
    .a_rst(wbs_rst),
290
    // b side
291
    .b_d(b_d),
292
    .b_wr(b_wr),
293
    .b_fifo_full(b_fifo_full),
294
    .b_q(b_q),
295
    .b_rd(b_rd),
296
    .b_fifo_empty(b_fifo_empty),
297
    .b_clk(wbm_clk),
298
    .b_rst(wbm_rst)
299
    );
300
 
301
endmodule
302 40 unneback
`undef WE
303
`undef BTE
304
`undef CTI
305
`endif
306 17 unneback
 
307 75 unneback
`ifdef WB3AVALON_BRIDGE
308
`define MODULE wb3avalon_bridge
309
module `BASE`MODULE (
310
`undef MODULE
311
        // wishbone slave side
312
        wbs_dat_i, wbs_adr_i, wbs_sel_i, wbs_bte_i, wbs_cti_i, wbs_we_i, wbs_cyc_i, wbs_stb_i, wbs_dat_o, wbs_ack_o, wbs_clk, wbs_rst,
313 77 unneback
        // avalon master side
314 75 unneback
        readdata, readdatavalid, address, read, be, write, burstcount, writedata, waitrequest, beginbursttransfer, clk, rst);
315
 
316
input [31:0] wbs_dat_i;
317
input [31:2] wbs_adr_i;
318
input [3:0]  wbs_sel_i;
319
input [1:0]  wbs_bte_i;
320
input [2:0]  wbs_cti_i;
321
input wbs_we_i, wbs_cyc_i, wbs_stb_i;
322
output [31:0] wbs_dat_o;
323
output wbs_ack_o;
324
input wbs_clk, wbs_rst;
325
 
326
input [31:0] readdata;
327
output [31:0] writedata;
328
output [31:2] address;
329
output [3:0]  be;
330
output write;
331
output read;
332
output beginbursttransfer;
333
output [3:0] burstcount;
334
input readdatavalid;
335
input waitrequest;
336
input clk;
337
input rst;
338
 
339
wire [1:0] wbm_bte_o;
340
wire [2:0] wbm_cti_o;
341
wire wbm_we_o, wbm_cyc_o, wbm_stb_o, wbm_ack_i;
342
reg last_cyc;
343
 
344
always @ (posedge clk or posedge rst)
345
if (rst)
346
    last_cyc <= 1'b0;
347
else
348
    last_cyc <= wbm_cyc_o;
349
 
350
assign beginbursttransfer = (!last_cyc & wbm_cyc_o) & wbm_cti_o==3'b010;
351
assign burstcount = (wbm_bte_o==2'b01) ? 4'd4 :
352
                    (wbm_bte_o==2'b10) ? 4'd8 :
353 78 unneback
                    (wbm_bte_o==2'b11) ? 4'd16:
354
                    4'd1;
355 75 unneback
assign write = wbm_cyc_o & wbm_stb_o &  wbm_we_o;
356
assign read  = wbm_cyc_o & wbm_stb_o & !wbm_we_o;
357
assign wbm_ack_i = (readdatavalid & !waitrequest) | (write & !waitrequest);
358
 
359
`define MODULE wb3wb3_bridge
360 77 unneback
`BASE`MODULE wbwb3inst (
361 75 unneback
`undef MODULE
362
    // wishbone slave side
363
    .wbs_dat_i(wbs_dat_i),
364
    .wbs_adr_i(wbs_adr_i),
365
    .wbs_sel_i(wbs_sel_i),
366
    .wbs_bte_i(wbs_bte_i),
367
    .wbs_cti_i(wbs_cti_i),
368
    .wbs_we_i(wbs_we_i),
369
    .wbs_cyc_i(wbs_cyc_i),
370
    .wbs_stb_i(wbs_stb_i),
371
    .wbs_dat_o(wbs_dat_o),
372
    .wbs_ack_o(wbs_ack_o),
373
    .wbs_clk(wbs_clk),
374
    .wbs_rst(wbs_rst),
375
    // wishbone master side
376
    .wbm_dat_o(writedata),
377 78 unneback
    .wbm_adr_o(address),
378 75 unneback
    .wbm_sel_o(be),
379
    .wbm_bte_o(wbm_bte_o),
380
    .wbm_cti_o(wbm_cti_o),
381
    .wbm_we_o(wbm_we_o),
382
    .wbm_cyc_o(wbm_cyc_o),
383
    .wbm_stb_o(wbm_stb_o),
384
    .wbm_dat_i(readdata),
385
    .wbm_ack_i(wbm_ack_i),
386
    .wbm_clk(clk),
387
    .wbm_rst(rst));
388
 
389
 
390
endmodule
391
`endif
392
 
393 40 unneback
`ifdef WB3_ARBITER_TYPE1
394
`define MODULE wb3_arbiter_type1
395 42 unneback
module `BASE`MODULE (
396 40 unneback
`undef MODULE
397 39 unneback
    wbm_dat_o, wbm_adr_o, wbm_sel_o, wbm_cti_o, wbm_bte_o, wbm_we_o, wbm_stb_o, wbm_cyc_o,
398
    wbm_dat_i, wbm_ack_i, wbm_err_i, wbm_rty_i,
399
    wbs_dat_i, wbs_adr_i, wbs_sel_i, wbs_cti_i, wbs_bte_i, wbs_we_i, wbs_stb_i, wbs_cyc_i,
400
    wbs_dat_o, wbs_ack_o, wbs_err_o, wbs_rty_o,
401
    wb_clk, wb_rst
402
);
403
 
404
parameter nr_of_ports = 3;
405
parameter adr_size = 26;
406
parameter adr_lo   = 2;
407
parameter dat_size = 32;
408
parameter sel_size = dat_size/8;
409
 
410
localparam aw = (adr_size - adr_lo) * nr_of_ports;
411
localparam dw = dat_size * nr_of_ports;
412
localparam sw = sel_size * nr_of_ports;
413
localparam cw = 3 * nr_of_ports;
414
localparam bw = 2 * nr_of_ports;
415
 
416
input  [dw-1:0] wbm_dat_o;
417
input  [aw-1:0] wbm_adr_o;
418
input  [sw-1:0] wbm_sel_o;
419
input  [cw-1:0] wbm_cti_o;
420
input  [bw-1:0] wbm_bte_o;
421
input  [nr_of_ports-1:0] wbm_we_o, wbm_stb_o, wbm_cyc_o;
422
output [dw-1:0] wbm_dat_i;
423
output [nr_of_ports-1:0] wbm_ack_i, wbm_err_i, wbm_rty_i;
424
 
425
output [dat_size-1:0] wbs_dat_i;
426
output [adr_size-1:adr_lo] wbs_adr_i;
427
output [sel_size-1:0] wbs_sel_i;
428
output [2:0] wbs_cti_i;
429
output [1:0] wbs_bte_i;
430
output wbs_we_i, wbs_stb_i, wbs_cyc_i;
431
input  [dat_size-1:0] wbs_dat_o;
432
input  wbs_ack_o, wbs_err_o, wbs_rty_o;
433
 
434
input wb_clk, wb_rst;
435
 
436 44 unneback
reg  [nr_of_ports-1:0] select;
437 39 unneback
wire [nr_of_ports-1:0] state;
438
wire [nr_of_ports-1:0] eoc; // end-of-cycle
439
wire [nr_of_ports-1:0] sel;
440
wire idle;
441
 
442
genvar i;
443
 
444
assign idle = !(|state);
445
 
446
generate
447
if (nr_of_ports == 2) begin
448
 
449
    wire [2:0] wbm1_cti_o, wbm0_cti_o;
450
 
451
    assign {wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
452
 
453 44 unneback
    //assign select = (idle) ? {wbm_cyc_o[1],!wbm_cyc_o[1] & wbm_cyc_o[0]} : {nr_of_ports{1'b0}};
454
 
455
    always @ (idle or wbm_cyc_o)
456
    if (idle)
457
        casex (wbm_cyc_o)
458
        2'b1x : select = 2'b10;
459
        2'b01 : select = 2'b01;
460
        default : select = {nr_of_ports{1'b0}};
461
        endcase
462
    else
463
        select = {nr_of_ports{1'b0}};
464
 
465 39 unneback
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
466
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
467
 
468
end
469
endgenerate
470
 
471
generate
472
if (nr_of_ports == 3) begin
473
 
474
    wire [2:0] wbm2_cti_o, wbm1_cti_o, wbm0_cti_o;
475
 
476
    assign {wbm2_cti_o,wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
477
 
478 44 unneback
    always @ (idle or wbm_cyc_o)
479
    if (idle)
480
        casex (wbm_cyc_o)
481
        3'b1xx : select = 3'b100;
482
        3'b01x : select = 3'b010;
483
        3'b001 : select = 3'b001;
484
        default : select = {nr_of_ports{1'b0}};
485
        endcase
486
    else
487
        select = {nr_of_ports{1'b0}};
488
 
489
//    assign select = (idle) ? {wbm_cyc_o[2],!wbm_cyc_o[2] & wbm_cyc_o[1],wbm_cyc_o[2:1]==2'b00 & wbm_cyc_o[0]} : {nr_of_ports{1'b0}};
490 39 unneback
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
491
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
492
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
493
 
494
end
495
endgenerate
496
 
497
generate
498 44 unneback
if (nr_of_ports == 4) begin
499
 
500
    wire [2:0] wbm3_cti_o, wbm2_cti_o, wbm1_cti_o, wbm0_cti_o;
501
 
502
    assign {wbm3_cti_o, wbm2_cti_o,wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
503
 
504
    //assign select = (idle) ? {wbm_cyc_o[3],!wbm_cyc_o[3] & wbm_cyc_o[2],wbm_cyc_o[3:2]==2'b00 & wbm_cyc_o[1],wbm_cyc_o[3:1]==3'b000 & wbm_cyc_o[0]} : {nr_of_ports{1'b0}};
505
 
506
    always @ (idle or wbm_cyc_o)
507
    if (idle)
508
        casex (wbm_cyc_o)
509
        4'b1xxx : select = 4'b1000;
510
        4'b01xx : select = 4'b0100;
511
        4'b001x : select = 4'b0010;
512
        4'b0001 : select = 4'b0001;
513
        default : select = {nr_of_ports{1'b0}};
514
        endcase
515
    else
516
        select = {nr_of_ports{1'b0}};
517
 
518
    assign eoc[3] = (wbm_ack_i[3] & (wbm3_cti_o == 3'b000 | wbm3_cti_o == 3'b111)) | !wbm_cyc_o[3];
519
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
520
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
521
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
522
 
523
end
524
endgenerate
525
 
526
generate
527
if (nr_of_ports == 5) begin
528
 
529
    wire [2:0] wbm4_cti_o, wbm3_cti_o, wbm2_cti_o, wbm1_cti_o, wbm0_cti_o;
530
 
531
    assign {wbm4_cti_o, wbm3_cti_o, wbm2_cti_o,wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
532
 
533
    //assign select = (idle) ? {wbm_cyc_o[3],!wbm_cyc_o[3] & wbm_cyc_o[2],wbm_cyc_o[3:2]==2'b00 & wbm_cyc_o[1],wbm_cyc_o[3:1]==3'b000 & wbm_cyc_o[0]} : {nr_of_ports{1'b0}};
534
 
535
    always @ (idle or wbm_cyc_o)
536
    if (idle)
537
        casex (wbm_cyc_o)
538
        5'b1xxxx : select = 5'b10000;
539
        5'b01xxx : select = 5'b01000;
540
        5'b001xx : select = 5'b00100;
541
        5'b0001x : select = 5'b00010;
542
        5'b00001 : select = 5'b00001;
543
        default : select = {nr_of_ports{1'b0}};
544
        endcase
545
    else
546
        select = {nr_of_ports{1'b0}};
547
 
548
    assign eoc[4] = (wbm_ack_i[4] & (wbm4_cti_o == 3'b000 | wbm4_cti_o == 3'b111)) | !wbm_cyc_o[4];
549
    assign eoc[3] = (wbm_ack_i[3] & (wbm3_cti_o == 3'b000 | wbm3_cti_o == 3'b111)) | !wbm_cyc_o[3];
550
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
551
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
552
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
553
 
554
end
555
endgenerate
556
 
557
generate
558 67 unneback
if (nr_of_ports == 6) begin
559
 
560
    wire [2:0] wbm5_cti_o, wbm4_cti_o, wbm3_cti_o, wbm2_cti_o, wbm1_cti_o, wbm0_cti_o;
561
 
562
    assign {wbm5_cti_o, wbm4_cti_o, wbm3_cti_o, wbm2_cti_o,wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
563
 
564
    //assign select = (idle) ? {wbm_cyc_o[3],!wbm_cyc_o[3] & wbm_cyc_o[2],wbm_cyc_o[3:2]==2'b00 & wbm_cyc_o[1],wbm_cyc_o[3:1]==3'b000 & wbm_cyc_o[0]} : {nr_of_ports{1'b0}};
565
 
566
    always @ (idle or wbm_cyc_o)
567
    if (idle)
568
        casex (wbm_cyc_o)
569
        6'b1xxxxx : select = 6'b100000;
570
        6'b01xxxx : select = 6'b010000;
571
        6'b001xxx : select = 6'b001000;
572
        6'b0001xx : select = 6'b000100;
573
        6'b00001x : select = 6'b000010;
574
        6'b000001 : select = 6'b000001;
575
        default : select = {nr_of_ports{1'b0}};
576
        endcase
577
    else
578
        select = {nr_of_ports{1'b0}};
579
 
580
    assign eoc[5] = (wbm_ack_i[5] & (wbm5_cti_o == 3'b000 | wbm5_cti_o == 3'b111)) | !wbm_cyc_o[5];
581
    assign eoc[4] = (wbm_ack_i[4] & (wbm4_cti_o == 3'b000 | wbm4_cti_o == 3'b111)) | !wbm_cyc_o[4];
582
    assign eoc[3] = (wbm_ack_i[3] & (wbm3_cti_o == 3'b000 | wbm3_cti_o == 3'b111)) | !wbm_cyc_o[3];
583
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
584
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
585
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
586
 
587
end
588
endgenerate
589
 
590
generate
591
if (nr_of_ports == 7) begin
592
 
593
    wire [2:0] wbm6_cti_o, wbm5_cti_o, wbm4_cti_o, wbm3_cti_o, wbm2_cti_o, wbm1_cti_o, wbm0_cti_o;
594
 
595
    assign {wbm6_cti_o, wbm5_cti_o, wbm4_cti_o, wbm3_cti_o, wbm2_cti_o,wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
596
 
597
    //assign select = (idle) ? {wbm_cyc_o[3],!wbm_cyc_o[3] & wbm_cyc_o[2],wbm_cyc_o[3:2]==2'b00 & wbm_cyc_o[1],wbm_cyc_o[3:1]==3'b000 & wbm_cyc_o[0]} : {nr_of_ports{1'b0}};
598
 
599
    always @ (idle or wbm_cyc_o)
600
    if (idle)
601
        casex (wbm_cyc_o)
602
        7'b1xxxxxx : select = 7'b1000000;
603
        7'b01xxxxx : select = 7'b0100000;
604
        7'b001xxxx : select = 7'b0010000;
605
        7'b0001xxx : select = 7'b0001000;
606
        7'b00001xx : select = 7'b0000100;
607
        7'b000001x : select = 7'b0000010;
608
        7'b0000001 : select = 7'b0000001;
609
        default : select = {nr_of_ports{1'b0}};
610
        endcase
611
    else
612
        select = {nr_of_ports{1'b0}};
613
 
614
    assign eoc[6] = (wbm_ack_i[6] & (wbm6_cti_o == 3'b000 | wbm6_cti_o == 3'b111)) | !wbm_cyc_o[6];
615
    assign eoc[5] = (wbm_ack_i[5] & (wbm5_cti_o == 3'b000 | wbm5_cti_o == 3'b111)) | !wbm_cyc_o[5];
616
    assign eoc[4] = (wbm_ack_i[4] & (wbm4_cti_o == 3'b000 | wbm4_cti_o == 3'b111)) | !wbm_cyc_o[4];
617
    assign eoc[3] = (wbm_ack_i[3] & (wbm3_cti_o == 3'b000 | wbm3_cti_o == 3'b111)) | !wbm_cyc_o[3];
618
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
619
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
620
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
621
 
622
end
623
endgenerate
624
 
625
generate
626
if (nr_of_ports == 8) begin
627
 
628
    wire [2:0] wbm7_cti_o, wbm6_cti_o, wbm5_cti_o, wbm4_cti_o, wbm3_cti_o, wbm2_cti_o, wbm1_cti_o, wbm0_cti_o;
629
 
630
    assign {wbm7_cti_o, wbm6_cti_o, wbm5_cti_o, wbm4_cti_o, wbm3_cti_o, wbm2_cti_o,wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
631
 
632
    //assign select = (idle) ? {wbm_cyc_o[3],!wbm_cyc_o[3] & wbm_cyc_o[2],wbm_cyc_o[3:2]==2'b00 & wbm_cyc_o[1],wbm_cyc_o[3:1]==3'b000 & wbm_cyc_o[0]} : {nr_of_ports{1'b0}};
633
 
634
    always @ (idle or wbm_cyc_o)
635
    if (idle)
636
        casex (wbm_cyc_o)
637
        8'b1xxxxxxx : select = 8'b10000000;
638
        8'b01xxxxxx : select = 8'b01000000;
639
        8'b001xxxxx : select = 8'b00100000;
640
        8'b0001xxxx : select = 8'b00010000;
641
        8'b00001xxx : select = 8'b00001000;
642
        8'b000001xx : select = 8'b00000100;
643
        8'b0000001x : select = 8'b00000010;
644
        8'b00000001 : select = 8'b00000001;
645
        default : select = {nr_of_ports{1'b0}};
646
        endcase
647
    else
648
        select = {nr_of_ports{1'b0}};
649
 
650
    assign eoc[7] = (wbm_ack_i[7] & (wbm7_cti_o == 3'b000 | wbm7_cti_o == 3'b111)) | !wbm_cyc_o[7];
651
    assign eoc[6] = (wbm_ack_i[6] & (wbm6_cti_o == 3'b000 | wbm6_cti_o == 3'b111)) | !wbm_cyc_o[6];
652
    assign eoc[5] = (wbm_ack_i[5] & (wbm5_cti_o == 3'b000 | wbm5_cti_o == 3'b111)) | !wbm_cyc_o[5];
653
    assign eoc[4] = (wbm_ack_i[4] & (wbm4_cti_o == 3'b000 | wbm4_cti_o == 3'b111)) | !wbm_cyc_o[4];
654
    assign eoc[3] = (wbm_ack_i[3] & (wbm3_cti_o == 3'b000 | wbm3_cti_o == 3'b111)) | !wbm_cyc_o[3];
655
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
656
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
657
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
658
 
659
end
660
endgenerate
661
 
662
generate
663 63 unneback
for (i=0;i<nr_of_ports;i=i+1) begin : spr0
664 42 unneback
`define MODULE spr
665
    `BASE`MODULE sr0( .sp(select[i]), .r(eoc[i]), .q(state[i]), .clk(wb_clk), .rst(wb_rst));
666
`undef MODULE
667 39 unneback
end
668
endgenerate
669
 
670
    assign sel = select | state;
671
 
672 40 unneback
`define MODULE mux_andor
673
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(32)) mux0 ( .a(wbm_dat_o), .sel(sel), .dout(wbs_dat_i));
674
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(adr_size-adr_lo)) mux1 ( .a(wbm_adr_o), .sel(sel), .dout(wbs_adr_i));
675
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(sel_size)) mux2 ( .a(wbm_sel_o), .sel(sel), .dout(wbs_sel_i));
676
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(3)) mux3 ( .a(wbm_cti_o), .sel(sel), .dout(wbs_cti_i));
677
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(2)) mux4 ( .a(wbm_bte_o), .sel(sel), .dout(wbs_bte_i));
678
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(1)) mux5 ( .a(wbm_we_o), .sel(sel), .dout(wbs_we_i));
679
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(1)) mux6 ( .a(wbm_stb_o), .sel(sel), .dout(wbs_stb_i));
680
`undef MODULE
681 39 unneback
    assign wbs_cyc_i = |sel;
682
 
683
    assign wbm_dat_i = {nr_of_ports{wbs_dat_o}};
684
    assign wbm_ack_i = {nr_of_ports{wbs_ack_o}} & sel;
685
    assign wbm_err_i = {nr_of_ports{wbs_err_o}} & sel;
686
    assign wbm_rty_i = {nr_of_ports{wbs_rty_o}} & sel;
687
 
688
endmodule
689 40 unneback
`endif
690 39 unneback
 
691 60 unneback
`ifdef WB_B3_RAM_BE
692 49 unneback
// WB RAM with byte enable
693 59 unneback
`define MODULE wb_b3_ram_be
694
module `BASE`MODULE (
695
`undef MODULE
696 69 unneback
    wbs_dat_i, wbs_adr_i, wbs_cti_i, wbs_bte_i, wbs_sel_i, wbs_we_i, wbs_stb_i, wbs_cyc_i,
697
    wbs_dat_o, wbs_ack_o, wb_clk, wb_rst);
698 59 unneback
 
699 68 unneback
parameter adr_size = 16;
700 60 unneback
parameter adr_lo   = 2;
701 68 unneback
parameter mem_size = 1<<16;
702 60 unneback
parameter dat_size = 32;
703
parameter memory_init = 1;
704
parameter memory_file = "vl_ram.vmem";
705 59 unneback
 
706 69 unneback
localparam aw = (adr_size - adr_lo);
707
localparam dw = dat_size;
708
localparam sw = dat_size/8;
709
localparam cw = 3;
710
localparam bw = 2;
711 60 unneback
 
712 70 unneback
input [dw-1:0] wbs_dat_i;
713
input [aw-1:0] wbs_adr_i;
714
input [cw-1:0] wbs_cti_i;
715
input [bw-1:0] wbs_bte_i;
716
input [sw-1:0] wbs_sel_i;
717
input wbs_we_i, wbs_stb_i, wbs_cyc_i;
718
output [dw-1:0] wbs_dat_o;
719
output wbs_ack_o;
720 71 unneback
input wb_clk, wb_rst;
721 59 unneback
 
722 60 unneback
wire [sw-1:0] cke;
723 59 unneback
 
724 60 unneback
reg wbs_ack_o;
725
 
726
`define MODULE ram_be
727
`BASE`MODULE # (
728
    .data_width(dat_size),
729 72 unneback
    .addr_width(adr_size-2),
730 69 unneback
    .mem_size(mem_size),
731 68 unneback
    .memory_init(memory_init),
732
    .memory_file(memory_file))
733 60 unneback
ram0(
734
`undef MODULE
735
    .d(wbs_dat_i),
736
    .adr(wbs_adr_i[adr_size-1:2]),
737
    .be(wbs_sel_i),
738
    .we(wbs_we_i),
739
    .q(wbs_dat_o),
740
    .clk(wb_clk)
741
);
742
 
743 59 unneback
always @ (posedge wb_clk or posedge wb_rst)
744
if (wb_rst)
745 60 unneback
    wbs_ack_o <= 1'b0;
746 59 unneback
else
747 60 unneback
    if (wbs_cti_i==3'b000 | wbs_cti_i==3'b111)
748
        wbs_ack_o <= wbs_stb_i & wbs_cyc_i & !wbs_ack_o;
749 59 unneback
    else
750 60 unneback
        wbs_ack_o <= wbs_stb_i & wbs_cyc_i;
751
 
752 59 unneback
endmodule
753
`endif
754
 
755
`ifdef WB_B4_RAM_BE
756
// WB RAM with byte enable
757 49 unneback
`define MODULE wb_b4_ram_be
758
module `BASE`MODULE (
759
`undef MODULE
760
    wb_dat_i, wb_adr_i, wb_sel_i, wb_we_i, wb_stb_i, wb_cyc_i,
761 52 unneback
    wb_dat_o, wb_stall_o, wb_ack_o, wb_clk, wb_rst);
762 49 unneback
 
763
    parameter dat_width = 32;
764
    parameter adr_width = 8;
765
 
766
input [dat_width-1:0] wb_dat_i;
767
input [adr_width-1:0] wb_adr_i;
768
input [dat_width/8-1:0] wb_sel_i;
769
input wb_we_i, wb_stb_i, wb_cyc_i;
770
output [dat_width-1:0] wb_dat_o;
771 51 unneback
reg [dat_width-1:0] wb_dat_o;
772 52 unneback
output wb_stall_o;
773 49 unneback
output wb_ack_o;
774
reg wb_ack_o;
775
input wb_clk, wb_rst;
776
 
777 56 unneback
wire [dat_width/8-1:0] cke;
778
 
779 49 unneback
generate
780
if (dat_width==32) begin
781 51 unneback
reg [7:0] ram3 [1<<(adr_width-2)-1:0];
782
reg [7:0] ram2 [1<<(adr_width-2)-1:0];
783
reg [7:0] ram1 [1<<(adr_width-2)-1:0];
784
reg [7:0] ram0 [1<<(adr_width-2)-1:0];
785 56 unneback
assign cke = wb_sel_i & {(dat_width/8){wb_we_i}};
786 49 unneback
    always @ (posedge wb_clk)
787
    begin
788 56 unneback
        if (cke[3]) ram3[wb_adr_i[adr_width-1:2]] <= wb_dat_i[31:24];
789
        if (cke[2]) ram2[wb_adr_i[adr_width-1:2]] <= wb_dat_i[23:16];
790
        if (cke[1]) ram1[wb_adr_i[adr_width-1:2]] <= wb_dat_i[15:8];
791
        if (cke[0]) ram0[wb_adr_i[adr_width-1:2]] <= wb_dat_i[7:0];
792 49 unneback
    end
793 59 unneback
    always @ (posedge wb_clk or posedge wb_rst)
794
    begin
795
        if (wb_rst)
796
            wb_dat_o <= 32'h0;
797
        else
798
            wb_dat_o <= {ram3[wb_adr_i[adr_width-1:2]],ram2[wb_adr_i[adr_width-1:2]],ram1[wb_adr_i[adr_width-1:2]],ram0[wb_adr_i[adr_width-1:2]]};
799
    end
800 49 unneback
end
801
endgenerate
802
 
803 52 unneback
always @ (posedge wb_clk or posedge wb_rst)
804 55 unneback
if (wb_rst)
805 52 unneback
    wb_ack_o <= 1'b0;
806
else
807 54 unneback
    wb_ack_o <= wb_stb_i & wb_cyc_i;
808 52 unneback
 
809
assign wb_stall_o = 1'b0;
810
 
811 49 unneback
endmodule
812
`endif
813
 
814 48 unneback
`ifdef WB_B4_ROM
815
// WB ROM
816
`define MODULE wb_b4_rom
817
module `BASE`MODULE (
818
`undef MODULE
819
    wb_adr_i, wb_stb_i, wb_cyc_i,
820
    wb_dat_o, stall_o, wb_ack_o, wb_clk, wb_rst);
821
 
822
    parameter dat_width = 32;
823
    parameter dat_default = 32'h15000000;
824
    parameter adr_width = 32;
825
 
826
/*
827
//E2_ifndef ROM
828
//E2_define ROM "rom.v"
829
//E2_endif
830
*/
831
    input [adr_width-1:2]   wb_adr_i;
832
    input                   wb_stb_i;
833
    input                   wb_cyc_i;
834
    output [dat_width-1:0]  wb_dat_o;
835
    reg [dat_width-1:0]     wb_dat_o;
836
    output                  wb_ack_o;
837
    reg                     wb_ack_o;
838
    output                  stall_o;
839
    input                   wb_clk;
840
    input                   wb_rst;
841
 
842
always @ (posedge wb_clk or posedge wb_rst)
843
    if (wb_rst)
844
        wb_dat_o <= {dat_width{1'b0}};
845
    else
846
         case (wb_adr_i[adr_width-1:2])
847
//E2_ifdef ROM
848
//E2_include `ROM
849
//E2_endif
850
           default:
851
             wb_dat_o <= dat_default;
852
 
853
         endcase // case (wb_adr_i)
854
 
855
 
856
always @ (posedge wb_clk or posedge wb_rst)
857
    if (wb_rst)
858
        wb_ack_o <= 1'b0;
859
    else
860
        wb_ack_o <= wb_stb_i & wb_cyc_i;
861
 
862
assign stall_o = 1'b0;
863
 
864
endmodule
865
`endif
866
 
867
 
868 40 unneback
`ifdef WB_BOOT_ROM
869 17 unneback
// WB ROM
870 40 unneback
`define MODULE wb_boot_rom
871
module `BASE`MODULE (
872
`undef MODULE
873 17 unneback
    wb_adr_i, wb_stb_i, wb_cyc_i,
874 18 unneback
    wb_dat_o, wb_ack_o, hit_o, wb_clk, wb_rst);
875 17 unneback
 
876 18 unneback
    parameter adr_hi = 31;
877
    parameter adr_lo = 28;
878
    parameter adr_sel = 4'hf;
879
    parameter addr_width = 5;
880 33 unneback
/*
881 17 unneback
//E2_ifndef BOOT_ROM
882
//E2_define BOOT_ROM "boot_rom.v"
883
//E2_endif
884 33 unneback
*/
885 18 unneback
    input [adr_hi:2]    wb_adr_i;
886
    input               wb_stb_i;
887
    input               wb_cyc_i;
888
    output [31:0]        wb_dat_o;
889
    output              wb_ack_o;
890
    output              hit_o;
891
    input               wb_clk;
892
    input               wb_rst;
893
 
894
    wire hit;
895
    reg [31:0] wb_dat;
896
    reg wb_ack;
897
 
898
assign hit = wb_adr_i[adr_hi:adr_lo] == adr_sel;
899 17 unneback
 
900
always @ (posedge wb_clk or posedge wb_rst)
901
    if (wb_rst)
902 18 unneback
        wb_dat <= 32'h15000000;
903 17 unneback
    else
904 18 unneback
         case (wb_adr_i[addr_width-1:2])
905 33 unneback
//E2_ifdef BOOT_ROM
906 17 unneback
//E2_include `BOOT_ROM
907 33 unneback
//E2_endif
908 17 unneback
           /*
909
            // Zero r0 and jump to 0x00000100
910 18 unneback
 
911
            1 : wb_dat <= 32'hA8200000;
912
            2 : wb_dat <= 32'hA8C00100;
913
            3 : wb_dat <= 32'h44003000;
914
            4 : wb_dat <= 32'h15000000;
915 17 unneback
            */
916
           default:
917 18 unneback
             wb_dat <= 32'h00000000;
918 17 unneback
 
919
         endcase // case (wb_adr_i)
920
 
921
 
922
always @ (posedge wb_clk or posedge wb_rst)
923
    if (wb_rst)
924 18 unneback
        wb_ack <= 1'b0;
925 17 unneback
    else
926 18 unneback
        wb_ack <= wb_stb_i & wb_cyc_i & hit & !wb_ack;
927 17 unneback
 
928 18 unneback
assign hit_o = hit;
929
assign wb_dat_o = wb_dat & {32{wb_ack}};
930
assign wb_ack_o = wb_ack;
931
 
932 17 unneback
endmodule
933 40 unneback
`endif
934 32 unneback
 
935 40 unneback
`ifdef WB_DPRAM
936
`define MODULE wb_dpram
937
module `BASE`MODULE (
938
`undef MODULE
939 32 unneback
        // wishbone slave side a
940
        wbsa_dat_i, wbsa_adr_i, wbsa_we_i, wbsa_cyc_i, wbsa_stb_i, wbsa_dat_o, wbsa_ack_o,
941
        wbsa_clk, wbsa_rst,
942
        // wishbone slave side a
943
        wbsb_dat_i, wbsb_adr_i, wbsb_we_i, wbsb_cyc_i, wbsb_stb_i, wbsb_dat_o, wbsb_ack_o,
944
        wbsb_clk, wbsb_rst);
945
 
946
parameter data_width = 32;
947
parameter addr_width = 8;
948
 
949
parameter dat_o_mask_a = 1;
950
parameter dat_o_mask_b = 1;
951
 
952
input [31:0] wbsa_dat_i;
953
input [addr_width-1:2] wbsa_adr_i;
954
input wbsa_we_i, wbsa_cyc_i, wbsa_stb_i;
955
output [31:0] wbsa_dat_o;
956
output wbsa_ack_o;
957
input wbsa_clk, wbsa_rst;
958
 
959
input [31:0] wbsb_dat_i;
960
input [addr_width-1:2] wbsb_adr_i;
961
input wbsb_we_i, wbsb_cyc_i, wbsb_stb_i;
962
output [31:0] wbsb_dat_o;
963
output wbsb_ack_o;
964
input wbsb_clk, wbsb_rst;
965
 
966
wire wbsa_dat_tmp, wbsb_dat_tmp;
967
 
968 40 unneback
`define MODULE dpram_2r2w
969
`BASE`MODULE # (
970
`undef MODULE
971 33 unneback
    .data_width(data_width), .addr_width(addr_width) )
972 32 unneback
dpram0(
973
    .d_a(wbsa_dat_i),
974
    .q_a(wbsa_dat_tmp),
975
    .adr_a(wbsa_adr_i),
976
    .we_a(wbsa_we_i),
977
    .clk_a(wbsa_clk),
978
    .d_b(wbsb_dat_i),
979
    .q_b(wbsb_dat_tmp),
980
    .adr_b(wbsb_adr_i),
981
    .we_b(wbsb_we_i),
982
    .clk_b(wbsb_clk) );
983
 
984 33 unneback
generate if (dat_o_mask_a==1)
985 32 unneback
    assign wbsa_dat_o = wbsa_dat_tmp & {data_width{wbsa_ack_o}};
986
endgenerate
987 33 unneback
generate if (dat_o_mask_a==0)
988 32 unneback
    assign wbsa_dat_o = wbsa_dat_tmp;
989
endgenerate
990
 
991 33 unneback
generate if (dat_o_mask_b==1)
992 32 unneback
    assign wbsb_dat_o = wbsb_dat_tmp & {data_width{wbsb_ack_o}};
993
endgenerate
994 33 unneback
generate if (dat_o_mask_b==0)
995 32 unneback
    assign wbsb_dat_o = wbsb_dat_tmp;
996
endgenerate
997
 
998 40 unneback
`define MODULE spr
999
`BASE`MODULE ack_a( .sp(wbsa_cyc_i & wbsa_stb_i & !wbsa_ack_o), .r(1'b1), .q(wbsa_ack_o), .clk(wbsa_clk), .rst(wbsa_rst));
1000
`BASE`MODULE ack_b( .sp(wbsb_cyc_i & wbsb_stb_i & !wbsb_ack_o), .r(1'b1), .q(wbsb_ack_o), .clk(wbsb_clk), .rst(wbsb_rst));
1001
`undef MODULE
1002 32 unneback
 
1003
endmodule
1004 40 unneback
`endif

powered by: WebSVN 2.1.0

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