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 81

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 81 unneback
output read;
332 75 unneback
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 79 unneback
reg [3:0] counter;
344 75 unneback
 
345
always @ (posedge clk or posedge rst)
346
if (rst)
347
    last_cyc <= 1'b0;
348
else
349
    last_cyc <= wbm_cyc_o;
350
 
351 81 unneback
/*
352 79 unneback
always @ (posedge clk or posedge rst)
353
if (rst)
354
    read <= 1'b0;
355
else
356 80 unneback
    if (!last_cyc & wbm_cyc_o & !wbm_we_o)
357 79 unneback
        read <= 1'b1;
358
    else if (!waitrequest)
359
        read <= 1'b0;
360 81 unneback
*/
361
assign read = wbm_cyc_o & wbm_stb_o & !wbm_we_o & counter!=4'd0;
362
 
363 75 unneback
assign beginbursttransfer = (!last_cyc & wbm_cyc_o) & wbm_cti_o==3'b010;
364
assign burstcount = (wbm_bte_o==2'b01) ? 4'd4 :
365
                    (wbm_bte_o==2'b10) ? 4'd8 :
366 78 unneback
                    (wbm_bte_o==2'b11) ? 4'd16:
367
                    4'd1;
368 75 unneback
assign wbm_ack_i = (readdatavalid & !waitrequest) | (write & !waitrequest);
369
 
370 79 unneback
always @ (posedge clk or posedge rst)
371
if (rst) begin
372
    counter <= 4'd0;
373
end else
374 80 unneback
    if (wbm_we_o) begin
375
        if (!waitrequest & !last_cyc & wbm_cyc_o) begin
376
            counter <= burstcount -1;
377
        end else if (waitrequest & !last_cyc & wbm_cyc_o) begin
378
            counter <= burstcount;
379
        end else if (!waitrequest & wbm_stb_o) begin
380
            counter <= counter - 4'd1;
381
        end
382 79 unneback
    end
383 81 unneback
assign write = wbm_cyc_o & wbm_stb_o & wbm_we_o & counter!=4'd0;
384 79 unneback
 
385 75 unneback
`define MODULE wb3wb3_bridge
386 77 unneback
`BASE`MODULE wbwb3inst (
387 75 unneback
`undef MODULE
388
    // wishbone slave side
389
    .wbs_dat_i(wbs_dat_i),
390
    .wbs_adr_i(wbs_adr_i),
391
    .wbs_sel_i(wbs_sel_i),
392
    .wbs_bte_i(wbs_bte_i),
393
    .wbs_cti_i(wbs_cti_i),
394
    .wbs_we_i(wbs_we_i),
395
    .wbs_cyc_i(wbs_cyc_i),
396
    .wbs_stb_i(wbs_stb_i),
397
    .wbs_dat_o(wbs_dat_o),
398
    .wbs_ack_o(wbs_ack_o),
399
    .wbs_clk(wbs_clk),
400
    .wbs_rst(wbs_rst),
401
    // wishbone master side
402
    .wbm_dat_o(writedata),
403 78 unneback
    .wbm_adr_o(address),
404 75 unneback
    .wbm_sel_o(be),
405
    .wbm_bte_o(wbm_bte_o),
406
    .wbm_cti_o(wbm_cti_o),
407
    .wbm_we_o(wbm_we_o),
408
    .wbm_cyc_o(wbm_cyc_o),
409
    .wbm_stb_o(wbm_stb_o),
410
    .wbm_dat_i(readdata),
411
    .wbm_ack_i(wbm_ack_i),
412
    .wbm_clk(clk),
413
    .wbm_rst(rst));
414
 
415
 
416
endmodule
417
`endif
418
 
419 40 unneback
`ifdef WB3_ARBITER_TYPE1
420
`define MODULE wb3_arbiter_type1
421 42 unneback
module `BASE`MODULE (
422 40 unneback
`undef MODULE
423 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,
424
    wbm_dat_i, wbm_ack_i, wbm_err_i, wbm_rty_i,
425
    wbs_dat_i, wbs_adr_i, wbs_sel_i, wbs_cti_i, wbs_bte_i, wbs_we_i, wbs_stb_i, wbs_cyc_i,
426
    wbs_dat_o, wbs_ack_o, wbs_err_o, wbs_rty_o,
427
    wb_clk, wb_rst
428
);
429
 
430
parameter nr_of_ports = 3;
431
parameter adr_size = 26;
432
parameter adr_lo   = 2;
433
parameter dat_size = 32;
434
parameter sel_size = dat_size/8;
435
 
436
localparam aw = (adr_size - adr_lo) * nr_of_ports;
437
localparam dw = dat_size * nr_of_ports;
438
localparam sw = sel_size * nr_of_ports;
439
localparam cw = 3 * nr_of_ports;
440
localparam bw = 2 * nr_of_ports;
441
 
442
input  [dw-1:0] wbm_dat_o;
443
input  [aw-1:0] wbm_adr_o;
444
input  [sw-1:0] wbm_sel_o;
445
input  [cw-1:0] wbm_cti_o;
446
input  [bw-1:0] wbm_bte_o;
447
input  [nr_of_ports-1:0] wbm_we_o, wbm_stb_o, wbm_cyc_o;
448
output [dw-1:0] wbm_dat_i;
449
output [nr_of_ports-1:0] wbm_ack_i, wbm_err_i, wbm_rty_i;
450
 
451
output [dat_size-1:0] wbs_dat_i;
452
output [adr_size-1:adr_lo] wbs_adr_i;
453
output [sel_size-1:0] wbs_sel_i;
454
output [2:0] wbs_cti_i;
455
output [1:0] wbs_bte_i;
456
output wbs_we_i, wbs_stb_i, wbs_cyc_i;
457
input  [dat_size-1:0] wbs_dat_o;
458
input  wbs_ack_o, wbs_err_o, wbs_rty_o;
459
 
460
input wb_clk, wb_rst;
461
 
462 44 unneback
reg  [nr_of_ports-1:0] select;
463 39 unneback
wire [nr_of_ports-1:0] state;
464
wire [nr_of_ports-1:0] eoc; // end-of-cycle
465
wire [nr_of_ports-1:0] sel;
466
wire idle;
467
 
468
genvar i;
469
 
470
assign idle = !(|state);
471
 
472
generate
473
if (nr_of_ports == 2) begin
474
 
475
    wire [2:0] wbm1_cti_o, wbm0_cti_o;
476
 
477
    assign {wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
478
 
479 44 unneback
    //assign select = (idle) ? {wbm_cyc_o[1],!wbm_cyc_o[1] & wbm_cyc_o[0]} : {nr_of_ports{1'b0}};
480
 
481
    always @ (idle or wbm_cyc_o)
482
    if (idle)
483
        casex (wbm_cyc_o)
484
        2'b1x : select = 2'b10;
485
        2'b01 : select = 2'b01;
486
        default : select = {nr_of_ports{1'b0}};
487
        endcase
488
    else
489
        select = {nr_of_ports{1'b0}};
490
 
491 39 unneback
    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
if (nr_of_ports == 3) begin
499
 
500
    wire [2:0] wbm2_cti_o, wbm1_cti_o, wbm0_cti_o;
501
 
502
    assign {wbm2_cti_o,wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
503
 
504 44 unneback
    always @ (idle or wbm_cyc_o)
505
    if (idle)
506
        casex (wbm_cyc_o)
507
        3'b1xx : select = 3'b100;
508
        3'b01x : select = 3'b010;
509
        3'b001 : select = 3'b001;
510
        default : select = {nr_of_ports{1'b0}};
511
        endcase
512
    else
513
        select = {nr_of_ports{1'b0}};
514
 
515
//    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}};
516 39 unneback
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
517
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
518
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
519
 
520
end
521
endgenerate
522
 
523
generate
524 44 unneback
if (nr_of_ports == 4) begin
525
 
526
    wire [2:0] wbm3_cti_o, wbm2_cti_o, wbm1_cti_o, wbm0_cti_o;
527
 
528
    assign {wbm3_cti_o, wbm2_cti_o,wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
529
 
530
    //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}};
531
 
532
    always @ (idle or wbm_cyc_o)
533
    if (idle)
534
        casex (wbm_cyc_o)
535
        4'b1xxx : select = 4'b1000;
536
        4'b01xx : select = 4'b0100;
537
        4'b001x : select = 4'b0010;
538
        4'b0001 : select = 4'b0001;
539
        default : select = {nr_of_ports{1'b0}};
540
        endcase
541
    else
542
        select = {nr_of_ports{1'b0}};
543
 
544
    assign eoc[3] = (wbm_ack_i[3] & (wbm3_cti_o == 3'b000 | wbm3_cti_o == 3'b111)) | !wbm_cyc_o[3];
545
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
546
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
547
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
548
 
549
end
550
endgenerate
551
 
552
generate
553
if (nr_of_ports == 5) begin
554
 
555
    wire [2:0] wbm4_cti_o, wbm3_cti_o, wbm2_cti_o, wbm1_cti_o, wbm0_cti_o;
556
 
557
    assign {wbm4_cti_o, wbm3_cti_o, wbm2_cti_o,wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
558
 
559
    //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}};
560
 
561
    always @ (idle or wbm_cyc_o)
562
    if (idle)
563
        casex (wbm_cyc_o)
564
        5'b1xxxx : select = 5'b10000;
565
        5'b01xxx : select = 5'b01000;
566
        5'b001xx : select = 5'b00100;
567
        5'b0001x : select = 5'b00010;
568
        5'b00001 : select = 5'b00001;
569
        default : select = {nr_of_ports{1'b0}};
570
        endcase
571
    else
572
        select = {nr_of_ports{1'b0}};
573
 
574
    assign eoc[4] = (wbm_ack_i[4] & (wbm4_cti_o == 3'b000 | wbm4_cti_o == 3'b111)) | !wbm_cyc_o[4];
575
    assign eoc[3] = (wbm_ack_i[3] & (wbm3_cti_o == 3'b000 | wbm3_cti_o == 3'b111)) | !wbm_cyc_o[3];
576
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
577
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
578
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
579
 
580
end
581
endgenerate
582
 
583
generate
584 67 unneback
if (nr_of_ports == 6) begin
585
 
586
    wire [2:0] wbm5_cti_o, wbm4_cti_o, wbm3_cti_o, wbm2_cti_o, wbm1_cti_o, wbm0_cti_o;
587
 
588
    assign {wbm5_cti_o, wbm4_cti_o, wbm3_cti_o, wbm2_cti_o,wbm1_cti_o,wbm0_cti_o} = wbm_cti_o;
589
 
590
    //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}};
591
 
592
    always @ (idle or wbm_cyc_o)
593
    if (idle)
594
        casex (wbm_cyc_o)
595
        6'b1xxxxx : select = 6'b100000;
596
        6'b01xxxx : select = 6'b010000;
597
        6'b001xxx : select = 6'b001000;
598
        6'b0001xx : select = 6'b000100;
599
        6'b00001x : select = 6'b000010;
600
        6'b000001 : select = 6'b000001;
601
        default : select = {nr_of_ports{1'b0}};
602
        endcase
603
    else
604
        select = {nr_of_ports{1'b0}};
605
 
606
    assign eoc[5] = (wbm_ack_i[5] & (wbm5_cti_o == 3'b000 | wbm5_cti_o == 3'b111)) | !wbm_cyc_o[5];
607
    assign eoc[4] = (wbm_ack_i[4] & (wbm4_cti_o == 3'b000 | wbm4_cti_o == 3'b111)) | !wbm_cyc_o[4];
608
    assign eoc[3] = (wbm_ack_i[3] & (wbm3_cti_o == 3'b000 | wbm3_cti_o == 3'b111)) | !wbm_cyc_o[3];
609
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
610
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
611
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
612
 
613
end
614
endgenerate
615
 
616
generate
617
if (nr_of_ports == 7) begin
618
 
619
    wire [2:0] wbm6_cti_o, wbm5_cti_o, wbm4_cti_o, wbm3_cti_o, wbm2_cti_o, wbm1_cti_o, wbm0_cti_o;
620
 
621
    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;
622
 
623
    //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}};
624
 
625
    always @ (idle or wbm_cyc_o)
626
    if (idle)
627
        casex (wbm_cyc_o)
628
        7'b1xxxxxx : select = 7'b1000000;
629
        7'b01xxxxx : select = 7'b0100000;
630
        7'b001xxxx : select = 7'b0010000;
631
        7'b0001xxx : select = 7'b0001000;
632
        7'b00001xx : select = 7'b0000100;
633
        7'b000001x : select = 7'b0000010;
634
        7'b0000001 : select = 7'b0000001;
635
        default : select = {nr_of_ports{1'b0}};
636
        endcase
637
    else
638
        select = {nr_of_ports{1'b0}};
639
 
640
    assign eoc[6] = (wbm_ack_i[6] & (wbm6_cti_o == 3'b000 | wbm6_cti_o == 3'b111)) | !wbm_cyc_o[6];
641
    assign eoc[5] = (wbm_ack_i[5] & (wbm5_cti_o == 3'b000 | wbm5_cti_o == 3'b111)) | !wbm_cyc_o[5];
642
    assign eoc[4] = (wbm_ack_i[4] & (wbm4_cti_o == 3'b000 | wbm4_cti_o == 3'b111)) | !wbm_cyc_o[4];
643
    assign eoc[3] = (wbm_ack_i[3] & (wbm3_cti_o == 3'b000 | wbm3_cti_o == 3'b111)) | !wbm_cyc_o[3];
644
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
645
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
646
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
647
 
648
end
649
endgenerate
650
 
651
generate
652
if (nr_of_ports == 8) begin
653
 
654
    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;
655
 
656
    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;
657
 
658
    //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}};
659
 
660
    always @ (idle or wbm_cyc_o)
661
    if (idle)
662
        casex (wbm_cyc_o)
663
        8'b1xxxxxxx : select = 8'b10000000;
664
        8'b01xxxxxx : select = 8'b01000000;
665
        8'b001xxxxx : select = 8'b00100000;
666
        8'b0001xxxx : select = 8'b00010000;
667
        8'b00001xxx : select = 8'b00001000;
668
        8'b000001xx : select = 8'b00000100;
669
        8'b0000001x : select = 8'b00000010;
670
        8'b00000001 : select = 8'b00000001;
671
        default : select = {nr_of_ports{1'b0}};
672
        endcase
673
    else
674
        select = {nr_of_ports{1'b0}};
675
 
676
    assign eoc[7] = (wbm_ack_i[7] & (wbm7_cti_o == 3'b000 | wbm7_cti_o == 3'b111)) | !wbm_cyc_o[7];
677
    assign eoc[6] = (wbm_ack_i[6] & (wbm6_cti_o == 3'b000 | wbm6_cti_o == 3'b111)) | !wbm_cyc_o[6];
678
    assign eoc[5] = (wbm_ack_i[5] & (wbm5_cti_o == 3'b000 | wbm5_cti_o == 3'b111)) | !wbm_cyc_o[5];
679
    assign eoc[4] = (wbm_ack_i[4] & (wbm4_cti_o == 3'b000 | wbm4_cti_o == 3'b111)) | !wbm_cyc_o[4];
680
    assign eoc[3] = (wbm_ack_i[3] & (wbm3_cti_o == 3'b000 | wbm3_cti_o == 3'b111)) | !wbm_cyc_o[3];
681
    assign eoc[2] = (wbm_ack_i[2] & (wbm2_cti_o == 3'b000 | wbm2_cti_o == 3'b111)) | !wbm_cyc_o[2];
682
    assign eoc[1] = (wbm_ack_i[1] & (wbm1_cti_o == 3'b000 | wbm1_cti_o == 3'b111)) | !wbm_cyc_o[1];
683
    assign eoc[0] = (wbm_ack_i[0] & (wbm0_cti_o == 3'b000 | wbm0_cti_o == 3'b111)) | !wbm_cyc_o[0];
684
 
685
end
686
endgenerate
687
 
688
generate
689 63 unneback
for (i=0;i<nr_of_ports;i=i+1) begin : spr0
690 42 unneback
`define MODULE spr
691
    `BASE`MODULE sr0( .sp(select[i]), .r(eoc[i]), .q(state[i]), .clk(wb_clk), .rst(wb_rst));
692
`undef MODULE
693 39 unneback
end
694
endgenerate
695
 
696
    assign sel = select | state;
697
 
698 40 unneback
`define MODULE mux_andor
699
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(32)) mux0 ( .a(wbm_dat_o), .sel(sel), .dout(wbs_dat_i));
700
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(adr_size-adr_lo)) mux1 ( .a(wbm_adr_o), .sel(sel), .dout(wbs_adr_i));
701
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(sel_size)) mux2 ( .a(wbm_sel_o), .sel(sel), .dout(wbs_sel_i));
702
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(3)) mux3 ( .a(wbm_cti_o), .sel(sel), .dout(wbs_cti_i));
703
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(2)) mux4 ( .a(wbm_bte_o), .sel(sel), .dout(wbs_bte_i));
704
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(1)) mux5 ( .a(wbm_we_o), .sel(sel), .dout(wbs_we_i));
705
    `BASE`MODULE # ( .nr_of_ports(nr_of_ports), .width(1)) mux6 ( .a(wbm_stb_o), .sel(sel), .dout(wbs_stb_i));
706
`undef MODULE
707 39 unneback
    assign wbs_cyc_i = |sel;
708
 
709
    assign wbm_dat_i = {nr_of_ports{wbs_dat_o}};
710
    assign wbm_ack_i = {nr_of_ports{wbs_ack_o}} & sel;
711
    assign wbm_err_i = {nr_of_ports{wbs_err_o}} & sel;
712
    assign wbm_rty_i = {nr_of_ports{wbs_rty_o}} & sel;
713
 
714
endmodule
715 40 unneback
`endif
716 39 unneback
 
717 60 unneback
`ifdef WB_B3_RAM_BE
718 49 unneback
// WB RAM with byte enable
719 59 unneback
`define MODULE wb_b3_ram_be
720
module `BASE`MODULE (
721
`undef MODULE
722 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,
723
    wbs_dat_o, wbs_ack_o, wb_clk, wb_rst);
724 59 unneback
 
725 68 unneback
parameter adr_size = 16;
726 60 unneback
parameter adr_lo   = 2;
727 68 unneback
parameter mem_size = 1<<16;
728 60 unneback
parameter dat_size = 32;
729
parameter memory_init = 1;
730
parameter memory_file = "vl_ram.vmem";
731 59 unneback
 
732 69 unneback
localparam aw = (adr_size - adr_lo);
733
localparam dw = dat_size;
734
localparam sw = dat_size/8;
735
localparam cw = 3;
736
localparam bw = 2;
737 60 unneback
 
738 70 unneback
input [dw-1:0] wbs_dat_i;
739
input [aw-1:0] wbs_adr_i;
740
input [cw-1:0] wbs_cti_i;
741
input [bw-1:0] wbs_bte_i;
742
input [sw-1:0] wbs_sel_i;
743
input wbs_we_i, wbs_stb_i, wbs_cyc_i;
744
output [dw-1:0] wbs_dat_o;
745
output wbs_ack_o;
746 71 unneback
input wb_clk, wb_rst;
747 59 unneback
 
748 60 unneback
wire [sw-1:0] cke;
749 59 unneback
 
750 60 unneback
reg wbs_ack_o;
751
 
752
`define MODULE ram_be
753
`BASE`MODULE # (
754
    .data_width(dat_size),
755 72 unneback
    .addr_width(adr_size-2),
756 69 unneback
    .mem_size(mem_size),
757 68 unneback
    .memory_init(memory_init),
758
    .memory_file(memory_file))
759 60 unneback
ram0(
760
`undef MODULE
761
    .d(wbs_dat_i),
762
    .adr(wbs_adr_i[adr_size-1:2]),
763
    .be(wbs_sel_i),
764
    .we(wbs_we_i),
765
    .q(wbs_dat_o),
766
    .clk(wb_clk)
767
);
768
 
769 59 unneback
always @ (posedge wb_clk or posedge wb_rst)
770
if (wb_rst)
771 60 unneback
    wbs_ack_o <= 1'b0;
772 59 unneback
else
773 60 unneback
    if (wbs_cti_i==3'b000 | wbs_cti_i==3'b111)
774
        wbs_ack_o <= wbs_stb_i & wbs_cyc_i & !wbs_ack_o;
775 59 unneback
    else
776 60 unneback
        wbs_ack_o <= wbs_stb_i & wbs_cyc_i;
777
 
778 59 unneback
endmodule
779
`endif
780
 
781
`ifdef WB_B4_RAM_BE
782
// WB RAM with byte enable
783 49 unneback
`define MODULE wb_b4_ram_be
784
module `BASE`MODULE (
785
`undef MODULE
786
    wb_dat_i, wb_adr_i, wb_sel_i, wb_we_i, wb_stb_i, wb_cyc_i,
787 52 unneback
    wb_dat_o, wb_stall_o, wb_ack_o, wb_clk, wb_rst);
788 49 unneback
 
789
    parameter dat_width = 32;
790
    parameter adr_width = 8;
791
 
792
input [dat_width-1:0] wb_dat_i;
793
input [adr_width-1:0] wb_adr_i;
794
input [dat_width/8-1:0] wb_sel_i;
795
input wb_we_i, wb_stb_i, wb_cyc_i;
796
output [dat_width-1:0] wb_dat_o;
797 51 unneback
reg [dat_width-1:0] wb_dat_o;
798 52 unneback
output wb_stall_o;
799 49 unneback
output wb_ack_o;
800
reg wb_ack_o;
801
input wb_clk, wb_rst;
802
 
803 56 unneback
wire [dat_width/8-1:0] cke;
804
 
805 49 unneback
generate
806
if (dat_width==32) begin
807 51 unneback
reg [7:0] ram3 [1<<(adr_width-2)-1:0];
808
reg [7:0] ram2 [1<<(adr_width-2)-1:0];
809
reg [7:0] ram1 [1<<(adr_width-2)-1:0];
810
reg [7:0] ram0 [1<<(adr_width-2)-1:0];
811 56 unneback
assign cke = wb_sel_i & {(dat_width/8){wb_we_i}};
812 49 unneback
    always @ (posedge wb_clk)
813
    begin
814 56 unneback
        if (cke[3]) ram3[wb_adr_i[adr_width-1:2]] <= wb_dat_i[31:24];
815
        if (cke[2]) ram2[wb_adr_i[adr_width-1:2]] <= wb_dat_i[23:16];
816
        if (cke[1]) ram1[wb_adr_i[adr_width-1:2]] <= wb_dat_i[15:8];
817
        if (cke[0]) ram0[wb_adr_i[adr_width-1:2]] <= wb_dat_i[7:0];
818 49 unneback
    end
819 59 unneback
    always @ (posedge wb_clk or posedge wb_rst)
820
    begin
821
        if (wb_rst)
822
            wb_dat_o <= 32'h0;
823
        else
824
            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]]};
825
    end
826 49 unneback
end
827
endgenerate
828
 
829 52 unneback
always @ (posedge wb_clk or posedge wb_rst)
830 55 unneback
if (wb_rst)
831 52 unneback
    wb_ack_o <= 1'b0;
832
else
833 54 unneback
    wb_ack_o <= wb_stb_i & wb_cyc_i;
834 52 unneback
 
835
assign wb_stall_o = 1'b0;
836
 
837 49 unneback
endmodule
838
`endif
839
 
840 48 unneback
`ifdef WB_B4_ROM
841
// WB ROM
842
`define MODULE wb_b4_rom
843
module `BASE`MODULE (
844
`undef MODULE
845
    wb_adr_i, wb_stb_i, wb_cyc_i,
846
    wb_dat_o, stall_o, wb_ack_o, wb_clk, wb_rst);
847
 
848
    parameter dat_width = 32;
849
    parameter dat_default = 32'h15000000;
850
    parameter adr_width = 32;
851
 
852
/*
853
//E2_ifndef ROM
854
//E2_define ROM "rom.v"
855
//E2_endif
856
*/
857
    input [adr_width-1:2]   wb_adr_i;
858
    input                   wb_stb_i;
859
    input                   wb_cyc_i;
860
    output [dat_width-1:0]  wb_dat_o;
861
    reg [dat_width-1:0]     wb_dat_o;
862
    output                  wb_ack_o;
863
    reg                     wb_ack_o;
864
    output                  stall_o;
865
    input                   wb_clk;
866
    input                   wb_rst;
867
 
868
always @ (posedge wb_clk or posedge wb_rst)
869
    if (wb_rst)
870
        wb_dat_o <= {dat_width{1'b0}};
871
    else
872
         case (wb_adr_i[adr_width-1:2])
873
//E2_ifdef ROM
874
//E2_include `ROM
875
//E2_endif
876
           default:
877
             wb_dat_o <= dat_default;
878
 
879
         endcase // case (wb_adr_i)
880
 
881
 
882
always @ (posedge wb_clk or posedge wb_rst)
883
    if (wb_rst)
884
        wb_ack_o <= 1'b0;
885
    else
886
        wb_ack_o <= wb_stb_i & wb_cyc_i;
887
 
888
assign stall_o = 1'b0;
889
 
890
endmodule
891
`endif
892
 
893
 
894 40 unneback
`ifdef WB_BOOT_ROM
895 17 unneback
// WB ROM
896 40 unneback
`define MODULE wb_boot_rom
897
module `BASE`MODULE (
898
`undef MODULE
899 17 unneback
    wb_adr_i, wb_stb_i, wb_cyc_i,
900 18 unneback
    wb_dat_o, wb_ack_o, hit_o, wb_clk, wb_rst);
901 17 unneback
 
902 18 unneback
    parameter adr_hi = 31;
903
    parameter adr_lo = 28;
904
    parameter adr_sel = 4'hf;
905
    parameter addr_width = 5;
906 33 unneback
/*
907 17 unneback
//E2_ifndef BOOT_ROM
908
//E2_define BOOT_ROM "boot_rom.v"
909
//E2_endif
910 33 unneback
*/
911 18 unneback
    input [adr_hi:2]    wb_adr_i;
912
    input               wb_stb_i;
913
    input               wb_cyc_i;
914
    output [31:0]        wb_dat_o;
915
    output              wb_ack_o;
916
    output              hit_o;
917
    input               wb_clk;
918
    input               wb_rst;
919
 
920
    wire hit;
921
    reg [31:0] wb_dat;
922
    reg wb_ack;
923
 
924
assign hit = wb_adr_i[adr_hi:adr_lo] == adr_sel;
925 17 unneback
 
926
always @ (posedge wb_clk or posedge wb_rst)
927
    if (wb_rst)
928 18 unneback
        wb_dat <= 32'h15000000;
929 17 unneback
    else
930 18 unneback
         case (wb_adr_i[addr_width-1:2])
931 33 unneback
//E2_ifdef BOOT_ROM
932 17 unneback
//E2_include `BOOT_ROM
933 33 unneback
//E2_endif
934 17 unneback
           /*
935
            // Zero r0 and jump to 0x00000100
936 18 unneback
 
937
            1 : wb_dat <= 32'hA8200000;
938
            2 : wb_dat <= 32'hA8C00100;
939
            3 : wb_dat <= 32'h44003000;
940
            4 : wb_dat <= 32'h15000000;
941 17 unneback
            */
942
           default:
943 18 unneback
             wb_dat <= 32'h00000000;
944 17 unneback
 
945
         endcase // case (wb_adr_i)
946
 
947
 
948
always @ (posedge wb_clk or posedge wb_rst)
949
    if (wb_rst)
950 18 unneback
        wb_ack <= 1'b0;
951 17 unneback
    else
952 18 unneback
        wb_ack <= wb_stb_i & wb_cyc_i & hit & !wb_ack;
953 17 unneback
 
954 18 unneback
assign hit_o = hit;
955
assign wb_dat_o = wb_dat & {32{wb_ack}};
956
assign wb_ack_o = wb_ack;
957
 
958 17 unneback
endmodule
959 40 unneback
`endif
960 32 unneback
 
961 40 unneback
`ifdef WB_DPRAM
962
`define MODULE wb_dpram
963
module `BASE`MODULE (
964
`undef MODULE
965 32 unneback
        // wishbone slave side a
966
        wbsa_dat_i, wbsa_adr_i, wbsa_we_i, wbsa_cyc_i, wbsa_stb_i, wbsa_dat_o, wbsa_ack_o,
967
        wbsa_clk, wbsa_rst,
968
        // wishbone slave side a
969
        wbsb_dat_i, wbsb_adr_i, wbsb_we_i, wbsb_cyc_i, wbsb_stb_i, wbsb_dat_o, wbsb_ack_o,
970
        wbsb_clk, wbsb_rst);
971
 
972
parameter data_width = 32;
973
parameter addr_width = 8;
974
 
975
parameter dat_o_mask_a = 1;
976
parameter dat_o_mask_b = 1;
977
 
978
input [31:0] wbsa_dat_i;
979
input [addr_width-1:2] wbsa_adr_i;
980
input wbsa_we_i, wbsa_cyc_i, wbsa_stb_i;
981
output [31:0] wbsa_dat_o;
982
output wbsa_ack_o;
983
input wbsa_clk, wbsa_rst;
984
 
985
input [31:0] wbsb_dat_i;
986
input [addr_width-1:2] wbsb_adr_i;
987
input wbsb_we_i, wbsb_cyc_i, wbsb_stb_i;
988
output [31:0] wbsb_dat_o;
989
output wbsb_ack_o;
990
input wbsb_clk, wbsb_rst;
991
 
992
wire wbsa_dat_tmp, wbsb_dat_tmp;
993
 
994 40 unneback
`define MODULE dpram_2r2w
995
`BASE`MODULE # (
996
`undef MODULE
997 33 unneback
    .data_width(data_width), .addr_width(addr_width) )
998 32 unneback
dpram0(
999
    .d_a(wbsa_dat_i),
1000
    .q_a(wbsa_dat_tmp),
1001
    .adr_a(wbsa_adr_i),
1002
    .we_a(wbsa_we_i),
1003
    .clk_a(wbsa_clk),
1004
    .d_b(wbsb_dat_i),
1005
    .q_b(wbsb_dat_tmp),
1006
    .adr_b(wbsb_adr_i),
1007
    .we_b(wbsb_we_i),
1008
    .clk_b(wbsb_clk) );
1009
 
1010 33 unneback
generate if (dat_o_mask_a==1)
1011 32 unneback
    assign wbsa_dat_o = wbsa_dat_tmp & {data_width{wbsa_ack_o}};
1012
endgenerate
1013 33 unneback
generate if (dat_o_mask_a==0)
1014 32 unneback
    assign wbsa_dat_o = wbsa_dat_tmp;
1015
endgenerate
1016
 
1017 33 unneback
generate if (dat_o_mask_b==1)
1018 32 unneback
    assign wbsb_dat_o = wbsb_dat_tmp & {data_width{wbsb_ack_o}};
1019
endgenerate
1020 33 unneback
generate if (dat_o_mask_b==0)
1021 32 unneback
    assign wbsb_dat_o = wbsb_dat_tmp;
1022
endgenerate
1023
 
1024 40 unneback
`define MODULE spr
1025
`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));
1026
`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));
1027
`undef MODULE
1028 32 unneback
 
1029
endmodule
1030 40 unneback
`endif

powered by: WebSVN 2.1.0

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